Skip to content
test_tree.py 33.1 KiB
Newer Older
Matt Wala's avatar
Matt Wala committed

    # Find leaf boxes.
    from boxtree import box_flags_enum

    outer_space_invader_dist = np.zeros(tree.nboxes)

    for ibox in range(tree.nboxes):
        # We only want leaves here.
        if tree.box_flags[ibox] & box_flags_enum.HAS_CHILDREN:
            continue

        start, end = lbl.balls_near_box_starts[ibox:ibox + 2]
        space_invaders = lbl.balls_near_box_lists[start:end]
        if len(space_invaders) > 0:
            outer_space_invader_dist[ibox] = np.max(np.abs(
                    tree.box_centers[:, ibox].reshape((-1, 1))
                    - ball_centers[:, space_invaders]))

    assert np.allclose(siq, outer_space_invader_dist)

# }}}


Andreas Klöckner's avatar
Andreas Klöckner committed
# You can test individual routines by typing
Andreas Klöckner's avatar
Andreas Klöckner committed
# $ python test_tree.py 'test_routine(cl.create_some_context)'
Andreas Klöckner's avatar
Andreas Klöckner committed

if __name__ == "__main__":
    if len(sys.argv) > 1:
        exec(sys.argv[1])
    else:
        from py.test.cmdline import main
        main([__file__])

# vim: fdm=marker