sdf-xarray 0.1.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.
Files changed (38) hide show
  1. sdf_xarray-0.1.1/.github/workflows/black.yml +40 -0
  2. sdf_xarray-0.1.1/.github/workflows/build_publish.yml +75 -0
  3. sdf_xarray-0.1.1/.github/workflows/lint.yml +17 -0
  4. sdf_xarray-0.1.1/.github/workflows/tests.yml +34 -0
  5. sdf_xarray-0.1.1/.gitignore +288 -0
  6. sdf_xarray-0.1.1/.gitmodules +3 -0
  7. sdf_xarray-0.1.1/CMakeLists.txt +49 -0
  8. sdf_xarray-0.1.1/LICENCE +28 -0
  9. sdf_xarray-0.1.1/PKG-INFO +179 -0
  10. sdf_xarray-0.1.1/README.md +127 -0
  11. sdf_xarray-0.1.1/pyproject.toml +59 -0
  12. sdf_xarray-0.1.1/src/sdf_xarray/__init__.py +430 -0
  13. sdf_xarray-0.1.1/src/sdf_xarray/_version.py +16 -0
  14. sdf_xarray-0.1.1/src/sdf_xarray/csdf.pxd +127 -0
  15. sdf_xarray-0.1.1/src/sdf_xarray/sdf_interface.pyx +340 -0
  16. sdf_xarray-0.1.1/tests/example_array_no_grids/0000.sdf +0 -0
  17. sdf_xarray-0.1.1/tests/example_array_no_grids/0001.sdf +0 -0
  18. sdf_xarray-0.1.1/tests/example_array_no_grids/README.md +9 -0
  19. sdf_xarray-0.1.1/tests/example_array_no_grids/input.deck +119 -0
  20. sdf_xarray-0.1.1/tests/example_files/0000.sdf +0 -0
  21. sdf_xarray-0.1.1/tests/example_files/0001.sdf +0 -0
  22. sdf_xarray-0.1.1/tests/example_files/0002.sdf +0 -0
  23. sdf_xarray-0.1.1/tests/example_files/0003.sdf +0 -0
  24. sdf_xarray-0.1.1/tests/example_files/0004.sdf +0 -0
  25. sdf_xarray-0.1.1/tests/example_files/0005.sdf +0 -0
  26. sdf_xarray-0.1.1/tests/example_files/0006.sdf +0 -0
  27. sdf_xarray-0.1.1/tests/example_files/0007.sdf +0 -0
  28. sdf_xarray-0.1.1/tests/example_files/0008.sdf +0 -0
  29. sdf_xarray-0.1.1/tests/example_files/0009.sdf +0 -0
  30. sdf_xarray-0.1.1/tests/example_files/0010.sdf +0 -0
  31. sdf_xarray-0.1.1/tests/example_files/README.md +9 -0
  32. sdf_xarray-0.1.1/tests/example_files/input.deck +161 -0
  33. sdf_xarray-0.1.1/tests/example_mismatched_files/0000.sdf +0 -0
  34. sdf_xarray-0.1.1/tests/example_mismatched_files/0001.sdf +0 -0
  35. sdf_xarray-0.1.1/tests/example_mismatched_files/0002.sdf +0 -0
  36. sdf_xarray-0.1.1/tests/test_basic.py +130 -0
  37. sdf_xarray-0.1.1/tests/test_cython.py +141 -0
  38. sdf_xarray-0.1.1/uv.lock +1401 -0
