You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We ran into a lot of issues with mutability, hashing, and whatnot in the modals project. While they mostly seem to be resolved, I'm thinking it might be more elegant to re-factor our core classes into dataclasses, with their auto-generated hashers and whatnot.
The text was updated successfully, but these errors were encountered:
Major hurdle / issue to consider: Referent. Conceptually, this could really just be Referent = object. And then each application would specify a subclass of Referent that gives the actual fields (e.g. force and flavor for modals). On this approach, the main point of having Referent around is for conceptualization and readability.
The main use case of it right now is in Universe.from_dataframe, which is designed to enable folks to specify Referents and Universe in a CSV file. This method makes use of Referent.__init__ and its use of __dict__. This is a bit "frustrating", since a Referent is a paradigm for a frozen/immutable object.
Some options:
Let from_csv and from_dataframe also take in a referent_type argument that is the constructor for the relevant subclass of Referent. This, however, requires users to define their own class (likely a dataclass), which is not as user-friendly as described above.
Rewrite from_csv and from_dataframe to just call o.__dict__.update() directly.
Option 3 (where I'm leaning right now): keep Referent, including its flexible initializer, but then overwrite __setattr__ to imitate frozen-ness. I'll make a commit in the dataclass_refactor branch reflecting this idea soon.
We ran into a lot of issues with mutability, hashing, and whatnot in the modals project. While they mostly seem to be resolved, I'm thinking it might be more elegant to re-factor our core classes into
dataclass
es, with their auto-generated hashers and whatnot.The text was updated successfully, but these errors were encountered: