linerate 2.1.3__py3-none-any.whl → 2.2.0__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.
@@ -198,6 +198,7 @@ class ThermalModel(ABC):
198
198
  min_ampacity: Ampere = 0,
199
199
  max_ampacity: Ampere = 5000,
200
200
  tolerance: float = 1.0,
201
+ accept_invalid_values: bool = False,
201
202
  ) -> Ampere:
202
203
  r"""Use the bisection method to compute the steady-state thermal rating (ampacity).
203
204
 
@@ -216,6 +217,9 @@ class ThermalModel(ABC):
216
217
  bisection iterations will stop once the numerical ampacity uncertainty is below
217
218
  :math:`\Delta I`. The bisection method will run for
218
219
  :math:`\left\lceil\frac{I_\text{min} - I_\text{min}}{\Delta I}\right\rceil` iterations.
220
+ accept_invalid_values:
221
+ If True, np.nan is returned whenever the current cannot be found within the provided
222
+ search interval. If False, a ValueError will be raised instead.
219
223
 
220
224
  Returns
221
225
  -------
@@ -228,6 +232,7 @@ class ThermalModel(ABC):
228
232
  min_ampacity=min_ampacity,
229
233
  max_ampacity=max_ampacity,
230
234
  tolerance=tolerance,
235
+ accept_invalid_values=accept_invalid_values,
231
236
  )
232
237
  n = self.span.num_conductors
233
238
  return I * n
linerate/solver.py CHANGED
@@ -1,5 +1,5 @@
1
1
  from functools import partial
2
- from typing import Callable, Optional
2
+ from typing import Callable
3
3
 
4
4
  import numpy as np
5
5
 
@@ -13,7 +13,7 @@ def bisect(
13
13
  xmin: FloatOrFloatArray,
14
14
  xmax: FloatOrFloatArray,
15
15
  tolerance: float,
16
- invalid_value: Optional[float] = None,
16
+ accept_invalid_values: bool = False,
17
17
  ) -> FloatOrFloatArray:
18
18
  r"""Compute the roots of a function using a vectorized bisection method.
19
19
 
