cunumpy 0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
cunumpy-0.1/PKG-INFO ADDED
@@ -0,0 +1,78 @@
1
+ Metadata-Version: 2.4
2
+ Name: cunumpy
3
+ Version: 0.1
4
+ Summary: Simple wrapper for numpy and cupy. Replace `import numpy as np` with `import cunumpy as xp`.
5
+ Author: Max
6
+ Project-URL: Source, https://github.com/max-models/cunumpy
7
+ Keywords: python
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Programming Language :: Python :: 3 :: Only
10
+ Classifier: Programming Language :: Python :: 3.8
11
+ Classifier: Programming Language :: Python :: 3.9
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Requires-Python: >=3.8
17
+ Description-Content-Type: text/markdown
18
+ Requires-Dist: numpy
19
+ Provides-Extra: dev
20
+ Requires-Dist: black[jupyter]; extra == "dev"
21
+ Requires-Dist: isort; extra == "dev"
22
+ Requires-Dist: cunumpy[docs,test]; extra == "dev"
23
+ Provides-Extra: docs
24
+ Requires-Dist: ipykernel; extra == "docs"
25
+ Requires-Dist: myst-parser; extra == "docs"
26
+ Requires-Dist: nbconvert; extra == "docs"
27
+ Requires-Dist: nbsphinx; extra == "docs"
28
+ Requires-Dist: jupyterlab; extra == "docs"
29
+ Requires-Dist: pre-commit; extra == "docs"
30
+ Requires-Dist: pyproject-fmt; extra == "docs"
31
+ Requires-Dist: sphinx; extra == "docs"
32
+ Requires-Dist: sphinx-book-theme; extra == "docs"
33
+ Provides-Extra: test
34
+ Requires-Dist: coverage; extra == "test"
35
+ Requires-Dist: pytest; extra == "test"
36
+
37
+ # CuNumpy
38
+
39
+ Simple wrapper for numpy and cupy. Replace `import numpy as np` with `import cunumpy as xp`.
40
+
41
+ # Install
42
+
43
+ Create and activate python environment
44
+
45
+ ```
46
+ python -m venv env
47
+ source env/bin/activate
48
+ pip install --upgrade pip
49
+ ```
50
+
51
+ Install the code and requirements with pip
52
+
53
+ ```
54
+ pip install -e .
55
+ ```
56
+
57
+ Example usage:
58
+
59
+ ```
60
+ export ARRAY_BACKEND=cupy
61
+ ```
62
+
63
+ ```python
64
+ import cunumpy as xp
65
+ arr = xp.array([1,2])
66
+
67
+ print(type(arr))
68
+ print(xp.__version__)
69
+ ```
70
+
71
+ # Build docs
72
+
73
+
74
+ ```
75
+ make html
76
+ cd ../
77
+ open docs/_build/html/index.html
78
+ ```
cunumpy-0.1/README.md ADDED
@@ -0,0 +1,42 @@
1
+ # CuNumpy
2
+
3
+ Simple wrapper for numpy and cupy. Replace `import numpy as np` with `import cunumpy as xp`.
4
+
5
+ # Install
6
+
7
+ Create and activate python environment
8
+
9
+ ```
10
+ python -m venv env
11
+ source env/bin/activate
12
+ pip install --upgrade pip
13
+ ```
14
+
15
+ Install the code and requirements with pip
16
+
17
+ ```
18
+ pip install -e .
19
+ ```
20
+
21
+ Example usage:
22
+
23
+ ```
24
+ export ARRAY_BACKEND=cupy
25
+ ```
26
+
27
+ ```python
28
+ import cunumpy as xp
29
+ arr = xp.array([1,2])
30
+
31
+ print(type(arr))
32
+ print(xp.__version__)
33
+ ```
34
+
35
+ # Build docs
36
+
37
+
38
+ ```
39
+ make html
40
+ cd ../
41
+ open docs/_build/html/index.html
42
+ ```
@@ -0,0 +1,50 @@
1
+ [build-system]
2
+ build-backend = "setuptools.build_meta"
3
+
4
+ requires = [ "setuptools", "wheel" ]
5
+
6
+ [project]
7
+ name = "cunumpy"
8
+ version = "0.1"
9
+ description = "Simple wrapper for numpy and cupy. Replace `import numpy as np` with `import cunumpy as xp`."
10
+ readme = "README.md"
11
+ keywords = [ "python" ]
12
+ license = { file = "LICENSE.txt" }
13
+ authors = [ { name = "Max" } ]
14
+ requires-python = ">=3.8"
15
+ classifiers = [
16
+ "Development Status :: 3 - Alpha",
17
+ "Programming Language :: Python :: 3 :: Only",
18
+ "Programming Language :: Python :: 3.8",
19
+ "Programming Language :: Python :: 3.9",
20
+ "Programming Language :: Python :: 3.10",
21
+ "Programming Language :: Python :: 3.11",
22
+ "Programming Language :: Python :: 3.12",
23
+ "Programming Language :: Python :: 3.13",
24
+ ]
25
+ dependencies = [
26
+ "numpy",
27
+ ]
28
+
29
+ optional-dependencies.dev = [
30
+ "black[jupyter]",
31
+ "isort",
32
+ "cunumpy[test,docs]",
33
+ ]
34
+ # https://medium.com/@pratikdomadiya123/build-project-documentation-quickly-with-the-sphinx-python-2a9732b66594
35
+ optional-dependencies.docs = [
36
+ "ipykernel",
37
+ "myst-parser",
38
+ "nbconvert",
39
+ "nbsphinx",
40
+ "jupyterlab",
41
+ "pre-commit",
42
+ "pyproject-fmt",
43
+ "sphinx",
44
+ "sphinx-book-theme",
45
+ ]
46
+ optional-dependencies.test = [ "coverage", "pytest" ]
47
+ urls."Source" = "https://github.com/max-models/cunumpy"
48
+
49
+ [tool.setuptools.packages.find]
50
+ where = [ "src" ]
cunumpy-0.1/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,9 @@
1
+ # cunumpy/__init__.py
2
+ from . import xp
3
+
4
+ __all__ = ["xp"]
5
+
6
+
7
+ def __getattr__(name: str):
8
+ """Set cunumpy.<name> to cunumpy.xp.<name> (NumPy/CuPy)."""
9
+ return getattr(xp.xp, name)
@@ -0,0 +1,8 @@
1
+ """
2
+ Main module of the python package.
3
+ """
4
+
5
+
6
+ def main():
7
+ """Main method called from from the command line."""
8
+ print("Hello, world")
@@ -0,0 +1,64 @@
1
+ import os
2
+ from types import ModuleType
3
+ from typing import TYPE_CHECKING, Literal
4
+
5
+ BackendType = Literal["numpy", "cupy"]
6
+
7
+
8
+ class ArrayBackend:
9
+ def __init__(
10
+ self,
11
+ backend: BackendType = "numpy",
12
+ verbose: bool = False,
13
+ ) -> None:
14
+ assert backend.lower() in [
15
+ "numpy",
16
+ "cupy",
17
+ ], "Array backend must be either 'numpy' or 'cupy'."
18
+
19
+ self._backend: BackendType = "cupy" if backend.lower() == "cupy" else "numpy"
20
+
21
+ # Import numpy/cupy
22
+ if self.backend == "cupy":
23
+ try:
24
+ import cupy as cp
25
+
26
+ self._xp = cp
27
+ except ImportError:
28
+ if verbose:
29
+ print("CuPy not available.")
30
+ self._backend = "numpy"
31
+
32
+ if self.backend == "numpy":
33
+ import numpy as np
34
+
35
+ self._xp = np
36
+
37
+ assert isinstance(self.xp, ModuleType)
38
+
39
+ if verbose:
40
+ print(f"Using {self.xp.__name__} backend.")
41
+
42
+ @property
43
+ def backend(self) -> BackendType:
44
+ return self._backend
45
+
46
+ @property
47
+ def xp(self) -> ModuleType:
48
+ return self._xp
49
+
50
+
51
+ # TODO: Make this configurable via environment variable or config file.
52
+ array_backend = ArrayBackend(
53
+ backend=(
54
+ "cupy" if os.getenv("ARRAY_BACKEND", "numpy").lower() == "cupy" else "numpy"
55
+ ),
56
+ verbose=False,
57
+ )
58
+
59
+ # TYPE_CHECKING is True when type checking (e.g., mypy), but False at runtime.
60
+ # This allows us to use autocompletion for xp (i.e., numpy/cupy) as if numpy was imported.
61
+ if TYPE_CHECKING:
62
+ import numpy as xp
63
+ else:
64
+ xp = array_backend.xp
@@ -0,0 +1,78 @@
1
+ Metadata-Version: 2.4
2
+ Name: cunumpy
3
+ Version: 0.1
4
+ Summary: Simple wrapper for numpy and cupy. Replace `import numpy as np` with `import cunumpy as xp`.
5
+ Author: Max
6
+ Project-URL: Source, https://github.com/max-models/cunumpy
7
+ Keywords: python
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Programming Language :: Python :: 3 :: Only
10
+ Classifier: Programming Language :: Python :: 3.8
11
+ Classifier: Programming Language :: Python :: 3.9
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Requires-Python: >=3.8
17
+ Description-Content-Type: text/markdown
18
+ Requires-Dist: numpy
19
+ Provides-Extra: dev
20
+ Requires-Dist: black[jupyter]; extra == "dev"
21
+ Requires-Dist: isort; extra == "dev"
22
+ Requires-Dist: cunumpy[docs,test]; extra == "dev"
23
+ Provides-Extra: docs
24
+ Requires-Dist: ipykernel; extra == "docs"
25
+ Requires-Dist: myst-parser; extra == "docs"
26
+ Requires-Dist: nbconvert; extra == "docs"
27
+ Requires-Dist: nbsphinx; extra == "docs"
28
+ Requires-Dist: jupyterlab; extra == "docs"
29
+ Requires-Dist: pre-commit; extra == "docs"
30
+ Requires-Dist: pyproject-fmt; extra == "docs"
31
+ Requires-Dist: sphinx; extra == "docs"
32
+ Requires-Dist: sphinx-book-theme; extra == "docs"
33
+ Provides-Extra: test
34
+ Requires-Dist: coverage; extra == "test"
35
+ Requires-Dist: pytest; extra == "test"
36
+
37
+ # CuNumpy
38
+
39
+ Simple wrapper for numpy and cupy. Replace `import numpy as np` with `import cunumpy as xp`.
40
+
41
+ # Install
42
+
43
+ Create and activate python environment
44
+
45
+ ```
46
+ python -m venv env
47
+ source env/bin/activate
48
+ pip install --upgrade pip
49
+ ```
50
+
51
+ Install the code and requirements with pip
52
+
53
+ ```
54
+ pip install -e .
55
+ ```
56
+
57
+ Example usage:
58
+
59
+ ```
60
+ export ARRAY_BACKEND=cupy
61
+ ```
62
+
63
+ ```python
64
+ import cunumpy as xp
65
+ arr = xp.array([1,2])
66
+
67
+ print(type(arr))
68
+ print(xp.__version__)
69
+ ```
70
+
71
+ # Build docs
72
+
73
+
74
+ ```
75
+ make html
76
+ cd ../
77
+ open docs/_build/html/index.html
78
+ ```
@@ -0,0 +1,10 @@
1
+ README.md
2
+ pyproject.toml
3
+ src/cunumpy/__init__.py
4
+ src/cunumpy/main.py
5
+ src/cunumpy/xp.py
6
+ src/cunumpy.egg-info/PKG-INFO
7
+ src/cunumpy.egg-info/SOURCES.txt
8
+ src/cunumpy.egg-info/dependency_links.txt
9
+ src/cunumpy.egg-info/requires.txt
10
+ src/cunumpy.egg-info/top_level.txt
@@ -0,0 +1,21 @@
1
+ numpy
2
+
3
+ [dev]
4
+ black[jupyter]
5
+ isort
6
+ cunumpy[docs,test]
7
+
8
+ [docs]
9
+ ipykernel
10
+ myst-parser
11
+ nbconvert
12
+ nbsphinx
13
+ jupyterlab
14
+ pre-commit
15
+ pyproject-fmt
16
+ sphinx
17
+ sphinx-book-theme
18
+
19
+ [test]
20
+ coverage
21
+ pytest
@@ -0,0 +1 @@
1
+ cunumpy