Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions gsw/_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def masked_array_support(f):
When one or more masked arrays are encountered as arguments or keyword
arguments, the boolean masks are all logical ORed together then logical
NOT is applied to get the ufunc.where parameter.

If no masked arrays are found, the ufunc is immediately called without modification
of arguments.

Expand All @@ -40,7 +40,7 @@ def wrapper(*args, **kwargs):
)
if not has_masked_args:
return f(*args, **kwargs)

# The only thing done when a masked array is encountered is to figure out the correct value to set the where argument to.
# This logic inspired by how the np.ma wrapped ufuncs work.
# https://github.com/numpy/numpy/blob/cafec60a5e28af98fb8798049edd7942720d2d74/numpy/ma/core.py#L1016-L1025
Expand All @@ -51,7 +51,9 @@ def wrapper(*args, **kwargs):
)
where = ~mask

new_kwargs = {"where": where}
# out: None suppresses warnings about using where without an explicit out param
# this results in the masked values being uninitialized data (anything/UB)
new_kwargs = {"where": where, "out": None}
new_kwargs.update(
**kwargs
) # Allow user override of the where kwarg if they passed it in.
Expand Down
Loading