floer 1.0.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 (36) hide show
  1. floer-1.0.0/.flake8 +6 -0
  2. floer-1.0.0/.gitignore +2 -0
  3. floer-1.0.0/.hypothesis/.gitignore +9 -0
  4. floer-1.0.0/.hypothesis/constants/075ce22647cf3d14 +4 -0
  5. floer-1.0.0/.hypothesis/constants/5427d99abce53cc4 +4 -0
  6. floer-1.0.0/.hypothesis/constants/5cddfd4e9a2688e6 +4 -0
  7. floer-1.0.0/.hypothesis/constants/c6566da24ce65556 +4 -0
  8. floer-1.0.0/.hypothesis/constants/cfe227759f5e9958 +4 -0
  9. floer-1.0.0/.hypothesis/constants/e83184caa876cff5 +4 -0
  10. floer-1.0.0/.hypothesis/examples/04e6b3400353b141/87c3ab2b15754d04 +1 -0
  11. floer-1.0.0/.hypothesis/examples/04e6b3400353b141/8b0afdf2cf325292 +1 -0
  12. floer-1.0.0/.hypothesis/examples/04e6b3400353b141/a195ba7984f4cf9c +1 -0
  13. floer-1.0.0/.hypothesis/examples/87c3ab2b15754d04/13af9b5aaf5ff233 +0 -0
  14. floer-1.0.0/.hypothesis/examples/8b0afdf2cf325292/0b18b5ac54044796 +0 -0
  15. floer-1.0.0/.hypothesis/examples/8b0afdf2cf325292/32ad33906349d517 +0 -0
  16. floer-1.0.0/.hypothesis/examples/8b0afdf2cf325292/3332ab5d774e026b +0 -0
  17. floer-1.0.0/.hypothesis/examples/8b0afdf2cf325292/807c26144374c8cd +0 -0
  18. floer-1.0.0/.hypothesis/examples/8b0afdf2cf325292/c84c47a0b84cf658 +0 -0
  19. floer-1.0.0/.hypothesis/examples/8b0afdf2cf325292/e0b228860313f43a +0 -0
  20. floer-1.0.0/.hypothesis/examples/8b0afdf2cf325292/f205f3b2dd0c506c +1 -0
  21. floer-1.0.0/.hypothesis/examples/a195ba7984f4cf9c/83cd93c80f5a6c7c +0 -0
  22. floer-1.0.0/.hypothesis/examples/a195ba7984f4cf9c/8d4fd9a8a17ebdf2 +0 -0
  23. floer-1.0.0/.hypothesis/examples/a195ba7984f4cf9c/cdb6be07f0b7e400 +0 -0
  24. floer-1.0.0/CHANGELOG.md +20 -0
  25. floer-1.0.0/LICENCE.txt +18 -0
  26. floer-1.0.0/PKG-INFO +50 -0
  27. floer-1.0.0/README.md +23 -0
  28. floer-1.0.0/hatch.toml +26 -0
  29. floer-1.0.0/pylock.hatch-test-py3-14.toml +117 -0
  30. floer-1.0.0/pyproject.toml +74 -0
  31. floer-1.0.0/src/floer/__about__.py +4 -0
  32. floer-1.0.0/src/floer/__init__.py +3 -0
  33. floer-1.0.0/src/floer/model.py +297 -0
  34. floer-1.0.0/tests/__init__.py +3 -0
  35. floer-1.0.0/tests/test_model_objects.py +12 -0
  36. floer-1.0.0/tests/test_spectrum.py +165 -0
