@@ -1081,7 +1081,7 @@ def test_signed_distance(self):
10811081 max_v = np .max (self .v1 , axis = 0 )
10821082 n = 16
10831083 g = np .mgrid [min_v [0 ]:max_v [0 ]:complex (n ), min_v [1 ]:max_v [1 ]:complex (n ), min_v [2 ]:max_v [2 ]:complex (n )]
1084- p = np .vstack (map (np .ravel , g )).T
1084+ p = np .vstack (list ( map (np .ravel , g ) )).T
10851085 s , i , c = igl .signed_distance (p , self .v1 , self .f1 )
10861086
10871087 self .assertEqual (s .shape [0 ], p .shape [0 ])
@@ -2029,6 +2029,21 @@ def test_connected_components(self):
20292029 self .assertTrue (k .dtype == self .f1 .dtype )
20302030
20312031 self .assertTrue (c .shape [0 ] == a .shape [0 ])
2032+
2033+ def test_pso (self ):
2034+ def banana (x ):
2035+ x1 = x [0 ]
2036+ x2 = x [1 ]
2037+ return x1 ** 4 - 2 * x2 * x1 ** 2 + x2 ** 2 + x1 ** 2 - 2 * x1 + 5
2038+
2039+ lb = np .array ([- 3.0 , - 1.0 ])
2040+ ub = np .array ([2.0 , 6.0 ])
2041+
2042+ fopt , xopt = igl .pso (banana , lb , ub , max_iters = 10 , population = 10 )
2043+
2044+ self .assertTrue (xopt .flags .c_contiguous )
2045+ self .assertTrue (xopt .dtype == lb .dtype )
2046+ self .assertTrue (xopt .shape == (2 , ))
20322047
20332048
20342049if __name__ == '__main__' :
0 commit comments