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)
Esempio 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)
Esempio n. 3
0
    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()
    draw_line(x0, y0, x1, y1, 0, True, False, agg)
Esempio n. 4
0
    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)
draw_line = _build_draw_line(append, mapper, mapper)
extend_line = _build_extend_line(draw_line)

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


def test_draw_line():
    x0, y0 = (-3, -3)
    x1, y1 = (0, 0)
    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()
    draw_line(vt, bounds, x0, y0, x1, y1, 0, True, False, agg)
    np.testing.assert_equal(agg, out)
    agg = new_agg()
Esempio n. 5
0
def draw_line():
    @ngjit
    def append(i, x, y, agg):
        agg[y, x] += 1

    return _build_draw_line(append)
Esempio n. 6
0
@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():
    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],
Esempio n. 7
0
    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)
draw_line = _build_draw_line(append, mapper, mapper)
extend_line = _build_extend_line(draw_line)

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


def test_draw_line():
    x0, y0 = (-3, -3)
    x1, y1 = (0, 0)
    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()
Esempio n. 8
0
def draw_line():
    @ngjit
    def append(i, x, y, agg):
        agg[y, x] += 1

    return _build_draw_line(append)