Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent invalid edits to mc.Moves attributes #3

Open
rsdefever opened this issue Jan 20, 2020 · 0 comments
Open

Prevent invalid edits to mc.Moves attributes #3

rsdefever opened this issue Jan 20, 2020 · 0 comments
Labels
enhancement New feature or request

Comments

@rsdefever
Copy link
Collaborator

rsdefever commented Jan 20, 2020

Is your feature request related to a problem? Please describe.
Certain mc.Moves attributes can be edited in unrealistic ways. For example, I can create an mc.Moves object and then edit the max_translate attribute to 'happy new year':

species_list = [typed_methane,typed_ethane]
moves = mc.Moves('nvt',species_list)
moves.max_translate[0] = 'happy new year'

This is obviously absurd, but I cannot find a simple solution. The max_translate attribute is protected by @property, but the above example circumvents that because the moves.max_translate calls the getter, which returns the private moves._max_translate, which is subsequently sliced and edited, entirely circumventing the setter and any sanity checks.

Describe the solution you'd like
The ability for the user to edit the mc.Moves object after its creation, but check that the specified edits are valid. Currently, sanity checks are only applied if the user tries to replace the entire attribute (e.g., moves.max_translate = [[1.0, 2.0]] rather than moves.max_translate[0][0] = 1.0).

Describe alternatives you've considered
Certain attributes could be made immutable by using sets rather than lists. Alternatively, the attributes could be specific to the box and species, e.g. something like, moves.max_translate.box1.species1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant