This is an alternate take on Pull Request https://github.com/fusion-energy/openmc-plasma-source/pull/48 in which properties are avoided. Both versions behave essentially the same. I'd argue this version is simpler while the other is more robust. I also think the property version leads to a cleaner interface, but may be harder to understand and maintain.
Pros of property version:
Can't modify attributes to something inappropriate after initialisation
Cleaner TokamakSource.__init__, and constraints are clearly defined above.
Cons of property version:
Property factories are confusing, so it might be difficult to work with later.
Clutters up TokamakSource.__dict__ and dir(TokamakSource), but this is unlikely to matter for most users.
Let me know which version appeals most, and whether you'd like me to change anything I've added.
Hi @LiamPattinson I like the approach of the other PR. If in time we realise it's confusing, it will always be possible to go back to classic checking in the init.
This is an alternate take on Pull Request https://github.com/fusion-energy/openmc-plasma-source/pull/48 in which properties are avoided. Both versions behave essentially the same. I'd argue this version is simpler while the other is more robust. I also think the property version leads to a cleaner interface, but may be harder to understand and maintain.
Pros of property version:
TokamakSource.__init__
, and constraints are clearly defined above.Cons of property version:
TokamakSource.__dict__
anddir(TokamakSource)
, but this is unlikely to matter for most users.Let me know which version appeals most, and whether you'd like me to change anything I've added.