pytmpinv 2.5.0__tar.gz → 2.6.0__tar.gz
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.
Potentially problematic release.
This version of pytmpinv might be problematic. Click here for more details.
- {pytmpinv-2.5.0/pytmpinv.egg-info → pytmpinv-2.6.0}/PKG-INFO +1 -1
- {pytmpinv-2.5.0 → pytmpinv-2.6.0}/pyproject.toml +1 -1
- {pytmpinv-2.5.0 → pytmpinv-2.6.0/pytmpinv.egg-info}/PKG-INFO +1 -1
- {pytmpinv-2.5.0 → pytmpinv-2.6.0}/tmpinv/__init__.py +1 -1
- {pytmpinv-2.5.0 → pytmpinv-2.6.0}/tmpinv/tmpinv.py +15 -13
- {pytmpinv-2.5.0 → pytmpinv-2.6.0}/LICENSE +0 -0
- {pytmpinv-2.5.0 → pytmpinv-2.6.0}/README.md +0 -0
- {pytmpinv-2.5.0 → pytmpinv-2.6.0}/pytmpinv.egg-info/SOURCES.txt +0 -0
- {pytmpinv-2.5.0 → pytmpinv-2.6.0}/pytmpinv.egg-info/dependency_links.txt +0 -0
- {pytmpinv-2.5.0 → pytmpinv-2.6.0}/pytmpinv.egg-info/requires.txt +0 -0
- {pytmpinv-2.5.0 → pytmpinv-2.6.0}/pytmpinv.egg-info/top_level.txt +0 -0
- {pytmpinv-2.5.0 → pytmpinv-2.6.0}/setup.cfg +0 -0
|
@@ -168,14 +168,14 @@ def TMPinvSolve(
|
|
|
168
168
|
arguments are ignored in the reduced model given its replacement of `S`.
|
|
169
169
|
"""
|
|
170
170
|
# (m), (p) Process the parameters, assert conformity, and get dimensions
|
|
171
|
-
if
|
|
171
|
+
if b_row is None or b_col is None:
|
|
172
172
|
raise TMPinvInputError("Both b_row and b_col must be provided.")
|
|
173
|
-
if
|
|
173
|
+
if len(b_row) < 2 or len(b_col) < 2:
|
|
174
174
|
raise TMPinvInputError("Minimum length for b_row and b_col is 2.")
|
|
175
|
-
if not np.isfinite(b_row).all() or not np.isfinite(b_col).all():
|
|
176
|
-
raise TMPinvInputError("b_row and b_col must not contain inf or NaN.")
|
|
177
175
|
b_row = np.asarray(b_row, dtype=np.float64).reshape(-1, 1)
|
|
178
176
|
b_col = np.asarray(b_col, dtype=np.float64).reshape(-1, 1)
|
|
177
|
+
if not np.isfinite(b_row).all() or not np.isfinite(b_col).all():
|
|
178
|
+
raise TMPinvInputError("b_row and b_col must not contain inf or NaN.")
|
|
179
179
|
m = b_row.shape[0] * i
|
|
180
180
|
p = b_col.shape[0] * j
|
|
181
181
|
if S is not None:
|
|
@@ -269,8 +269,8 @@ def TMPinvSolve(
|
|
|
269
269
|
X_true = np.full((1*m, p), np.nan, dtype=np.float64)
|
|
270
270
|
for idx, row in enumerate(M):
|
|
271
271
|
col = np.argmax(row)
|
|
272
|
-
r, c =
|
|
273
|
-
X_true[r, c] = b_val.ravel()[idx]
|
|
272
|
+
r, c = col % m, col // m # M has m * p columns
|
|
273
|
+
X_true[r, c] = b_val.ravel(order='F')[idx]
|
|
274
274
|
if kwargs.get("b_lim") is not None:
|
|
275
275
|
X_lim = np.full((2*m, p), np.nan, dtype=np.float64)
|
|
276
276
|
l_idx = (lambda x: kwargs["b_lim"].shape[0] if not x.size else
|
|
@@ -278,13 +278,13 @@ def TMPinvSolve(
|
|
|
278
278
|
if l_idx > 0: # upper bounds
|
|
279
279
|
for idx, row in enumerate(kwargs["C_lim"][:l_idx,:]):
|
|
280
280
|
col = np.argmax(row)
|
|
281
|
-
r, c =
|
|
282
|
-
X_lim[ r, c] = kwargs["b_lim"].ravel()[ idx]
|
|
281
|
+
r, c = col % m, col // m
|
|
282
|
+
X_lim[ r, c] = kwargs["b_lim"].ravel(order='F')[ idx]
|
|
283
283
|
if l_idx < kwargs["b_lim"].shape[0]: # lower bounds
|
|
284
284
|
for idx, row in enumerate(kwargs["C_lim"][l_idx:,:]):
|
|
285
285
|
col = np.argmax(row)
|
|
286
|
-
r, c =
|
|
287
|
-
X_lim[m+r, c] = kwargs["b_lim"].ravel()[l_idx+idx]
|
|
286
|
+
r, c = col % m, col // m
|
|
287
|
+
X_lim[m+r, c] = kwargs["b_lim"].ravel(order='F')[l_idx+idx]
|
|
288
288
|
if S is not None and np.any(S[: S.shape[0] if kwargs.get("b_lim")
|
|
289
289
|
is None else -kwargs["b_lim"].shape[0],:] != 0):
|
|
290
290
|
warnings.warn("User-provided S is ignored in the reduced model.",
|
|
@@ -306,7 +306,7 @@ def TMPinvSolve(
|
|
|
306
306
|
subset = np.vstack([
|
|
307
307
|
X_lim[ m_start: m_end, p_start:p_end],
|
|
308
308
|
X_lim[m+m_start:m+m_end, p_start:p_end]
|
|
309
|
-
]).ravel()
|
|
309
|
+
]).ravel(order='F')
|
|
310
310
|
non_empty = ~np.isnan(subset)
|
|
311
311
|
if non_empty.any():
|
|
312
312
|
b_subset.append(subset[non_empty].reshape(-1, 1))
|
|
@@ -326,8 +326,11 @@ def TMPinvSolve(
|
|
|
326
326
|
np.hstack([np.zeros((S.shape[0],
|
|
327
327
|
S_subset.shape[1])),
|
|
328
328
|
S]) ])
|
|
329
|
+
S_subset = S_subset[:, ~np.all(S_subset == 0, axis=0)]
|
|
329
330
|
if M is not None:
|
|
330
|
-
subset = X_true[m_start:m_end, p_start:p_end].ravel(
|
|
331
|
+
subset = X_true[m_start:m_end, p_start:p_end].ravel(
|
|
332
|
+
order='F'
|
|
333
|
+
)
|
|
331
334
|
non_empty = ~np.isnan(subset)
|
|
332
335
|
if non_empty.any():
|
|
333
336
|
b_subset.append(subset[non_empty].reshape(-1, 1))
|
|
@@ -448,7 +451,6 @@ def tmpinv(
|
|
|
448
451
|
break
|
|
449
452
|
else:
|
|
450
453
|
M, b_val = kwargs.get("M"), kwargs.get("b_val")
|
|
451
|
-
|
|
452
454
|
result = TMPinvSolve(*args, b_lim=(b_lim[finite_rows, :]),
|
|
453
455
|
b_val=b_val,
|
|
454
456
|
C_lim=(C_lim[finite_rows, :]),
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|