Skip to content

Commit

Permalink
Revert "Merge remote-tracking branch 'origin/release/3.3.0' into deve…
Browse files Browse the repository at this point in the history
…lop-3.X"

This reverts commit da220e6, reversing
changes made to 9cdb687.
  • Loading branch information
mpu-creare committed Dec 27, 2023
1 parent 475d241 commit 42b446f
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 129 deletions.
8 changes: 3 additions & 5 deletions podpac/core/coordinates/array_coordinates1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
102 changes: 0 additions & 102 deletions podpac/core/coordinates/test/test_array_coordinates1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 0 additions & 10 deletions podpac/core/coordinates/test/test_uniform_coordinates1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
12 changes: 4 additions & 8 deletions podpac/core/coordinates/uniform_coordinates1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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')."
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions podpac/core/coordinates/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)

0 comments on commit 42b446f

Please sign in to comment.