Comments (16)
Yes, sendWarning
is the right function for this! You can call it with a string argument containing the warning message, something like sendWarning("this property contains negative values, taking the log will discard them")
.
from chemiscope.
This is a good issue for newcomers!
The code to change would be around https://github.com/cosmo-epfl/chemiscope/blob/15bdb4147c3bb022d17a8b67d82fa53fd3145d88/src/map/options.ts#L212, adding a check that all values are positive before applying the operation in the 'log'
case.
from chemiscope.
@Luthaf I think a quick array method on the value
would do the check. I'm a little stuck on what kind of warning to raise. Should the function return null
or would the warning need look like something else?
Edit: I found the sendWarning
, just going over how it works now.
from chemiscope.
@Luthaf I think I've got the right idea for what to do, but I'm having a bit of trouble with the linter. I wrote the check as an arrow function, and as per output I added parentheses and semi-colons. It is passing all other tests. Would you know why it's still failing that one with the linter?
from chemiscope.
Hi @3dvkr -- looking at #122 right now. I think I intended this issue to apply to the log scaling of the axes, as the sizes are never negative, but rather scaled between the max and min of the property value. This can be seen in the built chemiscope that the log-scaled sizes never make negative values disappear, but rather just get very small. However, when you apply a log scale to the axes, points do disappear. Sorry for the confusion! I should have corrected @Luthaf's original comment.
from chemiscope.
Right, I should have read the surrounding code as well =/. Really sorry about that.
This makes this issue a bit harder to deal with, the code to modify is now the three functions this._options.x.scale.onchange
/this._options.y.scale.onchange
/this._options.z.scale.onchange
; as well as changeRange
.
You can get the values for the coordinates on one axis using this._coordinates(this._option.x, 0)[0]
(and similar with this._option.y
and this._option.z
). The axis style (linear/log) is stored in this._options.x.scale.value
/this._options.y.scale.value
/this._options.z.scale.value
as either 'linear'
or 'log'
.
from chemiscope.
No problem. Would there be a threshold value that we should check for in the options.ts
file? If I understand correctly, we could have the check make sure that the values are above this threshold if the scale mode is log
instead of checking that the numbers are positive. I'll need a bit more time to comb through and come up with a plan for the three functions, but the check could acknowledge the issue to users for the time-being?
from chemiscope.
What happen in options.ts
is related to the size of the points in the map; but this issue is actually related to using log scale for the x/y/z coordinates of the points in the map.
What @rosecers was saying above is that for the size of the points, scaling happening in options.ts, and we already guarantee that values passed to Math.log
are positive by rescaling them between 0 and 1. The code doing this is here: https://github.com/cosmo-epfl/chemiscope/blob/eecc7349b2c31f992930ff7343086a8d98a28e62/src/map/options.ts#L237.
The only thing that needs a check is the corresponding code for x/y/z coordinates of the points. In this case, we use plotly's capabilities to do a logscale plot (setting xaxis.type
and friends to 'log'
), and do not compute the log ourself.
But since taking the log of a negative value results in NaN, the corresponding points are dropped from the map, and that's what the warning would have to be about.
Let me know if I'm unclear π
from chemiscope.
@3dvkr you're right on with making a threshold -- hypothetically if there's one value at 1E-12 and the rest between 1E-4 and 1E-2, we don't want the map to have the majority of the data squashed to one side and one lone point sitting on its own. Ideally it should be a tunable threshold, what do you think @Luthaf ?
from chemiscope.
There is already a min/max setting for the axis range, which should deal with this. Or are you referring to something different?
from chemiscope.
No, I'm talking with respect to this. When going to log scale, the minimum should automatically change to some epsilon > 0. Agreed?
from chemiscope.
I think this is a separate issue from this one π. My feeling here is that we should not mess with these value automatically in case the user already set them to something meaningful. If the min is negative, we will get a warning once this improvement is implemented (actually, we don't have to check all values for the warning, only the min). If the min is positive but the data distribution is strange, I'd rather leave it to the user to adapt visualization as they want.
from chemiscope.
from chemiscope.
Hi @Luthaf,
I tried going through the map.ts file, and I can find a min
value in line 369, but cannot find where the file checks the scaleMode
that the user has selected. I'm also unsure that the min
in line 369 is the same min
from options.ts.
In map.ts
there's also a this._options.size.mode.value
, line 550, which is a slightly different path than this.size.mode.value
which is what scaleMode
is assigned to in options.ts
.
They are both properties of a MapOptions-type object/class, but can you please confirm if I've found the correct values/properties in map.ts
? By checking if they're log
and negative
, would that check (this._options.size.mode.value === 'log')
be an else if
statement around line 553?
from chemiscope.
In map.ts there's also a
this._options.size.mode.value
, line 550, which is a slightly different path thanthis.size.mode.value
which is what scaleMode is assigned to in options.ts.
this._options
in the map is an instance of the MapOptions class defined in options.ts, so these refer to the same value.
But, as mentioned in the message above (#109 (comment)), this issue is not about the size.mode
option.
Instead, this is about the axis mode, stored in this._options.x.scale.value
/this._options.y.scale.value
/this._options.z.scale.value
.
I tried going through the map.ts file, and I can find a min value in line 369, but cannot find where the file checks the scaleMode that the user has selected. I'm also unsure that the min in line 369 is the same min from options.ts.
I don't think that the minimal value for coordinates along a given axis is already computed, so you would have to add code to compute it.
Overall, the code to modify would be the three callback functions this._options.x.scale.onchange
/this._options.y.scale.onchange
/this._options.z.scale.onchange
. You should compute the min value there directly; and send the warning from there directly as well.
from chemiscope.
Fixed in PR #146
from chemiscope.
Related Issues (20)
- Missing unit cell option in chemiscope jupyterwidget viewer HOT 5
- Rename master to main HOT 4
- Non-spherical particles in the structure viewer HOT 6
- Include chemiscope in docs using sphinx HOT 4
- Use labelalias when using categorical values as color
- Wrong text color with jupytelab 4 in darkmode HOT 1
- Add example of multi-dimensional property on the website HOT 2
- Example file with shapes HOT 2
- Add arrows as predefined shape type on the JS side HOT 1
- Better documentation needed for write_input(settings = ...) HOT 1
- Passing a list of lists to write_input gives an error.
- Issue with the atom labels HOT 2
- Manual is outdated, particularly for what concerns the walkthrough of the UI
- Broken link to the JSON format docs in the "Load/Save" dialog HOT 1
- Density heatmap for large datasets HOT 5
- Loading and manipulating a dataset triggers multiple, unnecessary full updates of the viewers
- Freezing upon settings change HOT 3
- Periodic neighbors of molecules are shown HOT 4
- The styling of the modals in the jupyter widget is broken HOT 1
- The new ASE release breaks all examples
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chemiscope.