Skip to content

Commit 3a3a172

Browse files
committed
Catch case where there are no pairs of stations when inferring pandas data resolution
1 parent 23e055b commit 3a3a172

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

deepsensor/data/utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,11 @@ def compute_pandas_data_resolution(
102102
closest_distances = []
103103
df = df.reset_index().set_index("time")
104104
for time in dates:
105-
df_t = df.loc[time]
105+
df_t = df.loc[[time]]
106106
X = df_t[["x1", "x2"]].values # (N, 2) array of coordinates
107+
if X.shape[0] < 2:
108+
# Skip this time if there are fewer than 2 stationS
109+
continue
107110
X_unique = np.unique(X, axis=0) # (N_unique, 2) array of unique coordinates
108111

109112
pairwise_distances = scipy.spatial.distance.cdist(X_unique, X_unique)

0 commit comments

Comments
 (0)