Skip to content

Commit

Permalink
Merge branch 'hotfix/nan-vals-in-enumerated-point-probe' into main-3.X
Browse files Browse the repository at this point in the history
  • Loading branch information
mpu-creare committed Mar 4, 2024
2 parents bcae0ff + 02cbba2 commit 9921582
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
11 changes: 10 additions & 1 deletion podpac/core/test/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
7 changes: 6 additions & 1 deletion podpac/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion podpac/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
##############
MAJOR = 3
MINOR = 4
HOTFIX = 0
HOTFIX = 1
##############


Expand Down

0 comments on commit 9921582

Please sign in to comment.