Skip to content

Conversation

@valeriupredoi
Copy link
Collaborator

@valeriupredoi valeriupredoi commented Jan 7, 2026

Description

I merged too fast #303 (like a .303 bullet hehe) but @davidhassell mentioned it's not complete since missing_value could be a multi-dim array, not just a size one, as I thought. This should fix that.

Reminder: numpy 2.4.0 doesn't allow stuff like ma.masked_equal or other such funcs that set fill_values, to have arrays passed for fill_value, eg their deprecation:

    @fill_value.setter
    def fill_value(self, value=None):
        target = _check_fill_value(value, self.dtype)
        if not target.ndim == 0:
            # 2019-11-12, 1.18.0
            warnings.warn(
                "Non-scalar arrays for the fill value are deprecated. Use "
                "arrays with scalar values instead. The filled function "
                "still supports any array as `fill_value`.",
                DeprecationWarning, stacklevel=2)
    
        _fill_value = self._fill_value
        if _fill_value is None:
            # Create the attribute if it was undefined
            self._fill_value = target
        else:
            # Don't overwrite the attribute, just fill it (for propagation)
>           _fill_value[()] = target
            ^^^^^^^^^^^^^^^
E           ValueError: setting an array element with a sequence.

This implementation here should be backwards compatible.

Before you get started

Checklist

  • This pull request has a descriptive title and labels
  • This pull request has a minimal description (most was discussed in the issue, but a two-liner description is still desirable)
  • Unit tests have been added (if codecov test fails)
  • All tests pass

@valeriupredoi valeriupredoi added the bug Something isn't working label Jan 7, 2026
@codecov
Copy link

codecov bot commented Jan 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.15%. Comparing base (451bab2) to head (571699a).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #304      +/-   ##
==========================================
+ Coverage   86.04%   86.15%   +0.10%     
==========================================
  Files           7        7              
  Lines         645      650       +5     
==========================================
+ Hits          555      560       +5     
  Misses         90       90              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

if missing_value is not None:
data = np.ma.masked_equal(data, missing_value)
if isinstance(missing_value, np.ndarray) or isinstance(missing_value, list):
data = np.ma.masked_where(data == missing_value, data)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surely this only works when missing_value broadcasts to data, which in general it wont.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well I'm running out of any valid numpy function that can mask with an array then 😁

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, I got distracted by the news, how do you even apply a missing_value mask array if it's not broadcastable? I am really not familiar with anything missing value that's dim > 1 (or not scalar) - please suggest code, buds 🍺

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants