xarray-binfile 0.1.0b1__tar.gz → 0.2.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 (75) hide show
  1. {xarray_binfile-0.1.0b1 → xarray_binfile-0.2.0}/.github/workflows/check-links.yaml +1 -1
  2. {xarray_binfile-0.1.0b1 → xarray_binfile-0.2.0}/.github/workflows/ci.yaml +9 -9
  3. {xarray_binfile-0.1.0b1 → xarray_binfile-0.2.0}/.github/workflows/docs.yaml +3 -3
  4. {xarray_binfile-0.1.0b1 → xarray_binfile-0.2.0}/.pre-commit-config.yaml +4 -4
  5. {xarray_binfile-0.1.0b1 → xarray_binfile-0.2.0}/.vscode/settings.json +1 -7
  6. xarray_binfile-0.2.0/CITATION.cff +21 -0
  7. xarray_binfile-0.2.0/CODE_OF_CONDUCT.md +83 -0
  8. xarray_binfile-0.2.0/CONTRIBUTING.md +42 -0
  9. {xarray_binfile-0.1.0b1 → xarray_binfile-0.2.0}/PKG-INFO +4 -4
  10. {xarray_binfile-0.1.0b1 → xarray_binfile-0.2.0}/docs/_config.yml +4 -0
  11. {xarray_binfile-0.1.0b1 → xarray_binfile-0.2.0}/docs/references/api-reference.rst +9 -0
  12. {xarray_binfile-0.1.0b1 → xarray_binfile-0.2.0}/docs/tutorials/benchmarking.ipynb +4 -3
  13. {xarray_binfile-0.1.0b1 → xarray_binfile-0.2.0}/docs/tutorials/examples.ipynb +7 -6
  14. {xarray_binfile-0.1.0b1 → xarray_binfile-0.2.0}/docs/tutorials/parallel-and-larger-than-memory.ipynb +4 -3
  15. {xarray_binfile-0.1.0b1 → xarray_binfile-0.2.0}/docs/tutorials/read.ipynb +8 -10
  16. {xarray_binfile-0.1.0b1 → xarray_binfile-0.2.0}/docs/tutorials/write.ipynb +15 -41
  17. xarray_binfile-0.2.0/docs/usage/spec-getter-protocols.md +205 -0
  18. {xarray_binfile-0.1.0b1 → xarray_binfile-0.2.0}/pyproject.toml +2 -2
  19. {xarray_binfile-0.1.0b1 → xarray_binfile-0.2.0}/src/xarray_binfile/_version.py +2 -2
  20. xarray_binfile-0.2.0/src/xarray_binfile/conventions/__init__.py +27 -0
  21. xarray_binfile-0.2.0/src/xarray_binfile/conventions/filename_pattern.py +233 -0
  22. xarray_binfile-0.2.0/src/xarray_binfile/conventions/folders.py +129 -0
  23. xarray_binfile-0.2.0/src/xarray_binfile/conventions/getters.py +375 -0
  24. xarray_binfile-0.2.0/src/xarray_binfile/conventions/layout.py +116 -0
  25. xarray_binfile-0.2.0/src/xarray_binfile/conventions/protocol.py +41 -0
  26. {xarray_binfile-0.1.0b1 → xarray_binfile-0.2.0}/src/xarray_binfile/tutorial/file_metadata.py +18 -0
  27. xarray_binfile-0.2.0/src/xarray_binfile/write/accessor.py +182 -0
  28. {xarray_binfile-0.1.0b1 → xarray_binfile-0.2.0}/src/xarray_binfile/write/file_metadata.py +5 -1
  29. xarray_binfile-0.2.0/tests/integration/test_conventions_roundtrip.py +109 -0
  30. {xarray_binfile-0.1.0b1 → xarray_binfile-0.2.0}/tests/integration/test_load_dataset.py +5 -4
  31. xarray_binfile-0.2.0/tests/unit/conventions/test_filename_pattern.py +132 -0
  32. xarray_binfile-0.2.0/tests/unit/conventions/test_folders.py +90 -0
  33. xarray_binfile-0.2.0/tests/unit/conventions/test_getters.py +206 -0
  34. xarray_binfile-0.2.0/tests/unit/conventions/test_layout.py +70 -0
  35. {xarray_binfile-0.1.0b1 → xarray_binfile-0.2.0}/tests/unit/read/test_array.py +2 -2
  36. {xarray_binfile-0.1.0b1 → xarray_binfile-0.2.0}/tests/unit/tutorial/test_file_metadata.py +7 -0
  37. xarray_binfile-0.2.0/tests/unit/write/__init__.py +0 -0
  38. xarray_binfile-0.2.0/tests/unit/write/test_accessor.py +198 -0
  39. xarray_binfile-0.1.0b1/docs/usage/spec-getter-protocols.md +0 -174
  40. xarray_binfile-0.1.0b1/src/xarray_binfile/write/accessor.py +0 -117
  41. xarray_binfile-0.1.0b1/tests/unit/write/test_accessor.py +0 -94
  42. {xarray_binfile-0.1.0b1 → xarray_binfile-0.2.0}/.github/dependabot.yml +0 -0
  43. {xarray_binfile-0.1.0b1 → xarray_binfile-0.2.0}/.github/release.yml +0 -0
  44. {xarray_binfile-0.1.0b1 → xarray_binfile-0.2.0}/.gitignore +0 -0
  45. {xarray_binfile-0.1.0b1 → xarray_binfile-0.2.0}/.vscode/extensions.json +0 -0
  46. {xarray_binfile-0.1.0b1 → xarray_binfile-0.2.0}/LICENSE +0 -0
  47. {xarray_binfile-0.1.0b1 → xarray_binfile-0.2.0}/README.md +0 -0
  48. {xarray_binfile-0.1.0b1 → xarray_binfile-0.2.0}/docs/_toc.yml +0 -0
  49. {xarray_binfile-0.1.0b1 → xarray_binfile-0.2.0}/docs/getting-started/about.md +0 -0
  50. {xarray_binfile-0.1.0b1 → xarray_binfile-0.2.0}/docs/getting-started/installation.md +0 -0
  51. {xarray_binfile-0.1.0b1 → xarray_binfile-0.2.0}/docs/intro.md +0 -0
  52. {xarray_binfile-0.1.0b1 → xarray_binfile-0.2.0}/docs/logo.png +0 -0
  53. {xarray_binfile-0.1.0b1 → xarray_binfile-0.2.0}/docs/references/further-reading.md +0 -0
  54. {xarray_binfile-0.1.0b1 → xarray_binfile-0.2.0}/docs/references/how-to-contribute.md +0 -0
  55. {xarray_binfile-0.1.0b1 → xarray_binfile-0.2.0}/docs/references/what-is-new.md +0 -0
  56. {xarray_binfile-0.1.0b1 → xarray_binfile-0.2.0}/docs/references.bib +0 -0
  57. {xarray_binfile-0.1.0b1 → xarray_binfile-0.2.0}/src/xarray_binfile/__init__.py +0 -0
  58. {xarray_binfile-0.1.0b1 → xarray_binfile-0.2.0}/src/xarray_binfile/py.typed +0 -0
  59. {xarray_binfile-0.1.0b1 → xarray_binfile-0.2.0}/src/xarray_binfile/read/__init__.py +0 -0
  60. {xarray_binfile-0.1.0b1 → xarray_binfile-0.2.0}/src/xarray_binfile/read/array.py +0 -0
  61. {xarray_binfile-0.1.0b1 → xarray_binfile-0.2.0}/src/xarray_binfile/read/entrypoint.py +0 -0
  62. {xarray_binfile-0.1.0b1 → xarray_binfile-0.2.0}/src/xarray_binfile/read/file_metadata.py +0 -0
  63. {xarray_binfile-0.1.0b1 → xarray_binfile-0.2.0}/src/xarray_binfile/tutorial/__init__.py +0 -0
  64. {xarray_binfile-0.1.0b1 → xarray_binfile-0.2.0}/src/xarray_binfile/tutorial/dataset_generator.py +0 -0
  65. {xarray_binfile-0.1.0b1 → xarray_binfile-0.2.0}/src/xarray_binfile/typing.py +0 -0
  66. {xarray_binfile-0.1.0b1 → xarray_binfile-0.2.0}/src/xarray_binfile/write/__init__.py +0 -0
  67. {xarray_binfile-0.1.0b1 → xarray_binfile-0.2.0}/tests/__init__.py +0 -0
  68. {xarray_binfile-0.1.0b1 → xarray_binfile-0.2.0}/tests/integration/__init__.py +0 -0
  69. {xarray_binfile-0.1.0b1 → xarray_binfile-0.2.0}/tests/integration/test_indexing.py +0 -0
  70. {xarray_binfile-0.1.0b1 → xarray_binfile-0.2.0}/tests/integration/test_roundtrip.py +0 -0
  71. {xarray_binfile-0.1.0b1 → xarray_binfile-0.2.0}/tests/unit/__init__.py +0 -0
  72. {xarray_binfile-0.1.0b1/tests/unit/read → xarray_binfile-0.2.0/tests/unit/conventions}/__init__.py +0 -0
  73. {xarray_binfile-0.1.0b1/tests/unit/tutorial → xarray_binfile-0.2.0/tests/unit/read}/__init__.py +0 -0
  74. {xarray_binfile-0.1.0b1 → xarray_binfile-0.2.0}/tests/unit/read/test_entrypoint.py +0 -0
  75. {xarray_binfile-0.1.0b1/tests/unit/write → xarray_binfile-0.2.0/tests/unit/tutorial}/__init__.py +0 -0
