Skip to content

Commit 343a87f

Browse files
committed
NominalDtypeEnum -> NominalDtype
1 parent ba6fff5 commit 343a87f

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

tests/strategies.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
from hypothesis import strategies as st
77
from hypothesis.extra import numpy as nps
88

9-
__all__ = ["mock_dataframes", "MockDataFrame", "MockColumn", "NominalDtypeEnum"]
9+
__all__ = ["mock_dataframes", "MockDataFrame", "MockColumn", "NominalDtype"]
1010

1111

12-
class NominalDtypeEnum(Enum):
12+
class NominalDtype(Enum):
1313
BOOL = "bool"
1414
UTF8 = "U8"
1515
DATETIME64NS = "datetime64[ns]"
@@ -29,7 +29,7 @@ class NominalDtypeEnum(Enum):
2929

3030
class MockColumn(NamedTuple):
3131
array: np.ndarray
32-
nominal_dtype: NominalDtypeEnum
32+
nominal_dtype: NominalDtype
3333

3434

3535
class MockDataFrame(Mapping):
@@ -73,7 +73,7 @@ def __repr__(self) -> str:
7373
def mock_dataframes(
7474
draw,
7575
*,
76-
exclude_dtypes: Collection[NominalDtypeEnum] = [],
76+
exclude_dtypes: Collection[NominalDtype] = [],
7777
allow_zero_cols: bool = True,
7878
allow_zero_rows: bool = True,
7979
) -> MockDataFrame:
@@ -85,10 +85,10 @@ def mock_dataframes(
8585
min_nrows = 0 if allow_zero_rows else 1
8686
nrows = draw(st.integers(min_nrows, 5))
8787
name_to_column = {}
88-
valid_dtypes = [e for e in NominalDtypeEnum if e not in exclude_dtypes]
88+
valid_dtypes = [e for e in NominalDtype if e not in exclude_dtypes]
8989
for colname in colnames:
9090
nominal_dtype = draw(st.sampled_from(valid_dtypes))
91-
if nominal_dtype == NominalDtypeEnum.CATEGORY:
91+
if nominal_dtype == NominalDtype.CATEGORY:
9292
x_strat = nps.arrays(
9393
dtype=np.int8, shape=nrows, elements=st.integers(0, 15)
9494
)

tests/test_dataframe_object.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from hypothesis import assume, given
66
from hypothesis import strategies as st
77

8-
from .strategies import MockColumn, MockDataFrame, NominalDtypeEnum, mock_dataframes
8+
from .strategies import MockColumn, MockDataFrame, NominalDtype, mock_dataframes
99
from .wrappers import LibraryInfo
1010

1111

@@ -23,7 +23,7 @@ def test_library_supports_zero_rows(libinfo: LibraryInfo):
2323
if not libinfo.allow_zero_rows:
2424
pytest.xfail("library doesn't support zero rows")
2525
mock_df = MockDataFrame(
26-
{"foo_col": MockColumn(np.asarray([], dtype=np.int64), NominalDtypeEnum.INT64)}
26+
{"foo_col": MockColumn(np.asarray([], dtype=np.int64), NominalDtype.INT64)}
2727
)
2828
df = libinfo.mock_to_toplevel(mock_df)
2929
# See above comment

tests/wrappers.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from hypothesis import strategies as st
88

99
from .api import DataFrame
10-
from .strategies import MockDataFrame, NominalDtypeEnum, mock_dataframes
10+
from .strategies import MockDataFrame, NominalDtype, mock_dataframes
1111

1212
__all__ = ["libname_to_libinfo", "libinfo_params", "LibraryInfo"]
1313

@@ -22,7 +22,7 @@ class LibraryInfo(NamedTuple):
2222
toplevel_to_compliant: Callable[[TopLevelDataFrame], DataFrame] = lambda df: (
2323
df.__dataframe__()["dataframe"]
2424
)
25-
exclude_dtypes: List[NominalDtypeEnum] = []
25+
exclude_dtypes: List[NominalDtype] = []
2626
allow_zero_cols: bool = True
2727
allow_zero_rows: bool = True
2828

@@ -68,7 +68,7 @@ def pandas_mock_to_toplevel(mock_df: MockDataFrame) -> pd.DataFrame:
6868
return pd.DataFrame()
6969
serieses = []
7070
for name, (array, nominal_dtype) in mock_df.items():
71-
if nominal_dtype == NominalDtypeEnum.UTF8:
71+
if nominal_dtype == NominalDtype.UTF8:
7272
dtype = pd.StringDtype()
7373
else:
7474
dtype = nominal_dtype.value
@@ -83,7 +83,7 @@ def pandas_mock_to_toplevel(mock_df: MockDataFrame) -> pd.DataFrame:
8383
from_dataframe=pandas_from_dataframe,
8484
frame_equal=lambda df1, df2: df1.equals(df2),
8585
toplevel_to_compliant=lambda df: df.__dataframe__(),
86-
exclude_dtypes=[NominalDtypeEnum.DATETIME64NS],
86+
exclude_dtypes=[NominalDtype.DATETIME64NS],
8787
)
8888
libinfo_params.append(pytest.param(pandas_libinfo, id=pandas_libinfo.name))
8989

