From 3ac79158b29fcdfdd3ff10a93f2f75d131c13539 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 20 Jan 2023 22:40:27 -0800 Subject: [PATCH] Made typing explicit in sts.py Newer versions of NumPy don't support inferring dtype=object from sequences, and this raises a ValueError (and a warning in older versions) See: https://numpy.org/neps/nep-0034-infer-dtype-is-object.html --- senteval/sts.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/senteval/sts.py b/senteval/sts.py index 541a1b7d..d3068219 100644 --- a/senteval/sts.py +++ b/senteval/sts.py @@ -39,8 +39,8 @@ def loadFile(self, fpath): not_empty_idx = raw_scores != '' gs_scores = [float(x) for x in raw_scores[not_empty_idx]] - sent1 = np.array([s.split() for s in sent1])[not_empty_idx] - sent2 = np.array([s.split() for s in sent2])[not_empty_idx] + sent1 = np.array([s.split() for s in sent1], dtype=object)[not_empty_idx] + sent2 = np.array([s.split() for s in sent2], dtype=object)[not_empty_idx] # sort data by length to minimize padding in batcher sorted_data = sorted(zip(sent1, sent2, gs_scores), key=lambda z: (len(z[0]), len(z[1]), z[2]))