-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
dim -> coord in DataArray.integrate #3993
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 4 commits
504ef80
0fcdfe6
f0074bf
ecb7cb1
b9c1e6f
75be024
4614d76
54a5fce
5bbee25
170cc62
92ac2dc
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 | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -3188,17 +3188,20 @@ def differentiate( | |||||||||||||||
return self._from_temp_dataset(ds) | ||||||||||||||||
|
||||||||||||||||
def integrate( | ||||||||||||||||
self, dim: Union[Hashable, Sequence[Hashable]], datetime_unit: str = None | ||||||||||||||||
self, | ||||||||||||||||
coord: Union[Hashable, Sequence[Hashable]], | ||||||||||||||||
dim: Union[Hashable, Sequence[Hashable]] = None, | ||||||||||||||||
datetime_unit: str = None, | ||||||||||||||||
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.
da.integrate("x", "y", "ns") so:
Suggested change
However, this means that you have to guard against specifying both (or none) of them |
||||||||||||||||
) -> "DataArray": | ||||||||||||||||
""" integrate the array with the trapezoidal rule. | ||||||||||||||||
""" Integrate along the given coordinate using the trapezoidal rule. | ||||||||||||||||
|
||||||||||||||||
.. note:: | ||||||||||||||||
This feature is limited to simple cartesian geometry, i.e. dim | ||||||||||||||||
This feature is limited to simple cartesian geometry, i.e. coord | ||||||||||||||||
must be one dimensional. | ||||||||||||||||
|
||||||||||||||||
Parameters | ||||||||||||||||
---------- | ||||||||||||||||
dim: hashable, or a sequence of hashable | ||||||||||||||||
coord: hashable, or a sequence of hashable | ||||||||||||||||
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.
Suggested change
|
||||||||||||||||
Coordinate(s) used for the integration. | ||||||||||||||||
datetime_unit: str, optional | ||||||||||||||||
dcherian marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||
Can be used to specify the unit if datetime coordinate is used. | ||||||||||||||||
|
@@ -3211,6 +3214,7 @@ def integrate( | |||||||||||||||
|
||||||||||||||||
See also | ||||||||||||||||
-------- | ||||||||||||||||
Dataset.integrate | ||||||||||||||||
numpy.trapz: corresponding numpy function | ||||||||||||||||
|
||||||||||||||||
Examples | ||||||||||||||||
|
@@ -3236,7 +3240,17 @@ def integrate( | |||||||||||||||
array([5.4, 6.6, 7.8]) | ||||||||||||||||
Dimensions without coordinates: y | ||||||||||||||||
""" | ||||||||||||||||
ds = self._to_temp_dataset().integrate(dim, datetime_unit) | ||||||||||||||||
|
||||||||||||||||
if dim is not None: | ||||||||||||||||
coord = dim | ||||||||||||||||
msg = ( | ||||||||||||||||
"The `dim` keyword argument to `DataArray.integrate` is " | ||||||||||||||||
"being replaced with `coord`, for consistency with " | ||||||||||||||||
"`Dataset.integrate`." | ||||||||||||||||
) | ||||||||||||||||
warnings.warn(msg, FutureWarning, stacklevel=2) | ||||||||||||||||
|
||||||||||||||||
ds = self._to_temp_dataset().integrate(coord, datetime_unit) | ||||||||||||||||
return self._from_temp_dataset(ds) | ||||||||||||||||
|
||||||||||||||||
def unify_chunks(self) -> "DataArray": | ||||||||||||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -5436,16 +5436,18 @@ def differentiate(self, coord, edge_order=1, datetime_unit=None): | |||||
variables[k] = v | ||||||
return self._replace(variables) | ||||||
|
||||||
def integrate(self, coord, datetime_unit=None): | ||||||
""" integrate the array with the trapezoidal rule. | ||||||
def integrate( | ||||||
self, coord: Union[Hashable, Sequence[Hashable]], datetime_unit: str = None | ||||||
) -> "Dataset": | ||||||
""" Integrate along the given coordinate using the trapezoidal rule. | ||||||
|
||||||
.. note:: | ||||||
This feature is limited to simple cartesian geometry, i.e. coord | ||||||
must be one dimensional. | ||||||
|
||||||
Parameters | ||||||
---------- | ||||||
coord: str, or a sequence of str | ||||||
coord: hashable, or a sequence of hashable | ||||||
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.
Suggested change
|
||||||
Coordinate(s) used for the integration. | ||||||
datetime_unit | ||||||
Can be specify the unit if datetime coordinate is used. One of | ||||||
|
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 think you need a newline before the nested list (this should be the reason why the docs CI fails)