NumpSy - Integrated NumPy, SymPy, SciPy and Pandas with unit management for scientific programming with IPython.
Project description
NumpSy
Straight up mix between NumPy, SymPy, SciPy, and Pandas into a value single-declaration extendable framework to simulatenously perform symbolic and numerical operations.
Objectives:
- Ever think you wanted to simultaneously perform numerical and symbolic mathematics for an engineering or optimization derivation? Now you can pretty much intuitively derivate simultaneously whilst performing unit management automatically.
- Integrate mathematical analytical derivation Python toolchains into a single handy one that retains and expands each of the constituent packages methods. Retain intuitive compatibility.
- Have fun!
Is it any good?
I think it's an elegant mathematical representation to simultanously perform symbolic, numerical, and data science operations into a single system.
Quick Start
Download the Anaconda distribution first.
Pip install:
$ pip install numpsy
Local install for most recent version:
$ git clone https://github.com/daquintero/numpsy.git
$ cd numpsy
$ python3 setup.py install
Quick Example
See the 10 minutes to NumpSy jupyter notebook for much more.
Installation
Import NumpSy
import numpsy as nsy
Units
Declare a Unit
meter = nsy.Unit(name="meter", symbol="m")
meter
Unit | |
---|---|
name | meter |
symbol | |
symbolic_expression |
Retrieve attributes from this Unit
meter.s
meter.symbol
meter.name
'meter'
Operate with this unit
farad_per_meter = nsy.Unit(name="Farad", symbol="F") / meter
farad_per_meter
Unit | |
---|---|
name | (Farad)per(meter) |
symbol | |
symbolic_expression |
Append to Unit Library
nsy.Units().data
Hertz Unit name name_expression ...
Farad Unit name name_expression ...
meter Unit name name_expression ...
ohm Unit name name_expression ...
ratio Unit name name_expression ...
second Unit name name_expression ...
Name: 0, dtype: object
nsy.u
Hertz Unit name name_expression ...
Farad Unit name name_expression ...
meter Unit name name_expression ...
ohm Unit name name_expression ...
ratio Unit name name_expression ...
second Unit name name_expression ...
Name: 0, dtype: object
Constant
e_0 = nsy.Constant(
name="permittivity_vaccum",
symbol= "\epsilon_0",
numerical=8.8541878128e-12,
unit=farad_per_meter
)
e_0
Constant | |
---|---|
name | permittivity_vaccum |
symbol | |
symbolic_expression | |
numerical | 8.8541878128e-12 |
unit | Symbol: |
Symbolic Expression: |
e_0.s
e_0.n
8.8541878128e-12
e_d = nsy.Constant(
name="dielectric_permittivity",
symbol= "\epsilon_d",
numerical=5,
unit=nsy.u.ratio
)
e_d
Constant | |
---|---|
name | dielectric_permittivity |
symbol | |
symbolic_expression | |
numerical | 5 |
unit | Symbol: |
Symbolic Expression: |
Constants cannot be mutated
e_d.n = 10
Constant cannot be mutated. You cannot set any attribute value. Instantiate a new variable.
Variable
capacitor_plate_separation = nsy.Variable(
name="capacitor_plate_separation",
symbol= "d",
numerical=None,
unit=nsy.u.meter
)
capacitor_plate_separation
Variable | |
---|---|
name | capacitor_plate_separation |
symbol | |
symbolic_expression | |
numerical | |
unit | Symbol: |
Symbolic Expression: |
capacitor_plate_separation.s
capacitor_plate_separation.u
Unit | |
---|---|
name | meter |
symbol | |
symbolic_expression |
Variables can be mutated
capacitor_plate_separation.n = 1e-6
capacitor_plate_separation.n
1e-06
capacitor_plate_separation.numerical = 3e-5
capacitor_plate_separation.numerical
3e-05
Operate between Value objects
Constants and Variables are value objects.
capacitance_per_plate_cross_sectional_area = e_d / (e_0 * capacitor_plate_separation)
capacitance_per_plate_cross_sectional_area
Value | |
---|---|
name | |
symbol | |
symbolic_expression | |
numerical | 1.8823484456216984e+16 |
unit | Symbol: |
Symbolic Expression: |
capacitance_per_plate_cross_sectional_area.se
capacitance_per_plate_cross_sectional_area.n
1.8823484456216984e+16
Perform Flexible Class Operations
raw_capacitor_cross_sectional_area = (1e-6) ** 2
raw_capacitor_cross_sectional_area
1e-12
device_capacitance = capacitance_per_plate_cross_sectional_area * raw_capacitor_cross_sectional_area
device_capacitance
Value | |
---|---|
name | |
symbol | |
symbolic_expression | |
numerical | 18823.484456216982 |
unit | Symbol: |
Symbolic Expression: |
device_capacitance.name
''
device_capacitance.se
device_capacitance.symbol = "F"
device_capacitance.symbol
raw_capacitor_cross_sectional_area
1e-12
Example Functions
nsy.sqrt(device_capacitance)
Value | |
---|---|
name | |
symbol | |
symbolic_expression | |
numerical | 137.19870428038664 |
unit | Symbol: |
Symbolic Expression: |
nsy.sinh(device_capacitance)
Value | |
---|---|
name | |
symbol | |
symbolic_expression | |
numerical | inf |
unit | Symbol: |
Symbolic Expression: |
Future plans
- Extend unit management and verification.
- Create a full constants list, probably even in Excel or as an importable CSV file into Pandas.
Open to contributions.
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.