|
| 1 | +# TODO the tests below only verify that the various functions don't crash. |
| 2 | +# Expand them to test the actual output contents. |
| 3 | + |
| 4 | +import platform |
| 5 | + |
| 6 | +import pytest |
| 7 | +import numpy as np |
| 8 | + |
| 9 | +import ml_datasets |
| 10 | + |
| 11 | +NP_VERSION = tuple(int(x) for x in np.__version__.split(".")[:2]) |
| 12 | + |
| 13 | +# FIXME warning on NumPy 2.4 when downloading pre-computed pickles: |
| 14 | +# Python or NumPy boolean but got `align=0`. |
| 15 | +# Did you mean to pass a tuple to create a subarray type? (Deprecated NumPy 2.4) |
| 16 | +if NP_VERSION >= (2, 4): |
| 17 | + np_24_deprecation = pytest.mark.filterwarnings( |
| 18 | + "ignore::numpy.exceptions.VisibleDeprecationWarning", |
| 19 | + |
| 20 | + ) |
| 21 | +else: |
| 22 | + # Note: can't use `condition=NP_VERSION >= (2, 4)` on the decorator directly |
| 23 | + # as numpy.exceptions did not exist in old NumPy versions. |
| 24 | + np_24_deprecation = lambda x: x |
| 25 | + |
| 26 | + |
| 27 | +@np_24_deprecation |
| 28 | +def test_cifar(): |
| 29 | + (X_train, y_train), (X_test, y_test) = ml_datasets.cifar() |
| 30 | + |
| 31 | + |
| 32 | +@pytest.mark.skip(reason="very slow download") |
| 33 | +def test_cmu(): |
| 34 | + train, dev = ml_datasets.cmu() |
| 35 | + |
| 36 | + |
| 37 | +def test_dbpedia(): |
| 38 | + train, dev = ml_datasets.dbpedia() |
| 39 | + |
| 40 | + |
| 41 | +def test_imdb(): |
| 42 | + train, dev = ml_datasets.imdb() |
| 43 | + |
| 44 | + |
| 45 | +@np_24_deprecation |
| 46 | +def test_mnist(): |
| 47 | + (X_train, y_train), (X_test, y_test) = ml_datasets.mnist() |
| 48 | + |
| 49 | + |
| 50 | +@pytest.mark.xfail(reason="403 Forbidden") |
| 51 | +def test_quora_questions(): |
| 52 | + train, dev = ml_datasets.quora_questions() |
| 53 | + |
| 54 | + |
| 55 | +@np_24_deprecation |
| 56 | +def test_reuters(): |
| 57 | + (X_train, y_train), (X_test, y_test) = ml_datasets.reuters() |
| 58 | + |
| 59 | + |
| 60 | +@pytest.mark.xfail(platform.system() == "Windows", reason="path issues") |
| 61 | +def test_snli(): |
| 62 | + train, dev = ml_datasets.snli() |
| 63 | + |
| 64 | + |
| 65 | +@pytest.mark.xfail(reason="no default path") |
| 66 | +def test_stack_exchange(): |
| 67 | + train, dev = ml_datasets.stack_exchange() |
| 68 | + |
| 69 | + |
| 70 | +def test_ud_ancora_pos_tags(): |
| 71 | + (train_X, train_y), (dev_X, dev_y) = ml_datasets.ud_ancora_pos_tags() |
| 72 | + |
| 73 | + |
| 74 | +@pytest.mark.xfail(reason="str column where int expected") |
| 75 | +def test_ud_ewtb_pos_tags(): |
| 76 | + (train_X, train_y), (dev_X, dev_y) = ml_datasets.ud_ewtb_pos_tags() |
| 77 | + |
| 78 | + |
| 79 | +@pytest.mark.xfail(reason="no default path") |
| 80 | +def test_wikiner(): |
| 81 | + train, dev = ml_datasets.wikiner() |
0 commit comments