-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
provide set_option collapse_html
to control HTML repr collapsed state
#4230
Conversation
I didn't But I'm getting this return while using $ isort -rc . (xarray-tests)
/home/maye/miniconda3/envs/xarray-tests/lib/python3.7/site-packages/setuptools/distutils_patch.py:26: UserWarning: Distutils was imported before Setuptools. This usage is discouraged and may exhibit undesirable behaviors or errors. Please use Setuptools' objects directly or at least import Setuptools first.
"Distutils was imported before Setuptools. This usage is discouraged "
Skipped 4 files |
For . is not a valid Python package name |
Oh, implemented the wrong default, things were confusing as the HTML code "checked" for the |
I'm looking at the relevant test function: def test_repr_of_dataarray(dataarray):
formatted = fh.array_repr(dataarray)
assert "dim_0" in formatted
# has an expanded data section
assert formatted.count("class='xr-array-in' type='checkbox' checked>") == 1
# coords and attrs don't have an items so they'll be be disabled and collapsed
assert (
formatted.count("class='xr-section-summary-in' type='checkbox' disabled >") == 2
) I'm not very good with HTML, does this only check on the number of collapsed sections? I am kinda guessing that this code is |
xarray/core/options.py
Outdated
@@ -21,6 +22,7 @@ | |||
CMAP_DIVERGENT: "RdBu_r", | |||
KEEP_ATTRS: "default", | |||
DISPLAY_STYLE: "html", | |||
COLLAPSE_HTML: True, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be False by default to match existing behavior
@@ -184,7 +185,7 @@ def dim_section(obj): | |||
def array_section(obj): | |||
# "unique" id to expand/collapse the section | |||
data_id = "section-" + str(uuid.uuid4()) | |||
collapsed = "checked" | |||
collapsed = "" if OPTIONS["collapse_html"] else "checked" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you are right that this collapsed var is misnamed. It would be clearer to rename it to "expanded". The collapsible_section
also has this inverted name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i can rename it in the array section but I guess renaming it in the collapsible_section
leaves the scope of this issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
problem is that for collapsible_section
it's a function parameter, so it would need to be changed in all calling cases as well for clarity?
Yes, that test counts expanded data sections and collapsed summary sections
Use |
Hello @michaelaye! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found: There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2021-02-27 20:54:05 UTC |
I support adding an option for this, but I think a name like I also agree with @jsignell that the current naming seems to be reversed "expanded" should mean show the data section and "collapsed" should mean hiding it. |
i'm fine in fixing the name of the variable, but usually open source teams don't want a PR that addresses more than one issue at a time, are you sure you want it in here? |
The scope is limited enough here that it would be fine to include the
cleanup in this PR. The bigger issue is that names exposed in a public API
need to be chosen much more carefully than internal only names — and we
definitely don’t want to expose the current poorly chosen internal name for
this feature to users.
…On Sat, Aug 1, 2020 at 7:32 PM Michael Aye ***@***.***> wrote:
i'm fine in fixing the name of the variable, but usually open source teams
don't want a PR that addresses more than one issue at a time, are you sure
you want it in here?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#4230 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAJJFVTTULSMPGZWCUNIGPTR6TF4LANCNFSM4O3LS7JA>
.
|
Do we want that this expand/collapse option affects the text repr too (i.e., collapsed = show inline values repr vs. expanded = show the whole data repr)? This might be more consistent, although obviously there's no way to interactively expand/collapse the data section in the text repr. In that case |
I would find it useful to have a generalized version of this for datasets, so it's possible to control independently whether the coordinates, data variables, and attributes sections are expanded by default. I'd be happy to pick this up if no one else is working on it. I have created a branch to try it out, which adds the options One thing I'm not sure about is maintaining the existing behaviour, which is that for the HTML dataset repr all three sections are expanded by default, up to a certain size limit, depending on the section (25 coordinates, 15 data variables, 10 attributes). |
The existing behaviour could be
These are a lot with potentially two more: Should we instead do something like xr.set_options(display_expand = {
"data_vars": False,
"coords": "default",
"attrs": False,
}) |
Not sure :). Can you open a PR please? EDIT: Oops you've already opened one! thanks! |
I think @tomwhite has implemented this functionality. Thanks everyone. |
isort -rc . && black . && mypy . && flake8
whats-new.rst