Handle the string used to represent missing data in a masked array.
| 2370 | |
| 2371 | |
| 2372 | class _MaskedPrintOption: |
| 2373 | """ |
| 2374 | Handle the string used to represent missing data in a masked array. |
| 2375 | |
| 2376 | """ |
| 2377 | |
| 2378 | def __init__(self, display): |
| 2379 | """ |
| 2380 | Create the masked_print_option object. |
| 2381 | |
| 2382 | """ |
| 2383 | self._display = display |
| 2384 | self._enabled = True |
| 2385 | |
| 2386 | def display(self): |
| 2387 | """ |
| 2388 | Display the string to print for masked values. |
| 2389 | |
| 2390 | """ |
| 2391 | return self._display |
| 2392 | |
| 2393 | def set_display(self, s): |
| 2394 | """ |
| 2395 | Set the string to print for masked values. |
| 2396 | |
| 2397 | """ |
| 2398 | self._display = s |
| 2399 | |
| 2400 | def enabled(self): |
| 2401 | """ |
| 2402 | Is the use of the display value enabled? |
| 2403 | |
| 2404 | """ |
| 2405 | return self._enabled |
| 2406 | |
| 2407 | def enable(self, shrink=1): |
| 2408 | """ |
| 2409 | Set the enabling shrink to `shrink`. |
| 2410 | |
| 2411 | """ |
| 2412 | self._enabled = shrink |
| 2413 | |
| 2414 | def __str__(self): |
| 2415 | return str(self._display) |
| 2416 | |
| 2417 | __repr__ = __str__ |
| 2418 | |
| 2419 | # if you single index into a masked location you get this object. |
| 2420 | masked_print_option = _MaskedPrintOption('--') |