Skip to content

Commit a207b46

Browse files
committed
Update the examples
Signed-off-by: GitHub Actions Bot <[email protected]>
1 parent 4f15d55 commit a207b46

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

examples/Power Flow Example.ipynb

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -447,8 +447,8 @@
447447
"name": "stdout",
448448
"output_type": "stream",
449449
"text": [
450-
"List of component types in result dataset and associated data types\n",
451-
"{'ComponentType.node': <class 'numpy.ndarray'>, 'ComponentType.line': <class 'dict'>, 'ComponentType.sym_load': <class 'dict'>}\n",
450+
"List of component types in result dataset\n",
451+
"[<ComponentType.node: 'node'>, <ComponentType.line: 'line'>, <ComponentType.sym_load: 'sym_load'>]\n",
452452
"------node result------\n",
453453
"('id', 'energized', 'u_pu', 'u', 'u_angle', 'p', 'q')\n",
454454
"------line result attributes------\n",
@@ -471,8 +471,8 @@
471471
" },\n",
472472
")\n",
473473
"\n",
474-
"print(\"List of component types in result dataset and associated data types\")\n",
475-
"print({str(component_type): type(component_data) for component_type, component_data in output_data.items()})\n",
474+
"print(\"List of component types in result dataset\")\n",
475+
"print(list(output_data.keys()))\n",
476476
"print(\"------node result------\")\n",
477477
"print(output_data[ComponentType.node].dtype.names)\n",
478478
"print(\"------line result attributes------\")\n",
@@ -499,8 +499,8 @@
499499
"name": "stdout",
500500
"output_type": "stream",
501501
"text": [
502-
"List of component types in result dataset and associated data types\n",
503-
"{'ComponentType.node': <class 'dict'>, 'ComponentType.line': <class 'dict'>, 'ComponentType.sym_load': <class 'dict'>, 'ComponentType.source': <class 'dict'>}\n",
502+
"List of component types in result dataset\n",
503+
"[<ComponentType.node: 'node'>, <ComponentType.line: 'line'>, <ComponentType.sym_load: 'sym_load'>, <ComponentType.source: 'source'>]\n",
504504
"------node result------\n",
505505
"['id', 'energized', 'u_pu', 'u', 'u_angle', 'p', 'q']\n",
506506
"------line result attributes------\n",
@@ -519,8 +519,8 @@
519519
" output_component_types=ComponentAttributeFilterOptions.everything, # all attributes for all component types as columns\n",
520520
")\n",
521521
"\n",
522-
"print(\"List of component types in result dataset and associated data types\")\n",
523-
"print({str(component_type): type(component_data) for component_type, component_data in output_data.items()})\n",
522+
"print(\"List of component types in result dataset\")\n",
523+
"print(list(output_data.keys()))\n",
524524
"print(\"------node result------\")\n",
525525
"print(list(output_data[ComponentType.node].keys()))\n",
526526
"print(\"------line result attributes------\")\n",
@@ -1430,6 +1430,7 @@
14301430
"# we run the batch calculation with continue_on_batch_error=True,\n",
14311431
"# it will return the results with partially valid data\n",
14321432
"\n",
1433+
"\n",
14331434
"output_data = model.calculate_power_flow(update_data=time_series_mutation, continue_on_batch_error=True)\n",
14341435
"\n",
14351436
"# print node data for u_pu, note that the data is rubbish for scenario 3 and 7\n",

examples/Validation Examples.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@
113113
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
114114
"\u001b[0;31mIDWrongType\u001b[0m Traceback (most recent call last)",
115115
"Cell \u001b[0;32mIn[2], line 2\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;66;03m# Without validation\u001b[39;00m\n\u001b[0;32m----> 2\u001b[0m model \u001b[38;5;241m=\u001b[39m \u001b[43mPowerGridModel\u001b[49m\u001b[43m(\u001b[49m\u001b[43merror_data\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 3\u001b[0m output_data \u001b[38;5;241m=\u001b[39m model\u001b[38;5;241m.\u001b[39mcalculate_state_estimation(symmetric\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m)\n",
116-
"File \u001b[0;32m~/pgm/power-grid-model/src/power_grid_model/core/power_grid_model.py:125\u001b[0m, in \u001b[0;36mPowerGridModel.__init__\u001b[0;34m(self, input_data, system_frequency)\u001b[0m\n\u001b[1;32m 123\u001b[0m prepared_input \u001b[38;5;241m=\u001b[39m prepare_input_view(_map_to_component_types(input_data))\n\u001b[1;32m 124\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_model_ptr \u001b[38;5;241m=\u001b[39m pgc\u001b[38;5;241m.\u001b[39mcreate_model(system_frequency, input_data\u001b[38;5;241m=\u001b[39mprepared_input\u001b[38;5;241m.\u001b[39mget_dataset_ptr())\n\u001b[0;32m--> 125\u001b[0m \u001b[43massert_no_error\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 126\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_all_component_count \u001b[38;5;241m=\u001b[39m {k: v \u001b[38;5;28;01mfor\u001b[39;00m k, v \u001b[38;5;129;01min\u001b[39;00m prepared_input\u001b[38;5;241m.\u001b[39mget_info()\u001b[38;5;241m.\u001b[39mtotal_elements()\u001b[38;5;241m.\u001b[39mitems() \u001b[38;5;28;01mif\u001b[39;00m v \u001b[38;5;241m>\u001b[39m \u001b[38;5;241m0\u001b[39m}\n",
117-
"File \u001b[0;32m~/pgm/power-grid-model/src/power_grid_model/core/error_handling.py:169\u001b[0m, in \u001b[0;36massert_no_error\u001b[0;34m(batch_size, decode_error)\u001b[0m\n\u001b[1;32m 167\u001b[0m error \u001b[38;5;241m=\u001b[39m find_error(batch_size\u001b[38;5;241m=\u001b[39mbatch_size, decode_error\u001b[38;5;241m=\u001b[39mdecode_error)\n\u001b[1;32m 168\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m error \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[0;32m--> 169\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m error\n",
116+
"File \u001b[0;32m~/pgm/power-grid-model/src/power_grid_model/_core/power_grid_model.py:125\u001b[0m, in \u001b[0;36mPowerGridModel.__init__\u001b[0;34m(self, input_data, system_frequency)\u001b[0m\n\u001b[1;32m 123\u001b[0m prepared_input \u001b[38;5;241m=\u001b[39m prepare_input_view(_map_to_component_types(input_data))\n\u001b[1;32m 124\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_model_ptr \u001b[38;5;241m=\u001b[39m pgc\u001b[38;5;241m.\u001b[39mcreate_model(system_frequency, input_data\u001b[38;5;241m=\u001b[39mprepared_input\u001b[38;5;241m.\u001b[39mget_dataset_ptr())\n\u001b[0;32m--> 125\u001b[0m \u001b[43massert_no_error\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 126\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_all_component_count \u001b[38;5;241m=\u001b[39m {k: v \u001b[38;5;28;01mfor\u001b[39;00m k, v \u001b[38;5;129;01min\u001b[39;00m prepared_input\u001b[38;5;241m.\u001b[39mget_info()\u001b[38;5;241m.\u001b[39mtotal_elements()\u001b[38;5;241m.\u001b[39mitems() \u001b[38;5;28;01mif\u001b[39;00m v \u001b[38;5;241m>\u001b[39m \u001b[38;5;241m0\u001b[39m}\n",
117+
"File \u001b[0;32m~/pgm/power-grid-model/src/power_grid_model/_core/error_handling.py:169\u001b[0m, in \u001b[0;36massert_no_error\u001b[0;34m(batch_size, decode_error)\u001b[0m\n\u001b[1;32m 167\u001b[0m error \u001b[38;5;241m=\u001b[39m find_error(batch_size\u001b[38;5;241m=\u001b[39mbatch_size, decode_error\u001b[38;5;241m=\u001b[39mdecode_error)\n\u001b[1;32m 168\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m error \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[0;32m--> 169\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m error\n",
118118
"\u001b[0;31mIDWrongType\u001b[0m: Wrong type for object with id 4\n\nTry validate_input_data() or validate_batch_data() to validate your data.\n"
119119
]
120120
}

0 commit comments

Comments
 (0)