MCPcopy Create free account
hub / github.com/dask/dask / svg

Function svg

dask/array/svg.py:13–43  ·  view source on GitHub ↗

Convert chunks from Dask Array into an SVG Image Parameters ---------- chunks: tuple size: int Rough size of the image Returns ------- text: An svg string depicting the array as a grid of chunks

(chunks, size=200, **kwargs)

Source from the content-addressed store, hash-verified

11
12@lru_cache(maxsize=512)
13def svg(chunks, size=200, **kwargs):
14 """Convert chunks from Dask Array into an SVG Image
15
16 Parameters
17 ----------
18 chunks: tuple
19 size: int
20 Rough size of the image
21
22 Returns
23 -------
24 text: An svg string depicting the array as a grid of chunks
25 """
26 shape = tuple(map(sum, chunks))
27 if np.isnan(shape).any(): # don't support unknown sizes
28 raise NotImplementedError(
29 "Can't generate SVG with unknown chunk sizes.\n\n"
30 " A possible solution is with x.compute_chunk_sizes()"
31 )
32 if not all(shape):
33 raise NotImplementedError("Can't generate SVG with 0-length dimensions")
34 if len(chunks) == 0:
35 raise NotImplementedError("Can't generate SVG with 0 dimensions")
36 if len(chunks) == 1:
37 return svg_1d(chunks, size=size, **kwargs)
38 elif len(chunks) == 2:
39 return svg_2d(chunks, size=size, **kwargs)
40 elif len(chunks) == 3:
41 return svg_3d(chunks, size=size, **kwargs)
42 else:
43 return svg_nd(chunks, size=size, **kwargs)
44
45
46text_style = 'font-size="1.0rem" font-weight="100" text-anchor="middle"'

Callers 3

_repr_html_Method · 0.90
to_svgMethod · 0.90
svg_ndFunction · 0.85

Calls 6

allFunction · 0.85
svg_1dFunction · 0.85
svg_2dFunction · 0.85
svg_3dFunction · 0.85
svg_ndFunction · 0.85
anyMethod · 0.45

Tested by

no test coverage detected