mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-05-14 11:33:42 +02:00
refactor: unnecessary code in scalar_mat_op removed
This commit is contained in:
parent
1ba7566a62
commit
b8c26fd41d
2 changed files with 2 additions and 4 deletions
|
@ -213,8 +213,6 @@ def _scalar_mat_op(op, obs, **kwargs):
|
||||||
"""Computes the matrix to scalar operation op to a given matrix of Obs."""
|
"""Computes the matrix to scalar operation op to a given matrix of Obs."""
|
||||||
def _mat(x, **kwargs):
|
def _mat(x, **kwargs):
|
||||||
dim = int(np.sqrt(len(x)))
|
dim = int(np.sqrt(len(x)))
|
||||||
if np.sqrt(len(x)) != dim:
|
|
||||||
raise Exception('Input has to have dim**2 entries')
|
|
||||||
|
|
||||||
mat = []
|
mat = []
|
||||||
for i in range(dim):
|
for i in range(dim):
|
||||||
|
@ -227,8 +225,6 @@ def _scalar_mat_op(op, obs, **kwargs):
|
||||||
|
|
||||||
if isinstance(obs, np.ndarray):
|
if isinstance(obs, np.ndarray):
|
||||||
raveled_obs = (1 * (obs.ravel())).tolist()
|
raveled_obs = (1 * (obs.ravel())).tolist()
|
||||||
elif isinstance(obs, list):
|
|
||||||
raveled_obs = obs
|
|
||||||
else:
|
else:
|
||||||
raise TypeError('Unproper type of input.')
|
raise TypeError('Unproper type of input.')
|
||||||
return derived_observable(_mat, raveled_obs, **kwargs)
|
return derived_observable(_mat, raveled_obs, **kwargs)
|
||||||
|
|
|
@ -314,6 +314,8 @@ def test_matrix_functions():
|
||||||
# Check determinant
|
# Check determinant
|
||||||
assert pe.linalg.det(np.diag(np.diag(matrix))) == np.prod(np.diag(matrix))
|
assert pe.linalg.det(np.diag(np.diag(matrix))) == np.prod(np.diag(matrix))
|
||||||
|
|
||||||
|
pe.linalg.pinv(matrix[:,:3])
|
||||||
|
|
||||||
|
|
||||||
def test_complex_matrix_operations():
|
def test_complex_matrix_operations():
|
||||||
dimension = 4
|
dimension = 4
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue