Skip to content

Commit e18ea2a

Browse files
committed
add src_cls to each layer
* use this if model spec'd with layer classes instead of dictionary to determine with class belongs to which layer
1 parent ad66532 commit e18ea2a

1 file changed

Lines changed: 13 additions & 10 deletions

File tree

carousel/core/layers.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,22 @@
2727

2828
import importlib
2929
import os
30-
from carousel.core.simulations import SimRegistry
31-
from carousel.core.data_sources import DataRegistry
32-
from carousel.core.formulas import FormulaRegistry
33-
from carousel.core.calculations import CalcRegistry
34-
from carousel.core.outputs import OutputRegistry
30+
from carousel.core.simulations import SimRegistry, Simulation
31+
from carousel.core.data_sources import DataRegistry, DataSource
32+
from carousel.core.formulas import FormulaRegistry, Formula
33+
from carousel.core.calculations import CalcRegistry, Calc
34+
from carousel.core.outputs import OutputRegistry, Output
3535

3636

3737
class Layer(object):
3838
"""
3939
A layer in the model.
4040
41-
:param layer_data: Dictionary of model data specific to this layer.
42-
:type layer_data: dict
41+
:param sources: Dictionary of model parameters specific to this layer.
42+
:type sources: dict
4343
"""
4444
reg_cls = NotImplemented #: registry class
45+
src_cls = NotImplemented #: source class
4546

4647
def __init__(self, sources=None):
4748
#: dictionary of layer sources
@@ -104,9 +105,6 @@ class Data(Layer):
104105
"""
105106
The Data layer of the model.
106107
107-
:param data: Dictionary of model data specific to the data layer.
108-
:type data: :class:`~carousel.core.data_sources.DataRegistry`
109-
110108
The :attr:`~Layer.layer` attribute is a dictionary of data sources names
111109
as keys of dictionaries for each data source with the module and optionally
112110
the package containing the module, the filename, which can be ``None``,
@@ -115,6 +113,7 @@ class Data(Layer):
115113
to Carousel is used. External data files should specify the path.
116114
"""
117115
reg_cls = DataRegistry #: data layer registry
116+
src_cls = DataSource #: data layer source
118117

119118
def add(self, data_source, module, package=None):
120119
"""
@@ -219,6 +218,7 @@ class Formulas(Layer):
219218
Layer containing formulas.
220219
"""
221220
reg_cls = FormulaRegistry #: formula layer registry
221+
src_cls = Formula #: formula layer source
222222

223223
def add(self, formula, module, package=None):
224224
"""
@@ -259,6 +259,7 @@ class Calculations(Layer):
259259
Layer containing formulas.
260260
"""
261261
reg_cls = CalcRegistry #: calculations layer registry
262+
src_cls = Calc #: calculation layer source
262263

263264
def add(self, calc, module, package=None):
264265
"""
@@ -289,6 +290,7 @@ class Outputs(Layer):
289290
Layer containing output sources.
290291
"""
291292
reg_cls = OutputRegistry #: output layer registry
293+
src_cls = Output #: output layer source
292294

293295
def add(self, output, module, package=None):
294296
"""
@@ -318,6 +320,7 @@ class Simulations(Layer):
318320
Layer containing simulation sources.
319321
"""
320322
reg_cls = SimRegistry #: simulation layer registry
323+
src_cls = Simulation #: simulation layer source
321324

322325
def add(self, sim, module, package=None):
323326
"""

0 commit comments

Comments
 (0)