Skip to content

Commit

Permalink
add __len__ to smrt_diag and solve a typo due to the last merge
Browse files Browse the repository at this point in the history
  • Loading branch information
ghislainp committed Aug 21, 2020
1 parent 6ebe343 commit 59bf912
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions smrt/core/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class smrt_diag(object):
__array_ufunc__ = None

def __init__(self, arr):
self.diag = np.atleast_1d(arr)

def diagonal(self):
return self.diag
Expand All @@ -79,6 +80,9 @@ def diagonal(self):
# def shape(self):
# return self.values.shape

def __len__(self):
return len(self.diag)

def __rmatmul__(self, other):
self.check_type(other)
return other * self.diag[np.newaxis, :]
Expand Down
2 changes: 1 addition & 1 deletion smrt/rtsolver/dort.py
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,7 @@ def combine_coherent_diffuse_matrix(coh, diff, weights, m, compute_coherent_only
npol = 3

mat_diff = diff.compress(mode=m, auto_reduce_npol=True)
# weight is reduce to match the size of mat_diff, this is the case when we have total reflection
# weight is reduced to match the size of mat_diff, this is the case when we have total reflection

full_weight = coef * np.repeat(weights[0:len(mat_diff) // npol], npol)

Expand Down

0 comments on commit 59bf912

Please sign in to comment.