mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-03-15 06:40:24 +01: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."""
|
||||
def _mat(x, **kwargs):
|
||||
dim = int(np.sqrt(len(x)))
|
||||
if np.sqrt(len(x)) != dim:
|
||||
raise Exception('Input has to have dim**2 entries')
|
||||
|
||||
mat = []
|
||||
for i in range(dim):
|
||||
|
@ -227,8 +225,6 @@ def _scalar_mat_op(op, obs, **kwargs):
|
|||
|
||||
if isinstance(obs, np.ndarray):
|
||||
raveled_obs = (1 * (obs.ravel())).tolist()
|
||||
elif isinstance(obs, list):
|
||||
raveled_obs = obs
|
||||
else:
|
||||
raise TypeError('Unproper type of input.')
|
||||
return derived_observable(_mat, raveled_obs, **kwargs)
|
||||
|
|
|
@ -314,6 +314,8 @@ def test_matrix_functions():
|
|||
# Check determinant
|
||||
assert pe.linalg.det(np.diag(np.diag(matrix))) == np.prod(np.diag(matrix))
|
||||
|
||||
pe.linalg.pinv(matrix[:,:3])
|
||||
|
||||
|
||||
def test_complex_matrix_operations():
|
||||
dimension = 4
|
||||
|
|
Loading…
Add table
Reference in a new issue