Skip to content

Commit

Permalink
Merge d43c56a into 02d7be4
Browse files Browse the repository at this point in the history
  • Loading branch information
hgrecco committed Jan 22, 2020
2 parents 02d7be4 + d43c56a commit 0757f9b
Show file tree
Hide file tree
Showing 13 changed files with 1,506 additions and 194 deletions.
11 changes: 11 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ Pint Changelog
0.11 (unreleased)
-----------------

- Add full support for Decimal and Fraction at the registry level.
**BREAKING CHANGE**:
`use_decimal` is deprecated. Use `non_int_type=Decimal` when instantiating
the registry.
- Moved Pi to defintions files.
- Use ints (not floats) a defaults at many points in the codebase as in Python 3
the true division is the default one.
- **BREAKING CHANGE**:
Added `from_string` method to all Definitions subclasses. The value/converter
argument of the constructor no longer accepts an string.
It is unlikely that this change affects the end user.
- Added additional NumPy function implementations (allclose, intersect1d)
(Issue #979, Thanks Jon Thielen)
- Allow constants in units by using a leading underscore (Issue #989, Thanks
Expand Down
2 changes: 1 addition & 1 deletion pint/constants_en.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#### MATHEMATICAL CONSTANTS ####
# As computed by Maxima with fpprec:50

#pi = 3.1415926535897932384626433832795028841971693993751 = π # pi
pi = 3.1415926535897932384626433832795028841971693993751 = π # pi
tansec = 4.8481368111333441675396429478852851658848753880815e-6 # tangent of 1 arc-second ~ arc_second/radian
ln10 = 2.3025850929940456840179914546843642076011014886288 # natural logarithm of 10
wien_x = 4.9651142317442763036987591313228939440555849867973 # solution to (x-5)*exp(x)+5 = 0 => x = W(5/exp(5))+5
Expand Down
12 changes: 9 additions & 3 deletions pint/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def from_context(cls, context, **defaults):
return context

@classmethod
def from_lines(cls, lines, to_base_func=None):
def from_lines(cls, lines, to_base_func=None, non_int_type=float):
lines = SourceIterator(lines)

lineno, header = next(lines)
Expand Down Expand Up @@ -186,14 +186,20 @@ def to_num(val):
func = _expression_to_function(eq)

if "<->" in rel:
src, dst = (ParserHelper.from_string(s) for s in rel.split("<->"))
src, dst = (
ParserHelper.from_string(s, non_int_type)
for s in rel.split("<->")
)
if to_base_func:
src = to_base_func(src)
dst = to_base_func(dst)
ctx.add_transformation(src, dst, func)
ctx.add_transformation(dst, src, func)
elif "->" in rel:
src, dst = (ParserHelper.from_string(s) for s in rel.split("->"))
src, dst = (
ParserHelper.from_string(s, non_int_type)
for s in rel.split("->")
)
if to_base_func:
src = to_base_func(src)
dst = to_base_func(dst)
Expand Down

0 comments on commit 0757f9b

Please sign in to comment.