From 42b446f35f52c8fc177b4083c531ddfbefc5af1b Mon Sep 17 00:00:00 2001 From: Matt Ueckermann Date: Wed, 27 Dec 2023 14:46:29 -0500 Subject: [PATCH] Revert "Merge remote-tracking branch 'origin/release/3.3.0' into develop-3.X" This reverts commit da220e62fc726f7de66363e77cf42f0a8c7b0d72, reversing changes made to 9cdb687fc5fb96c7fb35f35503babb62b718b8c1. --- .../core/coordinates/array_coordinates1d.py | 8 +- .../test/test_array_coordinates1d.py | 102 ------------------ .../test/test_uniform_coordinates1d.py | 10 -- .../core/coordinates/uniform_coordinates1d.py | 12 +-- podpac/core/coordinates/utils.py | 5 +- 5 files changed, 8 insertions(+), 129 deletions(-) diff --git a/podpac/core/coordinates/array_coordinates1d.py b/podpac/core/coordinates/array_coordinates1d.py index ec756192..2bc03897 100644 --- a/podpac/core/coordinates/array_coordinates1d.py +++ b/podpac/core/coordinates/array_coordinates1d.py @@ -306,8 +306,6 @@ def dtype(self): return float elif np.issubdtype(self.coordinates.dtype, np.datetime64): return np.datetime64 - elif np.issubdtype(self.coordinates.dtype, np.timedelta64): - return np.timedelta64 @property def is_monotonic(self): @@ -341,7 +339,7 @@ def bounds(self): lo, hi = np.nan, np.nan elif self.is_monotonic: lo, hi = sorted([self.coordinates[0], self.coordinates[-1]]) - elif (self.dtype is np.datetime64) or (self.dtype == np.timedelta64): + elif self.dtype is np.datetime64: lo, hi = np.min(self.coordinates), np.max(self.coordinates) else: lo, hi = np.nanmin(self.coordinates), np.nanmax(self.coordinates) @@ -438,14 +436,14 @@ def _select(self, bounds, return_index, outer): try: gt = self.coordinates >= max(self.coordinates[self.coordinates <= bounds[0]]) except ValueError as e: - if (self.dtype == np.datetime64) or (self.dtype == np.timedelta64): + if self.dtype == np.datetime64: gt = ~np.isnat(self.coordinates) else: gt = self.coordinates >= -np.inf try: lt = self.coordinates <= min(self.coordinates[self.coordinates >= bounds[1]]) except ValueError as e: - if self.dtype == np.datetime64 or (self.dtype == np.timedelta64): + if self.dtype == np.datetime64: lt = ~np.isnat(self.coordinates) else: lt = self.coordinates <= np.inf diff --git a/podpac/core/coordinates/test/test_array_coordinates1d.py b/podpac/core/coordinates/test/test_array_coordinates1d.py index 36952705..804393bf 100644 --- a/podpac/core/coordinates/test/test_array_coordinates1d.py +++ b/podpac/core/coordinates/test/test_array_coordinates1d.py @@ -275,108 +275,6 @@ def test_datetime_array(self): assert c.step == np.timedelta64(-365, "D") repr(c) - def test_timedelta_array(self): - # unsorted - values = [np.timedelta64(0, "h"), np.timedelta64(3, "h"), np.timedelta64(1, "h"), np.timedelta64(2, "h")] - a = np.array(values).astype(np.timedelta64) - c = ArrayCoordinates1d(values) - assert_equal(c.coordinates, a) - assert_equal(c.bounds, np.array([np.timedelta64(0, "h"), np.timedelta64(3, "h")])) - assert c.coordinates[c.argbounds[0]] == c.bounds[0] - assert c.coordinates[c.argbounds[1]] == c.bounds[1] - assert c.size == 4 - assert c.shape == (4,) - assert c.dtype == np.timedelta64 - assert c.deltatype == np.timedelta64 - assert c.is_monotonic == False - assert c.is_descending == False - assert c.is_uniform == False - assert c.start is None - assert c.stop is None - assert c.step is None - repr(c) - - # sorted ascending - values = [np.timedelta64(-1, "h"), np.timedelta64(1, "h"), np.timedelta64(2, "h"), np.timedelta64(3, "h")] - a = np.array(values) - c = ArrayCoordinates1d(values) - assert_equal(c.coordinates, a) - assert_equal(c.bounds, np.array([np.timedelta64(-1, "h"), np.timedelta64(3, "h")])) - assert c.coordinates[c.argbounds[0]] == c.bounds[0] - assert c.coordinates[c.argbounds[1]] == c.bounds[1] - assert c.size == 4 - assert c.shape == (4,) - assert c.dtype == np.timedelta64 - assert c.deltatype == np.timedelta64 - assert c.is_monotonic == True - assert c.is_descending == False - assert c.is_uniform == False - assert c.start is None - assert c.stop is None - assert c.step is None - repr(c) - - # sorted descending - values = [np.timedelta64(-1, "h"), np.timedelta64(1, "h"), np.timedelta64(2, "h"), np.timedelta64(3, "h")] - values = values[::-1] - a = np.array(values) - c = ArrayCoordinates1d(values) - assert_equal(c.coordinates, a) - assert_equal(c.bounds, np.array([np.timedelta64(-1, "h"), np.timedelta64(3, "h")])) - assert c.coordinates[c.argbounds[0]] == c.bounds[0] - assert c.coordinates[c.argbounds[1]] == c.bounds[1] - assert c.size == 4 - assert c.shape == (4,) - assert c.dtype == np.timedelta64 - assert c.deltatype == np.timedelta64 - assert c.is_monotonic == True - assert c.is_descending == True - assert c.is_uniform == False - assert c.start is None - assert c.stop is None - assert c.step is None - repr(c) - - # uniform ascending - values = [np.timedelta64(0, "h"), np.timedelta64(1, "h"), np.timedelta64(2, "h"), np.timedelta64(3, "h")] - a = np.array(values) - c = ArrayCoordinates1d(values) - assert_equal(c.coordinates, a) - assert_equal(c.bounds, np.array([np.timedelta64(0, "h"), np.timedelta64(3, "h")])) - assert c.coordinates[c.argbounds[0]] == c.bounds[0] - assert c.coordinates[c.argbounds[1]] == c.bounds[1] - assert c.size == 4 - assert c.shape == (4,) - assert c.dtype == np.timedelta64 - assert c.deltatype == np.timedelta64 - assert c.is_monotonic == True - assert c.is_descending == False - assert c.is_uniform == True - assert c.start == np.timedelta64(0, "h") - assert c.stop == np.timedelta64(3, "h") - assert c.step == np.timedelta64(1, "h") - repr(c) - - # uniform descending - values = [np.timedelta64(0, "h"), np.timedelta64(1, "h"), np.timedelta64(2, "h"), np.timedelta64(3, "h")][::-1] - a = np.array(values) - c = ArrayCoordinates1d(values) - assert_equal(c.coordinates, a) - assert_equal(c.bounds, np.array([np.timedelta64(0, "h"), np.timedelta64(3, "h")])) - assert c.coordinates[c.argbounds[0]] == c.bounds[0] - assert c.coordinates[c.argbounds[1]] == c.bounds[1] - assert c.size == 4 - assert c.shape == (4,) - assert c.dtype == np.timedelta64 - assert c.deltatype == np.timedelta64 - assert c.is_monotonic == True - assert c.is_descending == True - assert c.is_uniform == True - assert c.start == np.timedelta64(3, "h") - assert c.stop == np.timedelta64(0, "h") - assert c.step == np.timedelta64(-1, "h") - repr(c) - def test_numerical_shaped(self): values = [[1.0, 2.0, 3.0], [11.0, 12.0, 13.0]] c = ArrayCoordinates1d(values) diff --git a/podpac/core/coordinates/test/test_uniform_coordinates1d.py b/podpac/core/coordinates/test/test_uniform_coordinates1d.py index c9b3e0da..a25b40a0 100644 --- a/podpac/core/coordinates/test/test_uniform_coordinates1d.py +++ b/podpac/core/coordinates/test/test_uniform_coordinates1d.py @@ -114,16 +114,6 @@ def test_datetime(self): assert c.is_descending == True assert c.is_uniform == True - def test_timedelta(self): - c = UniformCoordinates1d(np.timedelta64(0, "h"), np.timedelta64(5, "h"), np.timedelta64(1, "h")) - assert c.start == np.timedelta64(0, "h") - assert c.stop == np.timedelta64(5, "h") - assert c.step == np.timedelta64(1, "h") - c = UniformCoordinates1d(np.timedelta64(5, "h"), np.timedelta64(0, "h"), np.timedelta64(-1, "h")) - assert c.start == np.timedelta64(5, "h") - assert c.stop == np.timedelta64(0, "h") - assert c.step == np.timedelta64(-1, "h") - def test_datetime_inexact(self): # ascending c = UniformCoordinates1d("2018-01-01", "2018-01-06", "2,D") diff --git a/podpac/core/coordinates/uniform_coordinates1d.py b/podpac/core/coordinates/uniform_coordinates1d.py index f5a4d1c1..3f7ae039 100644 --- a/podpac/core/coordinates/uniform_coordinates1d.py +++ b/podpac/core/coordinates/uniform_coordinates1d.py @@ -52,10 +52,10 @@ class UniformCoordinates1d(Coordinates1d): :class:`Coordinates1d`, :class:`ArrayCoordinates1d`, :class:`crange`, :class:`clinspace` """ - start = tl.Union([tl.Float(), tl.Instance(np.datetime64), tl.Instance(np.timedelta64)], read_only=True) + start = tl.Union([tl.Float(), tl.Instance(np.datetime64)], read_only=True) start.__doc__ = ":float, datetime64: Start coordinate." - stop = tl.Union([tl.Float(), tl.Instance(np.datetime64), tl.Instance(np.timedelta64)], read_only=True) + stop = tl.Union([tl.Float(), tl.Instance(np.datetime64)], read_only=True) stop.__doc__ = ":float, datetime64: Stop coordinate." step = tl.Union([tl.Float(), tl.Instance(np.timedelta64)], read_only=True) @@ -110,10 +110,6 @@ def __init__(self, start, stop, step=None, size=None, name=None, fix_stop_val=Fa fstep = step elif isinstance(start, np.datetime64) and isinstance(stop, np.datetime64) and isinstance(step, np.timedelta64): fstep = step.astype(float) - elif ( - isinstance(start, np.timedelta64) and isinstance(stop, np.timedelta64) and isinstance(step, np.timedelta64) - ): - fstep = step.astype(float) else: raise TypeError( "UniformCoordinates1d mismatching types (start '%s', stop '%s', step '%s')." @@ -290,7 +286,7 @@ def __contains__(self, item): if item < self.bounds[0] or item > self.bounds[1]: return False - if (self.dtype == np.datetime64) or (self.dtype == np.timedelta64): + if self.dtype == np.datetime64: return timedelta_divisible(item - self.start, self.step) else: return (item - self.start) % self.step == 0 @@ -503,7 +499,7 @@ def issubset(self, other): if self.size == 1: return True - if (self.dtype == np.datetime64) or (self.dtype == np.timedelta64): + if self.dtype == np.datetime64: return timedelta_divisible(self.step, other.step) else: return self.step % other.step == 0 diff --git a/podpac/core/coordinates/utils.py b/podpac/core/coordinates/utils.py index d8f731dd..fdbb3ab6 100644 --- a/podpac/core/coordinates/utils.py +++ b/podpac/core/coordinates/utils.py @@ -264,7 +264,7 @@ def make_coord_array(values): a = np.atleast_1d(values) - if a.dtype == float or np.issubdtype(a.dtype, np.datetime64) or np.issubdtype(a.dtype, np.timedelta64): + if a.dtype == float or np.issubdtype(a.dtype, np.datetime64): pass elif np.issubdtype(a.dtype, np.number): @@ -666,7 +666,4 @@ def add_valid_dimension(dimension_name): if dimension_name in VALID_DIMENSION_NAMES: raise ValueError(f"Dim `{dimension_name}` already a valid dimension.") - if "-" in dimension_name or "_" in dimension_name: - raise ValueError(f"Dim `{dimension_name}` may note contain `-` or `_`.") - VALID_DIMENSION_NAMES.append(dimension_name)