Perform calculation with various versions of variables
Project description
Varius
Perform computations using various versions of variables
Install
pip install varius
Usage Examples
import varius
from varius import *
# default variables
cst = vr('cost [usd]', 100)
rev = vr('revenue [usd]', 300)
# expressions: if values are not given the expressions will be symbolic
pft = ex('profit [usd]', rev - cst)
pmg = ex('profit margin', pft.expr/rev)
# show() will display the variables or expressions based on your python env
# if in jupyter notebooks, they will be displayed as beautiful latex equations otherwise as plain texts
with note('default') as d:
show(rev)
show(cst)
show(pft)
show(pmg)
print(d)
# new case
with note('20% discount', copy='default') as d:
rev(rev['default'] * 0.8)
show(rev)
show(cst)
show(pft)
show(pmg)
print(d)
# another case
with note('50% discount', copy='default') as d:
rev(rev['default'] * 0.5)
show(rev)
show(cst)
show(pft)
show(pmg)
print(d)
You will get summaries as follows:
Scope version: default
Variables:
(cost [usd]) = 100
(revenue [usd]) = 300
Expressions:
(profit [usd]) = 200
(profit margin) = 2/3
Scope version: 20% discount
Variables:
(cost [usd]) = 100
(revenue [usd]) = 240.0
Expressions:
(profit [usd]) = 140.000000000000
(profit margin) = 0.5833333333333
Scope version: 50% discount
Variables:
(cost [usd]) = 100
(revenue [usd]) = 150.0
Expressions:
(profit [usd]) = 50.0000000000000
(profit margin) = 0.3333333333333
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
varius-0.1.2.tar.gz
(5.0 kB
view hashes)
Built Distribution
varius-0.1.2-py3-none-any.whl
(5.8 kB
view hashes)