Ejemplo n.º 1
0
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)
Ejemplo n.º 2
0
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_for_line(mapper, mapper)
    draw_line = _build_draw_line(append)
    return _build_extend_line(draw_line, map_onto_pixel)
Ejemplo n.º 3
0
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_for_line(mapper, mapper)
    expand_aggs_and_cols = Glyph._expand_aggs_and_cols(append, 1)
    draw_line = _build_draw_segment(append, map_onto_pixel,
                                    expand_aggs_and_cols, False)
    return _build_extend_line_axis0(draw_line, expand_aggs_and_cols)[0]
Ejemplo n.º 4
0
    p = Point('x', 'y')
    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]])
Ejemplo n.º 5
0

@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_for_line = _build_map_onto_pixel_for_line(mapper, mapper)
map_onto_pixel_for_triangle = _build_map_onto_pixel_for_triangle(mapper, mapper)

# Line rasterization
draw_line = _build_draw_line(append)
extend_line = _build_extend_line_axis0(draw_line, map_onto_pixel_for_line)

# 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_for_triangle)

bounds = (-3, 1, -3, 1)
vt = (1., 3., 1., 3.)

def test_draw_line():