<commit_before>#!/usr/bin/env python

from ctypes import CDLL, c_double, c_int, c_bool, byref

lib = CDLL("libuav_utils.so")


def spiral_sweep(start, end, width, interval, inward=True, tol=0.01):
    size = lib.spiral_size(c_double(start[0]), c_double(start[1]),
                           c_double(end[0]), c_double(end[1]),
                           c_double(width), c_double(interval))
    x = (c_double * size)()
    y = (c_double * size)()
    res = lib.spiral_sweep(c_double(start[0]), c_double(start[1]),
                           c_double(end[0]), c_double(end[1]),
                           c_double(width), c_double(interval),
                           c_bool(inward), c_double(tol),
                           byref(x), byref(y), size)
    if res != 0:
        return list()
    else:
        return [(x[i], y[i]) for i in range(size)]


def rect_sweep(start, end, width, interval):
    size = lib.rect_size(c_double(start[0]), c_double(start[1]),
                         c_double(end[0]), c_double(end[1]),
                         c_double(width), c_double(interval))
    x = (c_double * size)()
    y = (c_double * size)()
    res = lib.rect_sweep(c_double(start[0]), c_double(start[1]),
                         c_double(end[0]), c_double(end[1]),
                         c_double(width), c_double(interval),
                         byref(x), byref(y), size)
    if res != 0:
        return list()
    else:
        return [(x[i], y[i]) for i in range(size)]


if __name__ == '__main__':
    print spiral_sweep([0, 0], [20, 21], 3, 10)
    print rect_sweep([2, 2], [12, 12], 2, 5)
<commit_msg>added compatibly with OS X<commit_after>#!/usr/bin/env python

import platform
from ctypes import CDLL, c_double, c_int, c_bool, byref

# load dynamic library on OS X
if platform.system() == 'Darwin':
    lib = CDLL("libuav_utils.dylib")

# otherwise assume unix extensions (not sure how to support windows)
else:
    lib = CDLL("libuav_utils.so")


def spiral_sweep(start, end, width, interval, inward=True, tol=0.01):
    size = lib.spiral_size(c_double(start[0]), c_double(start[1]),
                           c_double(end[0]), c_double(end[1]),
                           c_double(width), c_double(interval))
    x = (c_double * size)()
    y = (c_double * size)()
    res = lib.spiral_sweep(c_double(start[0]), c_double(start[1]),
                           c_double(end[0]), c_double(end[1]),
                           c_double(width), c_double(interval),
                           c_bool(inward), c_double(tol),
                           byref(x), byref(y), size)
    if res != 0:
        return list()
    else:
        return [(x[i], y[i]) for i in range(size)]


def rect_sweep(start, end, width, interval):
    size = lib.rect_size(c_double(start[0]), c_double(start[1]),
                         c_double(end[0]), c_double(end[1]),
                         c_double(width), c_double(interval))
    x = (c_double * size)()
    y = (c_double * size)()
    res = lib.rect_sweep(c_double(start[0]), c_double(start[1]),
                         c_double(end[0]), c_double(end[1]),
                         c_double(width), c_double(interval),
                         byref(x), byref(y), size)
    if res != 0:
        return list()
    else:
        return [(x[i], y[i]) for i in range(size)]


if __name__ == '__main__':
    print spiral_sweep([0, 0], [20, 21], 3, 10)
    print rect_sweep([2, 2], [12, 12], 2, 5)

{'fraction_non_alphanumeric': 0.15422596572756317, 'fraction_numerical': 0.02207377287249492, 'mean_word_length': 2.159633027522936, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1654744', 'n_tokens_mistral': 1248, 'n_tokens_neox': 1174, 'n_words': 258}