Skip to content

Commit 40079d2

Browse files
authored
Merge pull request #34 from NACLab/main
Merge on over changes in main to release (in prep for major release 1.0.0)
2 parents bdc0810 + 18b7c45 commit 40079d2

37 files changed

+1197
-517
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Python Package using Conda
2+
3+
on: [push]
4+
5+
jobs:
6+
build-linux:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
max-parallel: 5
10+
11+
steps:
12+
- uses: actions/checkout@v4
13+
- name: Set up Python 3.10
14+
uses: actions/setup-python@v3
15+
with:
16+
python-version: '3.10'
17+
- name: Add conda to system path
18+
run: |
19+
# $CONDA is an environment variable pointing to the root of the miniconda directory
20+
echo $CONDA/bin >> $GITHUB_PATH
21+
- name: Install current library and dependencies
22+
run: |
23+
pip install -e .
24+
# - name: Lint with flake8
25+
# run: |
26+
# conda install flake8
27+
# # stop the build if there are Python syntax errors or undefined names
28+
# flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
29+
# # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
30+
# flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
31+
- name: Test with pytest
32+
run: |
33+
conda install pytest
34+
pytest

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ $ pip install --editable . # OR pip install -e .
4141
</pre>
4242

4343
**Version:**<br>
44-
0.3.3-Beta <!-- -Alpha -->
44+
0.3.5-Beta <!-- -Alpha -->
4545

4646
Authors:
4747
William Gebhardt, Alexander G. Ororbia II<br>

ngcsimlib/__init__.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from ngcsimlib.configManager import init_config, get_config
99
from ngcsimlib.logger import warn
1010
from pkg_resources import get_distribution
11+
from ngcsimlib.compilers.process import Process, transition
1112

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

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

3839
for module in modules:
39-
mod = import_module(module.absolute_path)
40-
utils.modules._Loaded_Modules[module.absolute_path] = mod
40+
load_module(module)
4141

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

46-
utils.modules._Loaded_Attributes[".".join([module.absolute_path, attribute.name])] = atr
47-
if hasattr(attribute, "keywords"):
48-
for keyword in attribute.keywords:
49-
utils.modules._Loaded_Attributes[keyword] = atr
46+
for attribute in module.attributes:
47+
atr = getattr(mod, attribute.name)
48+
utils.modules._Loaded_Attributes[attribute.name] = atr
5049

51-
utils.set_loaded(True)
50+
utils.modules._Loaded_Attributes[
51+
".".join([module.absolute_path, attribute.name])] = atr
52+
if hasattr(attribute, "keywords"):
53+
for keyword in attribute.keywords:
54+
utils.modules._Loaded_Attributes[keyword] = atr
5255

5356
###### Initialize Config
5457
def configure():

ngcsimlib/compartment.py

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@
77
class Compartment:
88
"""
99
Compartments in ngcsimlib are container objects for storing the stateful
10-
values of components. Compartments are
11-
tracked globaly and are automatically linked to components and methods
12-
during compiling to allow for stateful
13-
mechanics to be run without the need for the class object. Compartments
14-
also provide an entry and exit point for
15-
values inside of components allowing for cables to be connected for
16-
sending and receiving values.
10+
values of components. Compartments are tracked globally and are
11+
automatically linked to components and methods during compiling to allow
12+
for stateful mechanics to be run without the need for the class object.
13+
Compartments also provide an entry and exit point for values inside of
14+
components allowing for cables to be connected for sending and receiving
15+
values.
1716
"""
1817

1918
@classmethod
@@ -31,19 +30,18 @@ def is_compartment(cls, obj):
3130
"""
3231
return hasattr(obj, "_is_compartment")
3332

34-
def __init__(self, initial_value=None, static=False, is_input=False):
33+
def __init__(self, initial_value=None, static=False, is_input=False,
34+
display_name=None, units=None):
3535
"""
3636
Builds a compartment to be used inside a component. It is important
37-
to note that building compartments
38-
outside of components may cause unexpected behavior as components
39-
interact with their compartments during
40-
construction to finish initializing them.
37+
to note that building compartments outside of components may cause
38+
unexpected behavior as components interact with their compartments
39+
during construction to finish initializing them.
4140
Args:
4241
initial_value: The initial value of the compartment. As a general
43-
practice it is a good idea to
44-
provide a value that is similar to the values that will
45-
normally be stored here, such as an array of
46-
zeros of the correct length. (default: None)
42+
practice it is a good idea to provide a value that is similar to
43+
the values that will normally be stored here, such as an array of
44+
zeros of the correct length. (default: None)
4745
4846
static: a flag to lock a compartment to be static (default: False)
4947
"""
@@ -56,6 +54,8 @@ def __init__(self, initial_value=None, static=False, is_input=False):
5654
self.path = None
5755
self.is_input = is_input
5856
self._is_destination = False
57+
self._display_name = display_name
58+
self._units = units
5959

6060
def _setup(self, current_component, key):
6161
"""
@@ -103,10 +103,9 @@ def __str__(self):
103103
def __lshift__(self, other) -> None:
104104
"""
105105
Overrides the left shift operation to be used for wiring compartments
106-
into one another
107-
if other is not an Operation it will create an overwrite operation
108-
with other as the argument,
109-
otherwise it will use the provided operation
106+
into one another if other is not an Operation it will create an
107+
overwrite operation with other as the argument, otherwise it will use
108+
the provided operation
110109
111110
Args:
112111
other: Either another component or an instance of BaseOp
@@ -131,3 +130,12 @@ def is_wired(self):
131130
return True
132131

133132
return self._is_destination
133+
134+
@property
135+
def display_name(self):
136+
return self._display_name if self._display_name is not None else (
137+
self.name)
138+
139+
@property
140+
def units(self):
141+
return self._units if self._units is not None else "dimensionless"

ngcsimlib/compilers/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
from .command_compiler import compile_command, dynamic_compile, wrap_command
2-
from .component_compiler import compile as compile_component
3-
from .op_compiler import compile as compile_op
1+
from .legacy_compiler.command_compiler import compile_command, dynamic_compile
2+
from .utils import wrap_command, compose

ngcsimlib/compilers/command_compiler.py

Lines changed: 0 additions & 157 deletions
This file was deleted.

ngcsimlib/compilers/legacy_compiler/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)