ssb-model-solver 1.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.
- ssb_model_solver-1.2.0/LICENSE +21 -0
- ssb_model_solver-1.2.0/PKG-INFO +153 -0
- ssb_model_solver-1.2.0/README.md +126 -0
- ssb_model_solver-1.2.0/pyproject.toml +156 -0
- ssb_model_solver-1.2.0/src/model_solver/__init__.py +5 -0
- ssb_model_solver-1.2.0/src/model_solver/model_solver.py +1643 -0
- ssb_model_solver-1.2.0/src/model_solver/py.typed +0 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright © 2024 Statistics Norway
|
|
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,153 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: ssb-model-solver
|
|
3
|
+
Version: 1.2.0
|
|
4
|
+
Summary: Class to define, block analyse and solve dynamic and algebraic models numerically
|
|
5
|
+
Home-page: https://github.com/statisticsnorway/ssb-model-solver
|
|
6
|
+
License: MIT
|
|
7
|
+
Author: Benedikt Goodman
|
|
8
|
+
Author-email: benedikt.goodman@ssb.no
|
|
9
|
+
Requires-Python: >=3.10,<4.0
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Requires-Dist: matplotlib (>=3.7.1)
|
|
17
|
+
Requires-Dist: networkx (>=3.3)
|
|
18
|
+
Requires-Dist: numba (>=0.57.0)
|
|
19
|
+
Requires-Dist: numpy (>=1.26)
|
|
20
|
+
Requires-Dist: pandas (>=2.0)
|
|
21
|
+
Requires-Dist: symengine (>=0.9.2)
|
|
22
|
+
Project-URL: Changelog, https://github.com/statisticsnorway/ssb-model-solver/releases
|
|
23
|
+
Project-URL: Documentation, https://statisticsnorway.github.io/ssb-model-solver
|
|
24
|
+
Project-URL: Repository, https://github.com/statisticsnorway/ssb-model-solver
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
|
|
27
|
+
# SSB Model Solver
|
|
28
|
+
|
|
29
|
+
[][pypi status]
|
|
30
|
+
[][pypi status]
|
|
31
|
+
[][pypi status]
|
|
32
|
+
[][license]
|
|
33
|
+
|
|
34
|
+
[][documentation]
|
|
35
|
+
[][tests]
|
|
36
|
+
[][sonarcov]
|
|
37
|
+
[][sonarquality]
|
|
38
|
+
|
|
39
|
+
[][pre-commit]
|
|
40
|
+
[][black]
|
|
41
|
+
[](https://github.com/astral-sh/ruff)
|
|
42
|
+
[][poetry]
|
|
43
|
+
|
|
44
|
+
[pypi status]: https://pypi.org/project/ssb-model-solver/
|
|
45
|
+
[documentation]: https://statisticsnorway.github.io/ssb-model-solver
|
|
46
|
+
[tests]: https://github.com/statisticsnorway/ssb-model-solver/actions?workflow=Tests
|
|
47
|
+
|
|
48
|
+
[sonarcov]: https://sonarcloud.io/summary/overall?id=statisticsnorway_ssb-model-solver
|
|
49
|
+
[sonarquality]: https://sonarcloud.io/summary/overall?id=statisticsnorway_ssb-model-solver
|
|
50
|
+
[pre-commit]: https://github.com/pre-commit/pre-commit
|
|
51
|
+
[black]: https://github.com/psf/black
|
|
52
|
+
[poetry]: https://python-poetry.org/
|
|
53
|
+
|
|
54
|
+
`ModelSolver` is a class that defines, block analyses and solves dynamic and algebraic models numerically.
|
|
55
|
+
See [documentation](https://github.com/statisticsnorway/model-solver/blob/main/model-solver.pdf) for detailed information about theory and implementation of the class.
|
|
56
|
+
|
|
57
|
+
Opprettet av:
|
|
58
|
+
Magnus Kvåle Helliesen <mkh@ssb.no>
|
|
59
|
+
|
|
60
|
+
## Features
|
|
61
|
+
|
|
62
|
+
ModelSolver is a Python class. It defines, analyses and solves dynamic algebraic model with lots of equations.
|
|
63
|
+
|
|
64
|
+
The package is imported using
|
|
65
|
+
|
|
66
|
+
```python
|
|
67
|
+
import model_solver as ms
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Usage is
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
model = ms.ModelSolver(equations, endogenous)
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
where `equations` are equations and `endogenous` are endogenous variables, both stored as strings in lists.
|
|
77
|
+
|
|
78
|
+
## Built with
|
|
79
|
+
ModelSolver uses the following packages
|
|
80
|
+
* [NumPy](https://numpy.org/)
|
|
81
|
+
* [NetworkX](https://networkx.org/)
|
|
82
|
+
* [Pandas](https://pandas.pydata.org/)
|
|
83
|
+
* [SymEngine](https://pypi.org/project/symengine/)
|
|
84
|
+
* [Numba](https://numba.pydata.org/)
|
|
85
|
+
* [collections](https://docs.python.org/3/library/collections.html)
|
|
86
|
+
* [functools](https://docs.python.org/3/library/functools.html)
|
|
87
|
+
* [Matplotlib](https://matplotlib.org/)
|
|
88
|
+
|
|
89
|
+
## Example of use
|
|
90
|
+
Let `equations = ['x+y = 1', 'x-y = 2']` and `endogenous = ['x', 'y']`, then the model class is initialized by
|
|
91
|
+
|
|
92
|
+
```python
|
|
93
|
+
model = ms.ModelSolver(equations, endogenous)
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
When initialized, the class reads in the equations, analyzes them for any lags, before it block analyzes it to find the smalles model blocks that must be solved simultaneously.
|
|
97
|
+
Note that ModelSolver is not case sensitive, such that 'x' and 'X' are the same, both in equations, lists and dataframe (below).
|
|
98
|
+
|
|
99
|
+
When the class is finished initializing, the user can call the following methods:
|
|
100
|
+
* ```solution = model.solve(dataframe)``` where `dataframe` is a **Pandas** dataframe containing initial values for the endogenous variables and values for the exogenous variables. `solution` is a dataframe with same dimensions as `dataframe` containing the solutions for the endogenous variables.
|
|
101
|
+
* ```model.switch_endo_vars(old_endo_var, new_endo_var)``` switches the endogenous variables `old_endo_var` for `new_endo_var`.
|
|
102
|
+
* ```model.describe()``` writes out information about the model: the number of blocks, the size of the blocks etc.
|
|
103
|
+
* ```model.find_endo_var('var')``` returns the block number in which `var` is solved for.
|
|
104
|
+
* ```model.show_block(block_number)``` returns information about the block: endogenous variables, predetermined variables and equations.
|
|
105
|
+
* ```model.show_blocks()``` returns information about all blocks.
|
|
106
|
+
* ```model.trace_to_exog_vars(block_nunber)``` traces back to the exogenous variables that may affect the block.
|
|
107
|
+
* ```model.trace_to_exog_vals(block_nunber, period_index)``` traces back to the exogenous variable values for the period.
|
|
108
|
+
* ```model.draw_blockwise_graph(variable, maximum_ancestor_generations, maximum_decendants_generations)``` where `variable` is a variable of interest, and `maximum_ancestor_generations` and `maximum_decendants_generations`are non-negative integers that governs the number of generations before and after the variable to be graphed. The output is a HTML-file with a relational graph.
|
|
109
|
+
* ```model.sensitivity(block_nunber, period_index[, method='std', exog_subset=None])``` analyses the sensitivity of the endogenous variable in the block with respect to the exogenous variabels that determine the solution for the period.
|
|
110
|
+
|
|
111
|
+
## Installation
|
|
112
|
+
|
|
113
|
+
You can install _SSB Model Solver_ via [pip] from [PyPI]:
|
|
114
|
+
|
|
115
|
+
```console
|
|
116
|
+
pip install ssb-model-solver
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Usage
|
|
120
|
+
|
|
121
|
+
Please see the [Reference Guide] for details.
|
|
122
|
+
|
|
123
|
+
## Contributing
|
|
124
|
+
|
|
125
|
+
Contributions are very welcome.
|
|
126
|
+
To learn more, see the [Contributor Guide].
|
|
127
|
+
|
|
128
|
+
## License
|
|
129
|
+
|
|
130
|
+
Distributed under the terms of the [MIT license][license],
|
|
131
|
+
_SSB Model Solver_ is free and open source software.
|
|
132
|
+
|
|
133
|
+
## Issues
|
|
134
|
+
|
|
135
|
+
If you encounter any problems,
|
|
136
|
+
please [file an issue] along with a detailed description.
|
|
137
|
+
|
|
138
|
+
## Credits
|
|
139
|
+
|
|
140
|
+
This project was generated from [Statistics Norway]'s [SSB PyPI Template].
|
|
141
|
+
|
|
142
|
+
[statistics norway]: https://www.ssb.no/en
|
|
143
|
+
[pypi]: https://pypi.org/
|
|
144
|
+
[ssb pypi template]: https://github.com/statisticsnorway/ssb-pypitemplate
|
|
145
|
+
[file an issue]: https://github.com/statisticsnorway/ssb-model-solver/issues
|
|
146
|
+
[pip]: https://pip.pypa.io/
|
|
147
|
+
|
|
148
|
+
<!-- github-only -->
|
|
149
|
+
|
|
150
|
+
[license]: https://github.com/statisticsnorway/ssb-model-solver/blob/main/LICENSE
|
|
151
|
+
[contributor guide]: https://github.com/statisticsnorway/ssb-model-solver/blob/main/CONTRIBUTING.md
|
|
152
|
+
[reference guide]: https://statisticsnorway.github.io/ssb-model-solver/reference.html
|
|
153
|
+
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# SSB Model Solver
|
|
2
|
+
|
|
3
|
+
[][pypi status]
|
|
4
|
+
[][pypi status]
|
|
5
|
+
[][pypi status]
|
|
6
|
+
[][license]
|
|
7
|
+
|
|
8
|
+
[][documentation]
|
|
9
|
+
[][tests]
|
|
10
|
+
[][sonarcov]
|
|
11
|
+
[][sonarquality]
|
|
12
|
+
|
|
13
|
+
[][pre-commit]
|
|
14
|
+
[][black]
|
|
15
|
+
[](https://github.com/astral-sh/ruff)
|
|
16
|
+
[][poetry]
|
|
17
|
+
|
|
18
|
+
[pypi status]: https://pypi.org/project/ssb-model-solver/
|
|
19
|
+
[documentation]: https://statisticsnorway.github.io/ssb-model-solver
|
|
20
|
+
[tests]: https://github.com/statisticsnorway/ssb-model-solver/actions?workflow=Tests
|
|
21
|
+
|
|
22
|
+
[sonarcov]: https://sonarcloud.io/summary/overall?id=statisticsnorway_ssb-model-solver
|
|
23
|
+
[sonarquality]: https://sonarcloud.io/summary/overall?id=statisticsnorway_ssb-model-solver
|
|
24
|
+
[pre-commit]: https://github.com/pre-commit/pre-commit
|
|
25
|
+
[black]: https://github.com/psf/black
|
|
26
|
+
[poetry]: https://python-poetry.org/
|
|
27
|
+
|
|
28
|
+
`ModelSolver` is a class that defines, block analyses and solves dynamic and algebraic models numerically.
|
|
29
|
+
See [documentation](https://github.com/statisticsnorway/model-solver/blob/main/model-solver.pdf) for detailed information about theory and implementation of the class.
|
|
30
|
+
|
|
31
|
+
Opprettet av:
|
|
32
|
+
Magnus Kvåle Helliesen <mkh@ssb.no>
|
|
33
|
+
|
|
34
|
+
## Features
|
|
35
|
+
|
|
36
|
+
ModelSolver is a Python class. It defines, analyses and solves dynamic algebraic model with lots of equations.
|
|
37
|
+
|
|
38
|
+
The package is imported using
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
import model_solver as ms
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Usage is
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
model = ms.ModelSolver(equations, endogenous)
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
where `equations` are equations and `endogenous` are endogenous variables, both stored as strings in lists.
|
|
51
|
+
|
|
52
|
+
## Built with
|
|
53
|
+
ModelSolver uses the following packages
|
|
54
|
+
* [NumPy](https://numpy.org/)
|
|
55
|
+
* [NetworkX](https://networkx.org/)
|
|
56
|
+
* [Pandas](https://pandas.pydata.org/)
|
|
57
|
+
* [SymEngine](https://pypi.org/project/symengine/)
|
|
58
|
+
* [Numba](https://numba.pydata.org/)
|
|
59
|
+
* [collections](https://docs.python.org/3/library/collections.html)
|
|
60
|
+
* [functools](https://docs.python.org/3/library/functools.html)
|
|
61
|
+
* [Matplotlib](https://matplotlib.org/)
|
|
62
|
+
|
|
63
|
+
## Example of use
|
|
64
|
+
Let `equations = ['x+y = 1', 'x-y = 2']` and `endogenous = ['x', 'y']`, then the model class is initialized by
|
|
65
|
+
|
|
66
|
+
```python
|
|
67
|
+
model = ms.ModelSolver(equations, endogenous)
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
When initialized, the class reads in the equations, analyzes them for any lags, before it block analyzes it to find the smalles model blocks that must be solved simultaneously.
|
|
71
|
+
Note that ModelSolver is not case sensitive, such that 'x' and 'X' are the same, both in equations, lists and dataframe (below).
|
|
72
|
+
|
|
73
|
+
When the class is finished initializing, the user can call the following methods:
|
|
74
|
+
* ```solution = model.solve(dataframe)``` where `dataframe` is a **Pandas** dataframe containing initial values for the endogenous variables and values for the exogenous variables. `solution` is a dataframe with same dimensions as `dataframe` containing the solutions for the endogenous variables.
|
|
75
|
+
* ```model.switch_endo_vars(old_endo_var, new_endo_var)``` switches the endogenous variables `old_endo_var` for `new_endo_var`.
|
|
76
|
+
* ```model.describe()``` writes out information about the model: the number of blocks, the size of the blocks etc.
|
|
77
|
+
* ```model.find_endo_var('var')``` returns the block number in which `var` is solved for.
|
|
78
|
+
* ```model.show_block(block_number)``` returns information about the block: endogenous variables, predetermined variables and equations.
|
|
79
|
+
* ```model.show_blocks()``` returns information about all blocks.
|
|
80
|
+
* ```model.trace_to_exog_vars(block_nunber)``` traces back to the exogenous variables that may affect the block.
|
|
81
|
+
* ```model.trace_to_exog_vals(block_nunber, period_index)``` traces back to the exogenous variable values for the period.
|
|
82
|
+
* ```model.draw_blockwise_graph(variable, maximum_ancestor_generations, maximum_decendants_generations)``` where `variable` is a variable of interest, and `maximum_ancestor_generations` and `maximum_decendants_generations`are non-negative integers that governs the number of generations before and after the variable to be graphed. The output is a HTML-file with a relational graph.
|
|
83
|
+
* ```model.sensitivity(block_nunber, period_index[, method='std', exog_subset=None])``` analyses the sensitivity of the endogenous variable in the block with respect to the exogenous variabels that determine the solution for the period.
|
|
84
|
+
|
|
85
|
+
## Installation
|
|
86
|
+
|
|
87
|
+
You can install _SSB Model Solver_ via [pip] from [PyPI]:
|
|
88
|
+
|
|
89
|
+
```console
|
|
90
|
+
pip install ssb-model-solver
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Usage
|
|
94
|
+
|
|
95
|
+
Please see the [Reference Guide] for details.
|
|
96
|
+
|
|
97
|
+
## Contributing
|
|
98
|
+
|
|
99
|
+
Contributions are very welcome.
|
|
100
|
+
To learn more, see the [Contributor Guide].
|
|
101
|
+
|
|
102
|
+
## License
|
|
103
|
+
|
|
104
|
+
Distributed under the terms of the [MIT license][license],
|
|
105
|
+
_SSB Model Solver_ is free and open source software.
|
|
106
|
+
|
|
107
|
+
## Issues
|
|
108
|
+
|
|
109
|
+
If you encounter any problems,
|
|
110
|
+
please [file an issue] along with a detailed description.
|
|
111
|
+
|
|
112
|
+
## Credits
|
|
113
|
+
|
|
114
|
+
This project was generated from [Statistics Norway]'s [SSB PyPI Template].
|
|
115
|
+
|
|
116
|
+
[statistics norway]: https://www.ssb.no/en
|
|
117
|
+
[pypi]: https://pypi.org/
|
|
118
|
+
[ssb pypi template]: https://github.com/statisticsnorway/ssb-pypitemplate
|
|
119
|
+
[file an issue]: https://github.com/statisticsnorway/ssb-model-solver/issues
|
|
120
|
+
[pip]: https://pip.pypa.io/
|
|
121
|
+
|
|
122
|
+
<!-- github-only -->
|
|
123
|
+
|
|
124
|
+
[license]: https://github.com/statisticsnorway/ssb-model-solver/blob/main/LICENSE
|
|
125
|
+
[contributor guide]: https://github.com/statisticsnorway/ssb-model-solver/blob/main/CONTRIBUTING.md
|
|
126
|
+
[reference guide]: https://statisticsnorway.github.io/ssb-model-solver/reference.html
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
[tool.poetry]
|
|
2
|
+
name = "ssb-model-solver"
|
|
3
|
+
version = "1.2.0"
|
|
4
|
+
description = "Class to define, block analyse and solve dynamic and algebraic models numerically"
|
|
5
|
+
authors = ["Benedikt Goodman <benedikt.goodman@ssb.no>"]
|
|
6
|
+
license = "MIT"
|
|
7
|
+
readme = "README.md"
|
|
8
|
+
homepage = "https://github.com/statisticsnorway/ssb-model-solver"
|
|
9
|
+
repository = "https://github.com/statisticsnorway/ssb-model-solver"
|
|
10
|
+
documentation = "https://statisticsnorway.github.io/ssb-model-solver"
|
|
11
|
+
packages = [{ include = "model_solver", from = "src" }]
|
|
12
|
+
classifiers = ["Development Status :: 4 - Beta"]
|
|
13
|
+
|
|
14
|
+
[tool.poetry.urls]
|
|
15
|
+
Changelog = "https://github.com/statisticsnorway/ssb-model-solver/releases"
|
|
16
|
+
|
|
17
|
+
[tool.poetry.dependencies]
|
|
18
|
+
python = ">=3.10,<4.0"
|
|
19
|
+
symengine = ">=0.9.2"
|
|
20
|
+
matplotlib = ">=3.7.1"
|
|
21
|
+
numba = ">=0.57.0"
|
|
22
|
+
numpy = ">=1.26"
|
|
23
|
+
pandas = ">=2.0"
|
|
24
|
+
networkx = ">=3.3"
|
|
25
|
+
|
|
26
|
+
[tool.poetry.group.dev.dependencies]
|
|
27
|
+
pygments = ">=2.10.0"
|
|
28
|
+
black = { extras = ["jupyter"], version = ">=23.1.0" }
|
|
29
|
+
coverage = { extras = ["toml"], version = ">=6.2" }
|
|
30
|
+
darglint = ">=1.8.1"
|
|
31
|
+
furo = ">=2021.11.12"
|
|
32
|
+
mypy = ">=0.930"
|
|
33
|
+
pre-commit = ">=2.16.0"
|
|
34
|
+
pre-commit-hooks = ">=4.1.0"
|
|
35
|
+
ruff = ">=0.0.284"
|
|
36
|
+
pytest = ">=6.2.5"
|
|
37
|
+
sphinx = ">=6.2.1"
|
|
38
|
+
sphinx-autobuild = ">=2021.3.14"
|
|
39
|
+
sphinx-autodoc-typehints = ">=1.24.0"
|
|
40
|
+
sphinx-click = ">=3.0.2"
|
|
41
|
+
typeguard = ">=2.13.3"
|
|
42
|
+
xdoctest = { extras = ["colors"], version = ">=0.15.10" }
|
|
43
|
+
myst-parser = { version = ">=0.16.1" }
|
|
44
|
+
pandas-stubs = ">=2.2.2.240807"
|
|
45
|
+
ipykernel = ">=6.29.5"
|
|
46
|
+
deptry = ">=0.20.0"
|
|
47
|
+
|
|
48
|
+
[tool.coverage.paths]
|
|
49
|
+
source = ["src", "*/site-packages"]
|
|
50
|
+
tests = ["tests", "*/tests"]
|
|
51
|
+
|
|
52
|
+
[tool.coverage.run]
|
|
53
|
+
branch = true
|
|
54
|
+
source = ["model_solver", "tests"]
|
|
55
|
+
relative_files = true
|
|
56
|
+
|
|
57
|
+
[tool.coverage.report]
|
|
58
|
+
show_missing = true
|
|
59
|
+
fail_under = 50
|
|
60
|
+
|
|
61
|
+
[tool.mypy]
|
|
62
|
+
strict = true
|
|
63
|
+
warn_unreachable = true
|
|
64
|
+
pretty = true
|
|
65
|
+
show_column_numbers = true
|
|
66
|
+
show_error_context = true
|
|
67
|
+
disallow_any_generics = false
|
|
68
|
+
|
|
69
|
+
[[tool.mypy.overrides]]
|
|
70
|
+
module = [
|
|
71
|
+
# "matplotlib",
|
|
72
|
+
# "matplotlib.pyplot",
|
|
73
|
+
"networkx.*",
|
|
74
|
+
"numba.*",
|
|
75
|
+
"symengine.*",
|
|
76
|
+
]
|
|
77
|
+
ignore_missing_imports = true
|
|
78
|
+
|
|
79
|
+
[tool.ruff]
|
|
80
|
+
force-exclude = true # Apply excludes to pre-commit
|
|
81
|
+
show-fixes = true
|
|
82
|
+
src = ["src", "tests"]
|
|
83
|
+
target-version = "py310" # Minimum Python version supported
|
|
84
|
+
include = ["*.py", "*.pyi", "**/pyproject.toml", "*.ipynb"]
|
|
85
|
+
extend-exclude = [
|
|
86
|
+
"__pycache__",
|
|
87
|
+
"old",
|
|
88
|
+
".ipynb_checkpoints",
|
|
89
|
+
"noxfile.py",
|
|
90
|
+
"docs/conf.py",
|
|
91
|
+
]
|
|
92
|
+
|
|
93
|
+
# Ruff rules may be customized as desired: https://docs.astral.sh/ruff/rules/
|
|
94
|
+
[tool.ruff.lint]
|
|
95
|
+
select = [
|
|
96
|
+
"A", # prevent using keywords that clobber python builtins
|
|
97
|
+
"ANN", # check type annotations
|
|
98
|
+
"B", # bugbear: security warnings
|
|
99
|
+
"D", # documentation
|
|
100
|
+
"E", # pycodestyle
|
|
101
|
+
"F", # pyflakes
|
|
102
|
+
"ISC", # implicit string concatenation
|
|
103
|
+
"I", # sort imports
|
|
104
|
+
"UP", # alert you when better syntax is available in your python version
|
|
105
|
+
"RUF", # the ruff developer's own rules
|
|
106
|
+
]
|
|
107
|
+
ignore = [
|
|
108
|
+
"ANN101", # Supress missing-type-self.
|
|
109
|
+
"ANN102", # Supress missing-type-cls.
|
|
110
|
+
"ANN202", # Don't requiere return type annotation for private functions.
|
|
111
|
+
"ANN401", # Allow type annotation with type Any.
|
|
112
|
+
"D100", # Supress undocumented-public-module. Only doc of public api required.
|
|
113
|
+
"E402", # Supress module-import-not-at-top-of-file, needed in jupyter notebooks.
|
|
114
|
+
"E501", # Supress line-too-long warnings: trust black's judgement on this one.
|
|
115
|
+
]
|
|
116
|
+
|
|
117
|
+
[tool.ruff.lint.isort]
|
|
118
|
+
force-single-line = true
|
|
119
|
+
|
|
120
|
+
[tool.ruff.lint.mccabe]
|
|
121
|
+
max-complexity = 15
|
|
122
|
+
|
|
123
|
+
[tool.ruff.lint.pydocstyle]
|
|
124
|
+
convention = "google" # You can also use "numpy".
|
|
125
|
+
|
|
126
|
+
[tool.ruff.lint.pep8-naming]
|
|
127
|
+
classmethod-decorators = ["classmethod", "validator", "root_validator", "pydantic.validator"]
|
|
128
|
+
|
|
129
|
+
[tool.ruff.lint.per-file-ignores]
|
|
130
|
+
"*/__init__.py" = ["F401"]
|
|
131
|
+
"**/tests/*" = [
|
|
132
|
+
"ANN001", # type annotations don't add value for test functions
|
|
133
|
+
"ANN002", # type annotations don't add value for test functions
|
|
134
|
+
"ANN003", # type annotations don't add value for test functions
|
|
135
|
+
"ANN201", # type annotations don't add value for test functions
|
|
136
|
+
"ANN204", # type annotations don't add value for test functions
|
|
137
|
+
"ANN205", # type annotations don't add value for test functions
|
|
138
|
+
"ANN206", # type annotations don't add value for test functions
|
|
139
|
+
"D100", # docstrings are overkill for test functions
|
|
140
|
+
"D101",
|
|
141
|
+
"D102",
|
|
142
|
+
"D103",
|
|
143
|
+
"S101", # asserts are encouraged in pytest
|
|
144
|
+
]
|
|
145
|
+
|
|
146
|
+
[tool.jupytext]
|
|
147
|
+
formats = "ipynb,auto:percent"
|
|
148
|
+
notebook_metadata_filter = "jupytext.text_representation,-jupytext.text_representation.jupytext_version,-widgets,-varInspector"
|
|
149
|
+
cell_metadata_filter = "-papermill,tags"
|
|
150
|
+
|
|
151
|
+
[tool.deptry.per_rule_ignores]
|
|
152
|
+
DEP001 = ["src", "nox", "nox_poetry"] # packages available by default
|
|
153
|
+
|
|
154
|
+
[build-system]
|
|
155
|
+
requires = ["poetry-core>=1.0.0"]
|
|
156
|
+
build-backend = "poetry.core.masonry.api"
|