impunity: Enforcing Physical Unit Consistency at Definition Time in Python
We introduce impunity, a Python library that enables static analysis of code annotations to ensure the consistency of physical units. It provides a framework for developers to annotate their Python code with physical units and automatically verifies if the units are compatible and adhere to predefined coherence rules. impunity comes as a decorator to apply on functions: it analyses the source code to check for consistency of physical dimensions, and applies minimal code rewriting if conversions are necessary. Overall, this approach takes the best of type-checking based methods and dynamic methods and provides a robust approach with no overhead at runtime.
DOI for the open reviews of this paper: https://doi.org/10.59490/joas.2023.7149
How to Cite
Copyright (c) 2023 Antoine Chevrot, Xavier Olive
This work is licensed under a Creative Commons Attribution 4.0 International License.