def extend_line(): @ngjit def append(i, x, y, agg): agg[y, x] += 1 mapper = ngjit(lambda x: x) map_onto_pixel = _build_map_onto_pixel(mapper, mapper) draw_line = _build_draw_line(append) return _build_extend_line(draw_line, map_onto_pixel)
p.validate(dshape("{x: int32, y: float32}")) with pytest.raises(ValueError): p.validate(dshape("{x: string, y: float32}")) @ngjit def append(i, x, y, agg): agg[y, x] += 1 def new_agg(): return np.zeros((5, 5), dtype='i4') mapper = ngjit(lambda x: x) map_onto_pixel = _build_map_onto_pixel(mapper, mapper) draw_line = _build_draw_line(append) extend_line = _build_extend_line(draw_line, map_onto_pixel) bounds = (-3, 1, -3, 1) vt = (1., 3., 1., 3.) xmin, xmax, ymin, ymax = map_onto_pixel(vt, *bounds) mbounds = (xmin, xmax - 1, ymin, ymax - 1) def test_draw_line(): x0, y0 = (0, 0) x1, y1 = (3, 3) out = np.array([[1, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 0]]) agg = new_agg()
@ngjit def append(i, x, y, agg): agg[y, x] += 1 @ngjit def tri_append(x, y, agg, n): agg[y, x] += n def new_agg(): return np.zeros((5, 5), dtype='i4') mapper = ngjit(lambda x: x) map_onto_pixel = _build_map_onto_pixel(mapper, mapper) # Line rasterization draw_line = _build_draw_line(append) extend_line = _build_extend_line(draw_line, map_onto_pixel) # Triangles rasterization draw_triangle, draw_triangle_interp = _build_draw_triangle(tri_append) extend_triangles = _build_extend_triangles(draw_triangle, draw_triangle_interp, map_onto_pixel) bounds = (-3, 1, -3, 1) vt = (1., 3., 1., 3.) def test_draw_line(): x0, y0 = (0, 0) x1, y1 = (3, 3)