diff --git a/examples/example1.ipynb b/examples/example1.ipynb index c41d316..8371fbb 100644 --- a/examples/example1.ipynb +++ b/examples/example1.ipynb @@ -102,7 +102,9 @@ { "cell_type": "code", "execution_count": 3, - "metadata": {}, + "metadata": { + "lines_to_next_cell": 2 + }, "outputs": [], "source": [ "flow_definitions = [\n", @@ -128,7 +130,9 @@ }, { "cell_type": "markdown", - "metadata": {}, + "metadata": { + "lines_to_next_cell": 2 + }, "source": [ "## 4. Define the MFA System equations\n", "We define a class with our system equations in the compute method. Afterwards we create an instance of this class, using the input data defined above. The class (system equations) can then easily be reused with different input data.\n", diff --git a/examples/example1.py b/examples/example1.py index 59b6349..e734181 100644 --- a/examples/example1.py +++ b/examples/example1.py @@ -112,6 +112,7 @@ # # We just need to define the compute method with our system equations, as all the other things we need are inherited from the MFASystem class. + # %% class SimpleMFA(MFASystem): def compute(self): diff --git a/examples/example2.ipynb b/examples/example2.ipynb index f37ef2e..99a85c6 100644 --- a/examples/example2.ipynb +++ b/examples/example2.ipynb @@ -165,7 +165,9 @@ "cell_type": "code", "execution_count": 20, "id": "1ea15908-23c4-424b-832d-d5507fd13021", - "metadata": {}, + "metadata": { + "lines_to_next_cell": 2 + }, "outputs": [], "source": [ "stock_definitions = [\n", @@ -185,7 +187,9 @@ { "cell_type": "markdown", "id": "f382cce6", - "metadata": {}, + "metadata": { + "lines_to_next_cell": 2 + }, "source": [ "\n", "We just need to define the compute method with our system equations, as all the other things we need are inherited from the MFASystem class. The flow names are generated from the processes each flow connects, in this case with the naming function `process_names_with_arrow`, which is passed to the flow initialization below." @@ -195,7 +199,9 @@ "cell_type": "code", "execution_count": 21, "id": "fef3eb3c-7f88-41b0-86a2-d23bccc0783a", - "metadata": {}, + "metadata": { + "lines_to_next_cell": 2 + }, "outputs": [], "source": [ "class SimpleMFA(MFASystem):\n", @@ -233,7 +239,9 @@ { "cell_type": "markdown", "id": "ea62e42a-4ece-4d6b-91cb-998553bb7e84", - "metadata": {}, + "metadata": { + "lines_to_next_cell": 2 + }, "source": [ "## 3. Load data and initialise flows and stocks\n", "Now that we have defined the MFA system and know what data we need, we can load the data.\n", diff --git a/examples/example2.py b/examples/example2.py index ac24df4..0475219 100644 --- a/examples/example2.py +++ b/examples/example2.py @@ -149,6 +149,7 @@ # # We just need to define the compute method with our system equations, as all the other things we need are inherited from the MFASystem class. The flow names are generated from the processes each flow connects, in this case with the naming function `process_names_with_arrow`, which is passed to the flow initialization below. + # %% class SimpleMFA(MFASystem): def compute(self): @@ -189,6 +190,7 @@ def compute(self): # # The methods `read_dimensions` and `read_parameters` are already defined in the parent DataReader class, and loop over the methods `read_dimension` and `read_parameter_values` that we specify for our usecase here. + # %% class CustomDataReader(DataReader): def __init__(self, path_to_time_parameters, path_to_element_parameters): diff --git a/examples/example5.ipynb b/examples/example5.ipynb index 0f3acb0..9c41603 100644 --- a/examples/example5.ipynb +++ b/examples/example5.ipynb @@ -129,9 +129,7 @@ "cell_type": "code", "execution_count": 4, "id": "5314d22c-a522-43db-be20-54fdbed58fab", - "metadata": { - "lines_to_next_cell": 1 - }, + "metadata": {}, "outputs": [], "source": [ "flow_definitions = [\n", @@ -157,7 +155,9 @@ "cell_type": "code", "execution_count": 5, "id": "5985b315-d592-4cce-8bcb-1b1aef0eeb5b", - "metadata": {}, + "metadata": { + "lines_to_next_cell": 2 + }, "outputs": [], "source": [ "class VehicleMFA(MFASystem):\n", @@ -211,7 +211,9 @@ { "cell_type": "markdown", "id": "48f46cc9-4637-41cb-980d-37b9930a4a86", - "metadata": {}, + "metadata": { + "lines_to_next_cell": 2 + }, "source": [ "## 3. Define our data reader\n", "Now that we have defined the MFA system and know what data we need, we can load the data.\n", @@ -324,9 +326,7 @@ "cell_type": "code", "execution_count": 8, "id": "55906a64-8b14-4015-aa5f-4383d019c1cd", - "metadata": { - "lines_to_next_cell": 1 - }, + "metadata": {}, "outputs": [ { "data": { @@ -436,7 +436,9 @@ { "cell_type": "markdown", "id": "4f90be3d-6663-4e6f-a10b-11f88404b44d", - "metadata": {}, + "metadata": { + "lines_to_next_cell": 2 + }, "source": [ "## 5. Improve the model\n", "\n", diff --git a/examples/example5.py b/examples/example5.py index de134bf..0f6f28a 100644 --- a/examples/example5.py +++ b/examples/example5.py @@ -120,6 +120,7 @@ ) ] + # %% class VehicleMFA(MFASystem): """We just need to define the compute method with our system equations, @@ -174,6 +175,7 @@ def compute_flows(self): # Now that we have defined the MFA system and know what data we need, we can load the data. # To do the data loading, we define a DataReader class. Such a class can be reused with different datasets of the same format by passing attributes, e.g. the directory where the data is stored, in the init function. In this example, we will also build upon this data reader in a following step. + # %% class CustomDataReader(DataReader): """The methods `read_dimensions` and `read_parameters` are already defined in the parent @@ -270,6 +272,7 @@ def vehicle_new_registration(self, data, dims): # # To make these changes in the model dimensions and parameters, we build on the `CustomDataReader` class defined above, extending the time dimension to earlier years, as well as extending the data for the `vehicle_new_registration` parameter, which is our only time-dependent parameter. + # %% class AnotherCustomDataReader(CustomDataReader): @property diff --git a/sodym/named_dim_arrays.py b/sodym/named_dim_arrays.py index e4f6584..de972e9 100644 --- a/sodym/named_dim_arrays.py +++ b/sodym/named_dim_arrays.py @@ -49,7 +49,8 @@ class NamedDimArray(PydanticBaseModel): foo[keys] = bar or foo = bar[keys]. For details on the allowed values of 'keys', see the docstring of the SubArrayHandler class. - The dimensions of a NamedDimArray stored as a :py:class:`sodym.dimensions.DimensionSet` object in the 'dims' attribute.""" + The dimensions of a NamedDimArray stored as a :py:class:`sodym.dimensions.DimensionSet` object in the 'dims' attribute. + """ model_config = ConfigDict(arbitrary_types_allowed=True, protected_namespaces=())