Skip to content
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

DataFilterExtension bug - 'get_filter_value' trait of a ScatterplotLayer instance expected filter_size (3) to match 2nd dimension of numpy array #363

Closed
jaanli opened this issue Feb 14, 2024 · 8 comments

Comments

@jaanli
Copy link

jaanli commented Feb 14, 2024

Context

Need to make several dashboards that have filtering linked to a map (#353).

Issue

Cannot use DataFilter extension: getting this error -

TraitError: The 'get_filter_value' trait of a ScatterplotLayer instance expected filter_size (3) to match 2nd dimension of numpy array, not the ndarray array([[12500.],

To reproduce: https://github.com/jaanli/lonboard/blob/example-american-community-survey/examples/american-community-survey.ipynb

Acceptance-Criteria

Mapping various census variables and filtering using them for exploratory data analysis and understanding social value + capital deployment using our tax dollars.

@kylebarron
Copy link
Member

kylebarron commented Feb 14, 2024

You're passing

filter_extension = DataFilterExtension(filter_size=3)

If you're filtering on one column you need to remove that or set to 1 (the default)

Aside: We should probably create a bug-specific issue ticket format. cc @emmalu

@kylebarron
Copy link
Member

Additionally you only need to create a multi-dimensional array when filter_size > 1, so you don't need the np.column_stack

@jaanli
Copy link
Author

jaanli commented Feb 14, 2024

Awesome, figured it was something simple. Thank you Kyle!!

@jaanli jaanli closed this as completed Feb 14, 2024
@jaanli
Copy link
Author

jaanli commented Feb 14, 2024

Small note in case this is under active development: instead of filter_size, would a rename to num_filters be viable? Or setting this automatically based on filter values or range...

(Coming from machine learning, 'size' in variable names tend to be for other things.)

@jaanli jaanli reopened this Feb 14, 2024
@jaanli
Copy link
Author

jaanli commented Feb 14, 2024

Reopening this in case others run into this too:

After fixing the filter_size parameter, I am unable to see the output:

In VS Code (seems like a separate issue):

image

In Jupyter notebook on Chrome (started with jupyter notebook):

image

Any idea how to fix the display of the filters?

Getting closer! Super exciting :D

@jaanli
Copy link
Author

jaanli commented Feb 14, 2024

Fixed! Had to:

  • restart the Jupyter kernel to get it working in VS Code
  • pass in a single slider instead of a MultiRangeSlider (was getting size mismatch errors otherwise that I couldn't figure out - could add different error messages when someone tries to pass a single slider to a MultiRangeSlider as a nice-to-have?)

Thank you!!

image

Super exciting!!

@jaanli jaanli closed this as completed Feb 14, 2024
@emmalu
Copy link
Member

emmalu commented Feb 14, 2024

Aside: We should probably create a bug-specific issue ticket format. cc @emmalu

💯 Will do!

@kylebarron
Copy link
Member

Small note in case this is under active development: instead of filter_size, would a rename to num_filters be viable?

I agree that I don't love filter_size, but that's the term used by upstream deck.gl and I'm reluctant to remove this consistency. We try to document this in the API docs https://developmentseed.org/lonboard/latest/api/layer-extensions/data-filter-extension/#lonboard.layer_extension.DataFilterExtension.filter_size. (Thought it is a little unclear the distinction between constructor parameters and layer parameters in the docs)

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

No branches or pull requests

3 participants