Skip to content

Conversation

@brownbaerchen
Copy link
Contributor

The idea behind FrozenClass is to allow to add and change only certain variables in order to prevent bugs from typos.
These are used in status objects, for instance. But we want to allow users to add status variables, without having a huge list of every variable anyone has ever used hardcoded in there.

In this PR, I fix a truly horribly BS solution that I implemented when I didn't know class attributes. I wrote a very complicated function that loops through all objects and bypasses the __set_attr__ functions by using __dict__.
The new solution uses a class attribute for FrozenClass and derived classes, which carries a list of the allowed variables. This can easily be appended, of course, but it cannot be confused with simple assignment.
This should also give slightly better performance because the variables have to be added to the class only once, whereas they had to be added to each object before.

I did not do this too thoroughly. Basically, I refactored until the tests passed. I am sure there is some BS left in the convergence controllers related to this. But this I want to do when I have more time for refactoring. I just felt that the current version is too bad to leave as is.

@brownbaerchen brownbaerchen added the girl scout rule All you did was leave the campground slightly cleaner than you found it. label May 22, 2024
@tlunet
Copy link
Member

tlunet commented May 22, 2024

Maybe get rid of those FrozenClass when you have more time for refactoring 😛 ...

@pancetta pancetta merged commit e372a43 into Parallel-in-Time:master May 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

girl scout rule All you did was leave the campground slightly cleaner than you found it.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants