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

Provide a way to avoid creating world<->pixel links in datasets #2526

Merged
merged 2 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions glue/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,7 @@ def _default_search_order():
settings.add('SHOW_WARN_PROFILE_DUPLICATE', True, validator=bool)
settings.add('FONT_SIZE', -1.0, validator=float)
settings.add('AUTOLINK', {}, validator=dict)
settings.add('AUTO_COMPUTE_COORDS_LINKS', True, validator=bool)


def check_unit_converter(value):
Expand Down
3 changes: 2 additions & 1 deletion glue/core/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -1179,7 +1179,8 @@ def delay_callbacks():
label = axis_label(self.coords, i)
cid = self.add_component(comp, label)
self._world_component_ids.append(cid)
self._set_up_coordinate_component_links(ndim)
if settings.AUTO_COMPUTE_COORDS_LINKS:
self._set_up_coordinate_component_links(ndim)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I assume the creation of the components above is still required.

Copy link
Member Author

Choose a reason for hiding this comment

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

We could remove that but it would be a bigger change - best to try this in a separate PR


def _set_up_coordinate_component_links(self, ndim):

Expand Down
18 changes: 18 additions & 0 deletions glue/core/tests/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from astropy.utils import NumpyRNGContext

from glue import core
from glue.config import settings

from ..component import Component, DerivedComponent, CategoricalComponent, DateTimeComponent
from ..component_id import ComponentID
Expand Down Expand Up @@ -1185,3 +1186,20 @@ def test_compute_histogram_random_subset_dask():

result = data.compute_histogram([data.id['x'], data.id['y']], range=[[-0.5, 10.5], [-0.5, 1.5]], bins=[5, 1], weights=data.id['y'], random_subset=100_000)
assert_allclose(result[:, 0], [178535., 230694., 229997., 231215., 178135.], atol=20_000)


def test_disable_auto_links():

settings.AUTO_COMPUTE_COORDS_LINKS = False

data1 = Data(a=[1, 2, 3], b=[2, 3, 4], label='data1',
coords=IdentityCoordinates(n_dim=1))

assert len(data1.links) == 0

settings.AUTO_COMPUTE_COORDS_LINKS = True

data2 = Data(a=[1, 2, 3], b=[2, 3, 4], label='data1',
coords=IdentityCoordinates(n_dim=1))

assert len(data2.links) == 2
Loading