A function-managing package for models and systems with shared variables.
Project description
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, underdocs/slides
.
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.
Source Distribution
Built Distribution
File details
Details for the file porchlight-1.0.2.tar.gz
.
File metadata
- Download URL: porchlight-1.0.2.tar.gz
- Upload date:
- Size: 44.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e37dd92c724fe5d71cc14c570cc9fb3259ba6ac7a21e3ccda4a01bacbd3a8ca6 |
|
MD5 | cf2eeaec281df597c26edd8fb64baece |
|
BLAKE2b-256 | 38fa180f57df4084b7b442249828fffe128722ff4594250e850753cda3056570 |
File details
Details for the file porchlight-1.0.2-py3-none-any.whl
.
File metadata
- Download URL: porchlight-1.0.2-py3-none-any.whl
- Upload date:
- Size: 50.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 23a6b7f45dfa6775e0fb3e2b7c477d4418564d1592f0d2c7b0c0047222c952fc |
|
MD5 | eaa9de6e9647db0bdffac887d97c2893 |
|
BLAKE2b-256 | 542d0a7a6a89ec5b889bca26bb5c457de1463ff242d9b9e3c4b94ad5a6fcd7bf |