Code Style
July 11, 2026 ยท View on GitHub
Code Formatting
- Follow existing code style (black) and conventions
- Maintain consistent indentation and spacing
- When initializing numpy arrays (e.g., using
np.zeros,np.ones,np.empty, etc.), always specify thedtypeparameter (e.g.,dtype=float,dtype=int,dtype=object, etc.)
Variable Naming
- Use descriptive variable names that clearly indicate their purpose
- Use underscores for variable names
- CRITICAL: Follow the formalized coordinate system naming conventions exactly as described in the
AXES_POINTS_AND_FRAMES.mdandANGLE_VECTORS_AND_TRANSFORMATIONS.mddocuments when naming vector-valued variables or things such as transformation and rotation matrices. - Do not use
wcs(or any other abbreviation) for "wing cross section" or "WingCrossSection" in variable names. Instead, always write it out in full (e.g.,wing_cross_section,wing_cross_section_movement, etc.). - For non-vector-valued variables whose values are in radians-based units (rad, rad/s, rad/s^2, etc.), append
_radto the variable name; noting the units in a docstring or comment alone is not enough. Vector-valued variables and their components instead mark radians withRadin their camelCase portions, as described in theANGLE_VECTORS_AND_TRANSFORMATIONS.mddocument. - When naming collections of vector-valued quantities, use the
stack,grid, andlistcamelCase prefixes as described in theAXES_POINTS_AND_FRAMES.mddocument. - In variable names, refer to a simulation time increment as a step (e.g.,
step,num_steps,step_discards);time_stepis also acceptable, but never usetimestep.
Running Black
Black is configured as a pre-commit hook. Run it with:
pre-commit run --all-files black
Running CodeSpell
CodeSpell is configured as a pre-commit hook. Run it with:
pre-commit run --all-files codespell
Running mypy
mypy is configured as a pre-commit hook. Run it with:
pre-commit run --all-files mypy
Imports
- Import Ptera Software using the following pattern:
import pterasoftware as ps - By default, place import statements at the top of the file and avoid imports inside functions or methods. The only exceptions are intentional lazy-import patterns (for example, using
importlib.import_moduleinside__getattr__for lazy loading) and cases where there is no other way to avoid circular imports.
Miscellaneous Guidelines
- Use
np.deg2radandnp.rad2degfor angle conversions instead ofnp.radiansandnp.degreesor manual conversions.