feat: add pretty nbytes repr to .show and jupyter repr#3348
Conversation
|
Love this improvement! There's the usual caveat note about |
|
Yes 👍, also it does not take into account the python objects/structure and whatever is in |
|
This is very nice! But can we make it say " Also, are you making the right distinction between "MB" (megabytes) and "MiB" (mebibytes)? One system uses factors of 1000 and the other uses factors of 1024. |
|
I chose
That should be correct, I'm using factors of |
|
Oh btw, one thing that I noticed is that the typetracer backend reports |
|
https://simple.wikipedia.org/wiki/Mebibyte (I'm in a meeting) |
|
as discussed I changed:
Example: In [1]: import awkward as ak; import numpy as np
In [2]: array = ak.with_named_axis(
...: ak.zip({
...: "one": np.full((1234567,), 1.0),
...: "two": np.full((1234567,), 2.0),
...: "three": np.full((1234567,), 3.0),
...: }),
...: named_axis=("some",),
...: )
In [3]: array.show(type=True, named_axis=True, nbytes=True, backend=True)
type: 1234567 * {
one: float64,
two: float64,
three: float64
}
axes: some:0
nbytes: 29.6 MB
backend: cpu
[{one: 1, two: 2, three: 3},
{one: 1, two: 2, three: 3},
{one: 1, two: 2, three: 3},
{one: 1, two: 2, three: 3},
{one: 1, two: 2, three: 3},
{one: 1, two: 2, three: 3},
{one: 1, two: 2, three: 3},
{one: 1, two: 2, three: 3},
{one: 1, two: 2, three: 3},
{one: 1, two: 2, three: 3},
...,For For the Jupyter repr the order is: |
|
@jpivarski could you have one last look at this PR? thanks 🙏 |
jpivarski
left a comment
There was a problem hiding this comment.
It looks great! I see that the code duplication is gone (now in highlevel_array_show_rows) and it has an all argument. I think the PR is ready to merge.
This is a little PR that adds (optionally, default is False) a new line to
.show(nbytes=True)and the jupyter repr of high-level ak.Arrays and ak.Records. It's for the lazy (like me) who don't want to do the calculation in their head...Preview (
.show()):Preview (Jupyter repr):

What do you think?