Skip to content

Map ordinal selected values against their position in the domain#1379

Merged
martinRenou merged 4 commits intobqplot:masterfrom
dfreeman06:ordinal_brushing_domain
Jun 28, 2021
Merged

Map ordinal selected values against their position in the domain#1379
martinRenou merged 4 commits intobqplot:masterfrom
dfreeman06:ordinal_brushing_domain

Conversation

@dfreeman06
Copy link
Copy Markdown

@dfreeman06 dfreeman06 commented Jun 16, 2021

Attempt to address #1378. Mapping the Ordinal selected values from a brush through their index position in the domain.

Comment thread js/src/OrdinalScaleModel.ts Outdated

typedRange(values) {
return new Int32Array(values.map(Number));
return new Int32Array(values.map((value) => this.domain.indexOf(value)));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could it just be:

return new Int32Array(values.map(this.domain.indexOf));

this would avoid allocating a new function/scope each time... though maybe the this shenanigans come into play...

Copy link
Copy Markdown
Author

@dfreeman06 dfreeman06 Jun 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I originally tried that, but it was throwing errors... probably due to this shenanigans.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

k, how about:

return new Int32Array(values.map(this.domain.indexOf, this.domain));

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that behaves and pushed the change.

@sanbales
Copy link
Copy Markdown

sanbales commented Jun 16, 2021

W.r.t. the test, the closest PR I can find didn't add a test, and looking through the existing tests, I'm not sure how we would add a test for this.

Maybe @martinRenou or @maartenbreddels can you point us to a PR that did something similar and had a test for it?

The process for producing the error is here, but it requires manual brushing.

@martinRenou
Copy link
Copy Markdown
Member

Since recently we added galata tests in bqplot. Galata should have everything for "manually" testing the brush and checking that it renders properly. But that requires good knowledge of galata which I don't have...

Can this be bug be triggered programmatically from Python? That should help create a visual test. I can look into it.

@dfreeman06
Copy link
Copy Markdown
Author

Thanks @martinRenou, it looks like that should work. However, in investigating programmatically setting the brush selected_y values another concern popped up.

This PR originally introduces using the domain index for the values in the brush's selected traits which is different than the existing behavior which uses the domain values itself. It might be more consistent to deal with the indices in the domain, however to minimize changes to other users it looks like the:

  typedRange(values) {
    return new Int32Array(values.map(this.domain.indexOf, this.domain));
  }

could be replaced with:

  typedRange(values) {
    return values;
  }

There is also a new galata test notebook ordinal_scale.ipynb which tests two different figures. One figure uses the ordinal scale with strings while the other uses the ordinal scale with integers. The test notebook also programatically sets the brush's selected values and captures the output screenshots.

@sanbales
Copy link
Copy Markdown

Since recently we added galata tests in bqplot. Galata should have everything for "manually" testing the brush and checking that it renders properly. But that requires good knowledge of galata which I don't have...

Can this be bug be triggered programmatically from Python? That should help create a visual test. I can look into it.

@martinRenou : @dfreeman06 added a test using Galata that we believe is working and testing the brushes programmatically, at least locally it is passing, would it be possible to run the workflow to see if everything is on the up and up?

@sanbales
Copy link
Copy Markdown

Just a friendly ping to the BQPlot team to see if there is something else we should do for this PR. Also curious if @maartenbreddels has any issues with this as per his PR.


typedRange(values) {
return new Int32Array(values.map(Number));
return values;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per @bollwyvl 's recommendation, this could be:

return new Int32Array(values.map(this.domain.indexOf, this.domain));

Which would make the scale work with the indeces of the domain (I believe that is what is meant by range here, @maartenbreddels please don't hesitate to let us know if we misunderstood what was intended by range).

We went with the values instead because otherwise it could break other people's code, but we acknowledge it would probably be better to use the line above.

@bollwyvl
Copy link
Copy Markdown
Contributor

y'all let me know if there's anything i can do to push this forward...

Copy link
Copy Markdown

@sanbales sanbales left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure non-contributor reviews matter, but in case it does, here is my approval.

@martinRenou
Copy link
Copy Markdown
Member

Thanks for adding tests. Ideally, we would add a galata test that simulates a selection with the mouse and test that the selected_y attribute gets changed properly. But I don't know yet how to do that, so let's merge and see later!

Thanks!

@martinRenou martinRenou merged commit a1a44f0 into bqplot:master Jun 28, 2021
@bollwyvl
Copy link
Copy Markdown
Contributor

bollwyvl commented Jul 9, 2021

Everybody's real busy, for sure, but Is there a timeline for a .30 release? Anything we can do to help?

martinRenou pushed a commit to martinRenou/bqscales that referenced this pull request Aug 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants