Commit a78c1e0
authored
dataset
* Delegate `max_rows` from dataset `__repr__`
As discussed in #5545
the default setting of `display_max_rows` is sometimes less useful to
inspect datasets for completeness, and changing the option is not
backwards compatible. In addition, a concise and short output dataset
seems to be preferred by most people.
The compromise is to keep the dataset's `__repr__` short and tunable via
`xr.set_options(display_max_rows=...)`, and at the same time to enable
the output of all items by explicitly requesting `ds.coords`,
`ds.data_vars`, and `ds.attrs`. These explicit `__repr__`s also restore
backwards compatibility in these cases.
Slightly changes the internal implementation of `_mapping_repr()`:
Setting (leaving) `max_rows` to `None` means "no limits".
* tests: Update dataset `__repr__` tests [1/2]
Updates the dataset `__repr__` test to assure that the dataset output
honours the `display_max_rows` setting, not the `data_vars` output.
Discussed in #5545
* tests: Extend dataset `__repr__` tests [2/2]
Extends the dataset `__repr__` test to ensure that the output of
`ds.coords`, `ds.data_vars`, and `ds.attrs` is of full length as
desired.
Includes more dimensions and coordinates to cover more cases.
Discussed in #5545
* doc: Add what's new entry for `__repr__` changes
Sorted as a "breaking change" for 0.18.3 for now.
* Revert "doc: Add what's new entry for `__repr__` changes"
This reverts commit 3dd645b.
* doc: Add what's new entry for `__repr__` changes
Sorted as a "breaking change", for 0.19.1 for now.
* doc: Remove `attrs` from `__repr__` changes
Address comment from @keewis:
`.attrs` is a standard python dict, so there's no custom repr.
* tests: Remove `ds.attrs` formatting test
According to @keewis:
I don't think we need to test this because `attrs_repr` will only ever
be called by `dataset_repr` / `array_repr`: on its own, the standard
python `dict`'s `repr` will be used.
* tests: Fix no. of coordinates in formatting_repr
The number of coordinates changed to be the same as the number of
variables, which only incidentally was fixed to 40.
Updates the to-be-tested format string to use the same number of
variables instead of the hard-coded one, which might be subject to
change.__repr__ updates (#5580)1 parent 28bdcf0 commit a78c1e0
File tree
3 files changed
+33
-15
lines changed- doc
- xarray
- core
- tests
3 files changed
+33
-15
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
36 | 41 | | |
37 | 42 | | |
38 | 43 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
377 | 377 | | |
378 | 378 | | |
379 | 379 | | |
380 | | - | |
381 | | - | |
382 | 380 | | |
383 | 381 | | |
384 | 382 | | |
385 | 383 | | |
386 | 384 | | |
387 | | - | |
| 385 | + | |
388 | 386 | | |
389 | 387 | | |
390 | 388 | | |
| |||
418 | 416 | | |
419 | 417 | | |
420 | 418 | | |
421 | | - | |
| 419 | + | |
422 | 420 | | |
423 | 421 | | |
424 | 422 | | |
| |||
427 | 425 | | |
428 | 426 | | |
429 | 427 | | |
| 428 | + | |
430 | 429 | | |
431 | 430 | | |
432 | 431 | | |
| |||
544 | 543 | | |
545 | 544 | | |
546 | 545 | | |
| 546 | + | |
547 | 547 | | |
548 | 548 | | |
549 | 549 | | |
550 | 550 | | |
551 | 551 | | |
552 | | - | |
| 552 | + | |
553 | 553 | | |
554 | 554 | | |
555 | 555 | | |
556 | 556 | | |
557 | 557 | | |
558 | | - | |
| 558 | + | |
559 | 559 | | |
560 | 560 | | |
561 | | - | |
| 561 | + | |
562 | 562 | | |
563 | 563 | | |
564 | 564 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
509 | 509 | | |
510 | 510 | | |
511 | 511 | | |
| 512 | + | |
512 | 513 | | |
513 | | - | |
| 514 | + | |
514 | 515 | | |
515 | | - | |
| 516 | + | |
516 | 517 | | |
517 | 518 | | |
518 | 519 | | |
519 | | - | |
520 | | - | |
| 520 | + | |
| 521 | + | |
521 | 522 | | |
522 | 523 | | |
523 | 524 | | |
524 | 525 | | |
525 | 526 | | |
526 | 527 | | |
527 | 528 | | |
528 | | - | |
| 529 | + | |
529 | 530 | | |
530 | | - | |
531 | 531 | | |
532 | 532 | | |
533 | 533 | | |
534 | 534 | | |
535 | 535 | | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
536 | 548 | | |
537 | 549 | | |
538 | 550 | | |
539 | 551 | | |
540 | 552 | | |
541 | 553 | | |
| 554 | + | |
542 | 555 | | |
543 | 556 | | |
544 | 557 | | |
545 | | - | |
546 | | - | |
| 558 | + | |
| 559 | + | |
547 | 560 | | |
548 | 561 | | |
549 | 562 | | |
| |||
0 commit comments