@@ -32,10 +32,10 @@ def bisect(
32
32
  bounded within an interval of size :math:`\Delta x` or less. The bisection method will
33
33
  run for :math:`\left\lceil\frac{x_\max - x_\min}{\Delta x}\right\rceil`
34
34
  iterations.
35
- invalid_value:
36
- This value is used whenever
37
- :math:`\text{sign}(f(\mathbf{x}_\min)) = \text{sign}(f(\mathbf{x}_\max))`. If not provided
38
- np.nan is used.
35
+ accept_invalid_values:
36
+ If True, np.nan is returned whenever
37
+ :math:`\text{sign}(f(\mathbf{x}_\min)) = \text{sign}(f(\mathbf{x}_\max))`
38
+ If False, a ValueError will be raised.
39
39
 
40
40
  Returns
41
41
  -------
@@ -44,7 +44,7 @@ def bisect(
44
44
  there is a root :math:`x_i \in [\tilde{x}_i - 0.5 \Delta x, \tilde{x}_i + 0.5 \Delta x]`
45
45
  so :math:`f_i(x_i) = 0`.
46
46
  """
47
- _invalid_value = np.nan if invalid_value is None else invalid_value
47
+ _invalid_value = np.nan
48
48
 
49
49
  if not np.all(np.isfinite(xmin)) or not np.all(np.isfinite(xmax)):
50
50
  raise ValueError("xmin and xmax must be finite.")
@@ -54,7 +54,7 @@ def bisect(
54
54
  f_right = f(xmax)
55
55
 
56
56
  invalid_mask = np.sign(f_left) == np.sign(f_right)
57
- if np.any(invalid_mask) and invalid_value is None:
57
+ if np.any(invalid_mask) and not accept_invalid_values:
58
58
  raise ValueError(
59
59
  "f(xmin) and f(xmax) have the same sign. Consider increasing the search interval."
60
60
  )
@@ -125,7 +125,7 @@ def compute_conductor_ampacity(
125
125
  min_ampacity: Ampere = 0,
126
126
  max_ampacity: Ampere = 5_000,
127
127
  tolerance: float = 1, # Ampere
128
- invalid_value=None,
128
+ accept_invalid_values: bool = False,
129
129
  ) -> Ampere:
130
130
  r"""Use the bisection method to compute the steady-state thermal rating (ampacity).
131
131
 
@@ -148,10 +148,9 @@ def compute_conductor_ampacity(
148
148
  bisection iterations will stop once the numerical ampacity uncertainty is below
149
149
  :math:`\Delta I`. The bisection method will run for
150
150
  :math:`\left\lceil\frac{I_\text{max} - I_\text{min}}{\Delta I}\right\rceil` iterations.
151
- invalid_value:
152
- if the optimization problem is invalid, this value is returned instead of an error.
153
- Suggested value: 0 for 0-ampacity when max_conductor_temperature is exceeded for all
154
- ampacities.
151
+ accept_invalid_values:
152
+ If True, np.nan is returned whenever the current cannot be found within the provided
153
+ search interval. If False, a ValueError will be raised instead.
155
154
 
156
155
  Returns
157
156
  -------
@@ -160,4 +159,6 @@ def compute_conductor_ampacity(
160
159
  """
161
160
  f = partial(heat_balance, max_conductor_temperature)
162
161
 
163
- return bisect(f, min_ampacity, max_ampacity, tolerance, invalid_value=invalid_value)
162
+ return bisect(
163
+ f, min_ampacity, max_ampacity, tolerance, accept_invalid_values=accept_invalid_values
164
+ )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: linerate
3
- Version: 2.1.3
3
+ Version: 2.2.0
4
4
  Summary: Library for computing line ampacity ratings for overhead lines
5
5
  Author-email: Statnett Datascience <Datascience.Drift@Statnett.no>, Yngve Mardal Moe <yngve.m.moe@gmail.com>
6
6
  Requires-Python: >=3.9
@@ -1,7 +1,7 @@
1
1
  linerate/__init__.py,sha256=456XlD7NFaT6nTM5k8qYpaf2Bg2ITYhh5wzL0CQRiDc,221
2
2
  linerate/model.py,sha256=SUj4NunXdCctezpGeS62OQNmFGf5IKO2plYQlsGJLow,651
3
3
  linerate/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- linerate/solver.py,sha256=OaaTUBii7pTPTQMqpePNRhheSpLCOd0zjkspuaeUads,6665
4
+ linerate/solver.py,sha256=UjZp7uKZjlzku6kICTreJML2JVyo7wAXh3qd8bJKYL8,6651
5
5
  linerate/types.py,sha256=HEon3gQU0dX0ZtTxhs4kOhL3jTamXoC3oBtX5b2-Piw,7595
6
6
  linerate/units.py,sha256=nNU9SQ-eeUCtmbttKZ9IlNzomF8wwUPPwmixXjfvKhI,1476
7
7
  linerate/equations/__init__.py,sha256=cNvISWCp5TbXv4gZ8SWPf0pICRpwDzLSaOxYy5lftsU,464
@@ -29,9 +29,9 @@ linerate/models/Cigre207.md,sha256=FCKspzRL5zX9kH3gj1D78F6eUHJeET9yuvrhGs-PQBg,1
29
29
  linerate/models/cigre207.py,sha256=FqeSkVzcsf8YIPuyxN0o3svrEp73vIAb42ylnQU_pBQ,5477
30
30
  linerate/models/cigre601.py,sha256=HuwAEsRtWdN5oG0AZqCISnww8ILFGdvk8IfrzLQ_nf0,7508
31
31
  linerate/models/ieee738.py,sha256=0o1rEjHhHUgCaK0PyBHBXvFCDs-c9HIF91uUP-VaLAg,4291
32
- linerate/models/thermal_model.py,sha256=SUeUrjxJaV4muoAiYNR-Ne-1vQspWCPsoJys6bP6pP8,10997
33
- linerate-2.1.3.dist-info/licenses/LICENSE,sha256=HDUtv1ujna13BmYSP7JtGGsG5kGPAaZY2C2qJrANAOo,1059
34
- linerate-2.1.3.dist-info/METADATA,sha256=EuetzmcfrIbkOFT7LHUXdlOZMHeqAg6plaR3ujXPlD8,4285
35
- linerate-2.1.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
36
- linerate-2.1.3.dist-info/top_level.txt,sha256=xHXGAzhQ04AqJCM-MG30tP_me8vBQ9PMlRWsbMLJdgE,9
37
- linerate-2.1.3.dist-info/RECORD,,
32
+ linerate/models/thermal_model.py,sha256=Qga5bKnC1sSocYes2XpNHVCvO3_ChXwsdReBEZvcwPo,11303
33
+ linerate-2.2.0.dist-info/licenses/LICENSE,sha256=HDUtv1ujna13BmYSP7JtGGsG5kGPAaZY2C2qJrANAOo,1059
34
+ linerate-2.2.0.dist-info/METADATA,sha256=-qeufq3gGYFZ_cClMqekvfP2iGQerPwgxSLuD4-eeP4,4285
35
+ linerate-2.2.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
36
+ linerate-2.2.0.dist-info/top_level.txt,sha256=xHXGAzhQ04AqJCM-MG30tP_me8vBQ9PMlRWsbMLJdgE,9
37
+ linerate-2.2.0.dist-info/RECORD,,