Skip to content

Commit 4f15d55

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

8 files changed

+114
-84
lines changed

examples/Asymmetric Calculation Example.ipynb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,7 @@
4646
"source": [
4747
"# some basic imports\n",
4848
"import numpy as np\n",
49-
"import warnings\n",
50-
"\n",
51-
"with warnings.catch_warnings(action=\"ignore\", category=DeprecationWarning):\n",
52-
" # suppress warning about pyarrow as future required dependency\n",
53-
" import pandas as pd\n",
49+
"import pandas as pd\n",
5450
"\n",
5551
"from power_grid_model import LoadGenType, ComponentType, DatasetType\n",
5652
"from power_grid_model import PowerGridModel, CalculationMethod, CalculationType, MeasuredTerminalType\n",

examples/Make Test Dataset.ipynb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,7 @@
161161
"# first build the network\n",
162162
"\n",
163163
"import numpy as np\n",
164-
"import warnings\n",
165-
"\n",
166-
"with warnings.catch_warnings(action=\"ignore\", category=DeprecationWarning):\n",
167-
" # suppress warning about pyarrow as future required dependency\n",
168-
" import pandas as pd\n",
164+
"import pandas as pd\n",
169165
"\n",
170166
"from power_grid_model import LoadGenType, ComponentType, DatasetType\n",
171167
"from power_grid_model import PowerGridModel\n",

examples/Power Flow Example.ipynb

Lines changed: 91 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,7 @@
4545
"source": [
4646
"# some basic imports\n",
4747
"import numpy as np\n",
48-
"import warnings\n",
49-
"\n",
50-
"with warnings.catch_warnings(action=\"ignore\", category=DeprecationWarning):\n",
51-
" # suppress warning about pyarrow as future required dependency\n",
52-
" import pandas as pd\n",
48+
"import pandas as pd\n",
5349
"\n",
5450
"from power_grid_model import LoadGenType, ComponentType, DatasetType, ComponentAttributeFilterOptions\n",
5551
"from power_grid_model import PowerGridModel, CalculationMethod, CalculationType\n",
@@ -640,15 +636,40 @@
640636
},
641637
{
642638
"cell_type": "markdown",
643-
"id": "fcc57354",
639+
"id": "25a3f722",
644640
"metadata": {},
645641
"source": [
646-
"Columnar data is also supported"
642+
"If you are updating all components of the same type (uniformly) in the same order as in the input data, providing IDs is optional."
647643
]
648644
},
649645
{
650646
"cell_type": "code",
651647
"execution_count": 15,
648+
"id": "6a4d9802",
649+
"metadata": {},
650+
"outputs": [],
651+
"source": [
652+
"update_sym_load_no_id = initialize_array(DatasetType.update, ComponentType.sym_load, 2)\n",
653+
"update_sym_load_no_id[\"p_specified\"] = [30e6, 15e6] # change active power for both sym_loads\n",
654+
"# leave reactive power the same, no need to specify\n",
655+
"\n",
656+
"update_line_no_id = initialize_array(DatasetType.update, ComponentType.line, 3)\n",
657+
"update_line_no_id[\"from_status\"] = [0, 1, 1] # switch off at from side for line #3\n",
658+
"\n",
659+
"update_data_no_id = {ComponentType.sym_load: update_sym_load_no_id, ComponentType.line: update_line_no_id}"
660+
]
661+
},
662+
{
663+
"cell_type": "markdown",
664+
"id": "fcc57354",
665+
"metadata": {},
666+
"source": [
667+
"Columnar data is also supported."
668+
]
669+
},
670+
{
671+
"cell_type": "code",
672+
"execution_count": 16,
652673
"id": "aaf8fe64",
653674
"metadata": {},
654675
"outputs": [],
@@ -660,7 +681,34 @@
660681
"}\n",
661682
"# leave to-side swiching status the same, no need to specify\n",
662683
"\n",
663-
"update_data = {ComponentType.sym_load: update_sym_load, ComponentType.line: columnar_update_line}"
684+
"update_data_col = {ComponentType.sym_load: update_sym_load, ComponentType.line: columnar_update_line}"
685+
]
686+
},
687+
{
688+
"cell_type": "markdown",
689+
"id": "f5179288",
690+
"metadata": {},
691+
"source": [
692+
"Columnar data also supports optional IDs."
693+
]
694+
},
695+
{
696+
"cell_type": "code",
697+
"execution_count": 17,
698+
"id": "7eabed0c",
699+
"metadata": {},
700+
"outputs": [],
701+
"source": [
702+
"line_update_dtype = power_grid_meta_data[DatasetType.update][ComponentType.line].dtype\n",
703+
"columnar_no_ID_update_line = {\n",
704+
" # Update IDs are not specified\n",
705+
" \"from_status\": np.array(\n",
706+
" [0, 1, 1], dtype=line_update_dtype[\"from_status\"]\n",
707+
" ), # The update for the whole column needs to be specified\n",
708+
"}\n",
709+
"# leave to-side swiching status the same, no need to specify\n",
710+
"\n",
711+
"update_data_col_no_id = {ComponentType.sym_load: update_sym_load, ComponentType.line: columnar_no_ID_update_line}"
664712
]
665713
},
666714
{
@@ -676,14 +724,21 @@
676724
},
677725
{
678726
"cell_type": "code",
679-
"execution_count": 16,
727+
"execution_count": 18,
680728
"id": "63ea4cc3",
681729
"metadata": {},
682730
"outputs": [],
683731
"source": [
684732
"from power_grid_model.validation import assert_valid_batch_data\n",
685733
"\n",
686-
"assert_valid_batch_data(input_data=input_data, update_data=update_data, calculation_type=CalculationType.power_flow)"
734+
"assert_valid_batch_data(input_data=input_data, update_data=update_data, calculation_type=CalculationType.power_flow)\n",
735+
"assert_valid_batch_data(\n",
736+
" input_data=input_data, update_data=update_data_no_id, calculation_type=CalculationType.power_flow\n",
737+
")\n",
738+
"assert_valid_batch_data(input_data=input_data, update_data=update_data_col, calculation_type=CalculationType.power_flow)\n",
739+
"assert_valid_batch_data(\n",
740+
" input_data=input_data, update_data=update_data_col_no_id, calculation_type=CalculationType.power_flow\n",
741+
")"
687742
]
688743
},
689744
{
@@ -699,7 +754,7 @@
699754
},
700755
{
701756
"cell_type": "code",
702-
"execution_count": 17,
757+
"execution_count": 19,
703758
"id": "188f6663",
704759
"metadata": {},
705760
"outputs": [],
@@ -721,7 +776,7 @@
721776
},
722777
{
723778
"cell_type": "code",
724-
"execution_count": 18,
779+
"execution_count": 20,
725780
"id": "a93c1e16",
726781
"metadata": {},
727782
"outputs": [
@@ -810,7 +865,7 @@
810865
},
811866
{
812867
"cell_type": "code",
813-
"execution_count": 19,
868+
"execution_count": 21,
814869
"id": "42d5cd8f",
815870
"metadata": {},
816871
"outputs": [],
@@ -844,7 +899,7 @@
844899
},
845900
{
846901
"cell_type": "code",
847-
"execution_count": 20,
902+
"execution_count": 22,
848903
"id": "4e25006f",
849904
"metadata": {
850905
"scrolled": true
@@ -887,7 +942,7 @@
887942
},
888943
{
889944
"cell_type": "code",
890-
"execution_count": 21,
945+
"execution_count": 23,
891946
"id": "afccf7a2",
892947
"metadata": {
893948
"scrolled": true
@@ -924,7 +979,7 @@
924979
},
925980
{
926981
"cell_type": "code",
927-
"execution_count": 22,
982+
"execution_count": 24,
928983
"id": "9af1be38",
929984
"metadata": {
930985
"scrolled": true
@@ -967,7 +1022,7 @@
9671022
},
9681023
{
9691024
"cell_type": "code",
970-
"execution_count": 23,
1025+
"execution_count": 25,
9711026
"id": "041368dc",
9721027
"metadata": {},
9731028
"outputs": [],
@@ -997,7 +1052,7 @@
9971052
},
9981053
{
9991054
"cell_type": "code",
1000-
"execution_count": 24,
1055+
"execution_count": 26,
10011056
"id": "34338ce3",
10021057
"metadata": {},
10031058
"outputs": [
@@ -1029,7 +1084,7 @@
10291084
},
10301085
{
10311086
"cell_type": "code",
1032-
"execution_count": 25,
1087+
"execution_count": 27,
10331088
"id": "04e56690",
10341089
"metadata": {},
10351090
"outputs": [],
@@ -1061,7 +1116,7 @@
10611116
},
10621117
{
10631118
"cell_type": "code",
1064-
"execution_count": 26,
1119+
"execution_count": 28,
10651120
"id": "0d5b94c2",
10661121
"metadata": {},
10671122
"outputs": [
@@ -1144,7 +1199,7 @@
11441199
},
11451200
{
11461201
"cell_type": "code",
1147-
"execution_count": 27,
1202+
"execution_count": 29,
11481203
"id": "b5f10bae",
11491204
"metadata": {},
11501205
"outputs": [
@@ -1204,7 +1259,7 @@
12041259
},
12051260
{
12061261
"cell_type": "code",
1207-
"execution_count": 28,
1262+
"execution_count": 30,
12081263
"id": "1a221507",
12091264
"metadata": {},
12101265
"outputs": [
@@ -1246,7 +1301,7 @@
12461301
},
12471302
{
12481303
"cell_type": "code",
1249-
"execution_count": 29,
1304+
"execution_count": 31,
12501305
"id": "541af620",
12511306
"metadata": {},
12521307
"outputs": [
@@ -1294,7 +1349,7 @@
12941349
},
12951350
{
12961351
"cell_type": "code",
1297-
"execution_count": 30,
1352+
"execution_count": 32,
12981353
"id": "20d8285c",
12991354
"metadata": {},
13001355
"outputs": [],
@@ -1305,7 +1360,7 @@
13051360
},
13061361
{
13071362
"cell_type": "code",
1308-
"execution_count": 31,
1363+
"execution_count": 33,
13091364
"id": "b702eb15",
13101365
"metadata": {},
13111366
"outputs": [
@@ -1340,7 +1395,7 @@
13401395
},
13411396
{
13421397
"cell_type": "code",
1343-
"execution_count": 32,
1398+
"execution_count": 34,
13441399
"id": "1ba71901",
13451400
"metadata": {},
13461401
"outputs": [
@@ -1349,16 +1404,16 @@
13491404
"output_type": "stream",
13501405
"text": [
13511406
"Node data with invalid results\n",
1352-
"[[9.99401170e-001 9.92685785e-001 9.94521366e-001]\n",
1353-
" [9.99347687e-001 9.86226389e-001 9.89352855e-001]\n",
1354-
" [9.99288384e-001 9.79654011e-001 9.84095542e-001]\n",
1355-
" [0.00000000e+000 3.04369633e+101 3.41345331e+241]\n",
1356-
" [9.99151380e-001 9.66149483e-001 9.73298790e-001]\n",
1357-
" [9.99073166e-001 9.59205860e-001 9.67750710e-001]\n",
1358-
" [9.98988099e-001 9.52126208e-001 9.62096474e-001]\n",
1359-
" [1.66994188e-321 3.12878333e-312 9.75772002e+199]\n",
1360-
" [9.98796126e-001 9.37530046e-001 9.50447962e-001]\n",
1361-
" [9.98688504e-001 9.29997471e-001 9.44441670e-001]]\n",
1407+
"[[0.99940117 0.99268579 0.99452137]\n",
1408+
" [0.99934769 0.98622639 0.98935286]\n",
1409+
" [0.99928838 0.97965401 0.98409554]\n",
1410+
" [0. 0. 0. ]\n",
1411+
" [0.99915138 0.96614948 0.97329879]\n",
1412+
" [0.99907317 0.95920586 0.96775071]\n",
1413+
" [0.9989881 0.95212621 0.96209647]\n",
1414+
" [0. 0. 0. ]\n",
1415+
" [0.99879613 0.93753005 0.95044796]\n",
1416+
" [0.9986885 0.92999747 0.94444167]]\n",
13621417
"Node data with only valid results\n",
13631418
"[[0.99940117 0.99268579 0.99452137]\n",
13641419
" [0.99934769 0.98622639 0.98935286]\n",

examples/Serialization Example.ipynb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,8 @@
2323
"outputs": [],
2424
"source": [
2525
"import json\n",
26+
"from pandas import DataFrame\n",
2627
"import pprint\n",
27-
"import warnings\n",
28-
"\n",
29-
"with warnings.catch_warnings(action=\"ignore\", category=DeprecationWarning):\n",
30-
" # suppress warning about pyarrow as future required dependency\n",
31-
" from pandas import DataFrame\n",
3228
"\n",
3329
"from power_grid_model import PowerGridModel, ComponentType, ComponentAttributeFilterOptions\n",
3430
"from power_grid_model.utils import json_deserialize, json_serialize"

examples/Short Circuit Example.ipynb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,7 @@
4848
"source": [
4949
"# some basic imports\n",
5050
"import numpy as np\n",
51-
"import warnings\n",
52-
"\n",
53-
"with warnings.catch_warnings(action=\"ignore\", category=DeprecationWarning):\n",
54-
" # suppress warning about pyarrow as future required dependency\n",
55-
" import pandas as pd\n",
51+
"import pandas as pd\n",
5652
"\n",
5753
"from power_grid_model import LoadGenType, ComponentType, DatasetType\n",
5854
"from power_grid_model import (\n",

examples/State Estimation Example.ipynb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,7 @@
4343
"source": [
4444
"# some basic imports\n",
4545
"import numpy as np\n",
46-
"import warnings\n",
47-
"\n",
48-
"with warnings.catch_warnings(action=\"ignore\", category=DeprecationWarning):\n",
49-
" # suppress warning about pyarrow as future required dependency\n",
50-
" import pandas as pd\n",
46+
"import pandas as pd\n",
5147
"\n",
5248
"from power_grid_model import LoadGenType, DatasetType, ComponentType\n",
5349
"from power_grid_model import PowerGridModel, CalculationMethod, CalculationType, MeasuredTerminalType\n",

examples/Transformer Examples.ipynb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,7 @@
3838
"source": [
3939
"# some basic imports\n",
4040
"import numpy as np\n",
41-
"import warnings\n",
42-
"\n",
43-
"with warnings.catch_warnings():\n",
44-
" warnings.simplefilter(\"ignore\", category=DeprecationWarning)\n",
45-
" # suppress warning about pyarrow as future required dependency\n",
46-
" import pandas as pd\n",
41+
"import pandas as pd\n",
4742
"\n",
4843
"from power_grid_model import LoadGenType, DatasetType, ComponentType\n",
4944
"from power_grid_model import (\n",

0 commit comments

Comments
 (0)