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

Ensure named_objs does not fail on unhashable objects #632

Merged
merged 4 commits into from
May 26, 2022

Conversation

philippjfr
Copy link
Member

@philippjfr philippjfr commented May 25, 2022

Not all objects are hashable so the named_objs implementation has started causing some errors (e.g. because mpl colormaps aren't hashable anymore). For unhashable objects we try to reverse map the objects by identity.

@codecov-commenter
Copy link

codecov-commenter commented May 25, 2022

Codecov Report

Merging #632 (91399e5) into master (d960230) will decrease coverage by 0.05%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master     #632      +/-   ##
==========================================
- Coverage   82.91%   82.86%   -0.06%     
==========================================
  Files           5        5              
  Lines        3073     3081       +8     
==========================================
+ Hits         2548     2553       +5     
- Misses        525      528       +3     
Impacted Files Coverage Δ
numbergen/__init__.py 80.56% <0.00%> (-0.15%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d960230...91399e5. Read the comment docs.

@jbednar
Copy link
Member

jbednar commented May 26, 2022

y main confusion here is why it even attempts a reverse mapping at all if an explicit namesdict has already been provided.

Even if an explicit namesdict has been provided, it isn't required to be complete. Where that matters is if check_on_set=False for this Selector, in which case someone can do Obj.x=val, for any val, whether that value is in the namesdict or not. The namesdict will then be incomplete, and so named_objs attempts to complete it by providing some representation for every item in the object list. Here you could maybe skip any unhashable items while still attempting to provide a representation for hashable items? But you'd then need the rest of the code to gracefully handle the case of an object not being in the namesdict.

@philippjfr
Copy link
Member Author

But you'd then need the rest of the code to gracefully handle the case of an object not being in the namesdict.

The rest of the code being what in this case? Panel already does and afaik that's the only thing that actually uses the names.

Copy link
Member

@jbednar jbednar left a comment

Choose a reason for hiding this comment

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

As revised this seems ok to merge, though really Selector needs to just store proper mappings as outlined in other PRs and issues...

@philippjfr philippjfr merged commit 9f1f855 into master May 26, 2022
@philippjfr philippjfr deleted the named_objs_not_hashable branch May 26, 2022 14:56
@maximlt maximlt mentioned this pull request Mar 10, 2023
8 tasks
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.

3 participants