8000 Change annotations to allow str keys by max-sixty · Pull Request #5690 · pydata/xarray · GitHub
[go: up one dir, main page]

Skip to content

Change annotations to allow str keys #5690

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 19, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading 8000
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add in some annotated tests
  • Loading branch information
max-sixty committed Aug 12, 2021
commit 78d4dd62d118e0afe490db4fb797cdd5e98d166c
10 changes: 5 additions & 5 deletions properties/test_pandas_roundtrip.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@


@st.composite
def datasets_1d_vars(draw):
def datasets_1d_vars(draw) -> xr.Dataset:
"""Generate datasets with only 1D variables

Suitable for converting to pandas dataframes.
Expand All @@ -49,7 +49,7 @@ def datasets_1d_vars(draw):


@given(st.data(), an_array)
def test_roundtrip_dataarray(data, arr):
def test_roundtrip_dataarray(data, arr) -> None:
names = data.draw(
st.lists(st.text(), min_size=arr.ndim, max_size=arr.ndim, unique=True).map(
tuple
Expand All @@ -62,15 +62,15 @@ def test_roundtrip_dataarray(data, arr):


@given(datasets_1d_vars())
def test_roundtrip_dataset(dataset):
def test_roundtrip_dataset(dataset) -> None:
df = dataset.to_dataframe()
assert isinstance(df, pd.DataFrame)
roundtripped = xr.Dataset(df)
xr.testing.assert_identical(dataset, roundtripped)


@given(numeric_series, st.text())
def test_roundtrip_pandas_series(ser, ix_name):
def test_roundtrip_pandas_series(ser, ix_name) -> None:
# Need to name the index, otherwise Xarray calls it 'dim_0'.
ser.index.name = ix_name
arr = xr.DataArray(ser)
Expand All @@ -87,7 +87,7 @@ def test_roundtrip_pandas_series(ser, ix_name):

@pytest.mark.xfail
@given(numeric_homogeneous_dataframe)
def test_roundtrip_pandas_dataframe(df):
def test_roundtrip_pandas_dataframe(df) -> None:
# Need to name the indexes, otherwise Xarray names them 'dim_0', 'dim_1'.
df.index.name = "rows"
df.columns.name = "cols"
Expand Down
0