Sheshuk/update flavor matrix interface#350
Conversation
…two dimensions are :
…eye to create larger matrices
|
Integration tests are failing because of this obsolete flavor transformation (line 152 of base.py) in the |
sybenzvi
left a comment
There was a problem hiding this comment.
Suggestion: while we have this PR open, rename the EnumMeta child class in flavor.py toFlavorEnumMeta.
Otherwise this looks pretty good.
After discussion on Zoom, we agree that the failing integration tests are all due to the obsolete code in |
sybenzvi
left a comment
There was a problem hiding this comment.
I made a cosmetic change of snewpy.flavor.EnumMeta to snewpy.flavor.FlavorEnumMeta, which feels a bit safer. Otherwise we can commit this, with the understanding that integration tests will fail in release_2.0.
This is a first part of changes, needed for #344
Expanding the interface of
FlavorSchemeandFlavorMatrixwith useful methods and syntactic sugar. The goal is to make the code using these classes more expressive and look more similar to the formulas in the papers.Example
This allows us to access and define individual matrix elements as well as whole submatrices with a clear interface (example from #344 defining the elements of matrix in
mass_basis<<flavor_basisspace)snewpy/python/snewpy/neutrino.py
Lines 178 to 193 in 8181503
Changes in
FlavorSchemeNU_prefix. Also ignoring the case.'NU'and'NU_BAR'names to access the list of all neutrinos or antineutrinosChanges in
FlavorMatrixreal,imag,abs,abs2,conjugate__matmul__method: added check if the flavor schemes of the matrices' dimensions are compatible.extra_dimsoptions to constructorsFlavorMatrix.eyeandFlavorMatrix.zeros- to initialize arrays of size(N x M x extra_dims). These extra dimensions can be energy and/or time dependency of the transformationconvert_to_flavormethod, and also<<and>>operators, which allows to do the flavor bases conversion in one line, for exampleM_3f = (ThreeFlavor<<M<<ThreeFlavor)np.einsumto perform the correct matrix multiplication of the matrices and matrix to flux(ThreeFlavor<<FourFlavor), it will check that the matrix is non-zero - to prevent silent zeroing out when there was an intrinsic conversion to an incompatible flavor schemeSee the changes in
test/test_flavors.pyfor the demonstration of some new functionality