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

Function svg_nd

dask/array/svg.py:146–177  ·  view source on GitHub ↗
(chunks, size=200)

Source from the content-addressed store, hash-verified

144
145
146def svg_nd(chunks, size=200):
147 if len(chunks) % 3 == 1:
148 chunks = ((1,),) + chunks
149 shape = tuple(map(sum, chunks))
150 sizes = draw_sizes(shape, size=size)
151
152 chunks2 = chunks
153 sizes2 = sizes
154 out = []
155 left = 0
156 total_height = 0
157 while chunks2:
158 n = len(chunks2) % 3 or 3
159 o = svg(chunks2[:n], sizes=sizes2[:n], offset=(left, 0))
160 chunks2 = chunks2[n:]
161 sizes2 = sizes2[n:]
162
163 lines = o.split("\n")
164 header = lines[0]
165 height = float(re.search(r'height="(\d*\.?\d*)"', header).groups()[0])
166 total_height = max(total_height, height)
167 width = float(re.search(r'width="(\d*\.?\d*)"', header).groups()[0])
168 left += width + 10
169 o = "\n".join(lines[1:-1]) # remove header and footer
170
171 out.append(o)
172
173 header = '<svg width="{}" height="{}" style="stroke:rgb(0,0,0);stroke-width:1" >\n'.format(
174 int(left), int(total_height)
175 )
176 footer = "\n</svg>"
177 return header + "\n\n".join(out) + footer
178
179
180def svg_lines(x1, y1, x2, y2, max_n=20):

Callers 1

svgFunction · 0.85

Calls 5

draw_sizesFunction · 0.85
svgFunction · 0.85
maxFunction · 0.85
splitMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected