binsparse 0.1.0__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.
Files changed (37) hide show
  1. binsparse-0.1.0/.github/workflows/ci.yml +99 -0
  2. binsparse-0.1.0/.github/workflows/publish.yml +46 -0
  3. binsparse-0.1.0/.gitignore +220 -0
  4. binsparse-0.1.0/PKG-INFO +18 -0
  5. binsparse-0.1.0/bin/binsparse_to_binsparse +8 -0
  6. binsparse-0.1.0/bin/binsparse_to_npy +8 -0
  7. binsparse-0.1.0/bin/npy_to_binsparse +8 -0
  8. binsparse-0.1.0/compliance-skips/numpy.txt +4 -0
  9. binsparse-0.1.0/compliance-skips/reference.txt +1 -0
  10. binsparse-0.1.0/compliance-skips/scipy.txt +10 -0
  11. binsparse-0.1.0/compliance-skips/sparse.txt +16 -0
  12. binsparse-0.1.0/pixi.lock +4222 -0
  13. binsparse-0.1.0/pyproject.toml +172 -0
  14. binsparse-0.1.0/src/binsparse/__init__.py +66 -0
  15. binsparse-0.1.0/src/binsparse/container.py +328 -0
  16. binsparse-0.1.0/src/binsparse/conversions/__init__.py +17 -0
  17. binsparse-0.1.0/src/binsparse/conversions/numpy.py +64 -0
  18. binsparse-0.1.0/src/binsparse/conversions/scipy.py +98 -0
  19. binsparse-0.1.0/src/binsparse/conversions/sparse.py +92 -0
  20. binsparse-0.1.0/src/binsparse/conversions/torch.py +179 -0
  21. binsparse-0.1.0/src/binsparse/errors.py +5 -0
  22. binsparse-0.1.0/src/binsparse/io.py +147 -0
  23. binsparse-0.1.0/src/binsparse/tensor.py +577 -0
  24. binsparse-0.1.0/src/binsparse/version.py +29 -0
  25. binsparse-0.1.0/src/reference_cli/__init__.py +1 -0
  26. binsparse-0.1.0/src/reference_cli/converters.py +178 -0
  27. binsparse-0.1.0/src/reference_cli/framework.py +81 -0
  28. binsparse-0.1.0/src/reference_cli/reformat.py +290 -0
  29. binsparse-0.1.0/src/tests/test_conversion_numpy.py +55 -0
  30. binsparse-0.1.0/src/tests/test_conversion_scipy.py +120 -0
  31. binsparse-0.1.0/src/tests/test_conversion_sparse.py +64 -0
  32. binsparse-0.1.0/src/tests/test_conversion_torch.py +106 -0
  33. binsparse-0.1.0/src/tests/test_conversions.py +28 -0
  34. binsparse-0.1.0/src/tests/test_executables.py +105 -0
  35. binsparse-0.1.0/src/tests/test_io.py +82 -0
  36. binsparse-0.1.0/src/tests/test_reformat.py +193 -0
  37. binsparse-0.1.0/src/tests/test_tensor.py +280 -0
