Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert ufloat objects in constructor. #8

Merged
merged 2 commits into from
Jul 17, 2020
Merged

Conversation

riga
Copy link
Owner

@riga riga commented Jul 17, 2020

When the Number constructor receives an object created with uncertainties.ufloat, its nominal value and uncertainties are extracted and stored properly in the created instance. Error components of the converted ufloat with the same name are assumed to be correlated.

from uncertainties import ufloat
from scinum import Number

# define a ufloat with 2 errors
u = ufloat(1., 0.5, tag="foo") + ufloat(0., 0.25, tag="bar")

# convert to number
n = Number(u)
print(n)
# -> "1.0 +- 0.5 (foo) +- 0.25 (bar)"

See

def test_constructor_ufloat(self):
for more examples.

Closes #6.

@riga riga self-assigned this Jul 17, 2020
@riga riga merged commit 6cce25e into master Jul 17, 2020
@riga riga deleted the feature/convert_ufloat branch July 10, 2022 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Accept uncertainties.{ufloat,uarray} in constructor.
1 participant