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

Fix GridSpace and GridMatrix sort=False #3769

Merged
merged 3 commits into from
Jun 21, 2019
Merged

Fix GridSpace and GridMatrix sort=False #3769

merged 3 commits into from
Jun 21, 2019

Conversation

poplarShift
Copy link
Collaborator

@poplarShift poplarShift commented Jun 12, 2019

Fixes #3462

Previously, sorted(set(...)) implicitly sorted grid keys, now passing sort=False has the intended effect:

import numpy as np
import holoviews as hv
hv.extension('matplotlib')

data = hv.Image(np.random.rand(10,10))
imgs = [
    (('C', 'dummy'), data),
    (('D', 'dummy'), data),
    (('A', 'dummy'), data),
    (('B', 'dummy'), data)
]
hv.GridSpace(imgs, sort=False, kdims=['dim1','dim2'])

Screen Shot 2019-06-12 at 12 29 10 PM

Screen Shot 2019-06-12 at 12 29 31 PM

#3770 is vaguely related (this PR highlights some code duplication) in the (non-) sorting of dimension values.

@poplarShift poplarShift added the type: bug Something isn't correct or isn't working label Jun 12, 2019
@philippjfr
Copy link
Member

There does seem to be a real failure in the Python 2 tests. Presumably something to do with dict ordering? Can't wait to drop py2 support.

@poplarShift
Copy link
Collaborator Author

poplarShift commented Jun 21, 2019

Great,

print(sorted(set(('c', 'b'))))
print(list(dict.fromkeys(('c', 'b'))))

print(sorted(set(('b', 'c'))))
print(list(dict.fromkeys(('b', 'c'))))

Yields

['b', 'c']
['c', 'b']
['b', 'c']
['b', 'c']

in python 3

but

['b', 'c']
['c', 'b']
['b', 'c']
['c', 'b']

in python 2!

@poplarShift
Copy link
Collaborator Author

So, that should do the trick I hope...

@philippjfr philippjfr merged commit b78a1a5 into master Jun 21, 2019
@philippjfr philippjfr deleted the grid_nosort branch August 5, 2019 13:54
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug Something isn't correct or isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GridMatrix(sort=False) still sorts keys
2 participants