@@ -17,7 +17,7 @@ jobs:
17
17
  check-links:
18
18
  runs-on: ubuntu-latest
19
19
  steps:
20
- - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
20
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
21
21
  with:
22
22
  persist-credentials: false
23
23
  - uses: gaurav-nelson/github-action-markdown-link-check@3c3b66f1f7d0900e37b71eca45b63ea9eedfce31 # 1.0.17
@@ -38,18 +38,18 @@ jobs:
38
38
  # Python 3.15 is still a release candidate, so keep a single advisory job
39
39
  continue-on-error: ${{ matrix.python-version == '3.15' }}
40
40
  steps:
41
- - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
41
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
42
42
  with:
43
43
  persist-credentials: false
44
44
 
45
45
  - name: Set up Python
46
- uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
46
+ uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
47
47
  with:
48
48
  python-version: ${{ matrix.python-version }}
49
49
  allow-prereleases: true
50
50
 
51
51
  - name: Install Hatch
52
- uses: pypa/hatch@257e27e51a6a5616ed08a39a408a21c35c9931bc
52
+ uses: pypa/hatch@f647ed70d49adb885f53a27d1c7f5bdaeacf2c60
53
53
 
54
54
  - name: Run tests
55
55
  run: |
@@ -65,14 +65,14 @@ jobs:
65
65
  needs: test
