Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Fixing time selection when precision is different #344

Merged
merged 4 commits into from
Dec 2, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions podpac/core/coordinates/coordinates1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,19 +350,31 @@ def select(self, bounds, return_indices=False, outer=False):
index or slice for the selected coordinates (only if return_indices=True)
"""

# empty case
if self.dtype is None:
return self._select_empty(return_indices)

if isinstance(bounds, dict):
bounds = bounds.get(self.name)
if bounds is None:
return self._select_full(return_indices)

bounds = make_coord_value(bounds[0]), make_coord_value(bounds[1])

# check type
if not isinstance(bounds[0], self.dtype):
raise TypeError(
"Input bounds do match the coordinates dtype (%s != %s)" % (type(self.bounds[0]), self.dtype)
)
if not isinstance(bounds[1], self.dtype):
raise TypeError(
"Input bounds do match the coordinates dtype (%s != %s)" % (type(self.bounds[1]), self.dtype)
)

my_bounds = self.area_bounds.copy()
mpu-creare marked this conversation as resolved.
Show resolved Hide resolved

# If the bounds are of instance datetime64, then the comparison should happen at the lowest precision
if self.dtype == np.datetime64:
if not isinstance(bounds[0], np.datetime64):
raise TypeError("Input bounds should be of type np.datetime64 when selecting data from:", str(self))

my_bounds, bounds = lower_precision_time_bounds(my_bounds, bounds, outer)

# full
Expand Down
3 changes: 0 additions & 3 deletions podpac/core/coordinates/uniform_coordinates1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,9 +389,6 @@ def _select(self, bounds, return_indices, outer):

# If the bounds are of instance datetime64, then the comparison should happen at the lowest precision
if self.dtype == np.datetime64:
if not isinstance(bounds[0], np.datetime64):
raise TypeError("Input bounds should be of type np.datetime64 when selecting data from:", str(self))

my_bounds, bounds = lower_precision_time_bounds(my_bounds, bounds, outer)

lo = max(bounds[0], my_bounds[0])
Expand Down