Skip to main content

A simple Python package for numeric, set, and equation operations (number; set; equation: solve linear, add/subtract/scale equations)

Project description

mathpacki

A lightweight Python package for numeric and set operations.

Installation

pip install mathpacki

Usage

Modular imports

from mathpacki import numbers
from mathpacki import sets
from mathpacki import equations

Number operations

from mathpacki import numbers

numbers.add(2, 3)        # 5
numbers.subtract(10, 4)  # 6
numbers.multiply(3, 7)   # 21
numbers.divide(15, 3)    # 5.0
numbers.power(2, 8)      # 256
numbers.modulo(17, 5)    # 2

Or import individual functions:

from mathpacki.numbers import add, multiply
add(2, 3)    # 5
multiply(3, 7)  # 21

Set operations

from mathpacki import sets

a, b = {1, 2, 3}, {2, 3, 4}

sets.union(a, b)                  # {1, 2, 3, 4}
sets.intersection(a, b)           # {2, 3}
sets.difference(a, b)             # {1}
sets.symmetric_difference(a, b)   # {1, 4}
sets.is_subset({1, 2}, a)         # True
sets.is_superset(a, {1, 2})       # True
sets.is_disjoint({1, 2}, {3, 4})  # True

Or import individual functions:

from mathpacki.sets import union, intersection
union({1, 2}, {2, 3})  # {1, 2, 3}

Equation operations (linear: a*x + b = c)

Equations are represented as tuples (a, b, c) for a·x + b = c.

from mathpacki import equations

# Solve a*x + b = c for x
equations.solve_linear(2, -3, 7)   # 2x - 3 = 7  ->  x = 5.0
equations.solve_linear(1, 0, 4)    # x = 4  ->  4.0

# Evaluate left-hand side at x
equations.evaluate_linear(2, -3, 5)   # 2*5 - 3 = 7.0

# Operate on equations (each eq = (a, b, c) for a*x + b = c)
eq1 = (2, 1, 5)   # 2x + 1 = 5
eq2 = (1, -1, 1)  # x - 1 = 1
equations.add_equations(eq1, eq2)      # (3, 0, 6)  ->  3x = 6
equations.subtract_equations(eq1, eq2)  # (1, 2, 4)  ->  x + 2 = 4
equations.scale_equation(eq1, 2)      # (4, 2, 10)  ->  4x + 2 = 10

Requirements

  • Python 3.8+

Publishing to PyPI

  1. Create a PyPI account at pypi.org.

  2. Install build tools:

    pip install --upgrade build twine
    
  3. Update pyproject.toml: Set your name, email, and project URLs (and change the package name if mathpack is already taken on PyPI).

  4. Build the package:

    python -m build
    

    This creates dist/ with a .whl and .tar.gz file.

  5. Upload to PyPI (you will be prompted for your PyPI username and password or API token):

    python -m twine upload dist/*
    

    For first-time testing, use TestPyPI: python -m twine upload --repository testpypi dist/*

License

MIT

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

mathpacki-0.3.0.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

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

mathpacki-0.3.0-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file mathpacki-0.3.0.tar.gz.

File metadata

  • Download URL: mathpacki-0.3.0.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for mathpacki-0.3.0.tar.gz
Algorithm Hash digest
SHA256 7eb2b91a2ece8f8a512f68aa652e775510f2c707c6ac43363b00c34038e910ac
MD5 da08802b875de6708487418eb0962c2d
BLAKE2b-256 5a8bb6f6b4658853d2012f5a8dc9ffaea0aea33d7bc90ab59dbf964780fab78a

See more details on using hashes here.

File details

Details for the file mathpacki-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: mathpacki-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for mathpacki-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 75b5cda20de99fa45d21a0e39b3788895eeb7525e4032a205ed2ad9304764893
MD5 746fd5815a03373aeb42f8b1356f7de8
BLAKE2b-256 f15ae395d7729348457e0aa732fe0e27dff78f5381ad94bedaf0b502e93eed42

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