Skip to main content

Perform calculation with various versions of variables

Project description

Varius

test License: MIT PyPI version

Perform computations using various versions of variables

Varius is the Latin word for "various."

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(cst, rev, pft, pmg)
    pft.grad()
    pmg.grad()
    print(d)

# new case
with note('20% discount', copy='default') as d:
    rev(rev['default'] * 0.8)
    show(cst, rev, pft, pmg)
    pft.grad()
    pmg.grad()
    print(d)


# another case
with note('50% discount', copy='default') as d:
    rev(rev['default'] * 0.5)
    show(cst, rev, pft, pmg)
    pft.grad()
    pmg.grad()
    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
    ∂ [(profit [usd])] / ∂ [(cost [usd])] = -1
    ∂ [(profit [usd])] / ∂ [(revenue [usd])] = 1
    ∂ [(profit margin)] / ∂ [(cost [usd])] = -1/300
    ∂ [(profit margin)] / ∂ [(revenue [usd])] = 1/900

Scope version: 20% discount
  Variables:
    (cost [usd]) = 100
    (revenue [usd]) = 240.0
  Expressions:
    ∂ [(profit [usd])] / ∂ [(cost [usd])] = -1
    ∂ [(profit [usd])] / ∂ [(revenue [usd])] = 1
    ∂ [(profit margin)] / ∂ [(cost [usd])] = -0.00416666666666667
    ∂ [(profit margin)] / ∂ [(revenue [usd])] = 0.00173611111111111
    (profit [usd]) = 140.000000000000
    (profit margin) = 0.583333333333333    

Scope version: 50% discount
  Variables:
    (cost [usd]) = 100
    (revenue [usd]) = 150.0
  Expressions:
    ∂ [(profit [usd])] / ∂ [(cost [usd])] = -1
    ∂ [(profit [usd])] / ∂ [(revenue [usd])] = 1
    ∂ [(profit margin)] / ∂ [(cost [usd])] = -0.00666666666666667
    ∂ [(profit margin)] / ∂ [(revenue [usd])] = 0.00444444444444445
    (profit [usd]) = 50.0000000000000
    (profit margin) = 0.333333333333333

Project details


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.10.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

varius-0.1.10-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file varius-0.1.10.tar.gz.

File metadata

  • Download URL: varius-0.1.10.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6

File hashes

Hashes for varius-0.1.10.tar.gz
Algorithm Hash digest
SHA256 ab5c13729dc333a237d83347e1808ee4bb115c3124e4da8844b863d97ce8cbf9
MD5 95e7d4b9e1d845fcca12ca54f2db38b9
BLAKE2b-256 e22b90def2acfe052b9847ee654f7d1e2d29f282b38a0865693e3eb40e226dc6

See more details on using hashes here.

File details

Details for the file varius-0.1.10-py3-none-any.whl.

File metadata

  • Download URL: varius-0.1.10-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6

File hashes

Hashes for varius-0.1.10-py3-none-any.whl
Algorithm Hash digest
SHA256 cc5e06c14808a87ce355a566bcfa0f9df94a37b5048e07ca47e2426fb14cdfdd
MD5 6c9ca2dec06beaf549831c67694a00f6
BLAKE2b-256 4e82895335471eaf15b1827f1945972a562b3e150474a55295d18b64a2048a17

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page