Skip to main content

SEPModules provides a handful of modules to aid in speeding up the production of small or medium-sized scripts.

Project description

SEPModules

Publish to PyPI | Documentation

Python package providing basic modules and functionality for various common tasks.


The package includes four base modules:

  • SEPMaths

    For mathematical operations, helper functions, and classes.

  • SEPAlgebra

    Provides classes and functions for performing computations on algebraic structures.

  • SEPIO

    Aids in IO tasks such as reading console line arguments and parameters.

  • SEPLogger

    Provides logging functionality interfacing with the color printing features of SEPPrinting.

  • SEPDecorators

    Contains miscellaneous function decorators.

  • SEPPrinting

    Provides easy and quick implementations of console UI elements like graphs, progress bars, and colored console printing.

  • SEPTeX

    Provides a Python wrapper API for constructing LaTeX documents in code.


Exmaple usages

SEPIO.ConsoleArguments

from SEPModules import SEPIO
# Pretend that the arguments "-h --verbosity 2" were passed to script
# for this example usage. In normal use 'sys.argv' would be automatically
# populated when the python script was started from the command line.
import sys
sys.argv = ["this_script_name", "-h", "--verbosity", "2"]
# instantiate object to hold arguments passed to this script
console_manager = SEPIO.ConsoleArguments(["h"], ["help", "verbosity="])
# print help message
if "h" in console_manager or "help" in console_manager:
    print("This is a help message... very helpful information goes here")

This is a help message... very helpful information goes here

# set a verbosity value based on what was passed after "--verbosity"
verbosity = 0 # default
if "verbosity" in console_manager:
    passed_verbosity = console_manager["verbosity"]
    
    # check if input is legal number
    if passed_verbosity not in ["0", "1", "2"]:
        print(f"'{passed_verbosity}' is not a valid verbosity value")
        sys.exit(1)
    
    verbosity = int(passed_verbosity) # get passed value
print(f"Verbosity was succesfully set to {verbosity}!")

Verbosity was succesfully set to 2!

SEPAlgebra

from SEPModules import SEPAlgebra
# create an algebraic structure and check if it is valid, i.e. closed
binary_and = SEPAlgebra.AlgebraicStructure({0, 1}, int.__mul__)
# this is a valid structure because it is closed
# bool(x) should amount to x.is_valid for all classes inheriting from AlgebraicStructure
print(f"is valid: {binary_and.is_valid()} \nbool alternative: {bool(binary_and)}")

is valid: True

bool alternative: True

# this structure is also commutative but since this is a general structure
# this function will return a list of boolean values for every operator
print(f"is commutative: {binary_and.is_commutative()}")

is commutative: [True]

# since it is commutative we might want to model it as monoid,
# which only takes one operator
binary_and = SEPAlgebra.Monoid({0, 1}, int.__mul__)
# this structure is still commutative but now the return value is simply one boolean
print(f"is commutative monoid: {binary_and.is_commutative()}")

is commutative monoid: True

# since a monoid needs to be a valid algebraic structure and commutative,
# we can also check if it is valid and expect this to be true
print(f"is a valid monoid: {binary_and.is_valid()}")

is a valid monoid: True

# but 0 does not have an inverse in this structure so
# the singleton 'NoElement' will be returned
print(f"inverse for 0: {binary_and.find_inverses(0)}")

inverse for 0: NoElement

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

SEPModules-0.1.2.dev1.tar.gz (45.5 kB view details)

Uploaded Source

Built Distribution

SEPModules-0.1.2.dev1-py3-none-any.whl (48.4 kB view details)

Uploaded Python 3

File details

Details for the file SEPModules-0.1.2.dev1.tar.gz.

File metadata

  • Download URL: SEPModules-0.1.2.dev1.tar.gz
  • Upload date:
  • Size: 45.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.10

File hashes

Hashes for SEPModules-0.1.2.dev1.tar.gz
Algorithm Hash digest
SHA256 ac50acf28c5cca4472b9311ee031a777d3acdb45da58f6a00d0d741bde499110
MD5 e7bdb3108427c1d97369ca3e775d9587
BLAKE2b-256 5c9685bd169cd8dd6a5b1a9322c7ff282f9327a0216812025071af9812e9fe9b

See more details on using hashes here.

File details

Details for the file SEPModules-0.1.2.dev1-py3-none-any.whl.

File metadata

  • Download URL: SEPModules-0.1.2.dev1-py3-none-any.whl
  • Upload date:
  • Size: 48.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.10

File hashes

Hashes for SEPModules-0.1.2.dev1-py3-none-any.whl
Algorithm Hash digest
SHA256 d8ea253e900c0575bca1ff646ac51a95b50de99985376b9e1a5046e4c8151bd9
MD5 beacc9154b0c1f4e8b49a31a149b7cb7
BLAKE2b-256 31f52d17a4c05155d9e1f986008c5c23ee35e8a9b08566178c3b6ba8a98e9160

See more details on using hashes here.

Supported by

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