File tree 1 file changed +22
-2
lines changed
1 file changed +22
-2
lines changed Original file line number Diff line number Diff line change
1
+ from pyomo .common .dependencies import (
2
+ numpy as np ,
3
+ numpy_available ,
4
+ pandas as pd ,
5
+ pandas_available ,
6
+ )
7
+
8
+ import pyomo .common .unittest as unittest
9
+ from pyomo .contrib .doe import DesignOfExperiments
10
+ from pyomo .contrib .doe .doe import compute_FIM_full_factorial , _SMALL_TOLERANCE_IMG
11
+ from pyomo .opt import SolverFactory
12
+
13
+
14
+ @unittest .skipIf (not numpy_available , "Numpy is not available" )
15
+ class TestFullFactrialMetrics (unittest .TestCase ):
16
+ def test_compute_FIM_full_factorial_metrics (self ):
17
+ # Create a sample Fisher Information Matrix (FIM)
18
+ FIM = np .array ([[4 , 2 ], [2 , 3 ]])
19
+
20
+
21
+ # ======================================================================
1
22
import numpy as np
2
23
3
24
# from pyomo.common.dependencies import numpy as np
4
25
from pyomo .contrib .doe .doe import _SMALL_TOLERANCE_IMG
5
- import pytest
6
26
7
27
8
28
def compute_FIM_metrics (FIM ):
@@ -14,7 +34,7 @@ def compute_FIM_metrics(FIM):
14
34
E_vals , E_vecs = np .linalg .eig (FIM ) # Grab eigenvalues and eigenvectors
15
35
16
36
E_ind = np .argmin (E_vals .real ) # Grab index of minima to check imaginary
17
- IMG_THERESHOLD = 1e-6 # Instead of creating a new constant, use `SMALL_DIFF` by importiing it form `doe.py`
37
+
18
38
# Warn the user if there is a ``large`` imaginary component (should not be)
19
39
if abs (E_vals .imag [E_ind ]) > _SMALL_TOLERANCE_IMG :
20
40
print (
You can’t perform that action at this time.
0 commit comments