Skip to content

Commit 3d05d46

Browse files
authored
Ignore cpflows dependencies in test workflows, fix numpy 2 incompatibilities. (#3227)
*Issue #, if available:* CPFlows is a dependency for `gluonts.torch.model.mqf2`, but it comes with dependencies constraints that hold us back. So for example, not the latest numpy version was used in CI tests. *Description of changes:* Ignore dependencies of CPFlows in GitHub workflows. Fix incompatibilities with the latest numpy. By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice. **Please tag this pr with at least one of these labels to make our release process faster:** BREAKING, new feature, bug fix, other change, dev setup
1 parent ede5664 commit 3d05d46

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

.github/workflows/tests-torch.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ jobs:
2424
pip install ".[arrow]" \
2525
-r requirements/requirements-test.txt \
2626
-r requirements/requirements-extras-m-competitions.txt \
27-
-r requirements/requirements-pytorch.txt \
28-
-r requirements/requirements-extras-cpflows.txt
27+
-r requirements/requirements-pytorch.txt
28+
pip install --no-deps -r requirements/requirements-extras-cpflows.txt
2929
- name: Test with pytest
3030
run: |
3131
pytest -n2 --doctest-modules --ignore test/nursery test

test/torch/distribution/test_negative_binomial.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# permissions and limitations under the License.
1313

1414
import pytest
15+
import sys
1516

1617
import numpy as np
1718
import torch
@@ -49,11 +50,13 @@ def test_custom_neg_bin_cdf(total_count, probs, value):
4950
@pytest.mark.parametrize("probs", [0.1, 0.5, 0.8])
5051
@pytest.mark.parametrize("total_count", [3, 7, 100])
5152
@pytest.mark.parametrize("value", [0.1, 0.5, 0.9])
52-
def test_custom_studentt_icdf(total_count, probs, value):
53+
def test_custom_neg_bin_icdf(total_count, probs, value):
5354
torch_dist = NegativeBinomial(total_count=total_count, probs=probs)
5455
scipy_dist = torch_dist.scipy_nbinom
5556

56-
torch_icdf = torch_dist.icdf(torch.as_tensor(value)).numpy()
57+
torch_icdf = torch_dist.icdf(
58+
torch.as_tensor(value, dtype=torch.float64)
59+
).numpy()
5760
scipy_icdf = scipy_dist.ppf(np.asarray(value))
5861

5962
assert np.allclose(torch_icdf, scipy_icdf)

test/transform/test_transform.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ def test_AddTimeFeatures(start, target, is_train: bool):
155155
tmp_idx = pd.period_range(
156156
start=start, freq=start.freq, periods=expected_length
157157
)
158-
assert np.alltrue(mat[0] == time_feature.day_of_week(tmp_idx))
159-
assert np.alltrue(mat[1] == time_feature.day_of_month(tmp_idx))
158+
assert np.all(mat[0] == time_feature.day_of_week(tmp_idx))
159+
assert np.all(mat[1] == time_feature.day_of_month(tmp_idx))
160160

161161

162162
@pytest.mark.parametrize("is_train", TEST_VALUES["is_train"])
@@ -285,7 +285,7 @@ def test_InstanceSplitter(
285285

286286
# expected_length = len(target) + (0 if is_train else pred_length)
287287
# assert len(out['age']) == expected_length
288-
# assert np.alltrue(out['age'] == np.log10(2.0 + np.arange(expected_length)))
288+
# assert np.all(out['age'] == np.log10(2.0 + np.arange(expected_length)))
289289

290290

291291
@pytest.mark.parametrize("is_train", TEST_VALUES["is_train"])

0 commit comments

Comments
 (0)