impunity: Enforcing Physical Unit Consistency at Definition Time in Python

Authors

  • Antoine Chevrot ONERA DTIS, Université de Toulouse, Toulouse, France
  • Xavier Olive ONERA DTIS, Université de Toulouse, Toulouse, France

DOI:

https://doi.org/10.59490/joas.2023.7071

Keywords:

Python, physical units, static analysis, code rewriting

Abstract

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.

Metrics

Metrics Loading ...

Additional Files

Published

2023-07-20

How to Cite

Chevrot, A., & Olive, X. (2023). impunity: Enforcing Physical Unit Consistency at Definition Time in Python. Journal of Open Aviation Science, 1(1). https://doi.org/10.59490/joas.2023.7071

Issue

Section

Research article, with focus on open software