epyt-flow 0.14.0__py3-none-any.whl → 0.14.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- epyt_flow/VERSION +1 -1
- epyt_flow/gym/scenario_control_env.py +26 -3
- epyt_flow/simulation/events/quality_events.py +6 -6
- epyt_flow/simulation/events/sensor_faults.py +24 -24
- epyt_flow/simulation/events/system_event.py +3 -3
- epyt_flow/simulation/scada/scada_data.py +2 -2
- epyt_flow/simulation/scenario_simulator.py +14 -11
- epyt_flow/topology.py +8 -1
- epyt_flow/uncertainty/model_uncertainty.py +292 -150
- epyt_flow/utils.py +66 -0
- epyt_flow/visualization/visualization_utils.py +4 -2
- {epyt_flow-0.14.0.dist-info → epyt_flow-0.14.2.dist-info}/METADATA +2 -2
- {epyt_flow-0.14.0.dist-info → epyt_flow-0.14.2.dist-info}/RECORD +16 -16
- {epyt_flow-0.14.0.dist-info → epyt_flow-0.14.2.dist-info}/WHEEL +0 -0
- {epyt_flow-0.14.0.dist-info → epyt_flow-0.14.2.dist-info}/licenses/LICENSE +0 -0
- {epyt_flow-0.14.0.dist-info → epyt_flow-0.14.2.dist-info}/top_level.txt +0 -0
epyt_flow/utils.py
CHANGED
|
@@ -6,6 +6,7 @@ import math
|
|
|
6
6
|
import tempfile
|
|
7
7
|
import zipfile
|
|
8
8
|
from pathlib import Path
|
|
9
|
+
import re
|
|
9
10
|
import requests
|
|
10
11
|
from tqdm import tqdm
|
|
11
12
|
import numpy as np
|
|
@@ -344,6 +345,71 @@ def plot_timeseries_prediction(y: np.ndarray, y_pred: np.ndarray,
|
|
|
344
345
|
return ax
|
|
345
346
|
|
|
346
347
|
|
|
348
|
+
def download_from_gdrive_if_necessary(download_path: str, url: str, verbose: bool = True) -> None:
|
|
349
|
+
"""
|
|
350
|
+
Downloads a file from a google drive repository if it does not already exist
|
|
351
|
+
in a given path.
|
|
352
|
+
|
|
353
|
+
Note that if the path (folder) does not already exist, it will be created.
|
|
354
|
+
|
|
355
|
+
Parameters
|
|
356
|
+
----------
|
|
357
|
+
download_path : `str`
|
|
358
|
+
Local path to the file -- if this path does not exist, the file will be downloaded from
|
|
359
|
+
the provided 'url' and stored in 'download_dir'.
|
|
360
|
+
url : `str`
|
|
361
|
+
Web-URL of the google drive repository.
|
|
362
|
+
verbose : `bool`, optional
|
|
363
|
+
If True, a progress bar is shown while downloading the file.
|
|
364
|
+
|
|
365
|
+
The default is True.
|
|
366
|
+
"""
|
|
367
|
+
folder_path = str(Path(download_path).parent.absolute())
|
|
368
|
+
create_path_if_not_exist(folder_path)
|
|
369
|
+
|
|
370
|
+
if not os.path.isfile(download_path):
|
|
371
|
+
session = requests.Session()
|
|
372
|
+
|
|
373
|
+
response = session.get(url)
|
|
374
|
+
html = response.text
|
|
375
|
+
|
|
376
|
+
def extract(pattern):
|
|
377
|
+
match = re.search(pattern, html)
|
|
378
|
+
return match.group(1) if match else None
|
|
379
|
+
|
|
380
|
+
file_id = extract(r'name="id" value="([^"]+)"')
|
|
381
|
+
file_confirm = extract(r'name="confirm" value="([^"]+)"')
|
|
382
|
+
file_uuid = extract(r'name="uuid" value="([^"]+)"')
|
|
383
|
+
|
|
384
|
+
if not all([file_id, file_confirm, file_uuid]):
|
|
385
|
+
raise SystemError("Failed to extract download parameters")
|
|
386
|
+
|
|
387
|
+
download_url = (
|
|
388
|
+
f"https://drive.usercontent.google.com/download"
|
|
389
|
+
f"?id={file_id}&export=download&confirm={file_confirm}&uuid={file_uuid}"
|
|
390
|
+
)
|
|
391
|
+
|
|
392
|
+
response = session.get(download_url, stream=True)
|
|
393
|
+
|
|
394
|
+
if response.status_code != 200:
|
|
395
|
+
raise SystemError(f"Failed to download -- {response.status_code}")
|
|
396
|
+
|
|
397
|
+
if verbose is True:
|
|
398
|
+
content_length = int(response.headers.get('content-length', 0))
|
|
399
|
+
with open(download_path, "wb") as file, tqdm(desc=download_path,
|
|
400
|
+
total=content_length,
|
|
401
|
+
ascii=True,
|
|
402
|
+
unit='B',
|
|
403
|
+
unit_scale=True,
|
|
404
|
+
unit_divisor=1024) as progress_bar:
|
|
405
|
+
for data in response.iter_content(chunk_size=1024):
|
|
406
|
+
size = file.write(data)
|
|
407
|
+
progress_bar.update(size)
|
|
408
|
+
else:
|
|
409
|
+
with open(download_path, "wb") as f_out:
|
|
410
|
+
f_out.write(response.content)
|
|
411
|
+
|
|
412
|
+
|
|
347
413
|
def download_if_necessary(download_path: str, url: str, verbose: bool = True,
|
|
348
414
|
backup_urls: list[str] = []) -> None:
|
|
349
415
|
"""
|
|
@@ -188,7 +188,8 @@ class JunctionObject:
|
|
|
188
188
|
|
|
189
189
|
valid_params = {
|
|
190
190
|
key: value for key, value in attributes.items()
|
|
191
|
-
if key in sig.parameters and
|
|
191
|
+
if key in sig.parameters and key not in ['vmin', 'vmax', 'cmap']
|
|
192
|
+
and value is not None
|
|
192
193
|
}
|
|
193
194
|
|
|
194
195
|
return valid_params
|
|
@@ -518,7 +519,8 @@ class EdgeObject:
|
|
|
518
519
|
|
|
519
520
|
valid_params = {
|
|
520
521
|
key: value for key, value in attributes.items()
|
|
521
|
-
if key in sig.parameters and
|
|
522
|
+
if key in sig.parameters and key not in ['vmin', 'vmax', 'cmap']
|
|
523
|
+
and value is not None
|
|
522
524
|
}
|
|
523
525
|
|
|
524
526
|
return valid_params
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: epyt-flow
|
|
3
|
-
Version: 0.14.
|
|
3
|
+
Version: 0.14.2
|
|
4
4
|
Summary: EPyT-Flow -- EPANET Python Toolkit - Flow
|
|
5
5
|
Author-email: André Artelt <aartelt@techfak.uni-bielefeld.de>, "Marios S. Kyriakou" <kiriakou.marios@ucy.ac.cy>, "Stelios G. Vrachimis" <vrachimis.stelios@ucy.ac.cy>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -20,7 +20,7 @@ Classifier: Programming Language :: Python :: 3.13
|
|
|
20
20
|
Requires-Python: >=3.9
|
|
21
21
|
Description-Content-Type: text/markdown
|
|
22
22
|
License-File: LICENSE
|
|
23
|
-
Requires-Dist: epyt>=1.2.
|
|
23
|
+
Requires-Dist: epyt>=1.2.2
|
|
24
24
|
Requires-Dist: requests>=2.31.0
|
|
25
25
|
Requires-Dist: scipy>=1.11.4
|
|
26
26
|
Requires-Dist: u-msgpack-python>=2.8.0
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
epyt_flow/VERSION,sha256=
|
|
1
|
+
epyt_flow/VERSION,sha256=IyzKFfnKsEU9gg0gZJBnV27BjSec47HcbSkx0etjhyE,7
|
|
2
2
|
epyt_flow/__init__.py,sha256=wktX10SXX9GEamDUWR-tcm-8T4d5s6j6aPYr_x4EpOc,1768
|
|
3
3
|
epyt_flow/serialization.py,sha256=uGGN1iZ21ek1u6Xzs4z2xum5Qt8554Wem-wEMGEaa7I,14574
|
|
4
|
-
epyt_flow/topology.py,sha256=
|
|
5
|
-
epyt_flow/utils.py,sha256=
|
|
4
|
+
epyt_flow/topology.py,sha256=FhkPa87vnVX_tQVOKumbRD6kMb3RpGgIdGfZdpmF1Bg,26396
|
|
5
|
+
epyt_flow/utils.py,sha256=dCEx7FwgTmU8T-ajI-abbrLzJu8llhgn0QDewfTuqHk,20074
|
|
6
6
|
epyt_flow/EPANET/compile_linux.sh,sha256=wcrDyiB8NkivmaC-X9FI2WxhY3IJqDLiyIbVTv2XEPY,489
|
|
7
7
|
epyt_flow/EPANET/compile_macos.sh,sha256=JfXkCDe5OHhNXgukU13_ViCsD7KPV8qClzSXGLH1HVk,504
|
|
8
8
|
epyt_flow/EPANET/EPANET/SRC_engines/AUTHORS,sha256=yie5yAsEEPY0984PmkSRUdqEU9rVvRSGGWmjxdwCYMU,925
|
|
@@ -90,7 +90,7 @@ epyt_flow/data/benchmarks/leakdb.py,sha256=IEP6-bx9il65kX5mlGK1M9cevQPvAwLaDxg9Y
|
|
|
90
90
|
epyt_flow/data/benchmarks/leakdb_data.py,sha256=FNssgMkC1wqWVlaOrrihr4Od9trEZY7KeK5KuBeRMvM,507058
|
|
91
91
|
epyt_flow/data/benchmarks/water_usage.py,sha256=RiLGLof1HT0luwn7_dG11_nP5U5r9B3L8vDLuwsIKTM,4962
|
|
92
92
|
epyt_flow/gym/__init__.py,sha256=gDIP9VGjKraajsJo6MnPN-TaEUTLnnJNj2c_7jrb8Bg,36
|
|
93
|
-
epyt_flow/gym/scenario_control_env.py,sha256=
|
|
93
|
+
epyt_flow/gym/scenario_control_env.py,sha256=0VT7B1xP-YGYN_eZqY0yHIgzh3u_OZEBhT5B_4fSteY,13655
|
|
94
94
|
epyt_flow/rest_api/__init__.py,sha256=4HilmXhdh6H56UHJBB2WUSULlEBUDnI1FPTP11ft3HE,126
|
|
95
95
|
epyt_flow/rest_api/base_handler.py,sha256=HDLXrMXqgWvxWAsB-3G4plyTyCv27_eBbq4eRl_FeBo,2609
|
|
96
96
|
epyt_flow/rest_api/res_manager.py,sha256=j6-3FUBZNLKM9bCsIDZzSytfDYJbDLRwjn1mIPstTqI,2342
|
|
@@ -108,7 +108,7 @@ epyt_flow/rest_api/scenario/uncertainty_handlers.py,sha256=Pdo2YmiawOqKXWcLs2P-l
|
|
|
108
108
|
epyt_flow/simulation/__init__.py,sha256=nihvZ8O2rJjYQkv7JhtVMqNacO5bA38VtS8Y_0BWrVQ,129
|
|
109
109
|
epyt_flow/simulation/parallel_simulation.py,sha256=ph4KXw9jCt-hiJFJbmC6fNvEsrbQoWV-tFKE5-qSfoQ,6523
|
|
110
110
|
epyt_flow/simulation/scenario_config.py,sha256=uHHwwzCRwooVdODxDNoCOUgfrlol1K-TS8P8_Ja9Coc,30435
|
|
111
|
-
epyt_flow/simulation/scenario_simulator.py,sha256=
|
|
111
|
+
epyt_flow/simulation/scenario_simulator.py,sha256=V5WIs5fvDHRKPq9bq3p2XVLo0Lm3G2EgKfU8wYXTD98,165399
|
|
112
112
|
epyt_flow/simulation/sensor_config.py,sha256=AGAIC5vqcu2UZsglSCwv2pvZ3E0kbTtdaqtFPEMBwSw,94262
|
|
113
113
|
epyt_flow/simulation/backend/__init__.py,sha256=tkJb2NB_hruTv39sYHAq9ffazyA-UzZzFmiy2nYVTqA,23
|
|
114
114
|
epyt_flow/simulation/backend/my_epyt.py,sha256=9zcHUo-shPuUNewsuxFpbBgtAbbTu7ppSaK6x4Xgt50,34414
|
|
@@ -116,27 +116,27 @@ epyt_flow/simulation/events/__init__.py,sha256=gv8ZcvwjJN0Z5MwRXEOVFRNq4X5NPyyqX
|
|
|
116
116
|
epyt_flow/simulation/events/actuator_events.py,sha256=gNOIZL9WNiIhEANi8yEyGxKx4vSMBZiRpiSJ4BbDL60,8171
|
|
117
117
|
epyt_flow/simulation/events/event.py,sha256=kARPV20XCAl6zxnJwI9U7ICtZUPACO_rgAmtHm1mGCs,2603
|
|
118
118
|
epyt_flow/simulation/events/leakages.py,sha256=pFSbOiKeGeHPZhLAgo2DFFI1QYImd7m167lMW6B-n-U,17838
|
|
119
|
-
epyt_flow/simulation/events/quality_events.py,sha256=
|
|
120
|
-
epyt_flow/simulation/events/sensor_faults.py,sha256=
|
|
119
|
+
epyt_flow/simulation/events/quality_events.py,sha256=XALoRlkVYZ36sBiV8fBxpII7mvyxO9eC0Beq4Xl9IxI,8047
|
|
120
|
+
epyt_flow/simulation/events/sensor_faults.py,sha256=RFR8LjePkDEkCgENHEgCGT7iKYYtr_qq87-IIwN6ezg,8423
|
|
121
121
|
epyt_flow/simulation/events/sensor_reading_attack.py,sha256=2E8q6yWnLxeLgYxW0MHw0GSjlUDjIIZ2GybVRLA7FJQ,7967
|
|
122
122
|
epyt_flow/simulation/events/sensor_reading_event.py,sha256=OWMRWPsvgMgaynMayJ-hQotP9zV5sDIYrOfY0fOCuvc,7586
|
|
123
|
-
epyt_flow/simulation/events/system_event.py,sha256=
|
|
123
|
+
epyt_flow/simulation/events/system_event.py,sha256=plnHp53Xnua5QMmSwrKsU6aP-omrTRCh1tGZLvNX6xI,2603
|
|
124
124
|
epyt_flow/simulation/scada/__init__.py,sha256=pfJhg-tM5DaiZTXs0_1qJsY2R6Py_LwSz6BUFJexfQM,150
|
|
125
125
|
epyt_flow/simulation/scada/complex_control.py,sha256=p2ehLyScJbj2jbyevXf7T3Ot8jnBYWgRR3Cz-m3boB0,22107
|
|
126
126
|
epyt_flow/simulation/scada/custom_control.py,sha256=QzkKcn7t53GcTaRofRDbY-HErcDReMF4utWkck6bN60,4681
|
|
127
|
-
epyt_flow/simulation/scada/scada_data.py,sha256=
|
|
127
|
+
epyt_flow/simulation/scada/scada_data.py,sha256=kkqb8iDWtoRYEkCoJ9Jy3kCi9vEQmM7bh028cUMX36o,203284
|
|
128
128
|
epyt_flow/simulation/scada/scada_data_export.py,sha256=WNAFn_WNfzYAEFbl2Al-cOIx-A0ozY4AI60-i_qEHdc,11643
|
|
129
129
|
epyt_flow/simulation/scada/simple_control.py,sha256=wUsxsrgqmYxXR93_atcKbV9E-t3hgqj60ZeTvoBBnoQ,12215
|
|
130
130
|
epyt_flow/uncertainty/__init__.py,sha256=ZRjuJL9rDpWVSdPwObPxFpEmMTcgAl3VmPOsS6cIyGg,89
|
|
131
|
-
epyt_flow/uncertainty/model_uncertainty.py,sha256=
|
|
131
|
+
epyt_flow/uncertainty/model_uncertainty.py,sha256=tCkETlCL__T5yXUDbM9_3l-kXxCHwV4OKTLeYpSbIY0,47343
|
|
132
132
|
epyt_flow/uncertainty/sensor_noise.py,sha256=-AnBfuW1VAx7Ya-q_gJ9bAr7Kx6pzP_y0PvNeuRjXIg,6477
|
|
133
133
|
epyt_flow/uncertainty/uncertainties.py,sha256=QBRbI3zIzkeFScyYD5Dy0TBxuL9jPV4SnVU8QwOrJq8,20495
|
|
134
134
|
epyt_flow/uncertainty/utils.py,sha256=K-ZhyO6Bg7UmNPgpfND0JLa_wRwyrtUUgGTWyWwy-fo,8029
|
|
135
135
|
epyt_flow/visualization/__init__.py,sha256=uQ7lO6AsgLc88X48Te3QhBQY-iDKGvdPtxKCl4b-Mfw,70
|
|
136
136
|
epyt_flow/visualization/scenario_visualizer.py,sha256=vkP0J_OfjvePUz_HehXJkH4CGKR3chAHe_UTx4hQ6XI,57860
|
|
137
|
-
epyt_flow/visualization/visualization_utils.py,sha256
|
|
138
|
-
epyt_flow-0.14.
|
|
139
|
-
epyt_flow-0.14.
|
|
140
|
-
epyt_flow-0.14.
|
|
141
|
-
epyt_flow-0.14.
|
|
142
|
-
epyt_flow-0.14.
|
|
137
|
+
epyt_flow/visualization/visualization_utils.py,sha256=-_Hs3FKQz--iVJ10ZeEv1Co9OSbayZmHjxyhKsnzalE,27629
|
|
138
|
+
epyt_flow-0.14.2.dist-info/licenses/LICENSE,sha256=YRJC2kcAhMlpEeHwUF0lzE-GRXLFyAjXNErI8L5UwYk,1071
|
|
139
|
+
epyt_flow-0.14.2.dist-info/METADATA,sha256=P3IAnVg0LiPBE2I2zfOlLGudlNwQzLjERE3vMH1TIPg,9713
|
|
140
|
+
epyt_flow-0.14.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
141
|
+
epyt_flow-0.14.2.dist-info/top_level.txt,sha256=Wh_kd7TRL8ownCw3Y3dxx-9C0iTSk6wNauv_NX9JcrY,10
|
|
142
|
+
epyt_flow-0.14.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|