Exemple #1
0
    def testImage(self):
        C = numpy.random.rand(50, 50)
        information = pinv(C)
        T = numpy.random.rand(50, 50, 3)

        report = Node("rangefinder")
        report.data("Tx", T[:, :, 0])
        report.data("Ty", T[:, :, 1])
        report.data("Tz", T[:, :, 2])
        cov = report.data("covariance", C)
        report.data("information", information)

        pylab = get_pylab_instance()
        with cov.data_file("plot", MIME_PNG) as f:
            pylab.figure()
            pylab.plot(C)
            pylab.savefig(f)
            pylab.close()

        report.table("results", cols=["One", "Two"], data=[[1, 2], [3, 4]])

        f = report.figure(caption="Covariance and information matrix", cols=3)
        f.sub("covariance", "should default to plot")
        f.sub("covariance/plot", "Same as <-")

        f = report.figure("Tensors", cols=3)
        f.sub("Tx", display="posneg")
        f.sub("Ty", display="posneg")
        f.sub("Tz", display="posneg")

        self.node_serialization_ok(report)
Exemple #2
0
 def setUp(self):
     # n1 -- n2 -- n3 -- n4
     #    \_ n3bis
     self.n1 = Node("n1")
     self.n3bis = self.n1.data("n3", None)
     self.n2 = self.n1.data("n2", None)
     self.n3 = self.n2.data("n3", None)
     self.n4 = self.n3.data("n4", None)
     self.all = [self.n1, self.n2, self.n3, self.n4, self.n3bis]
Exemple #3
0
def node_from_hdf_group_v1(hf, group):
    major = group._v_attrs["reprep_format_version"][0]
    if major != 1:
        raise ValueError("I can oly read v1, not %s" % major)

    nid = group._v_name
    caption = group._v_title
    cgroups = [
        child for child in group._f_listNodes("Group")
        if "reprep_format_version" in child._v_attrs
    ]
    cgroups.sort(key=lambda x: x._v_attrs["reprep_order"])

    children = [node_from_hdf_group_v1(hf, child) for child in cgroups]

    nodetype = group._v_attrs["reprep_node_type"]
    if nodetype == "Node":
        return Node(nid=nid, children=children, caption=caption)

    elif nodetype == "Figure":
        cols = group.ncols.read()
        if cols == 0:
            cols = None
        figure = Figure(nid=nid, caption=caption, cols=cols)
        nsubs = len(group.subfigures._f_listNodes())
        for i in range(nsubs):
            s = group.subfigures._v_children["sub%d" % i]
            sub = SubFigure(
                resource=s.resource.read(),
                image=s.image.read(),
                web_image=s.web_image.read(),
                caption=s.caption.read(),
            )
            figure.subfigures.append(sub)
        figure.children = children
        return figure

    elif nodetype == "Table":
        table_data = group.table_data.read()
        rows = group.rows.read()
        cols = group.cols.read()
        table = Table(nid,
                      data=table_data,
                      cols=cols,
                      rows=rows,
                      caption=caption)
        table.children = children
        return table

    elif nodetype == "DataNode":
        mime, raw_data = read_python_data(group, "data")
        res = DataNode(nid=nid, data=raw_data, mime=mime, caption=caption)
        res.children = children
        return res
    else:
        raise ValueError("Unknown node_type %r" % nodetype)
Exemple #4
0
 def testImageRGB(self):
     rgb = numpy.zeros((4, 4, 3), "uint8")
     report = Node("test")
     report.data_rgb("rgb", rgb)