diff --git a/glue/config.py b/glue/config.py index d12b55dce..3d789e77b 100644 --- a/glue/config.py +++ b/glue/config.py @@ -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): diff --git a/glue/core/data.py b/glue/core/data.py index 77359b96c..db6e6738c 100644 --- a/glue/core/data.py +++ b/glue/core/data.py @@ -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): diff --git a/glue/core/tests/test_data.py b/glue/core/tests/test_data.py index baa1aa825..f497d9585 100644 --- a/glue/core/tests/test_data.py +++ b/glue/core/tests/test_data.py @@ -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 @@ -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