From e8d0d90e3d4362e77acb390956cd67678866c3ba Mon Sep 17 00:00:00 2001 From: Kyle Conroy Date: Thu, 18 Apr 2024 09:56:03 -0400 Subject: [PATCH 1/6] Revert "temporarily avoid conflicts introduced by recent glue releases (#109)" This reverts commit 3ec3916185d11bb98c6e2351cd68be06cd5e9026. --- pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 225c740..a974fdc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,7 +20,6 @@ classifiers = [ ] dependencies = [ "astropy>=5.2", - "glue-core<1.19.0", # NOTE: if/when we stop pinning a minor version of jdaviz, add jdaviz # to devdeps in tox.ini "jdaviz==3.9.*", From a6d7b09f5e742e7342fda3128f1c85e146223649 Mon Sep 17 00:00:00 2001 From: Kyle Conroy Date: Fri, 19 Apr 2024 14:30:19 -0400 Subject: [PATCH 2/6] update jdaviz pin to pull in upstream fix --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index a974fdc..d2247f8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,7 +22,7 @@ dependencies = [ "astropy>=5.2", # NOTE: if/when we stop pinning a minor version of jdaviz, add jdaviz # to devdeps in tox.ini - "jdaviz==3.9.*", + "jdaviz>=3.9.1,<3.10.0", "lightkurve>=2.4.1", ] dynamic = [ From fe6cb7fc1ecb2839c22b37041d4db335b165794c Mon Sep 17 00:00:00 2001 From: Kyle Conroy Date: Fri, 19 Apr 2024 15:10:24 -0400 Subject: [PATCH 3/6] changelog entry --- CHANGES.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index 7eb1aa8..2669b83 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -12,6 +12,8 @@ * Raise error when parser can't identify file_obj [#106] +* Fixes compatibility with glue >= 1.19. [#109, #110] + 0.3.0 (04-05-2024) -------------------- From 7c82d5985c457ccdc83f9cd7a69bee3eb31665c1 Mon Sep 17 00:00:00 2001 From: Kyle Conroy Date: Fri, 19 Apr 2024 16:05:39 -0400 Subject: [PATCH 4/6] bypass jdaviz unit converter --- lcviz/helper.py | 15 +++++++++++++++ pyproject.toml | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lcviz/helper.py b/lcviz/helper.py index 79f9c25..143d076 100644 --- a/lcviz/helper.py +++ b/lcviz/helper.py @@ -4,13 +4,28 @@ from lightkurve import LightCurve +from glue.config import settings as glue_settings from glue.core.component_id import ComponentID from glue.core.link_helpers import LinkSame +from glue.core.units import unit_converter from jdaviz.core.helpers import ConfigHelper from lcviz.viewers import TimeScatterView __all__ = ['LCviz'] + +@unit_converter('custom-lcviz') +class UnitConverter: + def equivalent_units(self, data, cid, units): + return set(list(map(str, u.Unit(units).find_equivalent_units( + include_prefix_units=True, equivalencies=u.spectral())))) + + def to_unit(self, data, cid, values, original_units, target_units): + return (values * u.Unit(original_units)).to_value(u.Unit(target_units)) + + +glue_settings.UNIT_CONVERTER = 'custom-lcviz' + custom_components = {'plugin-ephemeris-select': 'components/plugin_ephemeris_select.vue'} # Register pure vue component. This allows us to do recursive component instantiation only in the diff --git a/pyproject.toml b/pyproject.toml index d2247f8..a974fdc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,7 +22,7 @@ dependencies = [ "astropy>=5.2", # NOTE: if/when we stop pinning a minor version of jdaviz, add jdaviz # to devdeps in tox.ini - "jdaviz>=3.9.1,<3.10.0", + "jdaviz==3.9.*", "lightkurve>=2.4.1", ] dynamic = [ From 692970db80bf2be8344daa47dcfc36afb7bb5502 Mon Sep 17 00:00:00 2001 From: Kyle Conroy Date: Fri, 19 Apr 2024 16:16:57 -0400 Subject: [PATCH 5/6] avoid error for incompat unit conversion request --- lcviz/helper.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lcviz/helper.py b/lcviz/helper.py index 143d076..586675e 100644 --- a/lcviz/helper.py +++ b/lcviz/helper.py @@ -17,10 +17,12 @@ @unit_converter('custom-lcviz') class UnitConverter: def equivalent_units(self, data, cid, units): - return set(list(map(str, u.Unit(units).find_equivalent_units( - include_prefix_units=True, equivalencies=u.spectral())))) + return set(list(map(str, u.Unit(units).find_equivalent_units(include_prefix_units=True)))) def to_unit(self, data, cid, values, original_units, target_units): + # for some reason, glue is trying to request a change for cid='flux' from d to electron / s + if target_units not in self.equivalent_units(data, cid, original_units): + return values return (values * u.Unit(original_units)).to_value(u.Unit(target_units)) From e8dedb3c9a5d2c26e3bf53715f4793a3fc027917 Mon Sep 17 00:00:00 2001 From: Kyle Conroy Date: Fri, 19 Apr 2024 19:03:44 -0400 Subject: [PATCH 6/6] TMP: expose traceback for incompat unit conversion --- lcviz/helper.py | 1 + 1 file changed, 1 insertion(+) diff --git a/lcviz/helper.py b/lcviz/helper.py index 586675e..e9207c2 100644 --- a/lcviz/helper.py +++ b/lcviz/helper.py @@ -22,6 +22,7 @@ def equivalent_units(self, data, cid, units): def to_unit(self, data, cid, values, original_units, target_units): # for some reason, glue is trying to request a change for cid='flux' from d to electron / s if target_units not in self.equivalent_units(data, cid, original_units): + raise ValueError(f"to_unit cannot convert units, cid={cid}, original_units={original_units}, target_units={target_units}, values={values}") # noqa return values return (values * u.Unit(original_units)).to_value(u.Unit(target_units))