Skip to main content

A function-managing package for models and systems with shared variables.

Project description

porchlight logo. A snake's head erupts from the bottom of a porchlight casing, reaching towards a spinning triangular pyramid. The pyramid radiates bright, saturated, multicolored light.

porchlight

porchlight is a function management suite that handles shared inputs and outputs of methods and/or functions which evolve over the lifetime of a program.

This package's original intent was to be a part of a modular scientific package yet to be released. Rather than isolating this method to a single model, the already-developed work has been modified to stand alone as a package.

porchlight does not have any dependencies outside of the standard CPython library. Please note that porchlight requires Python 3.9+, and that examples may require external libraries such as numpy and matplotlib.

Installation

You can install porchlight by cloning this repository to a local directory. Alternatively, you may use pip in the command line:

pip install porchlight

Usage

The main object used in porchlight is the porchlight.Neighborhood object. This groups all functions together and keeps track of call order and parameters.

import porchlight


# To add a function, we simply define it and pass it to porchlight.
def increase_x(x: int, y: int) -> int:
    x = x * y
    return x

# Type annotations are optional, as with normal python.
def string_x(x):
    x_string = f"{x = }"
    return x_string

def increment_y(y=0):
    y = y + 1
    return y

# Generating a complete, coupled model between these functions is as simple as
# adding all these functions to a Neighborhood object.
neighborhood = Neighborhood([increment_y, increase_x, string_x])

# The neighborhood object inspects the function, finding input and output
# variables if present. These are added to the collections of functions and
# parameters.
print(neighborhood)

# We initialize any variables we need to (in this case, just x), and then
# executing the model is a single method call.
neighborhood.set_param('x', 2)

neighborhood.run_step()

# Print out information.
for name, param in neighborhood.params.items():
    print(f"{name} = {param}")

Documentation

Documentation for porchlight can be found on Read the Docs here: https://porchlight.readthedocs.io/en/latest/

Other info

  • You can find slides from presentations about porchlight within the docs folder, under docs/slides.

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

porchlight-1.0.1.tar.gz (43.9 kB view details)

Uploaded Source

Built Distribution

porchlight-1.0.1-py3-none-any.whl (50.1 kB view details)

Uploaded Python 3

File details

Details for the file porchlight-1.0.1.tar.gz.

File metadata

  • Download URL: porchlight-1.0.1.tar.gz
  • Upload date:
  • Size: 43.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for porchlight-1.0.1.tar.gz
Algorithm Hash digest
SHA256 a0aeb3afabe1cbbc7dc66bf436fa11e678f75ce988b1b4120540fb32f0f23f71
MD5 e3aeb184206c62de92c5360bf6bab9eb
BLAKE2b-256 d81cb539699985b587ec708ce3eb0b1e243d90b130b92b41c11a614a9839ce2e

See more details on using hashes here.

File details

Details for the file porchlight-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: porchlight-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 50.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for porchlight-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0a7da665521d401d090738a508b4be103406e30132ff69389310303edf50959f
MD5 a0149e97254dfa3cc0ce723f1e784496
BLAKE2b-256 418758b5d982c134024d750fa62cb2b644b2a872399284ab2c6a5c0488021c3b

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