@@ -0,0 +1,40 @@
1
+ name: black
2
+
3
+ on:
4
+ push:
5
+ paths:
6
+ - '**.py'
7
+
8
+ defaults:
9
+ run:
10
+ shell: bash
11
+
12
+ jobs:
13
+ black:
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+ with:
18
+ ref: ${{ github.head_ref }}
19
+ - name: Setup Python
20
+ uses: actions/setup-python@v5
21
+ with:
22
+ python-version: 3.x
23
+ - name: Install dependencies
24
+ run: |
25
+ python -m pip install --upgrade pip
26
+ pip install black isort
27
+ - name: Version
28
+ run: |
29
+ python --version
30
+ black --version
31
+ isort --version
32
+ - name: Run isort
33
+ run: |
34
+ isort src
35
+ - name: Run black
36
+ run: |
37
+ black src tests
38
+ - uses: stefanzweifel/git-auto-commit-action@v4
39
+ with:
40
+ commit_message: "[skip ci] Apply black changes"
@@ -0,0 +1,75 @@
1
+ name: Build/publish package
2
+
3
+ on: push
4
+
5
+ jobs:
6
+ build_wheels:
7
+ strategy:
8
+ matrix:
9
+ os: [ubuntu-latest, windows-latest, macos-latest]
10
+ runs-on: ${{ matrix.os }}
11
+ name: Build wheels on ${{ matrix.os }}
12
+
13
+ steps:
14
+ - name: Checkout
15
+ uses: actions/checkout@v4
16
+ with:
17
+ fetch-depth: 0
18
+ submodules: "recursive"
19
+
20
+ - name: Setup uv
21
+ id: setup-uv
22
+ uses: astral-sh/setup-uv@v3
23
+
24
+ - name: Print the installed version
25
+ run: echo "Installed uv version is ${{ steps.setup-uv.outputs.uv-version }}"
26
+
27
+ - name: Set up Python 3.12 and install dependencies
28
+ run: |
29
+ uv python install 3.12
30
+ uv sync --python 3.12 --extra test --extra build --frozen
31
+
32
+ - name: Build
33
+ uses: pypa/cibuildwheel@v2.21.3
34
+ env:
35
+ CIBW_ARCHS_LINUX: auto
36
+ CIBW_ARCHS_MACOS: x86_64 arm64
37
+
38
+ - name: Upload Wheels
39
+ uses: actions/upload-artifact@v4
40
+ with:
41
+ name: dist-${{ matrix.os }}
42
+ path: wheelhouse
43
+
44
+ make_sdist:
45
+ name: Make SDist
46
+ runs-on: ubuntu-latest
47
+ steps:
48
+ - uses: actions/checkout@v4
49
+
50
+ - name: Build SDist
51
+ run: pipx run build --sdist
52
+
53
+ - uses: actions/upload-artifact@v4
54
+ with:
55
+ name: dist-src
56
+ path: dist/*.tar.gz
57
+
58
+ publish-to-pypi:
59
+ if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
60
+ needs: [build_wheels, make_sdist]
61
+ runs-on: ubuntu-latest
62
+ environment:
63
+ name: release
64
+ url: https://pypi.org/p/sdf-xarray
65
+ permissions:
66
+ id-token: write # IMPORTANT: mandatory for trusted publishing
67
+ steps:
68
+ - name: Download distribution packages
69
+ uses: actions/download-artifact@v4
70
+ with:
71
+ pattern: dist-*
72
+ path: dist/
73
+ merge-multiple: true
74
+ - name: Publish to PyPI
75
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,17 @@
1
+ name: lint
2
+ on: push
3
+ jobs:
4
+ build:
5
+ runs-on: ubuntu-latest
6
+ steps:
7
+ - uses: actions/checkout@v4
8
+ - name: Install Python
9
+ uses: actions/setup-python@v5
10
+ with:
11
+ python-version: "3.12"
12
+ - name: Install dependencies
13
+ run: |
14
+ python -m pip install --upgrade pip
15
+ pip install ruff
16
+ - name: Run Ruff
17
+ run: ruff check --output-format=github src tests
@@ -0,0 +1,34 @@
1
+ name: tests
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ pytest:
7
+ runs-on: ubuntu-latest
8
+ strategy:
9
+ fail-fast: false
10
+ matrix:
11
+ python-version: ["3.10", "3.11", "3.12", "3.13"]
12
+
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+ with:
16
+ fetch-depth: 0
17
+ submodules: "recursive"
18
+
19
+ - name: Setup uv
20
+ id: setup-uv
21
+ uses: astral-sh/setup-uv@v3
22
+ with:
23
+ enable-cache: true
24
+
25
+ - name: Print the installed version
26
+ run: echo "Installed uv version is ${{ steps.setup-uv.outputs.uv-version }}"
27
+
28
+ - name: Set up Python ${{ matrix.python-version }} and install dependencies
29
+ run: |
30
+ uv python install ${{ matrix.python-version }}
31
+ uv sync --python ${{ matrix.python-version }} --extra test --extra build --frozen
32
+
33
+ - name: Test with pytest
34
+ run: uv run pytest
@@ -0,0 +1,288 @@
1
+ # -*- mode: gitignore; -*-
2
+ *~
3
+ \#*\#
4
+ /.emacs.desktop
5
+ /.emacs.desktop.lock
6
+ *.elc
7
+ auto-save-list
8
+ tramp
9
+ .\#*
10
+
11
+ # Org-mode
12
+ .org-id-locations
13
+ *_archive
14
+
15
+ # flymake-mode
16
+ *_flymake.*
17
+
18
+ # eshell files
19
+ /eshell/history
20
+ /eshell/lastdir
21
+
22
+ # elpa packages
23
+ /elpa/
24
+
25
+ # reftex files
26
+ *.rel
27
+
28
+ # AUCTeX auto folder
29
+ /auto/
30
+
31
+ # cask packages
32
+ .cask/
33
+ dist/
34
+
35
+ # Flycheck
36
+ flycheck_*.el
37
+
38
+ # server auth directory
39
+ /server/
40
+
41
+ # projectiles files
42
+ .projectile
43
+
44
+ # directory configuration
45
+ .dir-locals.el
46
+
47
+ # network security
48
+ /network-security.data
49
+
50
+ *~
51
+
52
+ # temporary files which can be created if a process still has a handle open of a deleted file
53
+ .fuse_hidden*
54
+
55
+ # KDE directory preferences
56
+ .directory
57
+
58
+ # Linux trash folder which might appear on any partition or disk
59
+ .Trash-*
60
+
61
+ # .nfs files are created when an open file is removed but is still being accessed
62
+ .nfs*
63
+ # Byte-compiled / optimized / DLL files
64
+ __pycache__/
65
+ *.py[cod]
66
+ *$py.class
67
+
68
+ # C extensions
69
+ *.so
70
+
71
+ # Distribution / packaging
72
+ .Python
73
+ build/
74
+ develop-eggs/
75
+ dist/
76
+ downloads/
77
+ eggs/
78
+ .eggs/
79
+ lib/
80
+ lib64/
81
+ parts/
82
+ sdist/
83
+ var/
84
+ wheels/
85
+ share/python-wheels/
86
+ *.egg-info/
87
+ .installed.cfg
88
+ *.egg
89
+ MANIFEST
90
+
91
+ # PyInstaller
92
+ # Usually these files are written by a python script from a template
93
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
94
+ *.manifest
95
+ *.spec
96
+
97
+ # Installer logs
98
+ pip-log.txt
99
+ pip-delete-this-directory.txt
100
+
101
+ # Unit test / coverage reports
102
+ htmlcov/
103
+ .tox/
104
+ .nox/
105
+ .coverage
106
+ .coverage.*
107
+ .cache
108
+ nosetests.xml
109
+ coverage.xml
110
+ *.cover
111
+ *.py,cover
112
+ .hypothesis/
113
+ .pytest_cache/
114
+ cover/
115
+
116
+ # Translations
117
+ *.mo
118
+ *.pot
119
+
120
+ # Django stuff:
121
+ *.log
122
+ local_settings.py
123
+ db.sqlite3
124
+ db.sqlite3-journal
125
+
126
+ # Flask stuff:
127
+ instance/
128
+ .webassets-cache
129
+
130
+ # Scrapy stuff:
131
+ .scrapy
132
+
133
+ # Sphinx documentation
134
+ docs/_build/
135
+
136
+ # PyBuilder
137
+ .pybuilder/
138
+ target/
139
+
140
+ # Jupyter Notebook
141
+ .ipynb_checkpoints
142
+
143
+ # IPython
144
+ profile_default/
145
+ ipython_config.py
146
+
147
+ # pyenv
148
+ # For a library or package, you might want to ignore these files since the code is
149
+ # intended to run in multiple environments; otherwise, check them in:
150
+ # .python-version
151
+
152
+ # pipenv
153
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
154
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
155
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
156
+ # install all needed dependencies.
157
+ #Pipfile.lock
158
+
159
+ # poetry
160
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
161
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
162
+ # commonly ignored for libraries.
163
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
164
+ #poetry.lock
165
+
166
+ # pdm
167
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
168
+ #pdm.lock
169
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
170
+ # in version control.
171
+ # https://pdm.fming.dev/#use-with-ide
172
+ .pdm.toml
173
+
174
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
175
+ __pypackages__/
176
+
177
+ # Celery stuff
178
+ celerybeat-schedule
179
+ celerybeat.pid
180
+
181
+ # SageMath parsed files
182
+ *.sage.py
183
+
184
+ # Environments
185
+ .env
186
+ .venv
187
+ env/
188
+ venv/
189
+ ENV/
190
+ env.bak/
191
+ venv.bak/
192
+
193
+ # Spyder project settings
194
+ .spyderproject
195
+ .spyproject
196
+
197
+ # Rope project settings
198
+ .ropeproject
199
+
200
+ # mkdocs documentation
201
+ /site
202
+
203
+ # mypy
204
+ .mypy_cache/
205
+ .dmypy.json
206
+ dmypy.json
207
+
208
+ # Pyre type checker
209
+ .pyre/
210
+
211
+ # pytype static type analyzer
212
+ .pytype/
213
+
214
+ # Cython debug symbols
215
+ cython_debug/
216
+
217
+ # PyCharm
218
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
219
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
220
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
221
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
222
+ #.idea/
223
+ CMakeLists.txt.user
224
+ CMakeCache.txt
225
+ CMakeFiles
226
+ CMakeScripts
227
+ Testing
228
+ Makefile
229
+ cmake_install.cmake
230
+ install_manifest.txt
231
+ compile_commands.json
232
+ CTestTestfile.cmake
233
+ _deps
234
+ # Prerequisites
235
+ *.d
236
+
237
+ # Object files
238
+ *.o
239
+ *.ko
240
+ *.obj
241
+ *.elf
242
+
243
+ # Linker output
244
+ *.ilk
245
+ *.map
246
+ *.exp
247
+
248
+ # Precompiled Headers
249
+ *.gch
250
+ *.pch
251
+
252
+ # Libraries
253
+ *.lib
254
+ *.a
255
+ *.la
256
+ *.lo
257
+
258
+ # Shared objects (inc. Windows DLLs)
259
+ *.dll
260
+ *.so
261
+ *.so.*
262
+ *.dylib
263
+
264
+ # Executables
265
+ *.exe
266
+ *.out
267
+ *.app
268
+ *.i*86
269
+ *.x86_64
270
+ *.hex
271
+
272
+ # Debug files
273
+ *.dSYM/
274
+ *.su
275
+ *.idb
276
+ *.pdb
277
+
278
+ # Kernel Module Compile Results
279
+ *.mod*
280
+ *.cmd
281
+ .tmp_versions/
282
+ modules.order
283
+ Module.symvers
284
+ Mkfile.old
285
+ dkms.conf
286
+
287
+ # Generated version file
288
+ src/sdf_xarray/_version.py
@@ -0,0 +1,3 @@
1
+ [submodule "externals/sdf_c"]
2
+ path = externals/sdf_c
3
+ url = git@github.com:Warwick-Plasma/SDF_C.git
@@ -0,0 +1,49 @@
1
+ cmake_minimum_required(VERSION 3.15...3.27)
2
+
3
+ project(${SKBUILD_PROJECT_NAME}
4
+ LANGUAGES C
5
+ VERSION ${SKBUILD_PROJECT_VERSION}
6
+ )
7
+
8
+ option(SDF_XARRAY_UPDATE_GIT_SUBMODULE "Check submodules are up-to-date during build" ON)
9
+ # Adapted from https://cliutils.gitlab.io/modern-cmake/chapters/projects/submodule.html
10
+ # Update submodules as needed
11
+ if(SDF_XARRAY_UPDATE_GIT_SUBMODULE)
12
+ find_package(Git QUIET)
13
+ if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
14
+ message(STATUS "Submodule update")
15
+ execute_process(COMMAND ${GIT_EXECUTABLE} -c submodule.recurse=false submodule update --init --recursive
16
+ WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
17
+ RESULT_VARIABLE GIT_SUBMOD_RESULT)
18
+ if(NOT GIT_SUBMOD_RESULT EQUAL "0")
19
+ message(FATAL_ERROR "git submodule update --init failed with ${GIT_SUBMOD_RESULT}, please checkout submodules")
20
+ endif()
21
+ endif()
22
+ endif()
23
+
24
+ add_subdirectory(externals/sdf_c)
25
+
26
+ target_include_directories(sdfc PUBLIC
27
+ $<TARGET_FILE_DIR:sdfc>)
28
+
29
+ find_package(Python COMPONENTS Interpreter Development.Module NumPy REQUIRED)
30
+
31
+ set(_sdf_module_dir "${CMAKE_CURRENT_SOURCE_DIR}/src/sdf_xarray")
32
+ set(_sdf_input "${_sdf_module_dir}/sdf_interface.pyx")
33
+ set(_sdf_output "sdf_interface.c")
34
+ add_custom_command(
35
+ OUTPUT ${_sdf_output}
36
+ COMMENT
37
+ "Making ${CMAKE_CURRENT_BINARY_DIR}/${_sdf_output} from ${_sdf_input}"
38
+ COMMAND Python::Interpreter -m cython
39
+ "${_sdf_input}" --output-file ${_sdf_output}
40
+ "-I${_sdf_module_dir}"
41
+ -3
42
+ DEPENDS "${_sdf_input}"
43
+ VERBATIM)
44
+
45
+ python_add_library(sdf_interface MODULE ${_sdf_output} WITH_SOABI)
46
+ target_link_libraries(sdf_interface PRIVATE sdfc Python::NumPy)
47
+ target_compile_definitions(sdf_interface PRIVATE "NPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION")
48
+
49
+ install(TARGETS sdf_interface DESTINATION ${SKBUILD_PROJECT_NAME})
@@ -0,0 +1,28 @@
1
+ Copyright 2024, Peter Hill, Joel Adams, PlasmaFAIR team
2
+
3
+ Redistribution and use in source and binary forms, with or without
4
+ modification, are permitted provided that the following conditions are
5
+ met:
6
+
7
+ 1. Redistributions of source code must retain the above copyright
8
+ notice, this list of conditions and the following disclaimer.
9
+
10
+ 2. Redistributions in binary form must reproduce the above copyright
11
+ notice, this list of conditions and the following disclaimer in the
12
+ documentation and/or other materials provided with the distribution.
13
+
14
+ 3. Neither the name of the copyright holder nor the names of its
15
+ contributors may be used to endorse or promote products derived from
16
+ this software without specific prior written permission.
17
+
18
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
+ “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
+ HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.