def test_bad_repn(self):
        repn = list(transforms_nd.registered_transforms.keys())[0]
        self.assertTrue(repn in transforms_nd.registered_transforms)
        transforms_nd.piecewise_nd(_test_tri, _test_values, repn=repn)

        repn = '_bad_repn_'
        self.assertFalse(repn in transforms_nd.registered_transforms)
        with self.assertRaises(ValueError):
            transforms_nd.piecewise_nd(_test_tri, _test_values, repn=repn)
 def test_init(self):
     for key in transforms_nd.registered_transforms:
         for bound in ['lb','ub','eq','bad']:
             args = (_test_tri, _test_values)
             kwds = {'repn': key, 'bound': bound}
             if bound == 'bad':
                 with self.assertRaises(ValueError):
                     transforms_nd.piecewise_nd(*args, **kwds)
             else:
                 p = transforms_nd.piecewise_nd(*args, **kwds)
                 self.assertTrue(
                     isinstance(p, transforms_nd.registered_transforms[key]))
                 self.assertTrue(
                     isinstance(p, TransformedPiecewiseLinearFunctionND))
                 self.assertEqual(p.active, True)
                 self.assertIs(p.parent, None)
 def test_pickle(self):
     for key in transforms_nd.registered_transforms:
         p = transforms_nd.piecewise_nd(_test_tri, _test_values, repn=key)
         self.assertEqual(p.parent, None)
         pup = pickle.loads(pickle.dumps(p))
         self.assertEqual(pup.parent, None)
         b = block()
         b.p = p
         self.assertIs(p.parent, b)
         bup = pickle.loads(pickle.dumps(b))
         pup = bup.p
         self.assertIs(pup.parent, bup)
 def test_type(self):
     for key in transforms_nd.registered_transforms:
         p = transforms_nd.piecewise_nd(_test_tri, _test_values, repn=key)
         self.assertTrue(isinstance(p,
                                    TransformedPiecewiseLinearFunctionND))
         self.assertTrue(
             isinstance(p, transforms_nd.registered_transforms[key]))
         self.assertTrue(isinstance(p, ICategorizedObject))
         self.assertTrue(isinstance(p, IComponent))
         self.assertTrue(isinstance(p, IComponentContainer))
         self.assertTrue(isinstance(p, _ActiveObjectMixin))
         self.assertTrue(isinstance(p, tiny_block))
         self.assertTrue(isinstance(p, IBlockStorage))
class Test_piecewise_nd_list(_TestActiveComponentListBase,
                             unittest.TestCase):
    _container_type = block_list
    _ctype_factory = lambda self:\
                     transforms_nd.piecewise_nd(_test_tri,
                                                _test_values)