linerate 2.1.1__py3-none-any.whl → 2.1.3__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.
linerate/solver.py CHANGED
@@ -33,8 +33,9 @@ def bisect(
33
33
  run for :math:`\left\lceil\frac{x_\max - x_\min}{\Delta x}\right\rceil`
34
34
  iterations.
35
35
  invalid_value:
36
- If provided, then this value is used whenever
37
- :math:`\text{sign}(f(\mathbf{x}_\min)) = \text{sign}(f(\mathbf{x}_\max))`.
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.
38
39
 
39
40
  Returns
40
41
  -------
@@ -43,6 +44,8 @@ def bisect(
43
44
  there is a root :math:`x_i \in [\tilde{x}_i - 0.5 \Delta x, \tilde{x}_i + 0.5 \Delta x]`
44
45
  so :math:`f_i(x_i) = 0`.
45
46
  """
47
+ _invalid_value = np.nan if invalid_value is None else invalid_value
48
+
46
49
  if not np.all(np.isfinite(xmin)) or not np.all(np.isfinite(xmax)):
47
50
  raise ValueError("xmin and xmax must be finite.")
48
51
  interval = np.max(np.abs(xmax - xmin))
@@ -56,9 +59,10 @@ def bisect(
56
59
  "f(xmin) and f(xmax) have the same sign. Consider increasing the search interval."
57
60
  )
58
61
  elif isinstance(invalid_mask, bool) and invalid_mask:
59
- return invalid_value # type: ignore
62
+ return _invalid_value
60
63
 
61
- while interval > tolerance:
64
+ nan_mask = np.isnan(f_left) | np.isnan(f_right)
65
+ while interval > tolerance and not np.all(nan_mask):
62
66
  xmid = 0.5 * (xmax + xmin)
63
67
  interval *= 0.5
64
68
  f_mid = f(xmid)
@@ -69,7 +73,10 @@ def bisect(
69
73
  f_left = np.where(mask, f_mid, f_left)
70
74
  f_right = np.where(mask, f_right, f_mid)
71
75
 
72
- out = np.where(invalid_mask, invalid_value, 0.5 * (xmax + xmin)) # type: ignore
76
+ nan_mask = np.isnan(f_left) | np.isnan(f_right)
77
+
78
+ out = np.where(invalid_mask, _invalid_value, 0.5 * (xmax + xmin))
79
+ out = np.where(nan_mask, np.nan, out)
73
80
  return out
74
81
 
75
82
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: linerate
3
- Version: 2.1.1
3
+ Version: 2.1.3
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
@@ -15,7 +15,7 @@ Dynamic: license-file
15
15
  # Overview
16
16
 
17
17
  A package containing functionality to compute ampacity line ratings for overhead lines.
18
- Currently, the package only contains equations from CIGRE TB 601.
18
+ The package contains equations from CIGRE TB 601, CIGRE TB 207 and IEEE738.
19
19
 
20
20
  ## Installation
21
21
 
@@ -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=LipfG8EYKCCYn9npyVMdbS1F_6uarC6Lcl5l-WqPdUM,6424
4
+ linerate/solver.py,sha256=OaaTUBii7pTPTQMqpePNRhheSpLCOd0zjkspuaeUads,6665
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
@@ -30,8 +30,8 @@ linerate/models/cigre207.py,sha256=FqeSkVzcsf8YIPuyxN0o3svrEp73vIAb42ylnQU_pBQ,5
30
30
  linerate/models/cigre601.py,sha256=HuwAEsRtWdN5oG0AZqCISnww8ILFGdvk8IfrzLQ_nf0,7508
31
31
  linerate/models/ieee738.py,sha256=0o1rEjHhHUgCaK0PyBHBXvFCDs-c9HIF91uUP-VaLAg,4291
32
32
  linerate/models/thermal_model.py,sha256=SUeUrjxJaV4muoAiYNR-Ne-1vQspWCPsoJys6bP6pP8,10997
33
- linerate-2.1.1.dist-info/licenses/LICENSE,sha256=HDUtv1ujna13BmYSP7JtGGsG5kGPAaZY2C2qJrANAOo,1059
34
- linerate-2.1.1.dist-info/METADATA,sha256=o89E7Tp8kKzX5-LWFu0HnnS2_pdpoHI4RLldJSNpkNo,4275
35
- linerate-2.1.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
36
- linerate-2.1.1.dist-info/top_level.txt,sha256=xHXGAzhQ04AqJCM-MG30tP_me8vBQ9PMlRWsbMLJdgE,9
37
- linerate-2.1.1.dist-info/RECORD,,
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,,