achevrot / impunity Goto Github PK
View Code? Open in Web Editor NEWA Python library to check physical units
Home Page: https://achevrot.github.io/impunity/
License: MIT License
A Python library to check physical units
Home Page: https://achevrot.github.io/impunity/
License: MIT License
In some cases, lists shouldn't raise warnings:
a1: Annotated(list[float], "m") # should raise a warning
a2: Annotated(list[float], "m") = [] # should raise a warning
a3 = [] # should not raise a warning
x: "m"
a4 = [x] # should raise a warning
y: "ft"
y, *_ = a4 # does not convert units
@impunity(methods=False)
class M:
distance: "m"
time: pd.Timestamp
duration: "s"
def toto(self):
pass # not inspected
@impunity
def tata(self):
pass # inspected
@impunity(ignore_warnings=True)
def fun():
a: "m" = 1
x = [a]
return x
This is probably due to the fun.code.co_consts not being properly reconstructed due to pytest
decorators.
Might be an issue with other methods overhead.
from impunity import impunity
from typing_extensions import Annotated
@impunity
def above_sea_level(a: Annotated[float, "m"]):
return a > 0
Raises a KeyError: 'return'
alt_m1: "m" = 1000
alt_m2: "m" = 1000
alt_m3: "m" = 1000
l: "m" = [alt_m1, alt_m2, alt_m3]
self.assertEqual(l[0], 1000)
l2: "ft" = [alt_m1, alt_m2, alt_m3]
self.assertAlmostEqual(l2[0], 3280.84, delta=1e-2)
First test is fine but second one fails : can't multiply sequence by non-int of type 'float'
Would need to change the Annotated Assign node visitor implementation to do so.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.