Beispiel #1
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))
Beispiel #2
0
    def test_to_xml(self):
        pyhrf.verbose.set_verbosity(0)
        d = Dummy2()
        n = UiNode.from_py_object('dummy', d)

        xml = n.to_xml()

        if pyhrf.verbose.verbosity > 0:
            print 'xml:'
            print xml
Beispiel #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)
Beispiel #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)
Beispiel #5
0
    def test_from_xml(self):
        pyhrf.verbose.set_verbosity(0)

        d = Dummy2(p=56)
        n = UiNode.from_py_object('dummy', d)

        if pyhrf.verbose.verbosity > 0:
            print 'n:'
            print n.log()
            print ''

        xml = n.to_xml()

        if pyhrf.verbose.verbosity > 0:
            print 'xml:'
            print xml

        n2 = UiNode.from_xml(xml)

        if pyhrf.verbose.verbosity > 0:
            print 'n2:'
            print n2.log()
            print ''
Beispiel #6
0
    def test_xml_io(self):
        pyhrf.verbose.set_verbosity(0)

        info = {'test':53}
        treatment = Treatment(FmriData(func_file='blah.nii'),
                              Analyser(nb_iterations=345),
                              info=info)

        root_node = treatment.to_ui_node('treatment')

        if pyhrf.verbose.verbosity > 0:
            print 'root_node:'
            print root_node.log()


        sxml = root_node.to_xml()

        if pyhrf.verbose.verbosity > 0:

            print 'sxml:'
            print sxml
            print ''


            print 'from_xml ...'
        root_node2 = UiNode.from_xml(sxml)

        if pyhrf.verbose.verbosity > 0:

            print 'root_node2:'
            print root_node2.log()
            print ''

        treatment2 = Treatment.from_ui_node(root_node2)

        if pyhrf.verbose.verbosity > 0:

            print 'treatment2:'
            print treatment2
Beispiel #7
0
    def test_serialize_init_obj(self):
        d = Dummy2()
        s = UiNode._serialize_init_obj(d.__init__)
        f = UiNode._unserialize_init_obj(s)

        self.assertEqual(d.__class__, f)
Beispiel #8
0
 def from_xml(self, xml):
     from pyhrf.sandbox.design_and_ui import UiNode
     return Initable.from_ui_node(UiNode.from_xml(xml))