Conversation
|
Question:
cell = CollectionBase(name='Cell', length_a=length_a, length_b=length_b, length_c=length_c)as opposed to when we need positional args cell = CollectionBase(length_a, length_b, length_c, name='Cell')The keyword names are discarded, and only the values are kept as items. |
I don't really see the value of allowing keyword arguments? This is a list-class, i.e. it is more natural to add elements in a list-like fashion, i.e: best_list = [model_1, model_2, model_3]
model_collection = ModelCollection(model_1, model_2, model_3)The keyword arguments of the previous implementation was necessary to inject objects as attributes to the class, the keys were used for the attribute names, hence the reason to check for clashes. Since we don't want to allow parameter injection, we don't need this feature. |
|
My reply will overlap with Christian’s one, but I will still add it, since I already finished writing it before I saw his comment. When I see this example cell = CollectionBase(name='Cell', length_a=length_a, length_b=length_b, length_c=length_c)I am a bit confused. In my understanding, a In that case, we would have something like: atom_site = AtomSite(label='Si', type_symbol='Si', fract_x=0.5, fract_y=0, fract_z=1, b_iso=1, occupancy=1)Here keyword arguments are very important, because the positional version atom_site = AtomSite('Si', 'Si', 0.5, 0, 1, 1, 1)is not very clear. Then we create a collection: atom_sites = CollectionBase()and append items: atom_sites.append(atom_site1)
atom_sites.append(atom_site2)or maybe add them in bulk (e.g. list / numpy array). If we create a collection like: atom_sites = CollectionBase(atom_site1, atom_site2, ...)then using keyword names for items does not make sense. So, I think the named_items argument is not needed. |
|
There's still a legacy layer on top of the class, so the current Parameters/Descriptors can be added as members. |
|
251 files changed and 40 000 lines of code???? 😨 |
|
Meh, merging the new core completely screwed up the branch. Need to redo the changes based on the current |
|
closing for the updated version in #228 |
CollectionBase derived from EasyList
EasyListrather than re-implementingMutableSequencefrom scratch.EasyList(sequence operations, type protection, deduplication, serialization).and
NotarizedDicthave already been removed before this class is introduced.Inheritance Hierarchy
content:
get_all_variables(self)
get_all_parameters(self)
get_parameters(self)
get_fittable_parameters(self)
get_free_parameters(self)
get_fit_parameters(self)
These mirror the methods on
ModelBase, but aggregate across the list of items rather thanacross the attribute names of a single object.
dataPropertyLegacy Serialization (
_convert_to_dict)Support for the legacy encoder-based serialization path.
Serializes all items in _data under the 'data' key, consistent with the old CollectionBase._convert_to_dict signature.