floer-1.0.0/.flake8 ADDED
@@ -0,0 +1,6 @@
1
+ [flake8]
2
+ max-line-length = 80
3
+ select = C, E, F, W, B
4
+ extend-select = B902, B908, B950
5
+ extend-ignore = E203, E501, E704, W503
6
+ exclude = .venv*, .git, .hypothesis, __pycache__, .pytest_cache
floer-1.0.0/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ dist/*
2
+ **/__pycache__
@@ -0,0 +1,9 @@
1
+ # This .gitignore file was automatically created by Hypothesis. Hypothesis gitignores
2
+ # .hypothesis by default, because we generally recommend that .hypothesis not be checked
3
+ # into version control.
4
+ #
5
+ # If you *would* like to check .hypothesis into version control, you should delete this
6
+ # file. Hypothesis will not re-create this .gitignore unless .hypothesis is deleted (and
7
+ # if it does, that's a bug - please report it!)
8
+
9
+ *
@@ -0,0 +1,4 @@
1
+ # file: /home/mokni55p/Documents/floer/src/floer/model.py
2
+ # hypothesis_version: 6.165.10
3
+
4
+ [3e-05, 0.25, 0.3, 1.0, 922.5, 100000.0, 6000000000.0, 1025]
@@ -0,0 +1,4 @@
1
+ # file: /home/mokni55p/Documents/floer/src/floer/model.py
2
+ # hypothesis_version: 6.165.10
3
+
4
+ [3e-05, 0.25, 0.3, 1.0, 922.5, 100000.0, 6000000000.0, 1025]
@@ -0,0 +1,4 @@
1
+ # file: /home/mokni55p/Documents/floer/src/floer/model.py
2
+ # hypothesis_version: 6.165.10
3
+
4
+ [3e-05, 0.25, 0.3, 1.0, 922.5, 100000.0, 6000000000.0, 1025]
@@ -0,0 +1,4 @@
1
+ # file: /home/mokni55p/Documents/floer/src/floer/model.py
2
+ # hypothesis_version: 6.165.10
3
+
4
+ [0.25, 922.5, 1025]
@@ -0,0 +1,4 @@
1
+ # file: /home/mokni55p/Documents/floer/src/floer/__init__.py
2
+ # hypothesis_version: 6.165.10
3
+
4
+ []
@@ -0,0 +1,4 @@
1
+ # file: /home/mokni55p/Documents/floer/.hatch/hatch-test.py3.14/bin/pytest
2
+ # hypothesis_version: 6.165.10
3
+
4
+ ['-script.pyw', '.exe', '__main__']
@@ -0,0 +1 @@
1
+ K���bav�r�"щ�'Sr�#�f�`C�'��R��_�ih�g1N!h&.secondary
@@ -0,0 +1 @@
1
+ 澄���C�X)��4R�����p����(?��e��Y��ѳ��5��.secondary
@@ -0,0 +1 @@
1
+ �#��BM@q�A�S�𰿯L�O�T�� U +��W1
@@ -0,0 +1 @@
1
+ (@~����`�(@R8FqɄ(@q��d���(@�h%��[�(@z���懚(@~��l#8C(@��@�h�(@��A��5�(?񙙙���(?�������(@1 v�
@@ -0,0 +1,20 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a
6
+ Changelog](https://keepachangelog.com/en/2.0.0/), and this project adheres to
7
+ [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
8
+
9
+
10
+ ## [Unreleased]
11
+
12
+ ## [v1.0.0] -- 2026-08-20
13
+
14
+ ### Added
15
+
16
+ - Add basic classes adapted from [SWIIFT](https://github.com/sasip-climate/swiift).
17
+
18
+
19
+ [unreleased]: https://gitlab.com/tartopohm/floer/-/compare/v1.0.0...main
20
+ [v1.0.0]: https://gitlab.com/tartopohm/floer/-/tags/v1.0.0
@@ -0,0 +1,18 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026-present Nicolas Mokus <nmks@tuta.io>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
6
+ associated documentation files (the "Software"), to deal in the Software without restriction, including
7
+ without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
9
+ following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all copies or substantial
12
+ portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
15
+ LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
16
+ EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
18
+ USE OR OTHER DEALINGS IN THE SOFTWARE.
floer-1.0.0/PKG-INFO ADDED
@@ -0,0 +1,50 @@
1
+ Metadata-Version: 2.5
2
+ Name: floer
3
+ Version: 1.0.0
4
+ Summary: Building blocks for floe models to rest upon.
5
+ Project-URL: Documentation, https://gitlab.com/tartopohm/floer#readme
6
+ Project-URL: Issues, https://gitlab.com/tartopohm/floer/issues
7
+ Project-URL: Source, https://gitlab.com/tartopohm/floer
8
+ Author-email: Nicolas Mokus <nmks@tuta.io>
9
+ License-Expression: MIT
10
+ License-File: LICENCE.txt
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Natural Language :: English
15
+ Classifier: Programming Language :: Python
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Programming Language :: Python :: 3.14
21
+ Classifier: Programming Language :: Python :: Implementation :: CPython
22
+ Classifier: Topic :: Scientific/Engineering :: Oceanography
23
+ Requires-Python: >=3.10
24
+ Requires-Dist: attrs
25
+ Requires-Dist: numpy>=2
26
+ Description-Content-Type: text/markdown
27
+
28
+ # floer
29
+
30
+ [![PyPI - Version](https://img.shields.io/pypi/v/floer.svg)](https://pypi.org/project/floer)
31
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/floer.svg)](https://pypi.org/project/floer)
32
+
33
+ Building blocks for floe models to rest upon.
34
+
35
+ -----
36
+
37
+ ## Table of Contents
38
+
39
+ - [Installation](#installation)
40
+ - [Licence](#licence)
41
+
42
+ ## Installation
43
+
44
+ ```console
45
+ pip install floer
46
+ ```
47
+
48
+ ## Licence
49
+
50
+ `floer` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) licence.
floer-1.0.0/README.md ADDED
@@ -0,0 +1,23 @@
1
+ # floer
2
+
3
+ [![PyPI - Version](https://img.shields.io/pypi/v/floer.svg)](https://pypi.org/project/floer)
4
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/floer.svg)](https://pypi.org/project/floer)
5
+
6
+ Building blocks for floe models to rest upon.
7
+
8
+ -----
9
+
10
+ ## Table of Contents
11
+
12
+ - [Installation](#installation)
13
+ - [Licence](#licence)
14
+
15
+ ## Installation
16
+
17
+ ```console
18
+ pip install floer
19
+ ```
20
+
21
+ ## Licence
22
+
23
+ `floer` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) licence.
floer-1.0.0/hatch.toml ADDED
@@ -0,0 +1,26 @@
1
+ [envs.hatch-test]
2
+ locked = true
3
+ builder = true
4
+ dependency-groups = ["test"]
5
+
6
+ [[envs.hatch-test.matrix]]
7
+ python = ["3.11", "3.12", "3.13", "3.14"]
8
+
9
+ [envs.hatch-test.scripts]
10
+ run = "pytest{env:HATCH_TEST_ARGS:} {args}"
11
+ run-cov = "coverage run -m pytest{env:HATCH_TEST_ARGS:} {args}"
12
+ cov-combine = "coverage combine"
13
+ cov-report = "coverage html --show-contexts"
14
+
15
+ [envs.types]
16
+ dependency-groups = ["typecheck", "test"]
17
+
18
+ [envs.types.scripts]
19
+ check = "mypy --install-types --non-interactive {args:src/floer tests}"
20
+
21
+ [envs.dev]
22
+ dependency-groups = ["dev"]
23
+ builder = true
24
+
25
+ [version]
26
+ path = "src/floer/__about__.py"
@@ -0,0 +1,117 @@
1
+ lock-version = "1.0"
2
+ created-by = "uv"
3
+ requires-python = ">=3.14"
4
+
5
+ [[packages]]
6
+ name = "attrs"
7
+ version = "26.1.0"
8
+ sdist = { url = "https://files.pythonhosted.org/packages/9a/8e/82a0fe20a541c03148528be8cac2408564a6c9a0cc7e9171802bc1d26985/attrs-26.1.0.tar.gz", upload-time = 2026-03-19T14:22:25Z, size = 952055, hashes = { sha256 = "d03ceb89cb322a8fd706d4fb91940737b6642aa36998fe130a9bc96c985eff32" } }
9
+ wheels = [{ url = "https://files.pythonhosted.org/packages/64/b4/17d4b0b2a2dc85a6df63d1157e028ed19f90d4cd97c36717afef2bc2f395/attrs-26.1.0-py3-none-any.whl", upload-time = 2026-03-19T14:22:23Z, size = 67548, hashes = { sha256 = "c647aa4a12dfbad9333ca4e71fe62ddc36f4e63b2d260a37a8b83d2f043ac309" } }]
10
+
11
+ [[packages]]
12
+ name = "coverage"
13
+ version = "7.15.4"
14
+ sdist = { url = "https://files.pythonhosted.org/packages/be/c3/4f2195f512fb172aa425a8803a874b2baa9ba7f80ff7b6080998761fc701/coverage-7.15.4.tar.gz", upload-time = 2026-08-06T13:50:24Z, size = 936952, hashes = { sha256 = "0548198fff07ccf4faf469520bce1c2eceb1ce3e62891921138dec10907f9d00" } }
15
+ wheels = [
16
+ { url = "https://files.pythonhosted.org/packages/a1/26/595759762e514e81be1d7d01ed03444303bcd152226a6529998d253f9201/coverage-7.15.4-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", upload-time = 2026-08-06T13:48:31Z, size = 256492, hashes = { sha256 = "ff97a14362eef486483ed44042ca2027ea257df6ff768e62358ee0c9776925ac" } },
17
+ { url = "https://files.pythonhosted.org/packages/b4/d9/e70c286c979378f061d8266e279b686ab0b0b688e1fe0af864684f23a77d/coverage-7.15.4-py3-none-any.whl", upload-time = 2026-08-06T13:50:22Z, size = 214332, hashes = { sha256 = "964730a1e9de9c0cf11be6a1a3c79ce419c34882842abd256086ba4698705e84" } },
18
+ ]
19
+
20
+ [[packages]]
21
+ name = "coverage-enable-subprocess"
22
+ version = "1.0"
23
+ sdist = { url = "https://files.pythonhosted.org/packages/31/f4/57693bcf041ba641501b7a2fafc9d3d2de647355d78c6a2e07fb53648eaa/coverage_enable_subprocess-1.0.tar.gz", upload-time = 2016-05-11T18:49:48Z, size = 2695, hashes = { sha256 = "fdbd3dc9532007cd87ef84f38e16024c5b0ccb4ab2d1755225a7edf937acc011" } }
24
+ wheels = [{ url = "https://files.pythonhosted.org/packages/31/58/d8dd7edbf5e120942b6395b4c034506c68e56f656074522c83b59d9a4991/coverage_enable_subprocess-1.0-py2.py3-none-any.whl", upload-time = 2016-05-11T18:48:49Z, size = 4033, hashes = { sha256 = "27982522339ec77662965e0d859da5662162962c874d54d2250426506818cbdc" } }]
25
+
26
+ [[packages]]
27
+ name = "execnet"
28
+ version = "2.1.2"
29
+ sdist = { url = "https://files.pythonhosted.org/packages/bf/89/780e11f9588d9e7128a3f87788354c7946a9cbb1401ad38a48c4db9a4f07/execnet-2.1.2.tar.gz", upload-time = 2025-11-12T09:56:37Z, size = 166622, hashes = { sha256 = "63d83bfdd9a23e35b9c6a3261412324f964c2ec8dcd8d3c6916ee9373e0befcd" } }
30
+ wheels = [{ url = "https://files.pythonhosted.org/packages/ab/84/02fc1827e8cdded4aa65baef11296a9bbe595c474f0d6d758af082d849fd/execnet-2.1.2-py3-none-any.whl", upload-time = 2025-11-12T09:56:36Z, size = 40708, hashes = { sha256 = "67fba928dd5a544b783f6056f449e5e3931a5c378b128bc18501f7ea79e296ec" } }]
31
+
32
+ [[packages]]
33
+ name = "hypothesis"
34
+ version = "6.165.10"
35
+ sdist = { url = "https://files.pythonhosted.org/packages/5c/e2/0fad246d2b6330e1f78479bfc566b5c22be82aee8a865cde9a08f648487d/hypothesis-6.165.10.tar.gz", upload-time = 2026-08-16T22:56:15Z, size = 503703, hashes = { sha256 = "68b45e09834cd80523cb1eb274463073c7a9af4e4ef7cff34d9615f355572d32" } }
36
+ wheels = [
37
+ { url = "https://files.pythonhosted.org/packages/7d/18/8a26c24d3d9db20265f39df341ab265858c094e209571e3179cf237935f4/hypothesis-6.165.10-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", upload-time = 2026-08-16T22:56:02Z, size = 1157528, hashes = { sha256 = "2abb50cf1cf77d721de0a24c3f99d9c4ffdeb2cbd1e12aebb5a7a93e2b6b6d1f" } },
38
+ { url = "https://files.pythonhosted.org/packages/8f/b8/206468912d2153306bb8a41afdfc59e45b7a73a0495bbe4b9cb4f0e79c1d/hypothesis-6.165.10-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", upload-time = 2026-08-16T22:54:25Z, size = 1156915, hashes = { sha256 = "60cab3ab4ea468d31a33739ffd7e94ec3e37dea891d65a6582ecc8a477175191" } },
39
+ ]
40
+
41
+ [[packages]]
42
+ name = "hypothesis-miz"
43
+ version = "0.0.1"
44
+ sdist = { url = "https://files.pythonhosted.org/packages/5b/49/d3de60a5ee2fe56f380f16749bd779792288a4d22f544dd4fe6d27e0c233/hypothesis_miz-0.0.1.tar.gz", upload-time = 2026-08-04T01:11:08Z, size = 8801, hashes = { sha256 = "b9fe41b63f94cebfa94025a27e9b7d66bd64042a3934f7343f9a72a417ab87e4" } }
45
+ wheels = [{ url = "https://files.pythonhosted.org/packages/49/20/32230dc19707a51549cac0abb6c4a64667ca53cf3a59d4b0aa50c054f1bb/hypothesis_miz-0.0.1-py3-none-any.whl", upload-time = 2026-08-04T01:11:09Z, size = 9512, hashes = { sha256 = "29b61ac3a254177f6493db6e40ad2e2afe405d7ea5de2d85b754cf8a8f7f479a" } }]
46
+
47
+ [[packages]]
48
+ name = "iniconfig"
49
+ version = "2.3.0"
50
+ sdist = { url = "https://files.pythonhosted.org/packages/72/34/14ca021ce8e5dfedc35312d08ba8bf51fdd999c576889fc2c24cb97f4f10/iniconfig-2.3.0.tar.gz", upload-time = 2025-10-18T21:55:43Z, size = 20503, hashes = { sha256 = "c76315c77db068650d49c5b56314774a7804df16fee4402c1f19d6d15d8c4730" } }
51
+ wheels = [{ url = "https://files.pythonhosted.org/packages/cb/b1/3846dd7f199d53cb17f49cba7e651e9ce294d8497c8c150530ed11865bb8/iniconfig-2.3.0-py3-none-any.whl", upload-time = 2025-10-18T21:55:41Z, size = 7484, hashes = { sha256 = "f631c04d2c48c52b84d0d0549c99ff3859c98df65b3101406327ecc7d53fbf12" } }]
52
+
53
+ [[packages]]
54
+ name = "numpy"
55
+ version = "2.5.2"
56
+ sdist = { url = "https://files.pythonhosted.org/packages/9a/80/db0b4559e57ec36362bedbb05530a87fafbcb6067708c946967a41d449e7/numpy-2.5.2.tar.gz", upload-time = 2026-08-09T13:48:27Z, size = 20773161, hashes = { sha256 = "d482d171c406ae88c5b19cad3b6a1c4c5209f886ab74bc44c2c865c23f52d860" } }
57
+ wheels = [{ url = "https://files.pythonhosted.org/packages/c7/99/461bd36dbdfac6c1c53efa370bd55a83227542d0d118f1677dbf1a3dacd5/numpy-2.5.2-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", upload-time = 2026-08-09T13:46:18Z, size = 16713701, hashes = { sha256 = "318b9a4c845dbea06708a29c84ee429cc3065048db34cdb799047643492050ee" } }]
58
+
59
+ [[packages]]
60
+ name = "packaging"
61
+ version = "26.3"
62
+ sdist = { url = "https://files.pythonhosted.org/packages/7d/fa/3944b40b07da9ce895c0e6303a5ab7d53da063554f534556b134a54d6093/packaging-26.3.tar.gz", upload-time = 2026-08-04T18:15:28Z, size = 313412, hashes = { sha256 = "94edc256424af38762eb31306eed28beb9f0efc50a8837492c9d6fd6004aed79" } }
63
+ wheels = [{ url = "https://files.pythonhosted.org/packages/63/34/ba1c580383c9eada3711951fef0795c80b829a078d72188184bcab9dd527/packaging-26.3-py3-none-any.whl", upload-time = 2026-08-04T18:15:27Z, size = 129956, hashes = { sha256 = "d7193f7c8e4e93f444fde0262bf90af30e16fa0ad0ad44cb553c87339b23cd1c" } }]
64
+
65
+ [[packages]]
66
+ name = "pluggy"
67
+ version = "1.6.0"
68
+ sdist = { url = "https://files.pythonhosted.org/packages/f9/e2/3e91f31a7d2b083fe6ef3fa267035b518369d9511ffab804f839851d2779/pluggy-1.6.0.tar.gz", upload-time = 2025-05-15T12:30:07Z, size = 69412, hashes = { sha256 = "7dcc130b76258d33b90f61b658791dede3486c3e6bfb003ee5c9bfb396dd22f3" } }
69
+ wheels = [{ url = "https://files.pythonhosted.org/packages/54/20/4d324d65cc6d9205fabedc306948156824eb9f0ee1633355a8f7ec5c66bf/pluggy-1.6.0-py3-none-any.whl", upload-time = 2025-05-15T12:30:06Z, size = 20538, hashes = { sha256 = "e920276dd6813095e9377c0bc5566d94c932c33b27a3e3945d8389c374dd4746" } }]
70
+
71
+ [[packages]]
72
+ name = "psutil"
73
+ version = "7.2.2"
74
+ sdist = { url = "https://files.pythonhosted.org/packages/aa/c6/d1ddf4abb55e93cebc4f2ed8b5d6dbad109ecb8d63748dd2b20ab5e57ebe/psutil-7.2.2.tar.gz", upload-time = 2026-01-28T18:14:54Z, size = 493740, hashes = { sha256 = "0746f5f8d406af344fd547f1c8daa5f5c33dbc293bb8d6a16d80b4bb88f59372" } }
75
+ wheels = [{ url = "https://files.pythonhosted.org/packages/b5/70/5d8df3b09e25bce090399cf48e452d25c935ab72dad19406c77f4e828045/psutil-7.2.2-cp36-abi3-manylinux2010_x86_64.manylinux_2_12_x86_64.manylinux_2_28_x86_64.whl", upload-time = 2026-01-28T18:15:25Z, size = 155560, hashes = { sha256 = "076a2d2f923fd4821644f5ba89f059523da90dc9014e85f8e45a5774ca5bc6f9" } }]
76
+
77
+ [[packages]]
78
+ name = "pygments"
79
+ version = "2.21.0"
80
+ sdist = { url = "https://files.pythonhosted.org/packages/49/2e/ced460408999b33da6b31b0021b0f37d329e202d4169aeb164493778f25b/pygments-2.21.0.tar.gz", upload-time = 2026-08-17T08:02:48Z, size = 5005329, hashes = { sha256 = "610ca751c9bc2492b38eb9a38a7fbc93edbbb2d7182edaf34e66ae493dee5c8c" } }
81
+ wheels = [{ url = "https://files.pythonhosted.org/packages/71/46/17f022dd3e953bf20a04a028a21ec746d942f8d2af30fa0f124fa0e6a684/pygments-2.21.0-py3-none-any.whl", upload-time = 2026-08-17T08:02:44Z, size = 1250147, hashes = { sha256 = "2363c69b61c4a97c838da3b130dcd6468f4848992b21a82f2a63ec34377137d9" } }]
82
+
83
+ [[packages]]
84
+ name = "pytest"
85
+ version = "9.1.1"
86
+ sdist = { url = "https://files.pythonhosted.org/packages/e4/47/b9efed96c114afcfa3c9d3fe98a76a1d14c74a9e266d397cf6eb64be5e01/pytest-9.1.1.tar.gz", upload-time = 2026-06-19T10:58:32Z, size = 1636369, hashes = { sha256 = "1088fbde8f2b49d95a549a195707afa7a76a3ce9bcadc26b6d71f0ffda5fe313" } }
87
+ wheels = [{ url = "https://files.pythonhosted.org/packages/24/25/1de2678b631f5a49215c6c96fff41ba892b0a34df68d6d80292b1b48aa7f/pytest-9.1.1-py3-none-any.whl", upload-time = 2026-06-19T10:58:31Z, size = 386536, hashes = { sha256 = "37a86b45efb9a47a61a36449063e8e18d0cab3161329fc099eb21783169c4f0c" } }]
88
+
89
+ [[packages]]
90
+ name = "pytest-mock"
91
+ version = "3.15.1"
92
+ sdist = { url = "https://files.pythonhosted.org/packages/68/14/eb014d26be205d38ad5ad20d9a80f7d201472e08167f0bb4361e251084a9/pytest_mock-3.15.1.tar.gz", upload-time = 2025-09-16T16:37:27Z, size = 34036, hashes = { sha256 = "1849a238f6f396da19762269de72cb1814ab44416fa73a8686deac10b0d87a0f" } }
93
+ wheels = [{ url = "https://files.pythonhosted.org/packages/5a/cc/06253936f4a7fa2e0f48dfe6d851d9c56df896a9ab09ac019d70b760619c/pytest_mock-3.15.1-py3-none-any.whl", upload-time = 2025-09-16T16:37:25Z, size = 10095, hashes = { sha256 = "0a25e2eb88fe5168d535041d09a4529a188176ae608a6d249ee65abc0949630d" } }]
94
+
95
+ [[packages]]
96
+ name = "pytest-randomly"
97
+ version = "3.16.0"
98
+ sdist = { url = "https://files.pythonhosted.org/packages/c0/68/d221ed7f4a2a49a664da721b8e87b52af6dd317af2a6cb51549cf17ac4b8/pytest_randomly-3.16.0.tar.gz", upload-time = 2024-10-25T15:45:34Z, size = 13367, hashes = { sha256 = "11bf4d23a26484de7860d82f726c0629837cf4064b79157bd18ec9d41d7feb26" } }
99
+ wheels = [{ url = "https://files.pythonhosted.org/packages/22/70/b31577d7c46d8e2f9baccfed5067dd8475262a2331ffb0bfdf19361c9bde/pytest_randomly-3.16.0-py3-none-any.whl", upload-time = 2024-10-25T15:45:32Z, size = 8396, hashes = { sha256 = "8633d332635a1a0983d3bba19342196807f6afb17c3eef78e02c2f85dade45d6" } }]
100
+
101
+ [[packages]]
102
+ name = "pytest-rerunfailures"
103
+ version = "14.0"
104
+ sdist = { url = "https://files.pythonhosted.org/packages/cc/a4/6de45fe850759e94aa9a55cda807c76245af1941047294df26c851dfb4a9/pytest-rerunfailures-14.0.tar.gz", upload-time = 2024-03-13T08:21:39Z, size = 21350, hashes = { sha256 = "4a400bcbcd3c7a4ad151ab8afac123d90eca3abe27f98725dc4d9702887d2e92" } }
105
+ wheels = [{ url = "https://files.pythonhosted.org/packages/dc/e7/e75bd157331aecc190f5f8950d7ea3d2cf56c3c57fb44da70e60b221133f/pytest_rerunfailures-14.0-py3-none-any.whl", upload-time = 2024-03-13T08:21:37Z, size = 12709, hashes = { sha256 = "4197bdd2eaeffdbf50b5ea6e7236f47ff0e44d1def8dae08e409f536d84e7b32" } }]
106
+
107
+ [[packages]]
108
+ name = "pytest-xdist"
109
+ version = "3.8.0"
110
+ sdist = { url = "https://files.pythonhosted.org/packages/78/b4/439b179d1ff526791eb921115fca8e44e596a13efeda518b9d845a619450/pytest_xdist-3.8.0.tar.gz", upload-time = 2025-07-01T13:30:59Z, size = 88069, hashes = { sha256 = "7e578125ec9bc6050861aa93f2d59f1d8d085595d6551c2c90b6f4fad8d3a9f1" } }
111
+ wheels = [{ url = "https://files.pythonhosted.org/packages/ca/31/d4e37e9e550c2b92a9cbc2e4d0b7420a27224968580b5a447f420847c975/pytest_xdist-3.8.0-py3-none-any.whl", upload-time = 2025-07-01T13:30:56Z, size = 46396, hashes = { sha256 = "202ca578cfeb7370784a8c33d6d05bc6e13b4f25b5053c30a152269fd10f0b88" } }]
112
+
113
+ [[packages]]
114
+ name = "sortedcontainers"
115
+ version = "2.4.0"
116
+ sdist = { url = "https://files.pythonhosted.org/packages/e8/c4/ba2f8066cceb6f23394729afe52f3bf7adec04bf9ed2c820b39e19299111/sortedcontainers-2.4.0.tar.gz", upload-time = 2021-05-16T22:03:42Z, size = 30594, hashes = { sha256 = "25caa5a06cc30b6b83d11423433f65d1f9d76c4c6a0c90e3379eaa43b9bfdb88" } }
117
+ wheels = [{ url = "https://files.pythonhosted.org/packages/32/46/9cb0e58b2deb7f82b84065f37f3bffeb12413f947f9388e4cac22c4621ce/sortedcontainers-2.4.0-py2.py3-none-any.whl", upload-time = 2021-05-16T22:03:41Z, size = 29575, hashes = { sha256 = "a163dcaede0f1c021485e957a39245190e74249897e2ae4b2aa38595db237ee0" } }]
@@ -0,0 +1,74 @@
1
+ [project]
2
+ name = "floer"
3
+ description = "Building blocks for floe models to rest upon."
4
+ readme = "README.md"
5
+ requires-python = ">=3.10"
6
+ license = "MIT"
7
+ authors = [
8
+ { name = "Nicolas Mokus", email = "nmks@tuta.io" },
9
+ ]
10
+ keywords = []
11
+ classifiers = [
12
+ "Development Status :: 4 - Beta",
13
+ "Intended Audience :: Science/Research",
14
+ "License :: OSI Approved :: MIT License",
15
+ "Natural Language :: English",
16
+ "Programming Language :: Python",
17
+ "Programming Language :: Python :: 3.10",
18
+ "Programming Language :: Python :: 3.11",
19
+ "Programming Language :: Python :: 3.12",
20
+ "Programming Language :: Python :: 3.13",
21
+ "Programming Language :: Python :: 3.14",
22
+ "Programming Language :: Python :: Implementation :: CPython",
23
+ "Topic :: Scientific/Engineering :: Oceanography",
24
+ ]
25
+ dependencies = ["attrs", "numpy>=2"]
26
+ dynamic = ["version"]
27
+
28
+ [project.urls]
29
+ Documentation = "https://gitlab.com/tartopohm/floer#readme"
30
+ Issues = "https://gitlab.com/tartopohm/floer/issues"
31
+ Source = "https://gitlab.com/tartopohm/floer"
32
+
33
+ [dependency-groups]
34
+ dev = [
35
+ { include-group = "lint" },
36
+ { include-group = "test" },
37
+ { include-group = "typecheck" },
38
+ ]
39
+ lint = ["black", "flake8", "flake8-bugbear", "isort"]
40
+ test = [
41
+ "coverage",
42
+ "hypothesis",
43
+ "hypothesis-miz",
44
+ "pytest",
45
+ "pytest-xdist",
46
+ ]
47
+ typecheck = ["mypy", "scipy-stubs"]
48
+
49
+ [build-system]
50
+ requires = ["hatchling"]
51
+ build-backend = "hatchling.build"
52
+
53
+ [tool.coverage.run]
54
+ source_pkgs = ["floer", "tests"]
55
+ branch = true
56
+ parallel = true
57
+ omit = [
58
+ "src/floer/__about__.py",
59
+ ]
60
+
61
+ [tool.coverage.paths]
62
+ floer = ["src/floer", "*/floer/src/floer"]
63
+ tests = ["tests", "*/floer/tests"]
64
+
65
+ [tool.coverage.report]
66
+ exclude_lines = [
67
+ "no cov",
68
+ "if __name__ == .__main__.:",
69
+ "if TYPE_CHECKING:",
70
+ ]
71
+
72
+ [tool.pytest.ini_options]
73
+ addopts = "--import-mode=importlib"
74
+ pythonpath = "src"
@@ -0,0 +1,4 @@
1
+ # SPDX-FileCopyrightText: 2026-present Nicolas Mokus <nmks@tuta.io>
2
+ #
3
+ # SPDX-License-Identifier: MIT
4
+ __version__ = "1.0.0"
@@ -0,0 +1,3 @@
1
+ # SPDX-FileCopyrightText: 2026-present Nicolas Mokus <nmks@tuta.io>
2
+ #
3
+ # SPDX-License-Identifier: MIT
@@ -0,0 +1,297 @@
1
+ import functools
2
+ import math
3
+ import operator
4
+ from typing import Self
5
+
6
+ import attrs
7
+ import numpy as np
8
+ from numpy.typing import ArrayLike
9
+
10
+ _2PI = 2 * np.pi
11
+
12
+
13
+ @attrs.define(frozen=True)
14
+ class Ocean:
15
+ """The fluid bearing ice floes.
16
+
17
+ This class encapsulates the properties of an incompressible ocean of
18
+ constant depth and given density.
19
+
20
+ Parameters
21
+ ----------
22
+ depth : float
23
+ Ocean depth, in m.
24
+ density : float
25
+ Ocean density, in kg m^-3.
26
+
27
+ """
28
+
29
+ depth: float
30
+ density: float = 1025
31
+
32
+
33
+ @attrs.frozen
34
+ class _Subdomain:
35
+ """A segment localised in space.
36
+
37
+ Parameters
38
+ ----------
39
+ left_edge : float
40
+ Coordinate of the left edge of the domain, in m.
41
+ length : float
42
+ Length of the domain, in m.
43
+
44
+ Attributes
45
+ ----------
46
+ right_edge : float
47
+ Coordinate of the right edge of the domain, in m.
48
+
49
+ """
50
+
51
+ left_edge: float
52
+ length: float
53
+
54
+ @functools.cached_property
55
+ def right_edge(self) -> float:
56
+ return self.left_edge + self.length
57
+
58
+
59
+ @attrs.define(frozen=True)
60
+ class Ice:
61
+ """A container for ice mechanical properties.
62
+
63
+ Ice is modelled as an elastic thin plate, with prescribed density,
64
+ thickness, Poisson's ratio and Young's modulus. Its fracture under bending
65
+ is considered either through the lens of Griffith's fracture mechanics, or
66
+ through the framework of strain failure commonly used in the sea ice
67
+ modelling community. The fracture toughness is relevant to the former,
68
+ while the strain threshold is relevant to the latter. Ice is considered
69
+ translationally invariant in one horizontal direction, so that its
70
+ quadratic moment of area is given per unit length in that direction.
71
+
72
+ Parameters
73
+ ----------
74
+ density : float
75
+ Density, in kg m^-3.
76
+ poissons_ratio : float
77
+ Poisson's ratio.
78
+ thickness : float
79
+ Ice thickness, in m.
80
+ youngs_modulus : float
81
+ Scalar Young's modulus, in Pa.
82
+
83
+ Attributes
84
+ ----------
85
+ quad_moment : float
86
+ Quadratic moment of area, in m^3.
87
+ flex_rigidity : float
88
+ Flexural rigidity in, N m.
89
+
90
+ """
91
+
92
+ poissons_ratio: float
93
+ thickness: float
94
+ youngs_modulus: float
95
+ density: float = 922.5
96
+ # frac_toughness: float | None = None
97
+ # strain_threshold: float | None = None
98
+
99
+ @functools.cached_property
100
+ def quad_moment(self) -> float:
101
+ return self.thickness**3 / (12 * (1 - self.poissons_ratio**2))
102
+
103
+ @functools.cached_property
104
+ def flex_rigidity(self) -> float:
105
+ return self.quad_moment * self.youngs_modulus
106
+
107
+
108
+ @attrs.define
109
+ class FloatingIce:
110
+ """An extension of `Ice` to represent properties due to buyoancy.
111
+
112
+ Parameters
113
+ ----------
114
+ ice : Ice
115
+ The ice that floats.
116
+ draught : float
117
+ Immersed ice thickness at rest, in m.
118
+ dbd : float
119
+ Depth below draught, height of the water column underneath the ice at
120
+ rest, in m.
121
+ elastic_length_pow4 : float
122
+ Characteristic elastic length scale, raised to the 4th power, in m^4.
123
+
124
+ Attributes
125
+ ----------
126
+ elastic_length : float
127
+ Characteristic elastic length scale, in m.
128
+ freeboard : float
129
+ Emerged ice thickness at rest, in m.
130
+
131
+ """
132
+
133
+ ice: Ice
134
+ draught: float
135
+ dbd: float
136
+ elastic_length_pow4: float
137
+
138
+ @classmethod
139
+ def from_ice_ocean(cls, ice: Ice, ocean: Ocean, gravity: float) -> FloatingIce:
140
+ """Build an instance by combining properties of existing objects.
141
+
142
+ Parameters
143
+ ----------
144
+ ice : Ice
145
+ ocean : Ocean
146
+ gravity : float
147
+ Strengh of the local gravitational field, in m s^-2.
148
+
149
+ Returns
150
+ -------
151
+ FloatingIce
152
+
153
+ """
154
+ draught = ice.density / ocean.density * ice.thickness
155
+ dbd = ocean.depth - draught
156
+ # NOTE: as the 4th power of the elastic length scale arises naturally,
157
+ # we prefer using it to instantiate the class and computing the length
158
+ # scale when needed, over using the length scale for instantiation and
159
+ # recomputing the fourth power from it, as the latter approach can lead
160
+ # to substantial numerical imprecision.
161
+ el_lgth_pow4 = ice.flex_rigidity / (ocean.density * gravity)
162
+ return cls(
163
+ ice,
164
+ draught,
165
+ dbd,
166
+ elastic_length_pow4=el_lgth_pow4,
167
+ )
168
+
169
+ @functools.cached_property
170
+ def elastic_length(self) -> float:
171
+ return math.pow(self.elastic_length_pow4, 0.25)
172
+
173
+ @functools.cached_property
174
+ def freeboard(self) -> float:
175
+ return self.ice.thickness - self.draught
176
+
177
+ @functools.cached_property
178
+ def _elastic_number(self) -> float:
179
+ """Reciprocal of the Characteristic elastic length scale.
180
+
181
+ Returns
182
+ -------
183
+ float
184
+ Elastic number in m^-1
185
+
186
+ """
187
+ return 1 / self.elastic_length
188
+
189
+ @functools.cached_property
190
+ def _red_elastic_number(self) -> float:
191
+ """Characteristic elastic number scaled by 1/sqrt(2).
192
+
193
+ Returns
194
+ -------
195
+ float
196
+ Reduced elastic number, in m^-1
197
+
198
+ """
199
+ return 1 / (math.sqrt(2) * self.elastic_length)
200
+
201
+
202
+ # TODO: docstring inheritance
203
+ @attrs.define(kw_only=True)
204
+ class Floe(_Subdomain):
205
+ """An ice floe localised in space.
206
+
207
+ Parameters
208
+ ----------
209
+ ice : Ice
210
+ The mechanical properties of the floe.
211
+
212
+ """
213
+
214
+ ice: Ice
215
+
216
+
217
+ @attrs.frozen(init=False)
218
+ class DiscreteSpectrum:
219
+ """Container for a discretised spectrum.
220
+
221
+ This class allows for building a forcing from the linear
222
+ superposition of harmonic waves.
223
+
224
+ Attributes
225
+ ----------
226
+ amplitudes : np.ndarray
227
+ A 1D array of amplitudes, in m.
228
+ frequencies : np.ndarray
229
+ A 1D array of frequencies, in Hz.
230
+ phases : np.ndarray
231
+ A 1D array of phases, in rad.
232
+
233
+ """
234
+
235
+ amplitudes: np.ndarray[tuple[int], np.dtype[np.float64]]
236
+ frequencies: np.ndarray[tuple[int], np.dtype[np.float64]]
237
+ phases: np.ndarray[tuple[int], np.dtype[np.float64]]
238
+
239
+ def __init__(
240
+ self, amplitudes: ArrayLike, frequencies: ArrayLike, phases: ArrayLike = 0.0
241
+ ):
242
+
243
+ # np.ravel to force precisely 1D-arrays
244
+ # Promote the map to list so the iterator can be used several times.
245
+ # Eventual phases are modulo'd to 2pi rad.
246
+ args = [
247
+ _arr.astype(np.float64)
248
+ for _arr in map(np.ravel, (amplitudes, frequencies, phases))
249
+ ]
250
+ (size,) = np.broadcast_shapes(*(arr.shape for arr in args))
251
+
252
+ # If size is one, all the arguments are scalar and the "spectrum" is
253
+ # monochromatic. Otherwise, there is at least one argument with
254
+ # different components. The eventual other arguments with a single
255
+ # component are repeated so that the three arrays have the same size.
256
+ if size != 1:
257
+ for i, arr in enumerate(args):
258
+ if arr.size == 0:
259
+ raise ValueError(f"The spectral argument {i} is empty.")
260
+ if arr.size == 1:
261
+ args[i] = args[i] * np.ones(size)
262
+
263
+ # Remove entries corresponding to nan in any of the array
264
+ nan_mask = functools.reduce(operator.or_, (np.isnan(arr) for arr in args))
265
+ args = [arr[~nan_mask] for arr in args]
266
+ # Sort arrays by the frequency values
267
+ sk = np.argsort(args[1])
268
+ _amplitudes, _frequencies, _phases = (arr[sk] for arr in args)
269
+ _phases = _phases % _2PI
270
+
271
+ self.__attrs_init__(_amplitudes, _frequencies, _phases)
272
+
273
+ @classmethod
274
+ def from_periods(
275
+ cls, amplitudes: ArrayLike, periods: ArrayLike, phases: ArrayLike = 0.0
276
+ ) -> Self:
277
+ return cls(amplitudes, 1 / np.ravel(periods), phases)
278
+
279
+ @functools.cached_property
280
+ def periods(self) -> np.ndarray[tuple[int]]:
281
+ return 1 / self.frequencies
282
+
283
+ @functools.cached_property
284
+ def angular_frequencies(self) -> np.ndarray[tuple[int]]:
285
+ return self.frequencies * _2PI
286
+
287
+ @functools.cached_property
288
+ def _ang_freqs_pow2(self) -> np.ndarray[tuple[int], np.dtype[np.floating]]:
289
+ return self.angular_frequencies**2
290
+
291
+ @functools.cached_property
292
+ def nf(self) -> int:
293
+ return len(self.frequencies)
294
+
295
+ @functools.cached_property
296
+ def energy(self) -> float:
297
+ return np.sum(self.amplitudes**2) / 2
@@ -0,0 +1,3 @@
1
+ # SPDX-FileCopyrightText: 2026-present Nicolas Mokus <nmks@tuta.io>
2
+ #
3
+ # SPDX-License-Identifier: MIT
@@ -0,0 +1,12 @@
1
+ import pytest
2
+
3
+ import floer.model as md
4
+
5
+
6
+ class TestSubdomain:
7
+ @staticmethod
8
+ @pytest.mark.parametrize("left_edge", (-100, 0, 0.8, 45, 34.2))
9
+ @pytest.mark.parametrize("length", (10, 13.8, 101.9))
10
+ def test_right_edge(left_edge, length):
11
+ sd = md._Subdomain(left_edge, length)
12
+ assert sd.right_edge == left_edge + length
@@ -0,0 +1,165 @@
1
+ import numpy as np
2
+ import pytest
3
+ from hypothesis import given
4
+ from hypothesis import strategies as st
5
+ from hypothesis_miz.strategies import PHYSICAL_STRATEGIES
6
+
7
+ from floer.model import DiscreteSpectrum
8
+
9
+ # Valid cases: all sizes the same, or some are 1
10
+ valid_cases = [
11
+ # (amplitude, period, phase)
12
+ (1, 1, 7), # (1, 1, 1)
13
+ ([1], [1], [7]), # (1, 1, 1)
14
+ ([1, 2, 9, 6, 1], [1], [7]), # (5, 1, 1)
15
+ ([1, 3, 4, 2, 1], [1, 1, 1, 1, 1], 7), # (5, 5, 1)
16
+ ([1, 3, 1, 4, 1], [1, 8, 0.1, 1, 1], [7]), # (5, 5, 1)
17
+ ([1, 1, 2, 1, 1], [1.5, 1, 0.2, 1, 1], [7, 1, 7, 1, 1]), # (5, 5, 5)
18
+ ]
19
+ valid_shapes = [
20
+ tuple(
21
+ [
22
+ len(subsequence) if isinstance(subsequence, list) else 0
23
+ for subsequence in sequence
24
+ ]
25
+ )
26
+ for sequence in valid_cases
27
+ ]
28
+
29
+ invalid_cases = [
30
+ ([1, 1, 1], [1, 1], 1), # (3, 2, 1)
31
+ ([1, 1, 1], [1, 1], [1]), # (3, 2, 1)
32
+ ([1, 1, 1], [1, 1, 1, 1], [1]), # (3, 4, 1)
33
+ ([1, 1, 1], [1, 1], [1, 1, 1]), # (3, 2, 3)
34
+ ([1, 1, 1], [1, 1], [1, 1, 1, 1]), # (3, 2, 4)
35
+ ]
36
+
37
+
38
+ def parse_shape(
39
+ size: int, strategy: st.SearchStrategy[float]
40
+ ) -> st.SearchStrategy[float | list[float]]:
41
+ if size == 0:
42
+ return strategy
43
+ else:
44
+ return st.lists(
45
+ strategy,
46
+ min_size=size,
47
+ max_size=size,
48
+ )
49
+
50
+
51
+ @st.composite
52
+ def spectrum_arguments(
53
+ draw: st.DrawFn, sizes: tuple[int, int, int]
54
+ ) -> list[float | list[float]]:
55
+ return [
56
+ draw(parse_shape(size, strategy))
57
+ for size, strategy in zip(
58
+ sizes,
59
+ (
60
+ PHYSICAL_STRATEGIES[("wave", "amplitude")],
61
+ PHYSICAL_STRATEGIES[("wave", "frequency")],
62
+ PHYSICAL_STRATEGIES[("wave", "phase")],
63
+ ),
64
+ )
65
+ ]
66
+
67
+
68
+ @st.composite
69
+ def spectrum_arguments_periods(
70
+ draw: st.DrawFn, sizes: tuple[int, int, int]
71
+ ) -> list[float | list[float]]:
72
+ return [
73
+ draw(parse_shape(size, strategy))
74
+ for size, strategy in zip(
75
+ sizes,
76
+ (
77
+ PHYSICAL_STRATEGIES[("wave", "amplitude")],
78
+ PHYSICAL_STRATEGIES[("wave", "period")],
79
+ PHYSICAL_STRATEGIES[("wave", "phase")],
80
+ ),
81
+ )
82
+ ]
83
+
84
+
85
+ @pytest.mark.parametrize("args", valid_cases)
86
+ @pytest.mark.parametrize("with_shape", (True, False))
87
+ @pytest.mark.parametrize("as_array", (True, False))
88
+ def test_valid_shapes(args, with_shape: bool, as_array: bool):
89
+ passed_args = args[:-1] if not with_shape else args
90
+ if as_array:
91
+ passed_args = (np.asarray(_a) for _a in passed_args)
92
+ spectrum = DiscreteSpectrum(*passed_args)
93
+ assert spectrum.amplitudes.size > 0
94
+ assert len(spectrum.amplitudes.shape) == 1
95
+ assert spectrum.amplitudes.shape == spectrum.frequencies.shape
96
+ assert spectrum.amplitudes.shape == spectrum.phases.shape
97
+ assert np.all(spectrum.phases >= 0) and np.all(spectrum.phases < 2 * np.pi)
98
+
99
+
100
+ @pytest.mark.parametrize("args", invalid_cases)
101
+ @pytest.mark.parametrize("with_phase", (True, False))
102
+ @pytest.mark.parametrize("as_array", (True, False))
103
+ def test_invalid_shapes(args, with_phase: bool, as_array: bool):
104
+ passed_args = args if with_phase else args[:-1]
105
+ if as_array:
106
+ passed_args = (np.asarray(_a) for _a in passed_args)
107
+ with pytest.raises(ValueError):
108
+ DiscreteSpectrum(*passed_args)
109
+
110
+
111
+ @pytest.mark.parametrize("shapes", valid_shapes)
112
+ @pytest.mark.parametrize("with_phase", (True, False))
113
+ @given(data=st.data())
114
+ def test_from_periods(
115
+ data: st.DataObject, shapes: tuple[int, int, int], with_phase: bool
116
+ ):
117
+ amplitudes, periods, phases = data.draw(spectrum_arguments_periods(shapes))
118
+ if with_phase:
119
+ spectrum = DiscreteSpectrum.from_periods(amplitudes, periods, phases)
120
+ else:
121
+ spectrum = DiscreteSpectrum.from_periods(amplitudes, periods)
122
+ assert np.allclose(1 / spectrum.frequencies, spectrum.periods)
123
+ # Test frequencies rather than periods, because of floating point errors
124
+ assert np.isin(
125
+ 1 / np.array(periods), spectrum.frequencies, assume_unique=False
126
+ ).all()
127
+
128
+
129
+ @pytest.mark.parametrize("shapes", valid_shapes)
130
+ @pytest.mark.parametrize("with_phase", (True, False))
131
+ @pytest.mark.parametrize(
132
+ "property", ("periods", "angular_frequencies", "_ang_freqs_pow2", "nf", "energy")
133
+ )
134
+ @given(data=st.data())
135
+ def test_properties(
136
+ data: st.DataObject,
137
+ shapes: tuple[int, int, int],
138
+ with_phase: bool,
139
+ property: str,
140
+ ):
141
+ amplitudes, frequencies, phases = data.draw(spectrum_arguments(shapes))
142
+ if with_phase:
143
+ spectrum = DiscreteSpectrum(amplitudes, frequencies, phases)
144
+ else:
145
+ spectrum = DiscreteSpectrum(amplitudes, frequencies)
146
+
147
+ if property == "periods":
148
+ assert np.allclose(1 / spectrum.frequencies, spectrum.periods)
149
+ elif property == "angular_frequencies":
150
+ assert np.allclose(
151
+ 2 * np.pi * spectrum.frequencies, spectrum.angular_frequencies
152
+ )
153
+ elif property == "_ang_freqs_pow2":
154
+ assert np.allclose(
155
+ (2 * np.pi * spectrum.frequencies) ** 2, spectrum._ang_freqs_pow2
156
+ )
157
+ elif property == "nf":
158
+ nf = max(np.ravel(amplitudes).size, np.ravel(frequencies).size)
159
+ if with_phase:
160
+ nf = max(nf, np.ravel(phases).size)
161
+ assert nf == spectrum.nf
162
+ elif property == "energy":
163
+ assert np.allclose(np.sum(spectrum.amplitudes**2) / 2, spectrum.energy)
164
+ else:
165
+ raise ValueError(f"DiscreteSpectrum objects have no property {property}.")