Skip to content

Commit

Permalink
Rename pandera classes w/ schema in the name
Browse files Browse the repository at this point in the history
  • Loading branch information
trey-stafford committed Aug 14, 2024
1 parent 68115a9 commit b95c492
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 6 additions & 3 deletions src/iceflow/ingest/atm1b.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from numpy.typing import DTypeLike
from pandera.typing import Series

from iceflow.ingest.models import IceFlowData, commonDataColumns
from iceflow.ingest.models import IceFlowData, IceFlowDataSchema
from iceflow.itrf import SUPPORTED_ITRFS

"""
Expand Down Expand Up @@ -368,7 +368,7 @@ def _ilatm1bv2_data(fn: Path, file_date: dt.date) -> pd.DataFrame:
return df


class atm1bData(commonDataColumns):
class ATM1BDataSchema(IceFlowDataSchema):
# Data fields unique to ATM1B data.
rel_time: Series[pa.dtypes.Int32]
xmt_sigstr: Series[pa.dtypes.Int32]
Expand All @@ -388,7 +388,10 @@ class ATM1BData(IceFlowData):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# Validate the data w/ pandera
atm1bData.validate(self)
# TODO: Does this result in pandera validating the common columns twice?
# The `super` call above would trigger the `IceFlowData`'s __init__,
# which include a call to `validate` on the common data columns.
ATM1BDataSchema.validate(self)


def atm1b_data(filepath: Path) -> ATM1BData:
Expand Down
4 changes: 2 additions & 2 deletions src/iceflow/ingest/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
TDataFrame_co = TypeVar("TDataFrame_co", covariant=True)


class commonDataColumns(pa.DataFrameModel):
class IceFlowDataSchema(pa.DataFrameModel):
utc_datetime: Index[pa.dtypes.DateTime] = pa.Field(check_name=True)
ITRF: Series[str] = pa.Field(isin=SUPPORTED_ITRFS)
latitude: Series[pa.dtypes.Float] = pa.Field(coerce=True)
Expand All @@ -23,4 +23,4 @@ class IceFlowData(pd.DataFrame):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# Validate the data w/ pandera
commonDataColumns.validate(self)
IceFlowDataSchema.validate(self)

0 comments on commit b95c492

Please sign in to comment.