-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Skip mean over empty axis #5207
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -373,6 +373,16 @@ def test_cftime_datetime_mean_dask_error(): | |||||
da.mean() | ||||||
|
||||||
|
||||||
def test_mean_dtype(): | ||||||
ds = Dataset() | ||||||
ds["pos"] = [1, 2, 3] | ||||||
ds["data"] = ("pos", "time"), [[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]] | ||||||
ds["var"] = "pos", [2, 3, 4] | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FYI you can construct the dataset in a single expression, but it's also fine as-is ( |
||||||
ds2 = ds.mean(dim="time") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Convention:
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do not store the result but use it directly. Is that ok as well? |
||||||
assert all(ds2["var"] == ds["var"]) | ||||||
dschwoerer marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
assert ds2["var"].dtype == ds["var"].dtype | ||||||
|
||||||
|
||||||
@pytest.mark.parametrize("dim_num", [1, 2]) | ||||||
@pytest.mark.parametrize("dtype", [float, int, np.float32, np.bool_]) | ||||||
@pytest.mark.parametrize("dask", [False, True]) | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:py:func:
mean
is actually a method (there should be other references in the whats-new which can be copied)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't found an example, so I have removed the explicit reference