Skip to content

Commit

Permalink
We now have Float[np.ndarray, ...] <: np.ndarray. Added basic torch…
Browse files Browse the repository at this point in the history
… tests. (#68)

This required quite a lot of refactoring! JAX supports virtual subclass registration (its metaclass is ABCMeta) but NumPy does not, so we have to actually subclass `np.ndarray`.
Simple stuff like __base__ hacking fails due to deallocator conflicts.
  • Loading branch information
patrick-kidger authored Mar 4, 2023
1 parent fef81cf commit e03c1c3
Show file tree
Hide file tree
Showing 7 changed files with 248 additions and 279 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ jobs:
with:
python-version: "3.8"
test-script: |
python -m pip install pytest beartype equinox jaxlib
python -m pip install pytest beartype equinox jaxlib cloudpickle
python -m pip install torch --extra-index-url https://download.pytorch.org/whl/cpu
cp -r ${{ github.workspace }}/test ./test
pytest
pypi-token: ${{ secrets.pypi_token }}
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install pytest wheel beartype equinox jaxlib
python -m pip install pytest wheel beartype equinox jaxlib cloudpickle
python -m pip install torch --extra-index-url https://download.pytorch.org/whl/cpu
- name: Checks with pre-commit
uses: pre-commit/[email protected]
Expand Down
3 changes: 2 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ Now make your changes. Make sure to include additional tests if necessary.
Next verify the tests all pass:

```bash
pip install pytest
pip install pytest cloudpickle
pip install torch --extra-index-url https://download.pytorch.org/whl/cpu
pytest
```

Expand Down
2 changes: 2 additions & 0 deletions jaxtyping/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ class ArrayLike:

if typing.TYPE_CHECKING:
# Set up to deliberately confuse a static type checker.
import typing_extensions

PyTree: typing_extensions.TypeAlias = getattr(typing, "foo" + "bar")
# What's going on with this madness?
#
Expand Down
Loading

0 comments on commit e03c1c3

Please sign in to comment.