Skip to content

Commit

Permalink
Fix segfault
Browse files Browse the repository at this point in the history
  • Loading branch information
ppinchuk committed Feb 4, 2025
1 parent 0f899d8 commit 95a9edf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion rex/external/rexarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,9 @@ def _getitem(self, key):
with self.datastore.lock:
array = self.get_array(needs_lock=False)
if _is_time_index(self.variable_name):
return array[key].astype(TI_DTYPE)
values_as_str = array[key].astype("U")
values_no_tz = np.char.partition(values_as_str, "+")[:, 0]
return values_no_tz.astype(TI_DTYPE)

if _is_from_meta(self.meta_index):
if self.variable_name == "gid":
Expand Down
2 changes: 1 addition & 1 deletion tests/test_rexarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def check_data(fp, ds, group=None):

@pytest.mark.parametrize('fp', [WTK_2012_FP, WTK_2013_FP, WTK_2010_100M,
WTK_2010_200M, SZA_2012, SZA_2013, NSRDB_2012,
NSRDB_2013])
NSRDB_2013, WAVE_2010])
def test_open_with_xr(fp):
with xr.open_dataset(fp, engine="rex") as ds:
check_ti(fp, ds)
Expand Down

0 comments on commit 95a9edf

Please sign in to comment.