aesoptparam 0.3.6a0__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.

Potentially problematic release.


This version of aesoptparam might be problematic. Click here for more details.

Files changed (42) hide show
  1. aesoptparam-0.3.6a0/.coveragerc +2 -0
  2. aesoptparam-0.3.6a0/.gitignore +11 -0
  3. aesoptparam-0.3.6a0/.gitlab-ci.yml +27 -0
  4. aesoptparam-0.3.6a0/CHANGELOG.md +90 -0
  5. aesoptparam-0.3.6a0/LICENSE +21 -0
  6. aesoptparam-0.3.6a0/PKG-INFO +29 -0
  7. aesoptparam-0.3.6a0/README.md +52 -0
  8. aesoptparam-0.3.6a0/aesoptparam/__init__.py +13 -0
  9. aesoptparam-0.3.6a0/aesoptparam/example.py +110 -0
  10. aesoptparam-0.3.6a0/aesoptparam/parameterized.py +417 -0
  11. aesoptparam-0.3.6a0/aesoptparam/parameters.py +641 -0
  12. aesoptparam-0.3.6a0/aesoptparam/serializer.py +94 -0
  13. aesoptparam-0.3.6a0/aesoptparam/test/dummy_instance.json +30 -0
  14. aesoptparam-0.3.6a0/aesoptparam/test/dummy_schema.json +752 -0
  15. aesoptparam-0.3.6a0/aesoptparam/test/test_parameterized.py +574 -0
  16. aesoptparam-0.3.6a0/aesoptparam/test/test_parameters.py +519 -0
  17. aesoptparam-0.3.6a0/aesoptparam/test/test_units.py +369 -0
  18. aesoptparam-0.3.6a0/aesoptparam/test/test_utils.py +147 -0
  19. aesoptparam-0.3.6a0/aesoptparam/utils/__init__.py +63 -0
  20. aesoptparam-0.3.6a0/aesoptparam/utils/html_repr.py +533 -0
  21. aesoptparam-0.3.6a0/aesoptparam/utils/json_utils.py +127 -0
  22. aesoptparam-0.3.6a0/aesoptparam/utils/unit_library.ini +233 -0
  23. aesoptparam-0.3.6a0/aesoptparam/utils/units.py +1060 -0
  24. aesoptparam-0.3.6a0/aesoptparam.egg-info/PKG-INFO +29 -0
  25. aesoptparam-0.3.6a0/aesoptparam.egg-info/SOURCES.txt +40 -0
  26. aesoptparam-0.3.6a0/aesoptparam.egg-info/dependency_links.txt +1 -0
  27. aesoptparam-0.3.6a0/aesoptparam.egg-info/requires.txt +25 -0
  28. aesoptparam-0.3.6a0/aesoptparam.egg-info/top_level.txt +1 -0
  29. aesoptparam-0.3.6a0/docs/API/example.md +6 -0
  30. aesoptparam-0.3.6a0/docs/API/parameterized.md +6 -0
  31. aesoptparam-0.3.6a0/docs/API/parameters.md +6 -0
  32. aesoptparam-0.3.6a0/docs/API/serializer.md +6 -0
  33. aesoptparam-0.3.6a0/docs/HowTo/json_data_render.py +175 -0
  34. aesoptparam-0.3.6a0/docs/HowTo/model_docs.py +68 -0
  35. aesoptparam-0.3.6a0/docs/_toc.yml +17 -0
  36. aesoptparam-0.3.6a0/docs/changelog.md +2 -0
  37. aesoptparam-0.3.6a0/docs/conf.py +51 -0
  38. aesoptparam-0.3.6a0/docs/main.md +2 -0
  39. aesoptparam-0.3.6a0/docs/references.bib +14 -0
  40. aesoptparam-0.3.6a0/docs/references.md +4 -0
  41. aesoptparam-0.3.6a0/pyproject.toml +42 -0
  42. aesoptparam-0.3.6a0/setup.cfg +4 -0
