示例#1
0
    def _repr_html_(self, layer_index="", highlevelgraph_key=""):
        if highlevelgraph_key != "":
            shortname = key_split(highlevelgraph_key)
        elif hasattr(self, "name"):
            shortname = key_split(self.name)
        else:
            shortname = self.__class__.__name__

        svg_repr = ""
        if (self.collection_annotations
                and self.collection_annotations.get("type")
                == "dask.array.core.Array"):
            chunks = self.collection_annotations.get("chunks")
            if chunks:
                from dask.array.svg import svg

                svg_repr = svg(chunks)

        return get_template("highlevelgraph_layer.html.j2").render(
            materialized=self.is_materialized(),
            shortname=shortname,
            layer_index=layer_index,
            highlevelgraph_key=highlevelgraph_key,
            info=self.layer_info_dict(),
            svg_repr=svg_repr,
        )
示例#2
0
    def _repr_html_(self):

        chunks = [(s, ) for s in self.data.shape]
        arr_img = svg(chunks)

        table = [
            "<table>",
            "  <thead>",
            "    <tr><td> </td><th> Array </th></tr>",
            "  </thead>",
            "  <tbody>",
            f"    <tr><th> Shape </th><td> {self.data.shape} </td> </tr>",
            f"    <tr><th> Dims </th><td> {self.dims} </td> </tr>",
            "  </tbody>",
            "</table>",
        ]

        attrs_table = [
            "<table>", "<thead><tr><th></th><th>Attributes</th></tr></thead>",
            "<tbody>"
        ]
        for k, v in self.attrs.items():
            attrs_table.append(
                f"<tr><th>{k}</th> <td>{str(v).strip('<>')}</td> </tr>")
        attrs_table.append("</tbody></table>")

        dims_table = [
            "<table>",
            "<thead><tr> <td></td><th>Dimension Scales</th></tr></thead>"
        ]
        for k, v in self.scales.items():
            dims_table.append(
                f"<tr><th>{k}</th> <td>{v.val_start, v.val_step}</td> </tr>")
        dims_table.append("</tbody></table>")

        table = "\n".join(table)

        html = [
            "<table>",
            "<tr>",
            "<td>",
            table,
            *attrs_table,
            *dims_table,
            "</td>",
            "<td>",
            arr_img,
            "</td>",
            "</tr>",
            "</table>",
        ]
        return "\n".join(html)