Skip to content

Commit

Permalink
Fix when reading np.int64 integers (#60)
Browse files Browse the repository at this point in the history
* Fix when reading np.int64 integers

* Update changelog

* Fix no station within selected dist with new pygeogrids version
  • Loading branch information
wpreimes authored Jan 19, 2023
1 parent 96f8a39 commit ced57ab
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Version 1.3.1

- Added functionality to provide fill values with predefined custom metadata readers.
- Documentation and constants updated.
- ``ISMN_Interface.read_ts`` raised an error when np.int64 was passed.
- Fixed for `pygeogrids>=0.4.2` where dist=np.inf can be returned if

Version 1.3.0
=============
Expand All @@ -21,7 +23,6 @@ Version 1.3.0
- RTD build uses a separate, smaller environment.yml now (and mamba)
- ISMN_Interface now has a method to create an instance of itself for a selection of (`ISMN_Interface.subset_from_ids`)


Version 1.2.0
=============

Expand Down
12 changes: 4 additions & 8 deletions src/ismn/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,11 @@
from pathlib import Path
from tempfile import gettempdir
import platform
import os
import sys
from typing import Optional, Union

import numpy as np
import pandas as pd

from ismn.filecollection import IsmnFileCollection, _load_metadata_df
from ismn.filecollection import IsmnFileCollection
from collections.abc import Iterable
from ismn.components import *
from ismn.const import *
from ismn.base import IsmnRoot
Expand Down Expand Up @@ -542,8 +539,7 @@ def read_ts(self, idx, return_meta=False):
`return_meta=False`. If multiple indices were passed, this is a
DataFrame with the index as columns, otherwise a Series.
"""

if isinstance(idx, int):
if not isinstance(idx, Iterable):
filehandler = self.__file_collection.get_filehandler(idx)
if return_meta:
return filehandler.read_data(), filehandler.metadata.to_pd()
Expand Down Expand Up @@ -608,7 +604,7 @@ def find_nearest_station(self,
gpi, d = self.collection.grid.find_nearest_gpi(
lon, lat, max_dist=max_dist)

if len(np.atleast_1d(gpi)) == 0:
if (len(np.atleast_1d(gpi)) == 0) or (d == np.inf):
stat = None
d = None
else:
Expand Down

0 comments on commit ced57ab

Please sign in to comment.