Skip to content

Commit

Permalink
Merge pull request #2526 from astrofrog/disable-auto-coords-link
Browse files Browse the repository at this point in the history
Provide a way to avoid creating world<->pixel links in datasets
  • Loading branch information
astrofrog authored Jan 10, 2025
2 parents f356aeb + 4c4f651 commit 11d9f8d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
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)

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

0 comments on commit 11d9f8d

Please sign in to comment.