Skip to content

Commit

Permalink
Fix code to get rid of pandas warnings (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
caneff authored Oct 19, 2023
1 parent fe97d15 commit 293a0ab
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions tests/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def test_empty_dataset() -> None:
assert df.shape[0] == 0
assert np.all(df.columns == ["a", "b"])

assert df.dtypes[0] == int
assert df.dtypes[1] == object or isinstance(df.dtypes[1], StringDtype)
assert df.dtypes.iloc[0] == int
assert df.dtypes.iloc[1] == object or isinstance(df.dtypes.iloc[1], StringDtype)


def test_dataset() -> None:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_indexed_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ def test_empty_indexed_dataset() -> None:
assert df.index.get_level_values(0).dtype == int
assert df.index.get_level_values(1).dtype == object or isinstance(df.index.get_level_values(1).dtype, StringDtype)

assert df.dtypes[0] == int
assert df.dtypes[1] == object or isinstance(df.dtypes[1], StringDtype)
assert df.dtypes.iloc[0] == int
assert df.dtypes.iloc[1] == object or isinstance(df.dtypes.iloc[1], StringDtype)


def test_indexed_dataset() -> None:
Expand Down
8 changes: 4 additions & 4 deletions tests/test_type_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def is_backward_compatibility_type(dtype) -> bool:
if isinstance(dtype, BackwardCompatibility):
return True

if dtype not in [Any, np.integer]:
if dtype != Any:
if isinstance(dtype, Callable) and isinstance(dtype(), BackwardCompatibility): # type: ignore
return True

Expand Down Expand Up @@ -58,13 +58,13 @@ def check_list_of_types(observed, expected_to_match, expected_to_fail):


def test_numeric_base_python_types():
check_list_of_types(int, [np.int64, np.int_, np.integer, int], [float, np.float_])
check_list_of_types(int, [np.int64, np.int_, int], [float, np.float_])
check_list_of_types(float, [np.float64, np.float_, float], [int, np.int_])
check_list_of_types(bool, [np.bool_, bool], [int, np.int_])


def test_numpy_types():
check_list_of_types(np.int64, [np.int64, np.int_, np.integer, int], [float, np.float_])
check_list_of_types(np.int64, [np.int64, np.int_, int], [float, np.float_])
check_list_of_types(np.float64, [np.float64, np.float_, float], [int, np.int_])
check_list_of_types(np.bool_, [np.bool_, bool], [int, np.int_])
check_list_of_types(np.datetime64, [np.datetime64], [np.timedelta64, DatetimeTZDtype(tz="UTC"), np.int_])
Expand Down Expand Up @@ -99,7 +99,7 @@ def test_strings():

# as long as this is true
df = pd.DataFrame({"a": ["a", "b", "c"]})
assert df.dtypes[0] == object
assert df.dtypes.iloc[0] == object
# we'll need to do this
check_list_of_types(object, [str], [StringDtype])

Expand Down

0 comments on commit 293a0ab

Please sign in to comment.