Skip to content

`count_unique` data operation handles NaNs badly

Utopia Developers requested to merge quickfix-data_ops_count_unique into master

This MR corrects the handling of NaNs in data_ops.py::count_unique

Apparently np.nan == np.nan is false; hence, np.count_unique counts every np.nan value separately. This causes the conversion to coordinates in xr.DataArray to fail (multiple coordinates with same value). Removing the np.nans from the counts resolves this.

Is dropping all np.nans the expected behaviour? I would say yes, but we could also count the occurrences of np.nan instead.

Can this MR be accepted?

  • Implementation ready
  • Tests added or adjusted
  • Documentation extended or updated
  • Code quality
  • Ready for merging
    • Pipeline passes without warnings
    • History cleaned-up or squash option set
    • Changelog entry added
    • Version number bumped to appropriate v0.13.1 pre-release
    • Reviewed & approved by @blsqr or @herdeanu

Related issues

Edited by Utopia Developers

Merge request reports