diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d9f2260..44be66d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 3.4.1 Point Probe Value Format for Enumerated Legends HOTFIX + +### Hotfix +* Deals with 'nan' value for enumerated legends. + ## 3.4.0 Point Probe Value Format for Enumerated Legends ### Features diff --git a/podpac/core/test/test_utils.py b/podpac/core/test/test_utils.py index ed9f7e2f..05d2fcc6 100644 --- a/podpac/core/test/test_utils.py +++ b/podpac/core/test/test_utils.py @@ -715,9 +715,10 @@ def test_prober_with_enumerated_legends(self): enumeration_legend={0: "dirt", 1: "sand"}, enumeration_colors={0: (0, 0, 0), 1: (0.5, 0.5, 0.5)}, ) + nan = podpac.data.Array(source=np.ones((3, 3), int) * np.nan, coordinates=self.coords, style=enumeration_style) one = podpac.data.Array(source=np.ones((3, 3), int), coordinates=self.coords, style=enumeration_style) zero = podpac.data.Array(source=np.zeros((3, 3), int), coordinates=self.coords, style=enumeration_style) - a = podpac.compositor.OrderedCompositor(sources=[one, zero], style=enumeration_style) + a = podpac.compositor.OrderedCompositor(sources=[nan, one, zero], style=enumeration_style) expected = { "name": "composited", @@ -727,6 +728,14 @@ def test_prober_with_enumerated_legends(self): "params": {}, "inputs": { "inputs": [ + { + "name": "composited", + "value": "nan (unknown) my_units", + "active": False, + "node_id": nan.hash, + "params": {}, + "inputs": {}, + }, { "name": "composited", "value": "1 (sand) my_units", diff --git a/podpac/core/utils.py b/podpac/core/utils.py index ae9e6181..82ded19f 100644 --- a/podpac/core/utils.py +++ b/podpac/core/utils.py @@ -569,7 +569,12 @@ def get_entry(key, out, definition): def format_value(value, style, add_enumeration_labels): if not add_enumeration_labels or style.enumeration_legend is None: return value - return str(int(value)) + " ({})".format(style.enumeration_legend[int(value)]) + if np.isnan(value): + return str(value) + " (unknown)" + try: + return str(int(value)) + " ({})".format(style.enumeration_legend[int(value)]) + except ValueError: + return str(value) + " (unknown)" c = [(v, d) for v, d in zip([lat, lon, time, alt], ["lat", "lon", "time", "alt"]) if v is not None] coords = podpac.Coordinates([[v[0]] for v in c], [[d[1]] for d in c], crs=crs) diff --git a/podpac/version.py b/podpac/version.py index d94e5a53..050a0bc1 100644 --- a/podpac/version.py +++ b/podpac/version.py @@ -17,7 +17,7 @@ ############## MAJOR = 3 MINOR = 4 -HOTFIX = 0 +HOTFIX = 1 ##############