-
Notifications
You must be signed in to change notification settings - Fork 16
Add unit tests #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| name: Test | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
| branches: ["*"] | ||
| workflow_dispatch: # allows you to trigger manually | ||
|
|
||
| # When this workflow is queued, automatically cancel any previous running | ||
| # or pending jobs from the same branch | ||
| concurrency: | ||
| group: pytest-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| defaults: | ||
| run: | ||
| shell: bash -l {0} | ||
|
|
||
| jobs: | ||
| test: | ||
| name: Python ${{ matrix.python-version }} NumPy ${{ matrix.numpy-version}} | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| python-version: ["3.11", "3.14"] | ||
| numpy-version: ["2.3.0", latest] | ||
| include: | ||
| - python-version: "3.8" | ||
| numpy-version: "1.18.0" | ||
| - python-version: "3.14" | ||
| numpy-version: "nightly" | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v6 | ||
|
|
||
| - name: Set up Python ${{ matrix.python-version }} | ||
| uses: actions/setup-python@v4 | ||
| with: | ||
| python-version: ${{ matrix.python-version }} | ||
|
|
||
| - name: Install pinned NumPy | ||
| if: matrix.numpy-version != 'latest' && matrix.numpy-version != 'nightly' | ||
| run: python -m pip install numpy==${{ matrix.numpy-version }} | ||
|
|
||
| - name: Install nightly NumPy wheels | ||
| if: matrix.numpy-version == 'nightly' | ||
| run: pip install --pre --extra-index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple/ numpy | ||
|
|
||
| - name: Install package | ||
| run: pip install . | ||
|
|
||
| - name: Smoke test | ||
| run: python -c "import ml_datasets" | ||
|
|
||
| - name: Install test dependencies | ||
| run: pip install pytest | ||
|
|
||
| - name: Run tests | ||
| run: pytest |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| from .cifar import cifar | ||
| from .cmu import cmu | ||
| from .dbpedia import dbpedia | ||
| from .imdb import imdb | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| import pytest | ||
| import numpy as np | ||
|
|
||
| import ml_datasets | ||
|
|
||
| NP_VERSION = tuple(int(x) for x in np.__version__.split(".")[:2]) | ||
|
|
||
| # FIXME warning on NumPy 2.4 when downloading pre-computed pickles: | ||
| # Python or NumPy boolean but got `align=0`. | ||
| # Did you mean to pass a tuple to create a subarray type? (Deprecated NumPy 2.4) | ||
| if NP_VERSION >= (2, 4): | ||
| np_24_deprecation = pytest.mark.filterwarnings( | ||
| "ignore::numpy.exceptions.VisibleDeprecationWarning", | ||
|
|
||
| ) | ||
| else: | ||
| # Note: can't use `condition=NP_VERSION >= (2, 4)` on the decorator directly | ||
| # as numpy.exceptions did not exist in old NumPy versions. | ||
| np_24_deprecation = lambda x: x | ||
|
|
||
|
|
||
| @np_24_deprecation | ||
| def test_cifar(): | ||
| (X_train, y_train), (X_test, y_test) = ml_datasets.cifar() | ||
| # TODO test output contents | ||
|
|
||
|
|
||
| @pytest.mark.skip(reason="very slow download") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if it's always going to be skipped, why add the test?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To inform whoever reads it next that today the whole feature is functionally unusable. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you make that clear in the message or with a FIXME comment? |
||
| def test_cmu(): | ||
| train, dev = ml_datasets.cmu() | ||
| # TODO test output contents | ||
|
|
||
|
|
||
| def test_dbpedia(): | ||
| train, dev = ml_datasets.dbpedia() | ||
| # TODO test output contents | ||
|
|
||
|
|
||
| def test_imdb(): | ||
| train, dev = ml_datasets.imdb() | ||
| # TODO test output contents | ||
|
|
||
|
|
||
| @np_24_deprecation | ||
| def test_mnist(): | ||
| (X_train, y_train), (X_test, y_test) = ml_datasets.mnist() | ||
| # TODO test output contents | ||
|
|
||
|
|
||
| @pytest.mark.xfail(reason="403 Forbidden") | ||
| def test_quora_questions(): | ||
| train, dev = ml_datasets.quora_questions() | ||
| # TODO test output contents | ||
|
|
||
|
|
||
| @np_24_deprecation | ||
| def test_reuters(): | ||
| (X_train, y_train), (X_test, y_test) = ml_datasets.reuters() | ||
| # TODO test output contents | ||
|
|
||
|
|
||
| def test_snli(): | ||
| train, dev = ml_datasets.snli() | ||
| # TODO test output contents | ||
|
|
||
|
|
||
| @pytest.mark.xfail(reason="no default path") | ||
| def test_stack_exchange(): | ||
| train, dev = ml_datasets.stack_exchange() | ||
| # TODO test output contents | ||
|
|
||
|
|
||
| def test_ud_ancora_pos_tags(): | ||
| (train_X, train_y), (dev_X, dev_y) = ml_datasets.ud_ancora_pos_tags() | ||
| # TODO test output contents | ||
|
|
||
|
|
||
| @pytest.mark.xfail(reason="str column where int expected") | ||
| def test_ud_ewtb_pos_tags(): | ||
| (train_X, train_y), (dev_X, dev_y) = ml_datasets.ud_ewtb_pos_tags() | ||
| # TODO test output contents | ||
|
|
||
|
|
||
| @pytest.mark.xfail(reason="no default path") | ||
| def test_wikiner(): | ||
| train, dev = ml_datasets.wikiner() | ||
| # TODO test output contents | ||
crusaderky marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| [tool.pytest.ini_options] | ||
| addopts = "--strict-markers --strict-config -v -r sxfE --color=yes --durations=10" | ||
| xfail_strict = true | ||
| filterwarnings = [ | ||
| "error", | ||
| # FIXME spurious random download warnings; will cause trouble in downstream CI | ||
| "ignore:Implicitly cleaning up <HTTPError 403:ResourceWarning", | ||
| "ignore:unclosed <socket.socket:ResourceWarning", | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| numpy>=1.7.0 | ||
| numpy>=1.18 | ||
| scipy>=1.7.0 | ||
| tqdm>=4.10.0,<5.0.0 | ||
| # Our libraries | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,9 +11,9 @@ long_description_content_type = text/markdown | |
| [options] | ||
| zip_safe = true | ||
| include_package_data = true | ||
| python_requires = >=3.6 | ||
| python_requires = >=3.8 | ||
| install_requires = | ||
| numpy>=1.7.0 | ||
| numpy>=1.18 | ||
|
Comment on lines
14
to
17
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bump to lowest tested versions |
||
| tqdm>=4.10.0,<5.0.0 | ||
| # Our libraries | ||
| srsly>=1.0.1,<3.0.0 | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think just re-saving the pickle files with numpy 2.4 will fix this. But then you'd need to replace the files in the AWS bucket...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably. I'd open a follow-up ticket but the issues tab has been disabled for this repo.