66
66
  runs-on: ubuntu-latest
67
67
  steps:
68
- - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
68
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
69
69
  with:
70
70
  persist-credentials: false
71
- - uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
71
+ - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
72
72
  with:
73
73
  python-version: "3.12"
74
74
  - name: Install Hatch
75
- uses: pypa/hatch@257e27e51a6a5616ed08a39a408a21c35c9931bc
75
+ uses: pypa/hatch@f647ed70d49adb885f53a27d1c7f5bdaeacf2c60
76
76
  - name: Build package
77
77
  run: hatch build
78
78
  - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
@@ -91,7 +91,7 @@ jobs:
91
91
  permissions:
92
92
  contents: read
93
93
  steps:
94
- - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
94
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
95
95
  with:
96
96
  persist-credentials: false
97
97
  fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
@@ -103,7 +103,7 @@ jobs:
103
103
  merge-multiple: true
104
104
 
105
105
  - name: SonarQube Scan
106
- uses: SonarSource/sonarqube-scan-action@713881670b6b3676cda39549040e2d88c70d582e # v8.2.0
106
+ uses: SonarSource/sonarqube-scan-action@ba9859eae8dd6bd29e412f25ddbbef3d032000f4 # v8.2.2
107
107
  env:
108
108
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
109
109
  SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
@@ -139,4 +139,4 @@ jobs:
139
139
  path: dist
140
140
 
141
141
  - name: Publish package distributions to PyPI
142
- uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0
142
+ uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2
@@ -24,17 +24,17 @@ jobs:
24
24
  permissions:
25
25
  contents: read
26
26
  steps:
27
- - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
27
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
28
28
  with:
29
29
  persist-credentials: false
30
30
 
31
31
  - name: Set up Python
32
- uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
32
+ uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
33
33
  with:
34
34
  python-version: "3.13"
35
35
 
36
36
  - name: Install Hatch
37
- uses: pypa/hatch@257e27e51a6a5616ed08a39a408a21c35c9931bc
37
+ uses: pypa/hatch@f647ed70d49adb885f53a27d1c7f5bdaeacf2c60
38
38
 
39
39
  - name: Install Graphviz
40
40
  run: sudo apt-get update && sudo apt-get install --yes graphviz
@@ -17,7 +17,7 @@ repos:
17
17
  - id: mixed-line-ending
18
18
  - id: trailing-whitespace
19
19
  - repo: https://github.com/astral-sh/ruff-pre-commit
20
- rev: v0.15.20
20
+ rev: v0.16.10
21
21
  hooks:
22
22
  # Run the linter.
23
23
  - id: ruff
@@ -27,12 +27,12 @@ repos:
27
27
  - id: ruff-format
28
28
  types_or: [python, pyi, jupyter]
29
29
  - repo: https://github.com/pre-commit/mirrors-mypy
30
- rev: v2.1.0
30
+ rev: v2.4.0
31
31
  hooks:
32
32
  - id: mypy
33
33
  exclude: docs/conf.py
34
34
  - repo: https://github.com/codespell-project/codespell
35
- rev: v2.4.2
35
+ rev: v2.4.3
36
36
  hooks:
37
37
  - id: codespell
38
38
  additional_dependencies:
@@ -48,7 +48,7 @@ repos:
48
48
  hooks:
49
49
  - id: nbstripout
50
50
  - repo: https://github.com/woodruffw/zizmor-pre-commit
51
- rev: v1.26.1
51
+ rev: v1.30.1
52
52
  hooks:
