Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Dec 2, 2024
1 parent 2e7f45d commit 3a8fc0a
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 16 deletions.
8 changes: 6 additions & 2 deletions examples/example1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"metadata": {
"lines_to_next_cell": 2
},
"outputs": [],
"source": [
"flow_definitions = [\n",
Expand All @@ -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",
Expand Down
1 change: 1 addition & 0 deletions examples/example1.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
16 changes: 12 additions & 4 deletions examples/example2.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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."
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions examples/example2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down
20 changes: 11 additions & 9 deletions examples/example5.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -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",
Expand Down
3 changes: 3 additions & 0 deletions examples/example5.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@
)
]


# %%
class VehicleMFA(MFASystem):
"""We just need to define the compute method with our system equations,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion sodym/named_dim_arrays.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=())

Expand Down

0 comments on commit 3a8fc0a

Please sign in to comment.