Skip to content

Commit

Permalink
raise exceptions in the functions, remove the warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
jagerber48 committed Nov 4, 2024
1 parent 44186e2 commit e0b1b7d
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions uncertainties/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import copy
import collections
import warnings

from uncertainties.formatting import format_ufloat
from uncertainties.parsing import str_to_number_with_uncert
Expand Down Expand Up @@ -74,7 +73,6 @@
]
except ImportError:
msg = "Unable to import numpy. Some functionality will be unavailable"
warnings.warn(msg)
numpy = None


Expand Down Expand Up @@ -104,7 +102,12 @@ def correlated_values(nom_values, covariance_mat, tags=None):
tags -- if 'tags' is not None, it must list the tag of each new
independent variable.
"""

if numpy is None:
msg = (

Check warning on line 106 in uncertainties/core.py

View check run for this annotation

Codecov / codecov/patch

uncertainties/core.py#L106

Added line #L106 was not covered by tests
"uncertainties was not able to import numpy so "
"correlated_values is unavailable."
)
raise NotImplementedError(msg)

Check warning on line 110 in uncertainties/core.py

View check run for this annotation

Codecov / codecov/patch

uncertainties/core.py#L110

Added line #L110 was not covered by tests
# !!! It would in principle be possible to handle 0 variance
# variables by first selecting the sub-matrix that does not contain
# such variables (with the help of numpy.ix_()), and creating
Expand Down Expand Up @@ -153,6 +156,12 @@ def correlated_values_norm(values_with_std_dev, correlation_mat, tags=None):
tags -- like for correlated_values().
"""
if numpy is None:
msg = (

Check warning on line 160 in uncertainties/core.py

View check run for this annotation

Codecov / codecov/patch

uncertainties/core.py#L160

Added line #L160 was not covered by tests
"uncertainties was not able to import numpy so "
"correlated_values_norm is unavailable."
)
raise NotImplementedError(msg)

Check warning on line 164 in uncertainties/core.py

View check run for this annotation

Codecov / codecov/patch

uncertainties/core.py#L164

Added line #L164 was not covered by tests

# If no tags were given, we prepare tags for the newly created
# variables:
Expand Down Expand Up @@ -204,6 +213,12 @@ def correlation_matrix(nums_with_uncert):
Return the correlation matrix of the given sequence of
numbers with uncertainties, as a NumPy array of floats.
"""
if numpy is None:
msg = (

Check warning on line 217 in uncertainties/core.py

View check run for this annotation

Codecov / codecov/patch

uncertainties/core.py#L217

Added line #L217 was not covered by tests
"uncertainties was not able to import numpy so "
"correlation_matrix is unavailable."
)
raise NotImplementedError(msg)

Check warning on line 221 in uncertainties/core.py

View check run for this annotation

Codecov / codecov/patch

uncertainties/core.py#L221

Added line #L221 was not covered by tests

cov_mat = numpy.array(covariance_matrix(nums_with_uncert))

Expand Down

0 comments on commit e0b1b7d

Please sign in to comment.