Example #1
0
 def test_clip(self):
     tup = ((-1, 10), (-3, 4), (2, 5))
     array = numpy.array([[-10, 0, 0], [11, 0, 0], [0, 11, 0], [11, 11,
                                                                11]])
     bounds = Bounds.from_tuples(tup)
     clipped = bounds.clip(array)
     target = numpy.array([[-1, 0, 2], [10, 0, 2], [0, 4, 2], [10, 4, 5]])
     assert numpy.allclose(clipped, target), (clipped, target)
Example #2
0
 def test_from_tuples(self):
     tup = ((-1, 2), (-3, 4), (2, 5))
     bounds = Bounds.from_tuples(tup)
     assert (bounds.low == numpy.array([-1, -3, 2])).all()
     assert (bounds.high == numpy.array([2, 4, 5])).all()