Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
class HelperTestNumba(HelperTest):
# all Numba compiled functions have to receive their arguments in the proper data type (and numpy array shape)
try:
import timezonefinder.helpers_numba as helpers
fct_dict = {
"all_the_same": helpers.all_the_same,
"coord2int": helpers.coord2int,
"int2coord": helpers.int2coord,
"distance_to_point_on_equator": helpers.distance_to_point_on_equator,
"distance_to_polygon": helpers.distance_to_polygon,
"distance_to_polygon_exact": helpers.distance_to_polygon_exact,
"haversine": helpers.haversine,
"inside_polygon": helpers.inside_polygon,
"coord2shortcut": helpers.coord2shortcut,
"rectify_coordinates": helpers.rectify_coordinates,
'convert2coords': helpers.convert2coords,
'convert2coord_pairs': helpers.convert2coord_pairs,
}
print('\nNumba installation found.\ntesting helpers_numba.py functions...')
except ImportError:
fct_dict = {
"all_the_same": None,
"coord2int": None,
"int2coord": None,
"distance_to_point_on_equator": None,
"distance_to_polygon": None,
"distance_to_polygon_exact": None,
"haversine": None,
"inside_polygon": None,
"coord2shortcut": None,
"rectify_coordinates": None,
assert km2deg(distance_exact) == 0.5
# print('=====')
distance = distance_to_polygon(x_rad, y_rad, len(x_coords), np.array(points, dtype=DTYPE_FORMAT_SIGNED_I_NUMPY))
# print(km2deg(distance))
assert abs(km2deg(distance) - sqrt(2) / 2) < 0.00001
class HelperTestNumba(HelperTest):
# all Numba compiled functions have to receive their arguments in the proper data type (and numpy array shape)
try:
import timezonefinder.helpers_numba as helpers
fct_dict = {
"all_the_same": helpers.all_the_same,
"coord2int": helpers.coord2int,
"int2coord": helpers.int2coord,
"distance_to_point_on_equator": helpers.distance_to_point_on_equator,
"distance_to_polygon": helpers.distance_to_polygon,
"distance_to_polygon_exact": helpers.distance_to_polygon_exact,
"haversine": helpers.haversine,
"inside_polygon": helpers.inside_polygon,
"coord2shortcut": helpers.coord2shortcut,
"rectify_coordinates": helpers.rectify_coordinates,
'convert2coords': helpers.convert2coords,
'convert2coord_pairs': helpers.convert2coord_pairs,
}
print('\nNumba installation found.\ntesting helpers_numba.py functions...')
except ImportError:
fct_dict = {
"all_the_same": None,
"coord2int": None,
"int2coord": None,
# print(km2deg(distance))
assert abs(km2deg(distance) - sqrt(2) / 2) < 0.00001
class HelperTestNumba(HelperTest):
# all Numba compiled functions have to receive their arguments in the proper data type (and numpy array shape)
try:
import timezonefinder.helpers_numba as helpers
fct_dict = {
"all_the_same": helpers.all_the_same,
"coord2int": helpers.coord2int,
"int2coord": helpers.int2coord,
"distance_to_point_on_equator": helpers.distance_to_point_on_equator,
"distance_to_polygon": helpers.distance_to_polygon,
"distance_to_polygon_exact": helpers.distance_to_polygon_exact,
"haversine": helpers.haversine,
"inside_polygon": helpers.inside_polygon,
"coord2shortcut": helpers.coord2shortcut,
"rectify_coordinates": helpers.rectify_coordinates,
'convert2coords': helpers.convert2coords,
'convert2coord_pairs': helpers.convert2coord_pairs,
}
print('\nNumba installation found.\ntesting helpers_numba.py functions...')
except ImportError:
fct_dict = {
"all_the_same": None,
"coord2int": None,
"int2coord": None,
"distance_to_point_on_equator": None,
"distance_to_polygon": None,
"distance_to_polygon_exact": None,
# print('=====')
distance = distance_to_polygon(x_rad, y_rad, len(x_coords), np.array(points, dtype=DTYPE_FORMAT_SIGNED_I_NUMPY))
# print(km2deg(distance))
assert abs(km2deg(distance) - sqrt(2) / 2) < 0.00001
class HelperTestNumba(HelperTest):
# all Numba compiled functions have to receive their arguments in the proper data type (and numpy array shape)
try:
import timezonefinder.helpers_numba as helpers
fct_dict = {
"all_the_same": helpers.all_the_same,
"coord2int": helpers.coord2int,
"int2coord": helpers.int2coord,
"distance_to_point_on_equator": helpers.distance_to_point_on_equator,
"distance_to_polygon": helpers.distance_to_polygon,
"distance_to_polygon_exact": helpers.distance_to_polygon_exact,
"haversine": helpers.haversine,
"inside_polygon": helpers.inside_polygon,
"coord2shortcut": helpers.coord2shortcut,
"rectify_coordinates": helpers.rectify_coordinates,
'convert2coords': helpers.convert2coords,
'convert2coord_pairs': helpers.convert2coord_pairs,
}
print('\nNumba installation found.\ntesting helpers_numba.py functions...')
except ImportError:
fct_dict = {
"all_the_same": None,
"coord2int": None,
"int2coord": None,
"distance_to_point_on_equator": None,
distance = distance_to_polygon(x_rad, y_rad, len(x_coords), np.array(points, dtype=DTYPE_FORMAT_SIGNED_I_NUMPY))
# print(km2deg(distance))
assert abs(km2deg(distance) - sqrt(2) / 2) < 0.00001
class HelperTestNumba(HelperTest):
# all Numba compiled functions have to receive their arguments in the proper data type (and numpy array shape)
try:
import timezonefinder.helpers_numba as helpers
fct_dict = {
"all_the_same": helpers.all_the_same,
"coord2int": helpers.coord2int,
"int2coord": helpers.int2coord,
"distance_to_point_on_equator": helpers.distance_to_point_on_equator,
"distance_to_polygon": helpers.distance_to_polygon,
"distance_to_polygon_exact": helpers.distance_to_polygon_exact,
"haversine": helpers.haversine,
"inside_polygon": helpers.inside_polygon,
"coord2shortcut": helpers.coord2shortcut,
"rectify_coordinates": helpers.rectify_coordinates,
'convert2coords': helpers.convert2coords,
'convert2coord_pairs': helpers.convert2coord_pairs,
}
print('\nNumba installation found.\ntesting helpers_numba.py functions...')
except ImportError:
fct_dict = {
"all_the_same": None,
"coord2int": None,
"int2coord": None,
"distance_to_point_on_equator": None,
"distance_to_polygon": None,
np.array(points, dtype=DTYPE_FORMAT_SIGNED_I_NUMPY),
np.array(trans_points, dtype=DTYPE_FORMAT_F_NUMPY))
# print(km2deg(distance_exact))
assert km2deg(distance_exact) == 0.5
# print('=====')
distance = distance_to_polygon(x_rad, y_rad, len(x_coords), np.array(points, dtype=DTYPE_FORMAT_SIGNED_I_NUMPY))
# print(km2deg(distance))
assert abs(km2deg(distance) - sqrt(2) / 2) < 0.00001
class HelperTestNumba(HelperTest):
# all Numba compiled functions have to receive their arguments in the proper data type (and numpy array shape)
try:
import timezonefinder.helpers_numba as helpers
fct_dict = {
"all_the_same": helpers.all_the_same,
"coord2int": helpers.coord2int,
"int2coord": helpers.int2coord,
"distance_to_point_on_equator": helpers.distance_to_point_on_equator,
"distance_to_polygon": helpers.distance_to_polygon,
"distance_to_polygon_exact": helpers.distance_to_polygon_exact,
"haversine": helpers.haversine,
"inside_polygon": helpers.inside_polygon,
"coord2shortcut": helpers.coord2shortcut,
"rectify_coordinates": helpers.rectify_coordinates,
'convert2coords': helpers.convert2coords,
'convert2coord_pairs': helpers.convert2coord_pairs,
}
print('\nNumba installation found.\ntesting helpers_numba.py functions...')
except ImportError:
fct_dict = {
# print(km2deg(distance_exact))
assert km2deg(distance_exact) == 0.5
# print('=====')
distance = distance_to_polygon(x_rad, y_rad, len(x_coords), np.array(points, dtype=DTYPE_FORMAT_SIGNED_I_NUMPY))
# print(km2deg(distance))
assert abs(km2deg(distance) - sqrt(2) / 2) < 0.00001
class HelperTestNumba(HelperTest):
# all Numba compiled functions have to receive their arguments in the proper data type (and numpy array shape)
try:
import timezonefinder.helpers_numba as helpers
fct_dict = {
"all_the_same": helpers.all_the_same,
"coord2int": helpers.coord2int,
"int2coord": helpers.int2coord,
"distance_to_point_on_equator": helpers.distance_to_point_on_equator,
"distance_to_polygon": helpers.distance_to_polygon,
"distance_to_polygon_exact": helpers.distance_to_polygon_exact,
"haversine": helpers.haversine,
"inside_polygon": helpers.inside_polygon,
"coord2shortcut": helpers.coord2shortcut,
"rectify_coordinates": helpers.rectify_coordinates,
'convert2coords': helpers.convert2coords,
'convert2coord_pairs': helpers.convert2coord_pairs,
}
print('\nNumba installation found.\ntesting helpers_numba.py functions...')
except ImportError:
fct_dict = {
"all_the_same": None,
"coord2int": None,
# all Numba compiled functions have to receive their arguments in the proper data type (and numpy array shape)
try:
import timezonefinder.helpers_numba as helpers
fct_dict = {
"all_the_same": helpers.all_the_same,
"coord2int": helpers.coord2int,
"int2coord": helpers.int2coord,
"distance_to_point_on_equator": helpers.distance_to_point_on_equator,
"distance_to_polygon": helpers.distance_to_polygon,
"distance_to_polygon_exact": helpers.distance_to_polygon_exact,
"haversine": helpers.haversine,
"inside_polygon": helpers.inside_polygon,
"coord2shortcut": helpers.coord2shortcut,
"rectify_coordinates": helpers.rectify_coordinates,
'convert2coords': helpers.convert2coords,
'convert2coord_pairs': helpers.convert2coord_pairs,
}
print('\nNumba installation found.\ntesting helpers_numba.py functions...')
except ImportError:
fct_dict = {
"all_the_same": None,
"coord2int": None,
"int2coord": None,
"distance_to_point_on_equator": None,
"distance_to_polygon": None,
"distance_to_polygon_exact": None,
"haversine": None,
"inside_polygon": None,
"coord2shortcut": None,
"rectify_coordinates": None,
'convert2coords': None,