53
53
  - id: zizmor
54
54
 
@@ -24,11 +24,5 @@
24
24
  "cSpell.enabled": true,
25
25
  "cSpell.language": "en",
26
26
  "python.envFile": "${workspaceFolder}/.venv/xarray-binfile",
27
- "python-envs.pythonProjects": [
28
- {
29
- "path": ".",
30
- "envManager": "ms-python.python:venv",
31
- "packageManager": "ms-python.python:pip"
32
- }
33
- ]
27
+ "python.testing.pytestPath": "${workspaceFolder}/.venv/xarray-binfile/bin/pytest"
34
28
  }
@@ -0,0 +1,21 @@
1
+ cff-version: 1.2.0
2
+ message: If you use this software, please cite it using the metadata from this file.
3
+ type: software
4
+ title: Xarray-binfile
5
+ abstract: >-
6
+ Custom Xarray file engine to read and write raw binary files, with optional
7
+ lazy chunking through Dask.
8
+ authors:
9
+ - family-names: Schuch
10
+ given-names: Felipe N.
11
+ email: me@fschuch.com
12
+ orcid: https://orcid.org/0000-0002-6140-0273
13
+ license: MIT
14
+ repository-code: https://github.com/fschuch/xarray-binfile
15
+ url: https://docs.fschuch.com/xarray-binfile/
16
+ keywords:
17
+ - xarray
18
+ - dask
19
+ - binary files
20
+ - xcompact3d
21
+ - 2decomp
@@ -0,0 +1,83 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ - Demonstrating empathy and kindness toward other people
14
+ - Being respectful of differing opinions, viewpoints, and experiences
15
+ - Giving and gracefully accepting constructive feedback
16
+ - Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ - Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ - The use of sexualized language or imagery, and sexual attention or advances of any kind
22
+ - Trolling, insulting or derogatory comments, and personal or political attacks
23
+ - Public or private harassment
24
+ - Publishing others' private information, such as a physical or email address, without their explicit permission
25
+ - Other conduct which could reasonably be considered inappropriate in a professional setting
26
+
27
+ ## Enforcement Responsibilities
28
+
29
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
30
+
31
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
32
+
33
+ ## Scope
34
+
35
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
36
+
37
+ ## Enforcement
38
+
39
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at [contato@fschuch.com](mailto:contato@fschuch.com). All complaints will be reviewed and investigated promptly and fairly.
40
+
41
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
42
+
43
+ ## Enforcement Guidelines
44
+
45
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
46
+
47
+ ### 1. Correction
48
+
49
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
50
+
51
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
52
+
53
+ ### 2. Warning
54
+
55
+ **Community Impact**: A violation through a single incident or series of actions.
56
+
57
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
58
+
59
+ ### 3. Temporary Ban
60
+
61
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
62
+
63
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
64
+
65
+ ### 4. Permanent Ban
66
+
67
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
68
+
69
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
70
+
71
+ ## Attribution
72
+
73
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.1, available at [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
74
+
75
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder][mozilla coc].
76
+
77
+ For answers to common questions about this code of conduct, see the FAQ at [https://www.contributor-covenant.org/faq][faq]. Translations are available at [https://www.contributor-covenant.org/translations][translations].
78
+
79
+ [faq]: https://www.contributor-covenant.org/faq
80
+ [homepage]: https://www.contributor-covenant.org
81
+ [mozilla coc]: https://github.com/mozilla/diversity
82
+ [translations]: https://www.contributor-covenant.org/translations
83
+ [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
@@ -0,0 +1,42 @@
1
+ # Contributing to Xarray-binfile
2
+
3
+ Thank you for your interest in contributing! Contributions of all kinds are welcome: bug reports, feature requests, documentation improvements, and code.
4
+
5
+ ## Reporting issues
6
+
7
+ Open an issue at <https://github.com/fschuch/xarray-binfile/issues>. Please include the package version, Python version, operating system, and a minimal example that reproduces the problem.
8
+
9
+ ## Development setup
10
+
11
+ The development workflow is powered by [Hatch](https://hatch.pypa.io). After installing Hatch, fork and clone the repository, then run:
12
+
13
+ ```bash
14
+ hatch run qa
15
+ ```
16
+
17
+ This runs the pre-commit checks (ruff, mypy, codespell, and others) and the full test suite with coverage. Useful individual commands:
18
+
19
+ ```bash
20
+ hatch run check # pre-commit hooks on all files
21
+ hatch run test # tests with coverage
22
+ hatch run test-benchmark # benchmarks (pytest-benchmark and memray)
23
+ hatch run docs:serve # live preview of the documentation
24
+ ```
25
+
26
+ ## Pull requests
27
+
28
+ 1. Create a branch from `main`.
29
+ 1. Add or update tests for your change.
30
+ 1. Make sure `hatch run qa` passes locally.
31
+ 1. Open a pull request describing the motivation and the change.
32
+
33
+ Continuous integration runs the same checks across all supported Python versions.
34
+
35
+ ## Code of conduct
36
+
37
+ This project follows the [Contributor Covenant](CODE_OF_CONDUCT.md). By participating you agree to abide by its terms.
38
+
39
+ ## Full guide
40
+
41
+ The complete contributor guide, including details on releases, versioning, and documentation, lives in the documentation:
42
+ <https://docs.fschuch.com/xarray-binfile/references/how-to-contribute.html>
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.5
2
2
  Name: xarray-binfile
3
- Version: 0.1.0b1
3
+ Version: 0.2.0
4
4
  Summary: Read and write raw binary files using the familiar interface from the Xarray library
5
5
  Project-URL: Source, https://github.com/fschuch/xarray-binfile
6
6
  Project-URL: Tracker, https://github.com/fschuch/xarray-binfile/issues
@@ -41,8 +41,8 @@ Requires-Dist: pytest-benchmark>=5.1.0; extra == 'tests'
41
41
  Requires-Dist: pytest-cov>=5.0.0; extra == 'tests'
42
42
  Requires-Dist: pytest>=8.2.2; extra == 'tests'
43
43
  Provides-Extra: tests-extra
44
- Requires-Dist: pytest-randomly==4.1.0; extra == 'tests-extra'
45
- Requires-Dist: pytest-rerunfailures==16.3; extra == 'tests-extra'
44
+ Requires-Dist: pytest-randomly==5.0.0; extra == 'tests-extra'
45
+ Requires-Dist: pytest-rerunfailures==16.7; extra == 'tests-extra'
46
46
  Requires-Dist: pytest-xdist==3.8.0; extra == 'tests-extra'
47
47
  Description-Content-Type: text/markdown
48
48
 
@@ -49,6 +49,10 @@ sphinx:
49
49
  #https://github.com/executablebooks/jupyter-book/issues/1950#issuecomment-1454801479
50
50
  suppress_warnings: ["mystnb.unknown_mime_type"]
51
51
 
52
+ # allow_errors: false only reports failed cells as warnings; this makes
53
+ # a notebook execution error abort the build with a non-zero exit code
54
+ nb_execution_raise_on_error: true
55
+
52
56
  intersphinx_mapping:
53
57
  python:
54
58
  - "https://docs.python.org/3"
@@ -19,6 +19,15 @@ Write accessors
19
19
  :imported-members:
20
20
 
21
21
 
22
+ Conventions
23
+ -----------
24
+
25
+ .. automodule:: xarray_binfile.conventions
26
+ :members:
27
+ :show-inheritance:
28
+ :imported-members:
29
+
30
+
22
31
  Tutorial helpers
23
32
  ----------------
24
33
 
@@ -41,7 +41,8 @@
41
41
  "import xarray as xr\n",
42
42
  "\n",
43
43
  "import xarray_binfile # noqa: F401 (registers the .binary_engine accessors)\n",
44
- "from xarray_binfile.tutorial import DatasetGenerator, FileSpecsGetter\n",
44
+ "from xarray_binfile.conventions import Layout, StepIndexedFiles\n",
45
+ "from xarray_binfile.tutorial import DatasetGenerator\n",
45
46
  "\n",
46
47
  "workdir_holder = tempfile.TemporaryDirectory()\n",
47
48
  "workdir = pathlib.Path(workdir_holder.name)\n",
@@ -98,10 +99,10 @@
98
99
  " axis: np.linspace(0.0, 1.0, num=num_points, dtype=np.float32)\n",
99
100
  " for axis in (\"x\", \"y\", \"z\")\n",
100
101
  " }\n",
101
- " getter = FileSpecsGetter(base_coords=coords, dtype=dtype)\n",
102
+ " getter = StepIndexedFiles(Layout(coords, dtype=dtype))\n",
102
103
  " generator = DatasetGenerator(getter.reader)\n",
103
104
  " filenames = (\n",
104
- " getter.filename_template.format(name=name, digits=step)\n",
105
+ " getter.pattern.format(name=name, step=step)\n",
105
106
  " for name in variables\n",
106
107
  " for step in range(num_steps)\n",
107
108
  " )\n",
@@ -23,8 +23,8 @@
23
23
  "metadata": {},
24
24
  "source": [
25
25
  "```{note}\n",
26
- "These recipes reuse the shipped `FileSpecsGetter` convention\n",
27
- "(`{name}-{digits:04}.bin`). For a different on-disk layout, provide your own\n",
26
+ "These recipes reuse the shipped `StepIndexedFiles` convention\n",
27
+ "(`{name}-{step:04d}.bin`). For a different on-disk layout, provide your own\n",
28
28
  "read/write getters as shown in\n",
29
29
  "[Spec getter protocols](../usage/spec-getter-protocols.md).\n",
30
30
  "```"
@@ -46,7 +46,8 @@
46
46
  "import xarray as xr\n",
47
47
  "\n",
48
48
  "import xarray_binfile # noqa: F401 (registers the .binary_engine accessors)\n",
49
- "from xarray_binfile.tutorial import DatasetGenerator, FileSpecsGetter\n",
49
+ "from xarray_binfile.conventions import Layout, StepIndexedFiles\n",
50
+ "from xarray_binfile.tutorial import DatasetGenerator\n",
50
51
  "\n",
51
52
  "source_directory_holder = tempfile.TemporaryDirectory()\n",
52
53
  "float32_directory_holder = tempfile.TemporaryDirectory()\n",
@@ -80,10 +81,10 @@
80
81
  " \"z\": np.linspace(0.0, 2.0, num=8, dtype=np.float32),\n",
81
82
  "}\n",
82
83
  "\n",
83
- "reader_float64 = FileSpecsGetter(base_coords=base_coords, dtype=np.float64)\n",
84
+ "reader_float64 = StepIndexedFiles(Layout(base_coords, dtype=np.float64))\n",
84
85
  "dataset_generator = DatasetGenerator(reader_float64.reader)\n",
85
86
  "filenames = (\n",
86
- " reader_float64.filename_template.format(name=name, digits=step)\n",
87
+ " reader_float64.pattern.format(name=name, step=step)\n",
87
88
  " for name in (\"ux\", \"uy\", \"uz\")\n",
88
89
  " for step in range(6)\n",
89
90
  ")\n",
@@ -109,7 +110,7 @@
109
110
  "metadata": {},
110
111
  "outputs": [],
111
112
  "source": [
112
- "reader_float32 = FileSpecsGetter(base_coords=base_coords, dtype=np.float32)\n",
113
+ "reader_float32 = StepIndexedFiles(Layout(base_coords, dtype=np.float32))\n",
113
114
  "\n",
114
115
  "for path in sorted(source_directory.glob(\"*.bin\")):\n",
115
116
  " single = xr.open_dataset(\n",
@@ -44,7 +44,8 @@
44
44
  "import xarray as xr\n",
45
45
  "\n",
46
46
  "import xarray_binfile # noqa: F401 (registers the .binary_engine accessors)\n",
47
- "from xarray_binfile.tutorial import DatasetGenerator, FileSpecsGetter\n",
47
+ "from xarray_binfile.conventions import Layout, StepIndexedFiles\n",
48
+ "from xarray_binfile.tutorial import DatasetGenerator\n",
48
49
  "\n",
49
50
  "source_directory_holder = tempfile.TemporaryDirectory()\n",
50
51
  "derived_directory_holder = tempfile.TemporaryDirectory()\n",
@@ -76,10 +77,10 @@
76
77
  " \"z\": np.linspace(0.0, 2.0, num=16, dtype=np.float32),\n",
77
78
  "}\n",
78
79
  "\n",
79
- "getter = FileSpecsGetter(base_coords=base_coords, dtype=np.float32)\n",
80
+ "getter = StepIndexedFiles(Layout(base_coords, dtype=np.float32))\n",
80
81
  "dataset_generator = DatasetGenerator(getter.reader)\n",
81
82
  "filenames = (\n",
82
- " getter.filename_template.format(name=name, digits=step)\n",
83
+ " getter.pattern.format(name=name, step=step)\n",
83
84
  " for name in (\"ux\", \"uy\", \"uz\")\n",
84
85
  " for step in range(12)\n",
85
86
  ")\n",
@@ -9,7 +9,7 @@
9
9
  "\n",
10
10
  "This notebook shows the main xarray-binfile workflow:\n",
11
11
  "\n",
12
- "- describe a binary-file convention with `FileSpecsGetter`\n",
12
+ "- describe a binary-file convention with `StepIndexedFiles`\n",
13
13
  "- open individual files or a whole collection with `engine=\"binfile\"`\n",
14
14
  "- keep the resulting arrays lazy and Dask-backed\n",
15
15
  "- inspect the task graph before executing a calculation\n",
@@ -24,7 +24,6 @@
24
24
  "outputs": [],
25
25
  "source": [
26
26
  "import pathlib\n",
27
- "import re\n",
28
27
  "import tempfile\n",
29
28
  "from shutil import which\n",
30
29
  "\n",
@@ -33,7 +32,8 @@
33
32
  "from IPython.display import Markdown, display\n",
34
33
  "\n",
35
34
  "import xarray_binfile # noqa: F401 (registers the .binary_engine accessors)\n",
36
- "from xarray_binfile.tutorial import DatasetGenerator, FileSpecsGetter\n",
35
+ "from xarray_binfile.conventions import Layout, StepIndexedFiles\n",
36
+ "from xarray_binfile.tutorial import DatasetGenerator\n",
37
37
  "\n",
38
38
  "temporary_directory = tempfile.TemporaryDirectory()\n",
39
39
  "data_directory = pathlib.Path(temporary_directory.name)\n",
@@ -53,16 +53,14 @@
53
53
  " \"z\": np.linspace(0.0, 2.0, num=8, dtype=np.float32),\n",
54
54
  "}\n",
55
55
  "\n",
56
- "file_specs_getter = FileSpecsGetter(\n",
57
- " base_coords=base_coords,\n",
58
- " dtype=np.float32,\n",
59
- " filename_template=\"{name}-{digits:04}.bin\",\n",
60
- " filename_regex=re.compile(r\"(?P<name>\\w+)-(?P<digits>\\d{4})\\.bin\"),\n",
56
+ "file_specs_getter = StepIndexedFiles(\n",
57
+ " layout=Layout(base_coords, dtype=np.float32),\n",
58
+ " pattern=\"{name}-{step:04d}.bin\",\n",
61
59
  ")\n",
62
60
  "\n",
63
61
  "dataset_generator = DatasetGenerator(file_specs_getter.reader)\n",
64
62
  "filenames = (\n",
65
- " file_specs_getter.filename_template.format(name=name, digits=step)\n",
63
+ " file_specs_getter.pattern.format(name=name, step=step)\n",
66
64
  " for name in (\"ux\", \"uy\", \"uz\")\n",
67
65
  " for step in range(2)\n",
68
66
  ")\n",
@@ -89,7 +87,7 @@
89
87
  "outputs": [],
90
88
  "source": [
91
89
  "single_dataset = xr.open_dataset(\n",
92
- " sorted(data_directory.glob(\"ux-*.bin\"))[0],\n",
90
+ " min(data_directory.glob(\"ux-*.bin\")),\n",
93
91
  " engine=\"binfile\",\n",
94
92
  " read_specs_getter=file_specs_getter.reader,\n",
95
93
  ")\n",
@@ -34,15 +34,13 @@
34
34
  "outputs": [],
35
35
  "source": [
36
36
  "import pathlib\n",
37
- "import re\n",
38
37
  "import tempfile\n",
39
- "from dataclasses import dataclass\n",
40
38
  "\n",
41
39
  "import numpy as np\n",
42
40
  "import xarray as xr\n",
43
41
  "\n",
44
- "from xarray_binfile import WriteSpecs\n",
45
- "from xarray_binfile.tutorial import DatasetGenerator, FileSpecsGetter\n",
42
+ "from xarray_binfile.conventions import Layout, StepIndexedFiles\n",
43
+ "from xarray_binfile.tutorial import DatasetGenerator\n",
46
44
  "\n",
47
45
  "input_directory_holder = tempfile.TemporaryDirectory()\n",
48
46
  "output_directory_holder = tempfile.TemporaryDirectory()\n",
@@ -64,16 +62,14 @@
64
62
  " \"z\": np.linspace(0.0, 1.5, num=12, dtype=np.float32),\n",
65
63
  "}\n",
66
64
  "\n",
67
- "input_specs_getter = FileSpecsGetter(\n",
68
- " base_coords=base_coords,\n",
69
- " dtype=np.float32,\n",
70
- " filename_template=\"{name}-{digits:04}.bin\",\n",
71
- " filename_regex=re.compile(r\"(?P<name>\\w+)-(?P<digits>\\d{4})\\.bin\"),\n",
65
+ "input_specs_getter = StepIndexedFiles(\n",
66
+ " layout=Layout(base_coords, dtype=np.float32),\n",
67
+ " pattern=\"{name}-{step:04d}.bin\",\n",
72
68
  ")\n",
73
69
  "\n",
74
70
  "dataset_generator = DatasetGenerator(input_specs_getter.reader)\n",
75
71
  "filenames = (\n",
76
- " input_specs_getter.filename_template.format(name=name, digits=step)\n",
72
+ " input_specs_getter.pattern.format(name=name, step=step)\n",
77
73
  " for name in (\"ux\", \"uy\", \"uz\")\n",
78
74
  " for step in range(8)\n",
79
75
  ")\n",
@@ -138,9 +134,9 @@
138
134
  "source": [
139
135
  "## Custom write specifications\n",
140
136
  "\n",
141
- "`FileSpecsGetter.writer` is useful when your output convention matches the tutorial helper. If you need a different layout, implement a callable compatible with `WriteSpecsGetterProtocol`.\n",
137
+ "The derived array has the same layout as the inputs; only the filename differs. Declaring a second `StepIndexedFiles` with another `pattern` is enough, and because the regex used for reading is derived from that same pattern, the files can be read back without repeating the convention. When the shipped conventions do not fit, implement a callable compatible with `WriteSpecsGetterProtocol` as described in [Spec getter protocols](../usage/spec-getter-protocols.md).\n",
142
138
  "\n",
143
- "Setting `dtype` on each `WriteSpecs` pins the on-disk data type (including byte order): the values are cast right before serialization, so the files always match what the corresponding read getter declares. When `dtype` is omitted, the in-memory dtype and native byte order are written as-is."
139
+ "The `dtype` of the `Layout` pins the on-disk data type (including byte order): the values are cast right before serialization, so the files always match what the corresponding reader declares.\n"
144
140
  ]
145
141
  },
146
142
  {
@@ -150,26 +146,11 @@
150
146
  "metadata": {},
151
147
  "outputs": [],
152
148
  "source": [
153
- "@dataclass(frozen=True)\n",
154
- "class DerivedWriteSpecsGetter:\n",
155
- " prefix: str = \"derived\"\n",
156
- " base_dims: tuple[str, ...] = (\"x\", \"y\", \"z\")\n",
157
- " dtype: np.dtype = np.float32\n",
158
- "\n",
159
- " def __call__(self, data_array: xr.DataArray):\n",
160
- " for time_value in data_array.coords[\"time\"].values:\n",
161
- " timestep = int(time_value)\n",
162
- " yield WriteSpecs(\n",
163
- " filename=f\"{self.prefix}-{data_array.name}-{timestep:04}.bin\",\n",
164
- " sub_array=data_array.sel(time=timestep).transpose(\n",
165
- " *self.base_dims, missing_dims=\"raise\"\n",
166
- " ),\n",
167
- " dtype=self.dtype,\n",
168
- " )\n",
169
- "\n",
170
- "\n",
171
- "derived_write_specs_getter = DerivedWriteSpecsGetter()\n",
172
- "derived_write_specs_getter"
149
+ "output_specs_getter = StepIndexedFiles(\n",
150
+ " layout=Layout(base_coords, dtype=np.float32),\n",
151
+ " pattern=\"derived-{name}-{step:04d}.bin\",\n",
152
+ ")\n",
153
+ "output_specs_getter"
173
154
  ]
174
155
  },
175
156
  {
@@ -179,7 +160,7 @@
179
160
  "metadata": {},
180
161
  "outputs": [],
181
162
  "source": [
182
- "speed.binary_engine.to_file(derived_write_specs_getter, output_directory)\n",
163
+ "speed.binary_engine.to_file(output_specs_getter.writer, output_directory)\n",
183
164
  "sorted(path.name for path in output_directory.glob(\"*.bin\"))[:6]"
184
165
  ]
185
166
  },
@@ -191,7 +172,7 @@
191
172
  "Writing triggers the actual per-file materialization of each selected slice. That is often exactly what you want when handing data back to an external solver or post-processing pipeline.\n",
192
173
  "\n",
193
174
  "```{warning}\n",
194
- "`.binary_engine.to_file(...)` never writes a file partially. Each `sub_array` is fully loaded into memory (a Dask compute for lazy data) and the whole file is written in a single pass — there is no appending, patching, or resuming. Each file is also written atomically: the bytes go to a unique temporary directory inside the destination and are moved into place with `os.replace` only when complete, so an interrupted write never leaves a truncated file behind. This keeps the on-disk files consistent instead of risking partially-updated, corrupted content, but it means every individual output file must fit in memory. Plan your chunks and the number of output files accordingly, for example one file per time step. If you need streaming or partial writes, use one of the other xarray-supported formats such as NetCDF or Zarr.\n",
175
+ "`.binary_engine.to_file(...)` never writes a file partially. Each `sub_array` is fully loaded into memory (a Dask compute for lazy data) and the whole file is written in a single pass — there is no appending, patching, or resuming. Each file is also written atomically: the bytes go to a temporary file next to the destination and are moved into place with `os.replace` only when complete, so an interrupted write never leaves a truncated file behind. This keeps the on-disk files consistent instead of risking partially-updated, corrupted content, but it means every individual output file must fit in memory. Plan your chunks and the number of output files accordingly, for example one file per time step. If you need streaming or partial writes, use one of the other xarray-supported formats such as NetCDF or Zarr.\n",
195
176
  "```"
196
177
  ]
197
178
  },
@@ -202,13 +183,6 @@
202
183
  "metadata": {},
203
184
  "outputs": [],
204
185
  "source": [
205
- "output_specs_getter = FileSpecsGetter(\n",
206
- " base_coords=base_coords,\n",
207
- " dtype=np.float32,\n",
208
- " filename_template=\"derived-{name}-{digits:04}.bin\",\n",
209
- " filename_regex=re.compile(r\"derived-(?P<name>\\w+)-(?P<digits>\\d{4})\\.bin\"),\n",
210
- ")\n",
211
- "\n",
212
186
  "roundtrip_dataset = xr.open_mfdataset(\n",
213
187
  " sorted(output_directory.glob(\"derived-*.bin\")),\n",
214
188
  " engine=\"binfile\",\n",