@@ -0,0 +1,99 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+ workflow_dispatch:
9
+
10
+ permissions:
11
+ contents: read
12
+
13
+ concurrency:
14
+ group: ci-${{ github.workflow }}-${{ github.ref }}
15
+ cancel-in-progress: true
16
+
17
+ jobs:
18
+ test:
19
+ name: Test (${{ matrix.os }}, Python ${{ matrix.python-version }})
20
+ runs-on: ${{ matrix.os }}
21
+ strategy:
22
+ fail-fast: false
23
+ matrix:
24
+ os: [ubuntu-latest, macos-latest, windows-latest]
25
+ python-version: ["3.11", "3.14"]
26
+
27
+ steps:
28
+ - uses: actions/checkout@v6
29
+ - uses: actions/setup-python@v6
30
+ with:
31
+ python-version: ${{ matrix.python-version }}
32
+ cache: pip
33
+ - name: Install package and test dependencies
34
+ run: python -m pip install --upgrade pip pytest pytest-cov pytest-xdist -e .
35
+ - name: Run tests
36
+ run: python -m pytest -n auto --cov=binsparse --cov-report=term-missing
37
+
38
+ type-check:
39
+ name: Type check
40
+ runs-on: ubuntu-latest
41
+ steps:
42
+ - uses: actions/checkout@v6
43
+ - uses: actions/setup-python@v6
44
+ with:
45
+ python-version: "3.14"
46
+ cache: pip
47
+ - name: Install package and mypy
48
+ run: python -m pip install --upgrade pip mypy -e .
49
+ - name: Run mypy
50
+ run: python -m mypy
51
+
52
+ conversions:
53
+ name: ${{ matrix.name }} conversion
54
+ runs-on: ubuntu-latest
55
+ strategy:
56
+ fail-fast: false
57
+ matrix:
58
+ include:
59
+ - name: SciPy
60
+ extra: scipy
61
+ test: src/tests/test_conversion_scipy.py
62
+ - name: PyData/Sparse
63
+ extra: sparse
64
+ test: src/tests/test_conversion_sparse.py
65
+ - name: PyTorch
66
+ extra: torch
67
+ test: src/tests/test_conversion_torch.py
68
+
69
+ steps:
70
+ - uses: actions/checkout@v6
71
+ - uses: actions/setup-python@v6
72
+ with:
73
+ python-version: "3.13"
74
+ cache: pip
75
+ - name: Install ${{ matrix.name }} adapter
76
+ run: python -m pip install --upgrade pip pytest pytest-cov -e ".[${{ matrix.extra }}]"
77
+ - name: Test ${{ matrix.name }} adapter
78
+ run: python -m pytest -q ${{ matrix.test }}
79
+
80
+ package:
81
+ name: Build package
82
+ runs-on: ubuntu-latest
83
+ steps:
84
+ - uses: actions/checkout@v6
85
+ - uses: actions/setup-python@v6
86
+ with:
87
+ python-version: "3.14"
88
+ cache: pip
89
+ - name: Install build tools
90
+ run: python -m pip install --upgrade pip build twine
91
+ - name: Build distributions
92
+ run: python -m build
93
+ - name: Validate distributions
94
+ run: python -m twine check dist/*
95
+ - uses: actions/upload-artifact@v7
96
+ with:
97
+ name: distributions
98
+ path: dist/
99
+ if-no-files-found: error
@@ -0,0 +1,46 @@
1
+ name: Publish
2
+
3
+ on:
4
+ workflow_dispatch:
5
+
6
+ permissions:
7
+ contents: write
8
+ id-token: write
9
+
10
+ jobs:
11
+ build:
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: actions/checkout@v6
15
+ - name: Set up Python
16
+ uses: actions/setup-python@v6
17
+ with:
18
+ python-version: "3.x"
19
+ - name: Install dependencies
20
+ run: python -m pip install build
21
+ - uses: prefix-dev/setup-pixi@v0.10.0
22
+ with:
23
+ pixi-version: v0.71.3
24
+ - name: Get version
25
+ run: |
26
+ VERSION=$(python -c 'import tomllib; print("v" + tomllib.load(open("pyproject.toml", "rb"))["project"]["version"])')
27
+ echo "VERSION=$VERSION" >> "$GITHUB_ENV"
28
+ - name: Build PyPI package
29
+ run: python -m build
30
+ - name: Publish to PyPI
31
+ uses: pypa/gh-action-pypi-publish@release/v1
32
+ with:
33
+ password: ${{ secrets.PYPI_TOKEN }}
34
+ skip-existing: true
35
+ - name: Authenticate with Prefix.dev
36
+ run: pixi auth login --token "${{ secrets.PREFIX_API_KEY }}" https://prefix.dev
37
+ - name: Build and publish to Prefix.dev
38
+ run: pixi publish --target-channel https://prefix.dev/willow-ahrens/binsparse
39
+ - name: Create a release
40
+ uses: softprops/action-gh-release@v3
41
+ env:
42
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43
+ with:
44
+ name: Release ${{ env.VERSION }}
45
+ make_latest: true
46
+ tag_name: ${{ env.VERSION }}
@@ -0,0 +1,220 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py.cover
50
+ *.lcov
51
+ .hypothesis/
52
+ .pytest_cache/
53
+ cover/
54
+
55
+ # Translations
56
+ *.mo
57
+ *.pot
58
+
59
+ # Django stuff:
60
+ *.log
61
+ local_settings.py
62
+ db.sqlite3
63
+ db.sqlite3-journal
64
+
65
+ # Flask stuff:
66
+ instance/
67
+ .webassets-cache
68
+
69
+ # Scrapy stuff:
70
+ .scrapy
71
+
72
+ # Sphinx documentation
73
+ docs/_build/
74
+
75
+ # PyBuilder
76
+ .pybuilder/
77
+ target/
78
+
79
+ # Jupyter Notebook
80
+ .ipynb_checkpoints
81
+
82
+ # IPython
83
+ profile_default/
84
+ ipython_config.py
85
+
86
+ # pyenv
87
+ # For a library or package, you might want to ignore these files since the code is
88
+ # intended to run in multiple environments; otherwise, check them in:
89
+ # .python-version
90
+
91
+ # pipenv
92
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
93
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
94
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
95
+ # install all needed dependencies.
96
+ # Pipfile.lock
97
+
98
+ # UV
99
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
100
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
101
+ # commonly ignored for libraries.
102
+ # uv.lock
103
+
104
+ # poetry
105
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
106
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
107
+ # commonly ignored for libraries.
108
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
109
+ # poetry.lock
110
+ # poetry.toml
111
+
112
+ # pdm
113
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
114
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
115
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
116
+ # pdm.lock
117
+ # pdm.toml
118
+ .pdm-python
119
+ .pdm-build/
120
+
121
+ # pixi
122
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
123
+ # pixi.lock
124
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
125
+ # in the .venv directory. It is recommended not to include this directory in version control.
126
+ .pixi/*
127
+ !.pixi/config.toml
128
+
129
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
130
+ __pypackages__/
131
+
132
+ # Celery stuff
133
+ celerybeat-schedule*
134
+ celerybeat.pid
135
+
136
+ # Redis
137
+ *.rdb
138
+ *.aof
139
+ *.pid
140
+
141
+ # RabbitMQ
142
+ mnesia/
143
+ rabbitmq/
144
+ rabbitmq-data/
145
+
146
+ # ActiveMQ
147
+ activemq-data/
148
+
149
+ # SageMath parsed files
150
+ *.sage.py
151
+
152
+ # Environments
153
+ .env
154
+ .envrc
155
+ .venv
156
+ env/
157
+ venv/
158
+ ENV/
159
+ env.bak/
160
+ venv.bak/
161
+
162
+ # Spyder project settings
163
+ .spyderproject
164
+ .spyproject
165
+
166
+ # Rope project settings
167
+ .ropeproject
168
+
169
+ # mkdocs documentation
170
+ /site
171
+
172
+ # mypy
173
+ .mypy_cache/
174
+ .dmypy.json
175
+ dmypy.json
176
+
177
+ # Pyre type checker
178
+ .pyre/
179
+
180
+ # pytype static type analyzer
181
+ .pytype/
182
+
183
+ # Cython debug symbols
184
+ cython_debug/
185
+
186
+ # PyCharm
187
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
188
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
189
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
190
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
191
+ # .idea/
192
+
193
+ # Abstra
194
+ # Abstra is an AI-powered process automation framework.
195
+ # Ignore directories containing user credentials, local state, and settings.
196
+ # Learn more at https://abstra.io/docs
197
+ .abstra/
198
+
199
+ # Visual Studio Code
200
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
201
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
202
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
203
+ # you could uncomment the following to ignore the entire vscode folder
204
+ # .vscode/
205
+ # Temporary file for partial code execution
206
+ tempCodeRunnerFile.py
207
+
208
+ # Ruff stuff:
209
+ .ruff_cache/
210
+
211
+ # PyPI configuration file
212
+ .pypirc
213
+
214
+ # Marimo
215
+ marimo/_static/
216
+ marimo/_lsp/
217
+ __marimo__/
218
+
219
+ # Streamlit
220
+ .streamlit/secrets.toml
@@ -0,0 +1,18 @@
1
+ Metadata-Version: 2.5
2
+ Name: binsparse
3
+ Version: 0.1.0
4
+ Author-email: Willow Ahrens <ahrens@gatech.edu>
5
+ Requires-Python: >=3.11
6
+ Requires-Dist: h5py<4,>=3.16.0
7
+ Requires-Dist: numpy<3,>=2
8
+ Requires-Dist: semver<4,>=3
9
+ Provides-Extra: conversions
10
+ Requires-Dist: scipy; extra == 'conversions'
11
+ Requires-Dist: sparse; extra == 'conversions'
12
+ Requires-Dist: torch; extra == 'conversions'
13
+ Provides-Extra: scipy
14
+ Requires-Dist: scipy; extra == 'scipy'
15
+ Provides-Extra: sparse
16
+ Requires-Dist: sparse; extra == 'sparse'
17
+ Provides-Extra: torch
18
+ Requires-Dist: torch; extra == 'torch'
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env python3
2
+ """Round-trip a Binsparse file through the package representation."""
3
+
4
+ from reference_cli.converters import binsparse_to_binsparse_main
5
+
6
+
7
+ if __name__ == "__main__":
8
+ raise SystemExit(binsparse_to_binsparse_main())
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env python3
2
+ """Convert a Binsparse file to NumPy dense/pattern outputs."""
3
+
4
+ from reference_cli.converters import binsparse_to_npy_main
5
+
6
+
7
+ if __name__ == "__main__":
8
+ raise SystemExit(binsparse_to_npy_main())
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env python3
2
+ """Convert NumPy dense/pattern inputs to a Binsparse file."""
3
+
4
+ from reference_cli.converters import npy_to_binsparse_main
5
+
6
+
7
+ if __name__ == "__main__":
8
+ raise SystemExit(npy_to_binsparse_main())
@@ -0,0 +1,4 @@
1
+ # NumPy has no explicit-storage pattern or fill metadata. Every generated test
2
+ # varies one or both within a single test ID, so the suite cannot isolate a
3
+ # supported NumPy case using its ID-substring skip mechanism.
4
+ test_executables.py
@@ -0,0 +1 @@
1
+ # The reference executables implement every format exercised by the suite.
@@ -0,0 +1,10 @@
1
+ # SciPy only represents two-dimensional CSR, CSC, and COO arrays with zero fill.
2
+ # The generated suite varies fill values within each test ID, so unsupported cases
3
+ # cannot be isolated more narrowly with the suite's ID-based skip mechanism.
4
+ test_custom_0d
5
+ test_custom_1d
6
+ test_custom_2d
7
+ test_custom_3d
8
+ test_custom_nd
9
+ test_predefined_1d
10
+ test_predefined_2d
@@ -0,0 +1,16 @@
1
+ # PyData/Sparse has no scalar COO and custom tests mix nested/non-COO levels.
2
+ test_custom_0d
3
+ test_custom_1d
4
+ test_custom_2d
5
+ test_custom_3d
6
+ test_custom_nd
7
+ # Dense and compressed predefined formats are not PyData/Sparse COO tensors.
8
+ [DVEC-
9
+ [CVEC-
10
+ [DMAT-
11
+ [DMATR-
12
+ [DMATC-
13
+ [CSR-
14
+ [CSC-
15
+ [DCSR-
16
+ [DCSC-