Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ requires = [ "setuptools", "wheel" ]

[project]
name = "cunumpy"
version = "0.1"
version = "0.1.1"
description = "Simple wrapper for numpy and cupy. Replace `import numpy as np` with `import cunumpy as xp`."
readme = "README.md"
keywords = [ "python" ]
Expand Down Expand Up @@ -48,3 +48,6 @@ urls."Source" = "https://github.com/max-models/cunumpy"

[tool.setuptools.packages.find]
where = [ "src" ]

[tool.setuptools.package-data]
cunumpy = [ "py.typed", "*.pyi" ]
7 changes: 7 additions & 0 deletions src/cunumpy/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Stub file for Pylance/mypy: exposes all numpy symbols so that
# `import cunumpy as xp` followed by `xp.<Tab>` shows numpy completions.
# At runtime the real __init__.py dispatches to numpy or cupy via __getattr__.
from numpy import *
from numpy import __config__, __version__

from . import xp
Empty file added src/cunumpy/py.typed
Empty file.
13 changes: 13 additions & 0 deletions tests/unit/test_app.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import numpy as np

import cunumpy as xp


Expand All @@ -9,5 +11,16 @@ def test_xp_array():
print(f"{arr = } {type(arr) = }")


def test_numpy_symbols_accessible():
"""All public numpy symbols must be reachable via cunumpy.

This validates the runtime behaviour that the stub file (__init__.pyi)
declares to Pylance so that `xp.<Tab>` shows numpy completions in VS Code.
"""
missing = [name for name in np.__all__ if not hasattr(xp, name)]
assert missing == [], f"Symbols not accessible via cunumpy: {missing}"


if __name__ == "__main__":
test_xp_array()
test_numpy_symbols_accessible()
Loading