hydraflow 0.12.1__py3-none-any.whl → 0.12.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.
- hydraflow/executor/parser.py +63 -23
- {hydraflow-0.12.1.dist-info → hydraflow-0.12.2.dist-info}/METADATA +1 -1
- {hydraflow-0.12.1.dist-info → hydraflow-0.12.2.dist-info}/RECORD +6 -6
- {hydraflow-0.12.1.dist-info → hydraflow-0.12.2.dist-info}/WHEEL +0 -0
- {hydraflow-0.12.1.dist-info → hydraflow-0.12.2.dist-info}/entry_points.txt +0 -0
- {hydraflow-0.12.1.dist-info → hydraflow-0.12.2.dist-info}/licenses/LICENSE +0 -0
hydraflow/executor/parser.py
CHANGED
@@ -48,7 +48,7 @@ def to_number(x: str) -> int | float:
|
|
48
48
|
return int(x)
|
49
49
|
|
50
50
|
|
51
|
-
def
|
51
|
+
def count_decimal_digits(x: str) -> int:
|
52
52
|
"""Count decimal places in a string.
|
53
53
|
|
54
54
|
Examine a string representing a number and returns the count
|
@@ -62,13 +62,13 @@ def count_decimal_places(x: str) -> int:
|
|
62
62
|
int: The number of decimal places.
|
63
63
|
|
64
64
|
Examples:
|
65
|
-
>>>
|
65
|
+
>>> count_decimal_digits("1")
|
66
66
|
0
|
67
|
-
>>>
|
67
|
+
>>> count_decimal_digits("-1.2")
|
68
68
|
1
|
69
|
-
>>>
|
69
|
+
>>> count_decimal_digits("1.234")
|
70
70
|
3
|
71
|
-
>>>
|
71
|
+
>>> count_decimal_digits("-1.234e-10")
|
72
72
|
3
|
73
73
|
|
74
74
|
"""
|
@@ -82,6 +82,50 @@ def count_decimal_places(x: str) -> int:
|
|
82
82
|
return len(decimal_part)
|
83
83
|
|
84
84
|
|
85
|
+
def count_integer_digits(num_str: str) -> int:
|
86
|
+
"""Count the number of digits in the integer part of a number.
|
87
|
+
|
88
|
+
Consider only the integer part of a number, even if it is in
|
89
|
+
scientific notation.
|
90
|
+
|
91
|
+
Args:
|
92
|
+
num_str (str): The string representing a number.
|
93
|
+
|
94
|
+
Returns:
|
95
|
+
int: The number of digits in the integer part of a number.
|
96
|
+
(excluding the sign)
|
97
|
+
|
98
|
+
Examples:
|
99
|
+
>>> count_integer_digits("123")
|
100
|
+
3
|
101
|
+
>>> count_integer_digits("-123.45")
|
102
|
+
3
|
103
|
+
>>> count_integer_digits("+0.00123")
|
104
|
+
1
|
105
|
+
>>> count_integer_digits("-1.200")
|
106
|
+
1
|
107
|
+
>>> count_integer_digits("+1.20e3")
|
108
|
+
1
|
109
|
+
>>> count_integer_digits("-0.120e-3")
|
110
|
+
1
|
111
|
+
>>> count_integer_digits(".123")
|
112
|
+
0
|
113
|
+
|
114
|
+
"""
|
115
|
+
if num_str.startswith(("+", "-")):
|
116
|
+
num_str = num_str[1:]
|
117
|
+
|
118
|
+
if "e" in num_str.lower():
|
119
|
+
num_str = num_str.lower().split("e")[0]
|
120
|
+
|
121
|
+
if "." in num_str:
|
122
|
+
int_part = num_str.split(".")[0]
|
123
|
+
if not int_part:
|
124
|
+
return 0
|
125
|
+
return len(int_part)
|
126
|
+
return len(num_str)
|
127
|
+
|
128
|
+
|
85
129
|
def is_number(x: str) -> bool:
|
86
130
|
"""Check if a string represents a valid number.
|
87
131
|
|
@@ -158,26 +202,18 @@ def _arange(start: float, step: float, stop: float) -> list[float]:
|
|
158
202
|
if step == 0:
|
159
203
|
raise ValueError("Step cannot be zero")
|
160
204
|
|
161
|
-
epsilon = 1e-
|
162
|
-
|
163
|
-
decimal_places = max(
|
164
|
-
count_decimal_places(str(start)),
|
165
|
-
count_decimal_places(str(step)),
|
166
|
-
count_decimal_places(str(stop)),
|
167
|
-
)
|
205
|
+
epsilon = min(abs(start), abs(stop)) * 1e-5
|
168
206
|
|
169
207
|
result = []
|
170
208
|
current = start
|
171
209
|
|
172
210
|
if step > 0:
|
173
211
|
while current <= stop + epsilon:
|
174
|
-
|
175
|
-
result.append(rounded)
|
212
|
+
result.append(current)
|
176
213
|
current += step
|
177
214
|
else:
|
178
215
|
while current >= stop - epsilon:
|
179
|
-
|
180
|
-
result.append(rounded)
|
216
|
+
result.append(current)
|
181
217
|
current += step
|
182
218
|
|
183
219
|
return result
|
@@ -344,8 +380,9 @@ def collect_values(arg: str) -> list[str]:
|
|
344
380
|
if all(isinstance(x, int) for x in rng):
|
345
381
|
values = [str(x) for x in _arange(*rng)]
|
346
382
|
else:
|
347
|
-
n = max(*(
|
348
|
-
|
383
|
+
n = max(*(count_integer_digits(x) for x in arg.split(":")))
|
384
|
+
m = max(*(count_decimal_digits(x) for x in arg.split(":")))
|
385
|
+
values = [f"{x:.{n + m}g}" for x in _arange(*rng)]
|
349
386
|
|
350
387
|
return [add_exponent(x, exponent) for x in values]
|
351
388
|
|
@@ -415,8 +452,9 @@ def split(arg: str) -> list[str]:
|
|
415
452
|
def expand_values(arg: str, suffix: str = "") -> Iterator[str]:
|
416
453
|
"""Expand a string argument into a list of values.
|
417
454
|
|
418
|
-
Take a string containing comma-separated values or ranges
|
419
|
-
of all individual values.
|
455
|
+
Take a string containing comma-separated values or ranges
|
456
|
+
and return a list of all individual values.
|
457
|
+
Handle numeric ranges and special characters.
|
420
458
|
|
421
459
|
Args:
|
422
460
|
arg (str): The argument to expand.
|
@@ -439,7 +477,8 @@ def split_arg(arg: str) -> tuple[str, str, str]:
|
|
439
477
|
arg (str): The argument to split.
|
440
478
|
|
441
479
|
Returns:
|
442
|
-
tuple[str, str, str]: A tuple containing the key,
|
480
|
+
tuple[str, str, str]: A tuple containing the key,
|
481
|
+
suffix, and value.
|
443
482
|
|
444
483
|
"""
|
445
484
|
if "=" not in arg:
|
@@ -458,8 +497,9 @@ def split_arg(arg: str) -> tuple[str, str, str]:
|
|
458
497
|
def collect_arg(arg: str) -> str:
|
459
498
|
"""Collect a string of expanded key-value pairs.
|
460
499
|
|
461
|
-
Take a key-value pair argument and concatenates all expanded
|
462
|
-
returning a single string suitable for
|
500
|
+
Take a key-value pair argument and concatenates all expanded
|
501
|
+
values with commas, returning a single string suitable for
|
502
|
+
command-line usage.
|
463
503
|
|
464
504
|
Args:
|
465
505
|
arg (str): The argument to collect.
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: hydraflow
|
3
|
-
Version: 0.12.
|
3
|
+
Version: 0.12.2
|
4
4
|
Summary: Hydraflow integrates Hydra and MLflow to manage and track machine learning experiments.
|
5
5
|
Project-URL: Documentation, https://daizutabi.github.io/hydraflow/
|
6
6
|
Project-URL: Source, https://github.com/daizutabi/hydraflow
|
@@ -16,9 +16,9 @@ hydraflow/executor/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuF
|
|
16
16
|
hydraflow/executor/conf.py,sha256=2dv6_PlsynRmia-fGZlmBEVt8GopT0f32N13qY7tYnM,402
|
17
17
|
hydraflow/executor/io.py,sha256=yZMcBVmAbPZZ82cAXhgiJfj9p8WvHmzOCMBg_vtEVek,1509
|
18
18
|
hydraflow/executor/job.py,sha256=IL7ek0Vwa3Bl_gANq0wCbldNCUclo8YBckeEeO6W6xg,4852
|
19
|
-
hydraflow/executor/parser.py,sha256=
|
20
|
-
hydraflow-0.12.
|
21
|
-
hydraflow-0.12.
|
22
|
-
hydraflow-0.12.
|
23
|
-
hydraflow-0.12.
|
24
|
-
hydraflow-0.12.
|
19
|
+
hydraflow/executor/parser.py,sha256=_Rfund3FDgrXitTt_znsTpgEtMDqZ_ICynaB_Zje14Q,14561
|
20
|
+
hydraflow-0.12.2.dist-info/METADATA,sha256=8i5Ejzdakw6X9t6ddhuNGW0DaeQT9N3-xVCWrmX1QfQ,4549
|
21
|
+
hydraflow-0.12.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
22
|
+
hydraflow-0.12.2.dist-info/entry_points.txt,sha256=XI0khPbpCIUo9UPqkNEpgh-kqK3Jy8T7L2VCWOdkbSM,48
|
23
|
+
hydraflow-0.12.2.dist-info/licenses/LICENSE,sha256=IGdDrBPqz1O0v_UwCW-NJlbX9Hy9b3uJ11t28y2srmY,1062
|
24
|
+
hydraflow-0.12.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|