@@ -0,0 +1,2 @@
1
+ [run]
2
+ omit = **/test/*
@@ -0,0 +1,11 @@
1
+ *.ipynb
2
+ .vscode
3
+ __pycache__
4
+ .pytest_cache
5
+ *.egg-info
6
+ .coverage
7
+ _build
8
+ build
9
+ .env
10
+ .tool-versions
11
+ dist/
@@ -0,0 +1,27 @@
1
+ image: continuumio/anaconda3
2
+
3
+ before_script:
4
+ - python -m venv ~/aesoptparam
5
+ - source ~/aesoptparam/bin/activate
6
+
7
+ format_test:
8
+ script:
9
+ - pip install -e .[test]
10
+ - isort aesoptparam --check-only
11
+ - black --check --diff aesoptparam
12
+
13
+ tests_coverage:
14
+ script:
15
+ - pip install -e .[test]
16
+ - pytest -s --cov-report term-missing --cov=aesoptparam ./aesoptparam
17
+ coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'
18
+
19
+
20
+ pages:
21
+ script:
22
+ - pip install .[docs]
23
+ - sphinx-build -M html docs _build
24
+ - mv ./_build/html public
25
+ artifacts:
26
+ paths:
27
+ - public
@@ -0,0 +1,90 @@
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 Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.3.5] - 2024-12-17
9
+
10
+ ### Fix
11
+
12
+ - Refactor for the use of `param.parameters._dict_update` to simply use `dict`
13
+
14
+ ### Changed
15
+
16
+ - Changed project to be dynamically versioned from git tags
17
+
18
+ ## [0.3.4] - 2024-11-03
19
+
20
+ ### Fix
21
+
22
+ - `AESOptArray`, `shape` was not fetching shape from string
23
+ - `AESOptArray`, `default` was returned when using `.as_dict(onlychanged=False)`
24
+ - `AESOptArray`, Add possibility to set array with a scalar if `shape` is set
25
+ - `default_ref`, fix for setting `Reference` directly
26
+
27
+ ## [0.3.3] - 2024-10-11
28
+
29
+ ### Added
30
+
31
+ - `max_arr_size`, for `display_json_data` to avoid printing large amounts of data for large dict's
32
+ - `.display` method for `AESOptParametrized` to add more control over the rendering
33
+
34
+ ### Changed
35
+
36
+ - HTML rendering of `AESOptParametrized` to render values of entries by default. Rendering `list`, `dict` and `ndarray` using `json2html`.
37
+
38
+ ## [0.3.2] - 2024-10-09
39
+
40
+ ### Fix
41
+
42
+ - `AESOptString`, was missing `___slots__=["default_ref"]` (lead to missing rendering for refs in HTML)
43
+
44
+ ## [0.3.1] - 2024-10-07
45
+
46
+ ### Changed
47
+
48
+ - `display_json_data`, smoother rendering and extended argument specs
49
+
50
+ ## [0.3.0] - 2024-10-07
51
+
52
+ ### Added
53
+
54
+ - `AESOptInteger`, Integer parameter which allow to set references and functions
55
+ - `AESOptBoolean`, Boolean parameter which allow to set references and functions
56
+ - `.has_parent`, to `AESOptParametrized`. Can be used to test if object is *root*
57
+ - `utils.json_utils`, tools for reading and writing json with numpy data
58
+ - `utils.html_repr.json_data_render`, tool for rendering json-data in notebook
59
+ - `utils.copy_param` and `utils.copy_param_ref`, tools for copying parameters while allowing to update/remove some elements. Useful for linking two parameters.
60
+
61
+ ### Fix
62
+
63
+ - Bug-fix for `AESOptNumber` with `allow_none` to `allow_None`
64
+
65
+ ### Changed
66
+
67
+ - Allowed `ListOfParametrized` to initialize from function by adding `default_call`
68
+
69
+ ## [0.2.0] - 2024-09-27
70
+
71
+ ### Added
72
+
73
+ - `AESOptString`, extension of `param.Sting` which adds *default_ref*
74
+
75
+ ## [0.0.1] - 2024-08-06
76
+
77
+ ### Fixed
78
+
79
+ - Included `unit_library.ini` in the wheel build (added to `pyproject.toml`)
80
+
81
+ ## [0.0.0] - 2024-05-06
82
+ First version
83
+
84
+ ### Added
85
+
86
+ - `AESOptParametrized`, an extension of the `param.Parametrized`
87
+ - `SubParameterized`, dedicated parameter for adding nested parametrized models
88
+ - `ListOfParameterized`, dedicated parameters for adding a list of parametrized models
89
+ - `AESOptNumber`, extension of `param.Number` which adds *units* and *default_ref*
90
+ - `AESOptArray`, extension of `param.Array` which adds *bounds*, *units*, *dtype*, *shape*, *default_full*, *default_interp*, *default_ref*units
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 AESOpt Param
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,29 @@
1
+ Metadata-Version: 2.4
2
+ Name: aesoptparam
3
+ Version: 0.3.6a0
4
+ Author-email: Kenneth Loenbaek <kenloen@dtu.dk>
5
+ Maintainer-email: Kenneth Loenbaek <kenloen@dtu.dk>
6
+ License-File: LICENSE
7
+ Requires-Dist: param
8
+ Requires-Dist: numpy
9
+ Requires-Dist: scipy
10
+ Provides-Extra: test
11
+ Requires-Dist: pytest; extra == "test"
12
+ Requires-Dist: pytest-cov; extra == "test"
13
+ Requires-Dist: isort; extra == "test"
14
+ Requires-Dist: black; extra == "test"
15
+ Requires-Dist: jsonschema; extra == "test"
16
+ Provides-Extra: docs
17
+ Requires-Dist: sphinx; extra == "docs"
18
+ Requires-Dist: sphinx-design; extra == "docs"
19
+ Requires-Dist: sphinx_book_theme; extra == "docs"
20
+ Requires-Dist: myst-parser; extra == "docs"
21
+ Requires-Dist: sphinx_external_toc; extra == "docs"
22
+ Requires-Dist: sphinxcontrib.bibtex; extra == "docs"
23
+ Requires-Dist: myst-nb; extra == "docs"
24
+ Requires-Dist: markdown; extra == "docs"
25
+ Requires-Dist: jupytext; extra == "docs"
26
+ Requires-Dist: setuptools; extra == "docs"
27
+ Provides-Extra: all
28
+ Requires-Dist: aesoptparam[docs,test]; extra == "all"
29
+ Dynamic: license-file
@@ -0,0 +1,52 @@
1
+ # AESOpt Param (`aesoptparam`)
2
+
3
+ [![pipeline status](https://gitlab.windenergy.dtu.dk/AESOpt/aesoptparam/badges/main/pipeline.svg)](https://gitlab.windenergy.dtu.dk/AESOpt/aesoptparam/-/commits/main) [![coverage report](https://gitlab.windenergy.dtu.dk/AESOpt/aesoptparam/badges/main/coverage.svg)](https://gitlab.windenergy.dtu.dk/AESOpt/aesoptparam/-/commits/main)
4
+
5
+ Is a light weight extension of the open source [`param`](https://param.holoviz.org/) project.
6
+
7
+ The `param` project is a library for handling all the user-modifiable parameters, arguments, and attributes that control code. It adds a way to declare parameters via their type while also adding meta data such as documentation, valid range, etc. For a more extensive introduction user are referred to the project homepage: https://param.holoviz.org/
8
+ The [`param`](https://param.holoviz.org/) webpage is also where users are expected to look for more detailed use of `aesoptparam`.
9
+
10
+ `aesoptparam` is purely extending `param`, by adding the following features:
11
+
12
+ - Make an extended `Parameterized` -> `AESOptParameterized`, which adds the following features:
13
+ - Method for getting data as a dict (`.as_dict`)
14
+ - Method for serializing data (`.as_serial`). Used for saving data to JSON, YAML, TOML
15
+ - Method for setting data from a dict (`.from_dict`). Also works for nested dicts
16
+ - Method for validating numpy array shapes (`.validate_array_shapes`). See `AESOptArray` for more.
17
+ - Method for interpolating arrays (`.interp`)
18
+ - Method for setting values in others units than their default units (`.set_val`)
19
+ - Method for gettting values in others units than their default units (`.get_val`)
20
+ - HTML rendering of the `AESOptParameterized` instance content (Name, Documentation, Type, Range, Units, Value)
21
+ - Adds posibility for setting a parent_object for nested `AESOptParameterized`, which allows others values to refer to any other value however deeply nested it is
22
+ - A set of new/modified parameters:
23
+ - `SubParameterized`: Parameter to add nested `AESOptParameterized`. It will automatically add the parent object.
24
+ - `ListOfParameterized`: Parameter to add a list of `AESOptParameterized`.
25
+ - `AESOptString`: Adds the following list of attributes or methods:
26
+ - `default_ref`: Referencing another parameter string
27
+ - `AESOptBoolean`: Adds the following list of attributes or methods:
28
+ - `default_ref`: Referencing another parameter string
29
+ - `AESOptNumber`: Adds the following list of attributes or methods:
30
+ - `units`
31
+ - `default_ref`: Referencing another parameter number
32
+ - `AESOptInteger`: Adds the following list of attributes or methods:
33
+ - `units`
34
+ - `default_ref`: Referencing another parameter number
35
+ - `AESOptArray`: Adds the following list of attributes or methods:
36
+ - `bounds`, `softbounds`. `inclusive_bounds`, similar to [`param.Number`](https://param.holoviz.org/user_guide/Parameter_Types.html#numbers)
37
+ - `units`
38
+ - `dtype`: The array data type
39
+ - `shape`: The shape of the array. Can also be a reference to another parameter. Used for validating array shape.
40
+ - `default_full`: Makes the default a array full of a given number. Using `numpy.full`. The first argument can reference others parameters to get their shape.
41
+ - `default_interp`: The default is to interpolate the array from other arrays. Arguments can both be arrays or references to others arrays.
42
+ - `default_ref`: Referencing another parameter array
43
+
44
+ Besides the core features above, it also adds some utility tools:
45
+
46
+ - `display_json_data` : Function to render JSON compliant data as a HTML table in Jupyter notebooks. It also works for numpy data that has numeric data dtypes.
47
+ - `read_json` : Method for reading JSON data file, which automatically can convert numeric list's to numpy.
48
+ - `write_json` : Method for writing JSON data file, which automatically can convert numeric numpy arrays and types to list of build-in types.
49
+
50
+ ## Documentation
51
+
52
+ [AESOpt Param Documentation](https://aesopt.pages.windenergy.dtu.dk/aesoptparam)
@@ -0,0 +1,13 @@
1
+ from param import *
2
+
3
+ from .parameterized import AESOptParameterized
4
+ from .parameters import (
5
+ AESOptArray,
6
+ AESOptBoolean,
7
+ AESOptInteger,
8
+ AESOptNumber,
9
+ AESOptString,
10
+ ListOfParameterized,
11
+ SubParameterized,
12
+ )
13
+ from .utils import copy_param, copy_param_ref
@@ -0,0 +1,110 @@
1
+ import numpy as np
2
+
3
+ from aesoptparam import (
4
+ AESOptArray,
5
+ AESOptNumber,
6
+ AESOptParameterized,
7
+ AESOptString,
8
+ Dict,
9
+ ListOfParameterized,
10
+ String,
11
+ SubParameterized,
12
+ copy_param,
13
+ copy_param_ref,
14
+ )
15
+
16
+
17
+ class sub1_class(AESOptParameterized):
18
+ """Docs sub1"""
19
+
20
+ a = AESOptNumber(5.0, doc="Docs for sub1.a", bounds=(0, 10))
21
+ b = AESOptArray(np.linspace(0, 10, 10), doc="Docs for sub1.b")
22
+ c = AESOptArray(default_ref=".b", doc="Docs for sub1.c")
23
+ e = AESOptArray(
24
+ lambda self: np.full_like(self.b, self.a), shape=".b", doc="Docs for sub1.e"
25
+ )
26
+ f = AESOptArray(default_full=(".b", ".a"), doc="Docs for sub1.d")
27
+ g = AESOptArray(default_full=(".b", 6.0), doc="Docs for sub1.g")
28
+ h = AESOptArray(
29
+ default_interp=(np.linspace(0, 10, 5), ".b", ".c"), doc="Docs for sub1.h"
30
+ )
31
+ i = AESOptString("sub1.Dummy", doc="Docs for sub1.i")
32
+ j = AESOptString(".i", doc="Docs for sub1.j")
33
+ k = AESOptString(lambda self: self.i + "2", doc="Docs for sub1.k")
34
+
35
+
36
+ class sub2_class(AESOptParameterized):
37
+ """Docs sub2"""
38
+
39
+ a = copy_param_ref(
40
+ sub1_class.param.a, "..sub1.a", update=dict(doc="Docs for sub2.a")
41
+ )
42
+ b = AESOptNumber(default_ref="..a", doc="Docs for sub2.b")
43
+ c = AESOptNumber(default_ref="..sub_list[0].a", doc="Docs for sub2.c")
44
+ d = copy_param_ref(
45
+ sub1_class.param.b, "..sub1.b", update=dict(doc="Docs for sub2.d")
46
+ )
47
+ e = AESOptArray(
48
+ lambda self: (
49
+ None if self.parent_object.sub1.b is None else self.parent_object.sub1.b + 1
50
+ ),
51
+ doc="Docs for sub2.e",
52
+ )
53
+ f = AESOptString("..f", doc="Docs for sub2.f")
54
+ g = copy_param_ref(
55
+ sub1_class.param.i, "..sub1.i", update=dict(doc="Docs for sub2.g")
56
+ )
57
+ h = AESOptString("..sub_list[0].f", doc="Docs for sub2.h")
58
+
59
+
60
+ class sub_list_class(AESOptParameterized):
61
+ """Docs sub_list"""
62
+
63
+ a = AESOptNumber(6.0, doc="Docs for sub_list.a")
64
+ b = AESOptNumber(default_ref="..a", doc="Docs for sub_list.b")
65
+ c = AESOptNumber(default_ref="..sub1.a", doc="Docs for sub_list.c")
66
+ d = AESOptArray(default_ref="..d", doc="Docs for sub_list.d")
67
+ e = AESOptArray(default_ref="..sub1.b", doc="Docs for sub_list.e")
68
+ f = AESOptString(default_ref="..f", doc="Docs for sub_list.f")
69
+ g = AESOptString(default_ref="..sub1.i", doc="Docs for sub_list.g")
70
+
71
+
72
+ class main(AESOptParameterized):
73
+ """Main object"""
74
+
75
+ version = String("0.0.0", readonly=True, precedence=0.0)
76
+ name = String("Dummy", doc="Main dummy", precedence=0.01)
77
+ a = AESOptNumber(4.0, units="rad/s", doc="Docs for .a", bounds=(0, 10))
78
+ b = AESOptNumber(default_ref=".sub1.a", units="m/s", doc="Docs for .b")
79
+ c = AESOptNumber(default_ref=".sub_list[0].a", doc="Docs for .c")
80
+ d = AESOptArray(
81
+ default_ref=".sub1.b", units="mm/s", doc="Docs for .d", bounds=(0, 10)
82
+ )
83
+ e = AESOptArray(
84
+ np.array([0, 1, 2, 3]),
85
+ shape=4,
86
+ units="mm/s",
87
+ doc="Docs for .d",
88
+ bounds=(0, 10),
89
+ dtype=int,
90
+ )
91
+ f = AESOptString("Dummy", doc="Docs for .f")
92
+ g = AESOptString(".f", doc="Docs for .g")
93
+ h = AESOptString(lambda self: self.f + "2", doc="Docs for .h")
94
+ i = Dict(doc="Docs for .i")
95
+ sub1 = SubParameterized(sub1_class)
96
+ sub2 = SubParameterized(sub2_class)
97
+ sub_list = ListOfParameterized(sub_list_class)
98
+ sub_list2 = ListOfParameterized(
99
+ sub_list_class, default_call=lambda self: [self.add_sub_list2()]
100
+ )
101
+
102
+ def add_sub_list(self, **params):
103
+ return self.add_ListOfParameterized_item(
104
+ "sub_list", self.param.sub_list.item_type, **params
105
+ )
106
+
107
+ def add_sub_list2(self, **params):
108
+ return self.add_ListOfParameterized_item(
109
+ "sub_list2", self.param.sub_list2.item_type, **params
110
+ )