Пример #1
0
    def test_from_ui_node_basic(self):
        d = Dummy('a', 1.3, 5, np.arange(5), Dummy2('rr'))
        root_node = d.to_ui_node('dummy')
        d2 = Initable.from_ui_node(root_node)

        self.assertEqual(d.string_p, d2.string_p)
        self.assertEqual(d.float_p, d2.float_p)
        self.assertEqual(d.int_p, d2.int_p)
        assert_array_equal(d.array_p, d2.array_p)
Пример #2
0
    def test_from_numpy1D(self):

        n = UiNode.from_py_object('n', np.arange(5))
        if 0:
            print 'n:'
            print n.log()

        o = Initable.from_ui_node(n)
        assert_array_equal(o, np.arange(5))
Пример #3
0
    def test_from_numpy_scalar(self):

        a = np.float128(1.2)
        n = UiNode.from_py_object('a', a)
        if 0:
            print 'n:'
            print n.log()

        o = Initable.from_ui_node(n)
        self.assertEqual(o, a)
        self.assertEqual(o.dtype, a.dtype)
Пример #4
0
    def test_from_numpyND(self):

        sh = (2,3,4,5)
        a = np.arange(np.prod(sh)).reshape(sh)
        n = UiNode.from_py_object('n', a)
        if 0:
            print 'n:'
            print n.log()

        o = Initable.from_ui_node(n)
        assert_array_equal(o, a)
Пример #5
0
 def from_xml(self, xml):
     from pyhrf.sandbox.design_and_ui import UiNode
     return Initable.from_ui_node(UiNode.from_xml(xml))