Nicer BaseSpec.__repr__() for BaseSpec(lMax=...)
This commit is contained in:
parent
f0d0e48876
commit
4c0453a865
|
@ -1,4 +1,5 @@
|
|||
import numpy as np
|
||||
cimport numpy as np
|
||||
import enum
|
||||
from .cycommon import get_mn_y, tlm2uvswfi
|
||||
__VSWF_norm_dict = {
|
||||
|
@ -140,6 +141,11 @@ cdef class BaseSpec:
|
|||
return self.__ilist[key]
|
||||
|
||||
def __repr__(self):
|
||||
cdef qpms_l_t lMax_candidate
|
||||
lMax_candidate = qpms_nelem2lMax(len(self.__ilist) // 2)
|
||||
if lMax_candidate >= 0:
|
||||
if np.array_equal(self.__ilist, BaseSpec(lMax=lMax_candidate).ilist):
|
||||
return 'BaseSpec(lMax=%d)' % lMax_candidate
|
||||
return 'BaseSpec([' + ','.join('%d' % i for i in self.__ilist) + '])'
|
||||
|
||||
property ilist:
|
||||
|
|
|
@ -63,6 +63,15 @@ static inline qpms_y_t qpms_lMax2nelem(qpms_l_t lmax){
|
|||
return lmax * ((qpms_y_t)lmax + 2);
|
||||
}
|
||||
|
||||
/// Inverse of qpms_lMax2nelem(); returns -1 if there is no exact match.
|
||||
static inline qpms_l_t qpms_nelem2lMax(qpms_y_t nelem) {
|
||||
qpms_l_t l = qpms_y2n(nelem);
|
||||
if (l == -qpms_yn2m(nelem, l))
|
||||
return l - 1;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Scalar versions: they have a place for the 0, 0 term in the beginning
|
||||
|
||||
/// Mapping from multipole degree, order to flat index (degree ≥ 0)
|
||||
|
|
Loading…
Reference in New Issue