Thanks to visit codestin.com
Credit goes to github.com

Skip to content

BUG: Respect print options in masked array formatting #28698

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

VascoConceicao
Copy link

Previously, the string representation of masked arrays did not honor global print options such as floatmode, precision, and suppress. This led to inconsistencies between the display of masked and unmasked arrays.
This update addresses the issue by:

  • Utilizing np.array2string to format the underlying data, ensuring consistency with global print settings.
  • Replacing masked elements with the masked_print_option string ('--' by default) while preserving formatting for visible elements.
  • Maintaining support for legacy formatting options, including truncation with ellipsis (...) when legacy='1.13' is set. (Fixes BUG: print options not respected for masked arrays. #28685)

Maybe a bit overkill :)

@VascoConceicao VascoConceicao force-pushed the bugfix/maskedarray-printoptions branch from f5da334 to 7353323 Compare April 13, 2025 15:29
@jorenham jorenham added the component: numpy.ma masked arrays label May 1, 2025
@VascoConceicao VascoConceicao force-pushed the bugfix/maskedarray-printoptions branch 3 times, most recently from c2c46cf to 31eca68 Compare May 6, 2025 13:01
Previously, the string representation of masked arrays did not honor
global print options such as floatmode, precision, and suppress.
This led to inconsistencies between the display of masked and
unmasked arrays.
This update addresses the issue by:
– Utilizing np.array2string to format the underlying data, ensuring
  consistency with global print settings.
– Replacing masked elements with the masked_print_option string
  ('--' by default) while preserving formatting for visible elements.
– Maintaining support for legacy formatting options, including
  truncation with ellipsis (...) when legacy='1.13' is set.
(Fixes numpy#28685)
@VascoConceicao VascoConceicao force-pushed the bugfix/maskedarray-printoptions branch from 28dbacd to fc8a979 Compare May 6, 2025 13:13
@VascoConceicao
Copy link
Author

VascoConceicao commented May 6, 2025

The pipeline tests that failed pass locally. I didn't change anything related to those tests (I think).

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

Successfully merging this pull request may close these issues.

BUG: print options not respected for masked arrays.
2 participants