-
Notifications
You must be signed in to change notification settings - Fork 34
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
Add possibility to change the display mode (atom <-> structure) #351
Conversation
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 is working very well! The one small bug I found was that the color bar range is not reset when switching mode.
I've updated the example dataset for CSD to include a read structure PCA (the previous data only contained a single PCA dimension, with the other two being 0 everywhere); you can get the updated version by removing app/example
and starting the dev server again.
src/info/info.ts
Outdated
@@ -57,8 +57,11 @@ export class EnvironmentInfo { | |||
private _shadow: ShadowRoot; | |||
private _root: HTMLElement; | |||
private _atom?: Info; | |||
private _structure: Info; | |||
private _structure!: Info; |
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.
why is this needed? It it better to not use !
as much as possible, since it can hide errors that TS would have caught.
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 used ! it as _structure
is initialised not directly in the constructor but in the function called in constructor -> TS complains that _structure
might be undefined
had a quick look (will try to break it some more) - I know you've been talking about this already, but I noticed that it looks like settings for the structure viewers are preserved when you switch mode (e.g. if you set atoms to space filling, they remain space filling in both struc and env mode) while the map is reset. I find this very confusing. |
@ceriottm |
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.
The code looks good! I like that you moved a bunch of functionalities to async, this will be nicer long term.
I'll try to break it a bit, and when @ceriottm is also done with trying to break the code we can merge this.
src/mode-toggle.ts
Outdated
* @param element HTML element or HTML id of the DOM element where the toggle will be attached | ||
* @param isPerAtom flag indicating if the atom mode should be checked | ||
*/ | ||
constructor(element: string | HTMLElement, isPerAtom: boolean = 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.
instead of isPerAtom
, why not pass the mode
around here? (same in the function below)
I tweaked the style a bit, and removed the title that seemed heavy and out of style with the rest of the UI. Also, once we're done with the polish and the stress-testing, I think it'd be worth adding a sentence or two to the docs somewhere mentioning one can add both types of data to a json, and switch between the two. |
@ceriottm Thanks for checking! I pushed the fix for this issue you described with having the correct height back in map. |
I've one small and one big problem:
|
Co-authored-by: Guillaume Fraux <guillaume.fraux@epfl.ch>
af83cf4
to
1bc147b
Compare
@ceriottm Thanks for taking a look!
|
Ouch. I didn't realize we were using "atom". This is annoying because I'd say we don't want to lose backward compatibility over this. @Luthaf how would you see using and documenting target: "environment" but accepting also target: "atom"? |
I'm not sure about I agree on renaming "mode" to "target", since this matches the name we already use for the properties. |
ok but then we should be consistent with environments -> atom everywhere.
TBD
…On Tue, 30 Jul 2024 at 17:36, Guillaume Fraux ***@***.***> wrote:
I'm not sure about target: environment. For most people, the atom/
structure distinction is a lot clearer. The "environment" name was
initially introduced for displaying *atom*-centered environments in the
structure viewer. Unless there is a good reason to change it, I would keep
the "atom" name for target everywhere.
I agree on renaming "mode" to "target", since this matches the name we
already use for the properties.
—
Reply to this email directly, view it on GitHub
<#351 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAIREZ3ENK3LS3WSHVN4KBLZO6XHVAVCNFSM6AAAAABKRGMHRKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENJYGY2DMMBXHA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
@ceriottm @Luthaf
(Let me know if there is a better way, please) After this re-install, I tested with the example Please let me know if we need to see the buttons in the jupyter widget. |
Do you mean it should change if one changes the |
@ceriottm |
chemiscope.show returns an object (which you can show with display(cs)) |
Thanks for explaining!
Please let me know if I do it correctly and if it does work on your side |
So, most likely the string was invalid, or the range giving nans (a PCA with a log scale is likely to give problems). |
… into change-display-mode
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.
We already had a lot of back-and-forth, and I did my own round of polish. This is good to go IMO
Just to say I'll merge given that it looks like this works well, and that further tweaks of the logging and/or the traitlet interface will better wait for separate PRs. #1 is fixed! |
Where to play around with modes:
Open the
Chemical Shieldings
exampleOpen
examples/2-structure_map.html
TODO:
After review:
Display errors as errors instread of warning--> throw error, change logging in separate PRmode
to the settingsNote for exporting/importing of the dataset:
z.min
andz.max
; hence it breaks once someone wants to import this dataset to the chemiscope. To do the import, it is necessary to delete the z-axes from the json settings (or set 0).