Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Binder CircleCI Documentation Status License PyPI

dewloosh.math

Warning This package is under active development and in an beta stage. Come back later, or star the repo to make sure you don’t miss the first stable release!

dewloosh.math is a rapid prototyping platform focused on numerical calculations mainly corcerned with simulations of natural phenomena. It provides a set of common functionalities and interfaces with a number of state-of-the-art open source packages to combine their power seamlessly under a single development environment.

The most important features:

  • Numba-jitted classes and an extendible factory to define and manipulate vectors and tensors.

  • Classes to define and solve linear and nonlinear optimization problems.

  • A set of array routines for fast prorotyping, including random data creation to assure well posedness, or other properties of test problems.

Documentation

Click here to read the documentation.

Installation

This is optional, but we suggest you to create a dedicated virtual enviroment at all times to avoid conflicts with your other projects. Create a folder, open a command shell in that folder and use the following command

>>> python -m venv venv_name

Once the enviroment is created, activate it via typing

>>> .\venv_name\Scripts\activate

dewloosh.math can be installed (either in a virtual enviroment or globally) from PyPI using pip on Python >= 3.6:

>>> pip install dewloosh.math

Crash Course

Linear Algebra

Define a reference frame (B) relative to the ambient frame (A):

>>> from dewloosh.math.linalg import ReferenceFrame
>>> A = ReferenceFrame(name='A', axes=np.eye(3))
>>> B = A.orient_new('Body', [0, 0, 90*np.pi/180], 'XYZ', name='B')

Get the DCM matrix of the transformation between two frames:

>>> B.dcm(target=A)

Define a vector in frame A and view the components of it in frame B:

>>> v = Vector([0.0, 1.0, 0.0], frame=A)
>>> v.view(B)

Define the same vector in frame B:

>>> v = Vector(v.show(B), frame=B)
>>> v.show(A)

Linear Programming

Solve a following Linear Programming Problem (LPP) with one unique solution:

>>> from dewloosh.math.optimize import LinearProgrammingProblem as LPP
>>> import sympy as sy
>>> variables = ['x1', 'x2', 'x3', 'x4']
>>> x1, x2, x3, x4 = syms = sy.symbols(variables, positive=True)
>>> obj1 = Function(3*x1 + 9*x3 + x2 + x4, variables=syms)
>>> eq11 = Equality(x1 + 2*x3 + x4 - 4, variables=syms)
>>> eq12 = Equality(x2 + x3 - x4 - 2, variables=syms)
>>> problem = LPP(cost=obj1, constraints=[eq11, eq12], variables=syms)
>>> problem.solve()['x']
array([0., 6., 0., 4.])

NonLinear Programming

Find the minimizer of the Rosenbrock function:

>>> from dewloosh.math.optimize import BinaryGeneticAlgorithm
>>> def Rosenbrock(x, y):
>>>     a = 1, b = 100
>>>     return (a-x)**2 + b*(y-x**2)**2
>>> ranges = [[-10, 10],[-10, 10]]
>>> BGA = BinaryGeneticAlgorithm(Rosenbrock, ranges, length=12, nPop=200)
>>> BGA.solve()
array([0.99389553, 0.98901176]) 

Testing

To run all tests, open up a console in the root directory of the project and type the following

>>> python -m unittest

Dependencies

must have

  • Numba, NumPy, SciPy, SymPy, awkward

optional

  • networkx

License

This package is licensed under the MIT license.

Metadata

Release files for dewloosh.math 0.0.1b0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dewloosh.math 0.0.1b0
File Size Uploaded Provenance
dewloosh.math-0.0.1b0.tar.gz 51.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for dewloosh.math 0.0.1b0
File Interpreter ABI Platform
dewloosh.math-0.0.1b0-py3-none-any.whl Python 3 none any Details

Total release size: 118.0 kB

Release files / dewloosh.math-0.0.1b0.tar.gz

Download URL dewloosh.math-0.0.1b0.tar.gz
Size 51.7 kB
Tags Source
SHA-256 checksum
How to use checksums
76a770e958ca948d807266044b18fae4cd06216a612379c1858116d6cc96371f
BLAKE2b-256 checksum
How to use checksums
ed770492affef396c46f9bf314d060ce09ae11b73adaff40e668b8b05426436e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.8.10

Release files / dewloosh.math-0.0.1b0-py3-none-any.whl

Download URL dewloosh.math-0.0.1b0-py3-none-any.whl
Size 66.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d8f8c4e1acec283fddaded5a212f12bbdfb41a20a1c5e61c5dc10da1fb643df1
BLAKE2b-256 checksum
How to use checksums
4e639f1c31d810604492e219523264308550a6dfd29c016a4cede57162b2efd4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.8.10

Security for dewloosh.math 0.0.1b0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page