Plusminus

Latest version: v0.8.1

Safety actively analyzes 681857 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 1 of 2

0.8.1

- Fixed bug in evaluating boolean expressions with more than
two terms, reported by ccaapton - fixed Issue 23.

0.8.0

- Added tox for automated testing on multiple Python versions.

- Added support for Python 3.12 and 3.13.

- Added support for serializing plusminus parsers and results over
cloudpickle (used in Apache Spark applications). Fixes Issue 22,
reported and assisted by ccaapton, thanks!

- Added a "use_decimal" keyword argument to the `BaseArithmeticParser`
class. If passed as `True`, the parser will evaluate float values using
Python's `decimal.Decimal` class. Addresses Issue 20, submitted by
ezekielnewren, nice idea!

0.7.0

- Added type annotations on public methods, to aid in type checking and
autocomplete.

- Added sin², sin³, sin⁻¹, etc. methods for common mathematical notation
such as sin²(x) for sin(x)**2, and sin⁻¹(x) for asin(x).

- Dropped BasicArithmeticParser synonym for ArithmeticParser
(too easily confused with BaseArithmeticParser).

- Added symmetric difference set operations, supported by '∆' and '^'
operators.

- Added radical expressions for roots > 2, up to 9, to the ArithmeticParser
class:

³√2 -> 2**(1/3) (1.259921049894873)
⁹√2 -> 2**(1/9) (1.080059738892306)

- Added Unicode variable assignment operator '←'.

- Added option to allow/disallow user-defined variables in expressions.

- Added better docstring to enumerate all supported parser options.

- Added scan_string method, to replace deprecated scanString method.

(Many features added by TheOneMusic, thanks!)

0.6.0

- Auto-promote operators that are alphabetic to pyparsing Keywords,
to help differentiate operators that are similar.

- Added "less" and "off" operators to BusinessArithmeticParser for parsing
discounting expressions like "20% off of 30" or "30 less 20%".

0.5.0

- Python 3.5 is no longer supported, plusminus now only works with
Python 3.6 and later.

- Refactored classes and parser interface to support better
definition of precedence of operations for custom operators, and to better
align the BaseArithmeticParser class to standard Python `eval()`, with
some enhancements/distinctions:
- `|x|` absolute value notation included
- Unicode operators included (`≠ ≤ ≥ ∈ ∉ ∩ ∪ ∧ ∨` for
`!= <= >= in not-in intersection union and or`)
- C-style `condition ? true_value : false_value` ternary operator included
- support for set union, intersection, and element
- dict and list containers not supported

The new ArithmeticParser class (renamed from BasicArithmeticParser) adds:
- trig, algebra, and random functions
- algebra constants `π τ e φ ϕ`
- `√` square root operator (unary and binary)
- exponent operators `⁻¹ ⁰ ¹ ² ³`
- `!` factorial operator
- `°` degrees-to-radians conversion operator

The former `BasicArithmeticParser` is deprecated, as too easily confused with the
`BaseArithmeticParser`. A compatibility synonym is defined for now, but this
will be removed in a future release (probably 1.0).

- Dropped support for "in" range notation, with ranges specified
using (), (], [) or [] notation ("in" with sets is still
supported).

- Deleted the example_parsers.py module in the examples directory, and split
the parsers out into separate modules in that directory.

- Added __version_info__ structure, following pattern of sys.version_info
field names.

- Added `user_defined_formulas_supported` attribute for parsers,
to enable/disable support for `=` formula assignment operator
(default=`True`)

- Added documentation to functions in the ArithmeticParser class
for better understanding and readability.

- Unary "+" operator can now be used. For example:

parser = ArithmeticParser()
parser.evaluate("+5")

- "&" and "|" added as set operations, respectively intersection and
union (same as "∩" and "∪" characters).

0.4.0

- Update default `sys.setrecursionlimit` to 3000 if it has not
already been modified, to allow for deep call stacks generated
from infixNotation parsers.

- Custom functions can now take different numbers of arguments,
using a tuple of integers for the arity. For example, here is the
log function, that can take only one or two arguments:

self.add_function("log", (1, 2), math.log)

- Updated operators and functions in ArithmeticParser:

- "−" can now be used as a unary minus operator, like "-".

- "//" operator for floor division added.

- round function now accepts one or two arguments, instead of two only.

- Updated operators, functions and variables in BasicArithmeticParser:

- Added the log function above in the BasicArithmeticParser. If called
with one argument, base e is used. If called with two, the second
argument is used as the base.

- Removed the nhypot function. The hypot function now takes any number
of arguments.

- gamma function now takes one parameter, instead of two.

- Added variable "tau" (same as "τ"), which is equal to 2×π.

- Added variables "ϕ" and "phi" (same as "φ", the golden number).

- Updated documentation and examples in the BasicArithmeticParser class.

Thanks to TheOneMusic for his awesome contributions to this release!

- PLANNED FOR 0.5.0

- Refactoring the parser classes to provide a
parser for standard Python expressions using standard Python
operators and builtins, and functions from the math module
(may limit types to int and float). Will make this parser more
of a safe drop-in replacement for "eval" without extra bells and
whistles.

- Better definition of custom operators, to permit support for
proper definition of precedence of operations.

- Update web demo to support selection of different parsers.

Page 1 of 2

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.