ieeLabTools 0.1.2__tar.gz → 0.1.3__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.
- ieelabtools-0.1.3/.gitignore +207 -0
- {ieelabtools-0.1.2 → ieelabtools-0.1.3/Docs}/Documentation.md +30 -2
- ieelabtools-0.1.3/Docs/suomidocs.md +42 -0
- ieelabtools-0.1.3/LICENSE +21 -0
- {ieelabtools-0.1.2 → ieelabtools-0.1.3}/PKG-INFO +6 -5
- ieelabtools-0.1.3/ieeLabTools/__init__.py +20 -0
- {ieelabtools-0.1.2 → ieelabtools-0.1.3}/ieeLabTools/core.py +25 -10
- ieelabtools-0.1.3/mytest.py +22 -0
- {ieelabtools-0.1.2 → ieelabtools-0.1.3}/pyproject.toml +5 -5
- ieelabtools-0.1.2/ieeLabTools/__init__.py +0 -3
- {ieelabtools-0.1.2 → ieelabtools-0.1.3}/README.md +0 -0
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[codz]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py.cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
#uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
#poetry.lock
|
|
109
|
+
#poetry.toml
|
|
110
|
+
|
|
111
|
+
# pdm
|
|
112
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
113
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
114
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
115
|
+
#pdm.lock
|
|
116
|
+
#pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# pixi
|
|
121
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
122
|
+
#pixi.lock
|
|
123
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
124
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
125
|
+
.pixi
|
|
126
|
+
|
|
127
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
128
|
+
__pypackages__/
|
|
129
|
+
|
|
130
|
+
# Celery stuff
|
|
131
|
+
celerybeat-schedule
|
|
132
|
+
celerybeat.pid
|
|
133
|
+
|
|
134
|
+
# SageMath parsed files
|
|
135
|
+
*.sage.py
|
|
136
|
+
|
|
137
|
+
# Environments
|
|
138
|
+
.env
|
|
139
|
+
.envrc
|
|
140
|
+
.venv
|
|
141
|
+
env/
|
|
142
|
+
venv/
|
|
143
|
+
ENV/
|
|
144
|
+
env.bak/
|
|
145
|
+
venv.bak/
|
|
146
|
+
|
|
147
|
+
# Spyder project settings
|
|
148
|
+
.spyderproject
|
|
149
|
+
.spyproject
|
|
150
|
+
|
|
151
|
+
# Rope project settings
|
|
152
|
+
.ropeproject
|
|
153
|
+
|
|
154
|
+
# mkdocs documentation
|
|
155
|
+
/site
|
|
156
|
+
|
|
157
|
+
# mypy
|
|
158
|
+
.mypy_cache/
|
|
159
|
+
.dmypy.json
|
|
160
|
+
dmypy.json
|
|
161
|
+
|
|
162
|
+
# Pyre type checker
|
|
163
|
+
.pyre/
|
|
164
|
+
|
|
165
|
+
# pytype static type analyzer
|
|
166
|
+
.pytype/
|
|
167
|
+
|
|
168
|
+
# Cython debug symbols
|
|
169
|
+
cython_debug/
|
|
170
|
+
|
|
171
|
+
# PyCharm
|
|
172
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
173
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
174
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
175
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
176
|
+
#.idea/
|
|
177
|
+
|
|
178
|
+
# Abstra
|
|
179
|
+
# Abstra is an AI-powered process automation framework.
|
|
180
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
181
|
+
# Learn more at https://abstra.io/docs
|
|
182
|
+
.abstra/
|
|
183
|
+
|
|
184
|
+
# Visual Studio Code
|
|
185
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
186
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
187
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
188
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
189
|
+
# .vscode/
|
|
190
|
+
|
|
191
|
+
# Ruff stuff:
|
|
192
|
+
.ruff_cache/
|
|
193
|
+
|
|
194
|
+
# PyPI configuration file
|
|
195
|
+
.pypirc
|
|
196
|
+
|
|
197
|
+
# Cursor
|
|
198
|
+
# Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
|
|
199
|
+
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
|
|
200
|
+
# refer to https://docs.cursor.com/context/ignore-files
|
|
201
|
+
.cursorignore
|
|
202
|
+
.cursorindexingignore
|
|
203
|
+
|
|
204
|
+
# Marimo
|
|
205
|
+
marimo/_static/
|
|
206
|
+
marimo/_lsp/
|
|
207
|
+
__marimo__/
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# Documentation
|
|
2
2
|
|
|
3
|
+
<a href="https://github.com/ieepirzy/PhySiLight-Tools/blob/main/Packages/ieeLabTools/suomidocs.md"> Dokumentaation pikaohjeet suomeksi </a>
|
|
4
|
+
|
|
3
5
|
## Quickstart / TL;DR
|
|
4
6
|
|
|
5
7
|
```python
|
|
@@ -10,7 +12,7 @@ import numpy as np
|
|
|
10
12
|
#Example variables and function
|
|
11
13
|
U, I = sp.symbols("U I")
|
|
12
14
|
R = U/I
|
|
13
|
-
calc = Yvel(R)
|
|
15
|
+
calc = Yvel(R,vars=[U,I])
|
|
14
16
|
|
|
15
17
|
U_vals = np.array([1,2,3,4,5,6])
|
|
16
18
|
I_vals = np.array([6,5,4,3,2,1])
|
|
@@ -23,6 +25,10 @@ sigmas = np.column_stack([U_err, I_err])
|
|
|
23
25
|
sigma_R = calc.numeric(values, sigmas)
|
|
24
26
|
```
|
|
25
27
|
|
|
28
|
+
>⚠ Important ⚠:
|
|
29
|
+
>The order of columns in `values` and `sigmas` must match the order of variables in `vars`.
|
|
30
|
+
>If `vars` is omitted, variables are ordered lexicographically by symbol name.
|
|
31
|
+
|
|
26
32
|
> ⚠ The current version uses the **non-covariant** general error propagation formula. Covariance-aware propagation is planned for a future release.
|
|
27
33
|
|
|
28
34
|
## 1. YVEL: Yleinen virheen etenemisen lauseke
|
|
@@ -40,6 +46,7 @@ The **initializer expects a sympy object representing the function** referred to
|
|
|
40
46
|
An optional parameter for the initializer is a 1D array-like of the **variables as Sympy symbols** referred to as `var`.
|
|
41
47
|
|
|
42
48
|
For note, the covariant expression for the YVEL is:
|
|
49
|
+
|
|
43
50
|
$$
|
|
44
51
|
\sigma = \sqrt{ \sum_{i} \left( \frac{\partial f}{\partial x_{i}} \right) ^{2}\sigma_{i}^{2} +2 \sum_{i>j} \frac{\partial f}{\partial x_{i}} \frac{\partial f}{\partial x_{j}} \text{cov}(x_{i},x_{j}) }
|
|
45
52
|
$$
|
|
@@ -55,9 +62,11 @@ Then a symbolic representation of the general error propagation equation is buil
|
|
|
55
62
|
#### Example.
|
|
56
63
|
|
|
57
64
|
For a simplistic example, consider Ohm's law:
|
|
65
|
+
|
|
58
66
|
$$
|
|
59
67
|
R=\frac{U}{I}
|
|
60
68
|
$$
|
|
69
|
+
|
|
61
70
|
To find the deviation for $R$ using the ieeLabTools package, we will first build an instance of the Yvel class:
|
|
62
71
|
>Note: for correct usage, some degree of familiarity with numpy and sympy is required.
|
|
63
72
|
|
|
@@ -136,7 +145,7 @@ $$
|
|
|
136
145
|
|
|
137
146
|
Internally, the method uses numpy for vectorized processing and does shape validation.
|
|
138
147
|
|
|
139
|
-
Example usage:
|
|
148
|
+
Example usage for `numeric()` continuing with the same instance of the class as in the quickstart:
|
|
140
149
|
```python
|
|
141
150
|
#lets assume the variables from earlier have some values and deviations:
|
|
142
151
|
import numpy as np
|
|
@@ -169,4 +178,23 @@ print(deviation)
|
|
|
169
178
|
|
|
170
179
|
```
|
|
171
180
|
|
|
181
|
+
Note: The known bug causing indeterministic ordering in Sympy's `free_symbols` method means that it is usually preferred to pass the variables explicitly, as how the script enforces deterministic ordering is by sorting the variables found by free_symbols lexographically, and as the user passes data to the `numeric()` method, must the ordering of the arrays corresponding to each measurement be in lexicographical order (the same order as the variables).
|
|
182
|
+
|
|
183
|
+
> Note: The bug arrises from the way the set() function, used in the `free_symbols` method interacts with pythons HASHSEED.
|
|
184
|
+
> HASHSEED being randomized for DoS-attack prevention. It is then assumed that if order matters, it is specified, hence a strong recommendation to pass the `vars` as a parameter directly.
|
|
185
|
+
|
|
186
|
+
Example of indeterministic behaviour:
|
|
187
|
+
|
|
188
|
+
```python
|
|
189
|
+
|
|
190
|
+
# DON'T DO THIS - order may vary between runs:
|
|
191
|
+
calc = Yvel(R) # vars detected as [I, U] or [U, I] unpredictably
|
|
192
|
+
values = np.column_stack([U_vals, I_vals]) # assumes [U, I]
|
|
193
|
+
# ❌ Mismatch possible!
|
|
194
|
+
|
|
195
|
+
# DO THIS - explicit and deterministic:
|
|
196
|
+
calc = Yvel(R, vars=[U, I]) # ✅ Order guaranteed
|
|
197
|
+
values = np.column_stack([U_vals, I_vals])
|
|
198
|
+
|
|
199
|
+
```
|
|
172
200
|
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Dokumentaatio
|
|
2
|
+
|
|
3
|
+
Saat moduulin käyttöösi suorittamalla komennon:
|
|
4
|
+
|
|
5
|
+
```CLI
|
|
6
|
+
pip install ieeLabTools
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
<a href="https://pypi.org/project/ieeLabTools/">Moduuli on julkaistu PyPi alustalle</a>
|
|
10
|
+
|
|
11
|
+
## Pikaesimerkki:
|
|
12
|
+
```python
|
|
13
|
+
from ieeLabTools.core import Yvel
|
|
14
|
+
import sympy as sp
|
|
15
|
+
import numpy as np
|
|
16
|
+
|
|
17
|
+
#Luodaan esimerkkimuuttujat, näiden täytyy olla sympy-symboleja
|
|
18
|
+
U, I = sp.symbols("U I")
|
|
19
|
+
R = U/I #Rakennetaan symboleista/muututjista esimerkkifunktio
|
|
20
|
+
calc = Yvel(R) # Tässä luodaan Yvel-objekti yllä määritetyllä funktiolla.
|
|
21
|
+
#TS. Jotta voit käyttää Yvel:iä niin anna sille aina aluksi näin funktio
|
|
22
|
+
|
|
23
|
+
#Esimerkki arvot ja virheet.
|
|
24
|
+
U_arvot = np.array([1,2,3,4,5,6])
|
|
25
|
+
I_arvot = np.array([6,5,4,3,2,1])
|
|
26
|
+
U_err = U_arvot*0.001
|
|
27
|
+
I_err = I_arvot*0.05
|
|
28
|
+
|
|
29
|
+
#Muutetaan np.column_stack() metodilla arvot ja virheet muotoon, jota numeerinen laskuri odottaa.
|
|
30
|
+
arvot = np.column_stack([U_arvot, I_arvot])
|
|
31
|
+
virheet = np.column_stack([U_err, I_err])
|
|
32
|
+
|
|
33
|
+
# numeric() metodi odottaa parametreikseen m x k matriisin, jossa m on mittaussarjan pituus ja k muuttujien määrä.
|
|
34
|
+
sigma = calc.numeric(arvot, virheet) #Tällä tavalla kutsutaan numeric() metodia.
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
>Huom! Kaikilla muuttujilla ja virheillä tulee olla sama muoto. Eli mittaussarjoilla sama pituus.
|
|
38
|
+
|
|
39
|
+
>Huom! Jos jollakin muuttujalla ei ole virhettä, niin käytä sen virhesarjana 0-sarjaa.
|
|
40
|
+
|
|
41
|
+
Metodi toimii vain **toisistaan riippumattomille** muuttujille.
|
|
42
|
+
Kattavampi dokumentaatio ja läpikäyminen löytyy englanninkielisestä veriosta.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Ilari Pirkkalainen
|
|
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.
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ieeLabTools
|
|
3
|
-
Version: 0.1.
|
|
4
|
-
Summary: General symbolic + numeric uncertainty propagation, weighted linear regression
|
|
5
|
-
Project-URL: Homepage, https://github.com/ieepirzy/
|
|
6
|
-
Project-URL: Documentation, https://github.com/ieepirzy/
|
|
7
|
-
Project-URL: Source, https://github.com/ieepirzy/
|
|
3
|
+
Version: 0.1.3
|
|
4
|
+
Summary: General linear symbolic + numeric uncertainty propagation, weighted linear regression
|
|
5
|
+
Project-URL: Homepage, https://github.com/ieepirzy/ieeLabTools
|
|
6
|
+
Project-URL: Documentation, https://github.com/ieepirzy/ieeLabTools/blob/main/Docs/Documentation.md
|
|
7
|
+
Project-URL: Source, https://github.com/ieepirzy/ieeLabTools/blob/main/Source/core.py
|
|
8
8
|
Author-email: Ilari Pirkkalainen <iladevv0@gmail.com>
|
|
9
9
|
License: MIT
|
|
10
|
+
License-File: LICENSE
|
|
10
11
|
Classifier: Intended Audience :: Education
|
|
11
12
|
Classifier: Intended Audience :: Science/Research
|
|
12
13
|
Classifier: License :: OSI Approved :: MIT License
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"""
|
|
2
|
+
ieeLabTools
|
|
3
|
+
===========
|
|
4
|
+
|
|
5
|
+
Tools for symbolic and numeric uncertainty propagation
|
|
6
|
+
and weighted linear regression for laboratory data analysis.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
from .core import (
|
|
11
|
+
Yvel,
|
|
12
|
+
WeightedLinregress,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
__all__ = [
|
|
16
|
+
"Yvel",
|
|
17
|
+
"WeightedLinearRegression",
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
__version__ = "0.1.2"
|
|
@@ -20,26 +20,34 @@ class Yvel():
|
|
|
20
20
|
|
|
21
21
|
self.f = f
|
|
22
22
|
|
|
23
|
+
# Assign from user declared variables or find variables automatically
|
|
23
24
|
if vars is not None:
|
|
24
25
|
self.vars = vars
|
|
25
26
|
else:
|
|
26
|
-
self.vars =
|
|
27
|
-
|
|
27
|
+
self.vars = sorted(f.free_symbols, key=lambda s: s.name)
|
|
28
|
+
|
|
29
|
+
#print(f"variables:{self.vars}") #debug print
|
|
30
|
+
|
|
31
|
+
# Find partials with sp.diff, looping over the function with each variable
|
|
28
32
|
self.partials = []
|
|
29
33
|
for v in self.vars:
|
|
30
34
|
self.partials.append(sp.diff(self.f,v))
|
|
31
35
|
|
|
32
|
-
|
|
36
|
+
#Creating sigmas for all variables
|
|
33
37
|
self.sigmas = []
|
|
34
38
|
for v in self.vars:
|
|
35
|
-
sigma = sp.Symbol(f"
|
|
39
|
+
sigma = sp.Symbol(f"σ{v.name}")
|
|
36
40
|
self.sigmas.append(sigma)
|
|
37
|
-
|
|
41
|
+
|
|
42
|
+
# Construct symbolical sympy object
|
|
38
43
|
self.symbolic_f = sp.sqrt(
|
|
39
44
|
sum((partial*var)**2 for partial, var in zip(self.partials,self.sigmas))
|
|
40
45
|
)
|
|
41
|
-
|
|
46
|
+
|
|
47
|
+
# Lambdify object to make it
|
|
42
48
|
self.fn = sp.lambdify([*self.vars, *self.sigmas], self.symbolic_f, "numpy")
|
|
49
|
+
|
|
50
|
+
# Number of variables for later
|
|
43
51
|
self.k = len(self.vars)
|
|
44
52
|
|
|
45
53
|
def symbolic(self):
|
|
@@ -57,27 +65,34 @@ class Yvel():
|
|
|
57
65
|
|
|
58
66
|
Returns: numpy array length m
|
|
59
67
|
"""
|
|
68
|
+
|
|
69
|
+
# Assign into numpy arrays from input format
|
|
60
70
|
values = np.array(values, dtype=float)
|
|
61
71
|
sigmas = np.array(sigmas, dtype=float)
|
|
62
72
|
|
|
73
|
+
# Check correct shape
|
|
63
74
|
if values.shape != sigmas.shape:
|
|
64
75
|
raise ValueError("Measurement and uncertainty matrices must have same shape.")
|
|
65
76
|
m, k = values.shape
|
|
66
77
|
if k != self.k:
|
|
67
78
|
raise ValueError(f"Expected {self.k} variables, got {k} columns.")
|
|
68
79
|
|
|
80
|
+
# transpose for correct internal representation
|
|
69
81
|
vt = values.T
|
|
70
82
|
st = sigmas.T
|
|
71
83
|
|
|
72
|
-
# build argument list
|
|
84
|
+
# build argument list, pairing value with deviation.
|
|
73
85
|
args = [vt[i] for i in range(k)] + [st[i] for i in range(k)]
|
|
74
|
-
|
|
86
|
+
#print(f"arguments:{args}") #debug print
|
|
87
|
+
# pass args to lambidified sympy object, representing the function
|
|
75
88
|
return self.fn(*args)
|
|
76
89
|
|
|
77
90
|
def covariant_numeric(self,values,sigmas):
|
|
78
91
|
return NotImplementedError
|
|
79
92
|
|
|
80
|
-
|
|
93
|
+
|
|
94
|
+
class WeightedLinregress():
|
|
95
|
+
# Rework this to be stateless..
|
|
81
96
|
def __init__(self, y_sigma,x,y):
|
|
82
97
|
"""
|
|
83
98
|
Parameters
|
|
@@ -130,7 +145,7 @@ class weightedLinregress():
|
|
|
130
145
|
|
|
131
146
|
return slope, intercept, slope_err, intercept_err
|
|
132
147
|
|
|
133
|
-
class
|
|
148
|
+
class OrtDistanceRegress():
|
|
134
149
|
def __init__(self,x,y,x_sigma,y_sigma):
|
|
135
150
|
|
|
136
151
|
"""
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
from Source import Yvel
|
|
2
|
+
import sympy as sp
|
|
3
|
+
import numpy as np
|
|
4
|
+
|
|
5
|
+
#Example variables and function
|
|
6
|
+
U, I = sp.symbols("U I")
|
|
7
|
+
R = U/I
|
|
8
|
+
print(R.free_symbols)
|
|
9
|
+
calc = Yvel(R)
|
|
10
|
+
print(calc)
|
|
11
|
+
print(calc.symbolic())
|
|
12
|
+
U_vals = np.array([1,2,3,4,5,6])
|
|
13
|
+
I_vals = np.array([6,5,4,3,2,1])
|
|
14
|
+
U_err = U_vals*0.001
|
|
15
|
+
I_err = I_vals*0.05
|
|
16
|
+
#Convert to desirable input format: m x k array-like, where k is your number of variables and m is your number of measurement events.
|
|
17
|
+
values = np.column_stack([U_vals, I_vals])
|
|
18
|
+
sigmas = np.column_stack([U_err, I_err])
|
|
19
|
+
|
|
20
|
+
sigma_R = calc.numeric(values, sigmas)
|
|
21
|
+
|
|
22
|
+
print(sigma_R)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "ieeLabTools"
|
|
3
|
-
version = "0.1.
|
|
4
|
-
description = "General symbolic + numeric uncertainty propagation, weighted linear regression"
|
|
3
|
+
version = "0.1.3"
|
|
4
|
+
description = "General linear symbolic + numeric uncertainty propagation, weighted linear regression"
|
|
5
5
|
authors = [
|
|
6
6
|
{ name = "Ilari Pirkkalainen", email = "iladevv0@gmail.com" }
|
|
7
7
|
]
|
|
@@ -21,9 +21,9 @@ classifiers = [
|
|
|
21
21
|
]
|
|
22
22
|
|
|
23
23
|
[project.urls]
|
|
24
|
-
Homepage = "https://github.com/ieepirzy/
|
|
25
|
-
Documentation = "https://github.com/ieepirzy/
|
|
26
|
-
Source = "https://github.com/ieepirzy/
|
|
24
|
+
Homepage = "https://github.com/ieepirzy/ieeLabTools"
|
|
25
|
+
Documentation = "https://github.com/ieepirzy/ieeLabTools/blob/main/Docs/Documentation.md"
|
|
26
|
+
Source = "https://github.com/ieepirzy/ieeLabTools/blob/main/Source/core.py"
|
|
27
27
|
|
|
28
28
|
[build-system]
|
|
29
29
|
requires = ["hatchling"]
|
|
File without changes
|