Matlab uses a RingParam element to store lattice-related parameters. This element does not exist in python since these informations are stored in the Lattice object. When reading a .mat or .m file, python moves its information to the Lattice and discards the element. On saving, python creates a RingParam element and prepends it to the real lattice elements.
But the keep_all keyword argument in load_lattice allows, for special cases, to put a Marker placeholder replacing the RingParam, in order to keep the same number of elements as in the Matlab lattice. When saving, a new RingParam is created and inserted before the Marker, so that after a number of load/save sequences, Markers accumulate at the beginning of the lattice. This was reported by @lnadolski in #739.
In this PR, the Marker placeholder is identified as such by a tag attribute, and is removed when saving the file. Markers don't accumulate any more.
Note however that the keep_all keyword should not be used unless really necessary: keeping a useless element in the lattice is disturbing and inefficient.
Note: most of the changes are due to formatting the file with black. This gives a derministic format enabling easier code comparison in the future. I'm starting using it when modifying a file.
Matlab uses a
RingParam
element to store lattice-related parameters. This element does not exist in python since these informations are stored in theLattice
object. When reading a .mat or .m file, python moves its information to theLattice
and discards the element. On saving, python creates aRingParam
element and prepends it to the real lattice elements.But the
keep_all
keyword argument inload_lattice
allows, for special cases, to put aMarker
placeholder replacing theRingParam
, in order to keep the same number of elements as in the Matlab lattice. When saving, a newRingParam
is created and inserted before theMarker
, so that after a number of load/save sequences, Markers accumulate at the beginning of the lattice. This was reported by @lnadolski in #739.In this PR, the Marker placeholder is identified as such by a
tag
attribute, and is removed when saving the file. Markers don't accumulate any more.Note however that the
keep_all
keyword should not be used unless really necessary: keeping a useless element in the lattice is disturbing and inefficient.Note: most of the changes are due to formatting the file with black. This gives a derministic format enabling easier code comparison in the future. I'm starting using it when modifying a file.