GithubHelp home page GithubHelp logo

Comments (16)

Luthaf avatar Luthaf commented on June 11, 2024 1

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.

Luthaf avatar Luthaf commented on June 11, 2024

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.

3dvkr avatar 3dvkr commented on June 11, 2024

@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.

3dvkr avatar 3dvkr commented on June 11, 2024

@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.

rosecers avatar rosecers commented on June 11, 2024

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.

Luthaf avatar Luthaf commented on June 11, 2024

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.

https://github.com/cosmo-epfl/chemiscope/blob/eecc7349b2c31f992930ff7343086a8d98a28e62/src/map/map.ts#L350-L358

https://github.com/cosmo-epfl/chemiscope/blob/eecc7349b2c31f992930ff7343086a8d98a28e62/src/map/map.ts#L362

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.

3dvkr avatar 3dvkr commented on June 11, 2024

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.

Luthaf avatar Luthaf commented on June 11, 2024

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.

https://github.com/cosmo-epfl/chemiscope/blob/eecc7349b2c31f992930ff7343086a8d98a28e62/src/map/map.ts#L350-L358

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.

rosecers avatar rosecers commented on June 11, 2024

@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.

Luthaf avatar Luthaf commented on June 11, 2024

There is already a min/max setting for the axis range, which should deal with this. Or are you referring to something different?

Capture d’écran 2021-03-02 aΜ€ 15 03 54

from chemiscope.

rosecers avatar rosecers commented on June 11, 2024

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.

Luthaf avatar Luthaf commented on June 11, 2024

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.

ceriottm avatar ceriottm commented on June 11, 2024

from chemiscope.

3dvkr avatar 3dvkr commented on June 11, 2024

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.

Luthaf avatar Luthaf commented on June 11, 2024

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.

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.

jakublala avatar jakublala commented on June 11, 2024

Fixed in PR #146

from chemiscope.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.