Comments (1)
You observe the normal float imprecision. You should not compare floats for equality. Instead check closeness:
>>> 1.9 * 1e-6
1.8999999999999998e-06
>>> (1.9 * 1e-6)==1.9e-6
False
>>> import math
>>> math.isclose(1.9 * 1e-6, 1.9e-6)
True
An alternative may be to use decimals instead of floats by initializing the registry with ureg = pint.UnitRegistry( non_int_type = decimal.Decimal )
.
from pint.
Related Issues (20)
- USCSLengthSurvey group is defined based on the survey foot which is now defunct HOT 5
- Moving formatting into a delegate HOT 53
- surprising behavior when Quantity called on value from a foreign registry HOT 2
- Unexpected performance impact from order of operands HOT 2
- Parsing unit yield multiple results HOT 2
- Plotting with Matplotlib from Pandas HOT 3
- Pint should validate aliases HOT 5
- Failure to convert between dimensionally inconsistent Quantities within allowing Context HOT 1
- Plotting to matplotlib axis with `units=None` leads to ConversionError in 0.23, but not in 0.22
- Enable mismatching dimensions in broadcast_arrays
- Error while using to_preferred() HOT 1
- Could not define System from lines HOT 1
- Use `usedforsecurity=False` when calling `hashlib.blake2b` to avoid crashing on FIPS enabled systems HOT 3
- unit dB not hashable when using decimal as non_int_type when numpy is installed
- In place numpy array operations causing issues with dimensionality of quantities HOT 1
- Listing possible units based on dimensionality
- Adding vs multiplying quantities in different units
- floating point arithmetic errors HOT 3
- mypy error: ureg.m annotation is expected to be Quantity instead of Unit
- mypy error: defining a Quantity as multiplication of list and unit raises an error
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pint.