pyamrex
pyamrex copied to clipboard
Naming conventions or style in pyamrex
We were adding some examples in pyamrex and observed that we use small-case with underscore for functions
For example, in amrex, we have a function, setVal(), while in pyamrex we have set_val()
Additionally, the python bindings in warpx also dont have consistent conventions. Is there a preferable style, so going forward when we make changes, we ensure to stay aligned with preferred style.
The python is probably following pep-8
Good question!
Yes, somewhat inconsistently, I started to use more Pythonic names for methods where appropriate (or even standardized) in Python.
As Mike mentioned, part of PEP-8 is:
Use the function naming rules: lowercase with words separated by underscores as necessary to improve readability.
For formatting, we use black. black is a somewhat superset (with some reasonable breaks) of PEP-8, but the tool does not control that we use proper naming schemes (just formatting).
Going forward, I want the Python bindings to look Pythonic (and not like a wrapper on C++). Thus, renaming things to follow Python style guides as PRs is very welcome and breakage is encouraged to fulfill it.
We have tab completion and a full doc now, thus people will still find the methods they know from AMReX C++, as long as we keep the same naming schemes, but in the proper Python style.
I started to merge some breakage for the 24.01 release in that direction :)
- getter functions to properties
- snake_case instead of camelCase