Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
7d016ed
Add unit testing and example (#29)
rxng8 Jun 27, 2024
b0d91b1
Added functionality to the resolver
willgebhardt Jul 9, 2024
087706e
Sped up compiler
willgebhardt Jul 15, 2024
f9289c5
added compartment metadata
willgebhardt Jul 23, 2024
eacb6fb
Merge pull request #30 from NACLab/compartment_meta
ago109 Jul 23, 2024
2ad5049
Merge pull request #31 from NACLab/dev
willgebhardt Aug 7, 2024
371ecc5
Comment Styling Fix
willgebhardt Nov 21, 2024
0415c0c
Removal of required transitions
willgebhardt Dec 2, 2024
9d709c5
Added new transition pattern
willgebhardt Dec 18, 2024
9bcd8bc
Refactor resolver
willgebhardt Dec 18, 2024
abd0581
nudged version materials, README and toml file, in main branch to pip…
Dec 20, 2024
ad610db
Implemented process
willgebhardt Mar 21, 2025
51439d2
Removal of required transitions
willgebhardt Mar 21, 2025
d03fc10
Merge branch 'transition' into dev
willgebhardt Mar 21, 2025
78e4304
Merge branch 'dev'
willgebhardt Mar 21, 2025
255cef6
Dynamic lambda loop bug
willgebhardt Mar 26, 2025
24d0ff8
addef missing return
willgebhardt Mar 26, 2025
23481ba
Added functionality for saving process
willgebhardt Apr 3, 2025
a45bd51
Fixed bug
willgebhardt Apr 3, 2025
79072ff
updated context helpers
willgebhardt Apr 3, 2025
98df2d1
Loading
willgebhardt Apr 3, 2025
8bead45
Loaded processes acsessable
willgebhardt Apr 3, 2025
2eabe1f
Added helpers to get the model state
willgebhardt Apr 3, 2025
1904ac9
added updating the state from context
willgebhardt Apr 3, 2025
b1d3f91
updating state through process
willgebhardt Apr 3, 2025
0ae862c
Update op_compiler.py
willgebhardt Apr 7, 2025
42f8fa2
Builder support for process
willgebhardt Apr 7, 2025
bd55f1f
Allowed for custom process classes
willgebhardt Apr 7, 2025
18b7c45
Added comments to new methods
willgebhardt Apr 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/workflows/python-package-conda.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Python Package using Conda

on: [push]

jobs:
build-linux:
runs-on: ubuntu-latest
strategy:
max-parallel: 5

steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: '3.10'
- name: Add conda to system path
run: |
# $CONDA is an environment variable pointing to the root of the miniconda directory
echo $CONDA/bin >> $GITHUB_PATH
- name: Install current library and dependencies
run: |
pip install -e .
# - name: Lint with flake8
# run: |
# conda install flake8
# # stop the build if there are Python syntax errors or undefined names
# flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
# flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
conda install pytest
pytest
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ $ pip install --editable . # OR pip install -e .
</pre>

**Version:**<br>
0.3.3-Beta <!-- -Alpha -->
0.3.5-Beta <!-- -Alpha -->

Authors:
William Gebhardt, Alexander G. Ororbia II<br>
Expand Down
23 changes: 13 additions & 10 deletions ngcsimlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from ngcsimlib.configManager import init_config, get_config
from ngcsimlib.logger import warn
from pkg_resources import get_distribution
from ngcsimlib.compilers.process import Process, transition

__version__ = get_distribution('ngcsimlib').version ## set software version

Expand Down Expand Up @@ -36,19 +37,21 @@ def preload_modules(path=None):
modules = json.load(file, object_hook=lambda d: SimpleNamespace(**d))

for module in modules:
mod = import_module(module.absolute_path)
utils.modules._Loaded_Modules[module.absolute_path] = mod
load_module(module)

for attribute in module.attributes:
atr = getattr(mod, attribute.name)
utils.modules._Loaded_Attributes[attribute.name] = atr
def load_module(module):
mod = import_module(module.absolute_path)
utils.modules._Loaded_Modules[module.absolute_path] = mod

utils.modules._Loaded_Attributes[".".join([module.absolute_path, attribute.name])] = atr
if hasattr(attribute, "keywords"):
for keyword in attribute.keywords:
utils.modules._Loaded_Attributes[keyword] = atr
for attribute in module.attributes:
atr = getattr(mod, attribute.name)
utils.modules._Loaded_Attributes[attribute.name] = atr

utils.set_loaded(True)
utils.modules._Loaded_Attributes[
".".join([module.absolute_path, attribute.name])] = atr
if hasattr(attribute, "keywords"):
for keyword in attribute.keywords:
utils.modules._Loaded_Attributes[keyword] = atr

###### Initialize Config
def configure():
Expand Down
48 changes: 28 additions & 20 deletions ngcsimlib/compartment.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@
class Compartment:
"""
Compartments in ngcsimlib are container objects for storing the stateful
values of components. Compartments are
tracked globaly and are automatically linked to components and methods
during compiling to allow for stateful
mechanics to be run without the need for the class object. Compartments
also provide an entry and exit point for
values inside of components allowing for cables to be connected for
sending and receiving values.
values of components. Compartments are tracked globally and are
automatically linked to components and methods during compiling to allow
for stateful mechanics to be run without the need for the class object.
Compartments also provide an entry and exit point for values inside of
components allowing for cables to be connected for sending and receiving
values.
"""

@classmethod
Expand All @@ -31,19 +30,18 @@ def is_compartment(cls, obj):
"""
return hasattr(obj, "_is_compartment")

def __init__(self, initial_value=None, static=False, is_input=False):
def __init__(self, initial_value=None, static=False, is_input=False,
display_name=None, units=None):
"""
Builds a compartment to be used inside a component. It is important
to note that building compartments
outside of components may cause unexpected behavior as components
interact with their compartments during
construction to finish initializing them.
to note that building compartments outside of components may cause
unexpected behavior as components interact with their compartments
during construction to finish initializing them.
Args:
initial_value: The initial value of the compartment. As a general
practice it is a good idea to
provide a value that is similar to the values that will
normally be stored here, such as an array of
zeros of the correct length. (default: None)
practice it is a good idea to provide a value that is similar to
the values that will normally be stored here, such as an array of
zeros of the correct length. (default: None)

static: a flag to lock a compartment to be static (default: False)
"""
Expand All @@ -56,6 +54,8 @@ def __init__(self, initial_value=None, static=False, is_input=False):
self.path = None
self.is_input = is_input
self._is_destination = False
self._display_name = display_name
self._units = units

def _setup(self, current_component, key):
"""
Expand Down Expand Up @@ -103,10 +103,9 @@ def __str__(self):
def __lshift__(self, other) -> None:
"""
Overrides the left shift operation to be used for wiring compartments
into one another
if other is not an Operation it will create an overwrite operation
with other as the argument,
otherwise it will use the provided operation
into one another if other is not an Operation it will create an
overwrite operation with other as the argument, otherwise it will use
the provided operation

Args:
other: Either another component or an instance of BaseOp
Expand All @@ -131,3 +130,12 @@ def is_wired(self):
return True

return self._is_destination

@property
def display_name(self):
return self._display_name if self._display_name is not None else (
self.name)

@property
def units(self):
return self._units if self._units is not None else "dimensionless"
5 changes: 2 additions & 3 deletions ngcsimlib/compilers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
from .command_compiler import compile_command, dynamic_compile, wrap_command
from .component_compiler import compile as compile_component
from .op_compiler import compile as compile_op
from .legacy_compiler.command_compiler import compile_command, dynamic_compile
from .utils import wrap_command, compose
157 changes: 0 additions & 157 deletions ngcsimlib/compilers/command_compiler.py

This file was deleted.

Empty file.
Loading