@@ -106,7 +106,7 @@ def vaex_mock_to_toplevel(mock_df: MockDataFrame) -> TopLevelDataFrame:
106106
items.append((name, array))
107107
df = vaex.from_items(*items)
108108
for name, (array, nominal_dtype) in mock_df.items():
109-
if nominal_dtype == NominalDtypeEnum.CATEGORY:
109+
if nominal_dtype == NominalDtype.CATEGORY:
110110
if not np.issubdtype(array.dtype, np.integer):
111111
raise ValueError(
112112
f"Array with dtype {array.dtype} was given, "
@@ -141,7 +141,7 @@ def vaex_frame_equal(df1, df2) -> bool:
141141
from_dataframe=vaex_from_dataframe,
142142
frame_equal=vaex_frame_equal,
143143
toplevel_to_compliant=lambda df: df.__dataframe__(),
144-
exclude_dtypes=[NominalDtypeEnum.DATETIME64NS],
144+
exclude_dtypes=[NominalDtype.DATETIME64NS],
145145
# https://github.com/vaexio/vaex/issues/2094
146146
allow_zero_cols=False,
147147
allow_zero_rows=False,
@@ -188,7 +188,7 @@ def modin_mock_to_toplevel(mock_df: MockDataFrame) -> mpd.DataFrame:
188188
raise ValueError(f"{mock_df=} not supported by modin")
189189
serieses: List[mpd.Series] = []
190190
for name, (array, nominal_dtype) in mock_df.items():
191-
if nominal_dtype == NominalDtypeEnum.UTF8:
191+
if nominal_dtype == NominalDtype.UTF8:
192192
dtype = mpd.StringDtype()
193193
else:
194194
dtype = nominal_dtype.value
@@ -224,9 +224,9 @@ def modin_frame_equal(df1: mpd.DataFrame, df2: mpd.DataFrame) -> bool:
224224
# https://github.com/modin-project/modin/issues/4654
225225
# https://github.com/modin-project/modin/issues/4652
226226
exclude_dtypes=[
227-
NominalDtypeEnum.UTF8,
228-
NominalDtypeEnum.DATETIME64NS,
229-
NominalDtypeEnum.CATEGORY,
227+
NominalDtype.UTF8,
228+
NominalDtype.DATETIME64NS,
229+
NominalDtype.CATEGORY,
230230
],
231231
# https://github.com/modin-project/modin/issues/4643
232232
allow_zero_rows=False,
@@ -273,7 +273,7 @@ def cudf_mock_to_toplevel(mock_df: MockDataFrame) -> cudf.DataFrame:
273273
return cudf.DataFrame()
274274
serieses = []
275275
for name, (array, nominal_dtype) in mock_df.items():
276-
if NominalDtypeEnum.CATEGORY:
276+
if NominalDtype.CATEGORY:
277277
# See https://github.com/rapidsai/cudf/issues/11256
278278
data = array.tolist()
279279
else:

0 commit comments

Comments
 (0)