-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from kkraus14/style-fixes
[REVIEW] Python and Cython style cleanup, pre-commit hook
- Loading branch information
Showing
31 changed files
with
1,018 additions
and
652 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
repos: | ||
- repo: https://github.com/timothycrosley/isort | ||
rev: 4.3.21 | ||
hooks: | ||
- id: isort | ||
- repo: https://github.com/ambv/black | ||
rev: stable | ||
hooks: | ||
- id: black | ||
- repo: https://gitlab.com/pycqa/flake8 | ||
rev: 3.7.7 | ||
hooks: | ||
- id: flake8 | ||
- repo: https://gitlab.com/pycqa/flake8 | ||
rev: 3.7.7 | ||
hooks: | ||
- id: flake8 | ||
alias: flake8-cython | ||
name: flake8-cython | ||
args: ["--config=python/cuspatial/.flake8.cython"] | ||
types: [cython] | ||
default_language_version: | ||
python: python3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
from .core.trajectory import ( | ||
derive, | ||
distance_and_speed, | ||
spatial_bounds, | ||
subset_trajectory_id | ||
) | ||
from .core.gis import ( | ||
directed_hausdorff_distance, | ||
haversine_distance, | ||
lonlat_to_xy_km_coordinates, | ||
point_in_polygon_bitmap, | ||
window_points, | ||
) | ||
from .core.trajectory import ( | ||
derive, | ||
distance_and_speed, | ||
spatial_bounds, | ||
subset_trajectory_id, | ||
) | ||
from .io.soa import ( | ||
read_uint, | ||
read_its_timestamps, | ||
read_points_lonlat, | ||
read_points_xy_km, | ||
read_polygon | ||
read_polygon, | ||
read_uint, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,78 +1,104 @@ | ||
# Copyright (c) 2019, NVIDIA CORPORATION. | ||
|
||
# cython: profile=False | ||
# distutils: language = c++ | ||
# cython: embedsignature = True | ||
# cython: language_level = 3 | ||
|
||
|
||
from cudf.core.column import Column | ||
from cudf._lib.cudf import * | ||
from libc.stdlib cimport calloc, malloc, free | ||
from libcpp.pair cimport pair | ||
|
||
cpdef cpp_read_uint_soa(soa_file_name): | ||
# print("in cpp_read_id_soa, reading ",soa_file_name) | ||
cdef bytes py_bytes = soa_file_name.encode() | ||
cdef char* c_string = py_bytes | ||
cdef gdf_column c_id | ||
|
||
with nogil: | ||
c_id = read_uint32_soa(c_string) | ||
c_id = read_uint32_soa( | ||
c_string | ||
) | ||
|
||
id_data, id_mask = gdf_column_to_column_mem(&c_id) | ||
id=Column.from_mem_views(id_data,id_mask) | ||
id = Column.from_mem_views(id_data, id_mask) | ||
|
||
return id | ||
|
||
cpdef cpp_read_ts_soa(soa_file_name): | ||
# print("in cpp_read_ts_soa, reading ",soa_file_name) | ||
cdef bytes py_bytes = soa_file_name.encode() | ||
cdef char* c_string = py_bytes | ||
cdef gdf_column c_ts | ||
|
||
with nogil: | ||
c_ts = read_timestamp_soa(c_string) | ||
c_ts = read_timestamp_soa( | ||
c_string | ||
) | ||
|
||
ts_data, ts_mask = gdf_column_to_column_mem(&c_ts) | ||
ts=Column.from_mem_views(ts_data,ts_mask) | ||
ts = Column.from_mem_views(ts_data, ts_mask) | ||
|
||
return ts | ||
|
||
cpdef cpp_read_pnt_lonlat_soa(soa_file_name): | ||
# print("in cpp_read_pnt_lonlat_soa, reading ",soa_file_name) | ||
cdef bytes py_bytes = soa_file_name.encode() | ||
cdef char* c_string = py_bytes | ||
cdef pair[gdf_column, gdf_column] columns | ||
|
||
with nogil: | ||
columns = read_lonlat_points_soa(c_string) | ||
columns = read_lonlat_points_soa( | ||
c_string | ||
) | ||
|
||
lon_data, lon_mask = gdf_column_to_column_mem(&columns.first) | ||
lon=Column.from_mem_views(lon_data,lon_mask) | ||
lon = Column.from_mem_views(lon_data, lon_mask) | ||
lat_data, lat_mask = gdf_column_to_column_mem(&columns.second) | ||
lat=Column.from_mem_views(lat_data,lat_mask) | ||
lat = Column.from_mem_views(lat_data, lat_mask) | ||
|
||
return lon,lat | ||
return lon, lat | ||
|
||
cpdef cpp_read_pnt_xy_soa(soa_file_name): | ||
# print("in cpp_read_pnt_xy_soa, reading ",soa_file_name) | ||
cdef bytes py_bytes = soa_file_name.encode() | ||
cdef char* c_string = py_bytes | ||
cdef pair[gdf_column, gdf_column] columns | ||
|
||
with nogil: | ||
columns = read_xy_points_soa(c_string) | ||
columns = read_xy_points_soa( | ||
c_string | ||
) | ||
|
||
x_data, x_mask = gdf_column_to_column_mem(&columns.first) | ||
x=Column.from_mem_views(x_data,x_mask) | ||
x = Column.from_mem_views(x_data, x_mask) | ||
y_data, y_mask = gdf_column_to_column_mem(&columns.second) | ||
y=Column.from_mem_views(y_data,y_mask) | ||
y = Column.from_mem_views(y_data, y_mask) | ||
|
||
return x,y | ||
return x, y | ||
|
||
cpdef cpp_read_polygon_soa(soa_file_name): | ||
# print("in cpp_read_polygon_soa, reading ",soa_file_name) | ||
cdef bytes py_bytes = soa_file_name.encode() | ||
cdef char* c_string = py_bytes | ||
cdef gdf_column* c_ply_fpos=<gdf_column*>malloc(sizeof(gdf_column)) | ||
cdef gdf_column* c_ply_rpos=<gdf_column*>malloc(sizeof(gdf_column)) | ||
cdef gdf_column* c_ply_x=<gdf_column*>malloc(sizeof(gdf_column)) | ||
cdef gdf_column* c_ply_y=<gdf_column*>malloc(sizeof(gdf_column)) | ||
cdef gdf_column* c_ply_fpos = <gdf_column*>malloc(sizeof(gdf_column)) | ||
cdef gdf_column* c_ply_rpos = <gdf_column*>malloc(sizeof(gdf_column)) | ||
cdef gdf_column* c_ply_x = <gdf_column*>malloc(sizeof(gdf_column)) | ||
cdef gdf_column* c_ply_y = <gdf_column*>malloc(sizeof(gdf_column)) | ||
|
||
with nogil: | ||
read_polygon_soa(c_string,c_ply_fpos, c_ply_rpos, c_ply_x, c_ply_y) | ||
read_polygon_soa( | ||
c_string, | ||
c_ply_fpos, | ||
c_ply_rpos, | ||
c_ply_x, | ||
c_ply_y | ||
) | ||
|
||
f_data, f_mask = gdf_column_to_column_mem(c_ply_fpos) | ||
f_pos=Column.from_mem_views(f_data,f_mask) | ||
f_pos = Column.from_mem_views(f_data, f_mask) | ||
r_data, r_mask = gdf_column_to_column_mem(c_ply_rpos) | ||
r_pos=Column.from_mem_views(r_data,r_mask) | ||
r_pos = Column.from_mem_views(r_data, r_mask) | ||
x_data, x_mask = gdf_column_to_column_mem(c_ply_x) | ||
x=Column.from_mem_views(x_data,x_mask) | ||
x = Column.from_mem_views(x_data, x_mask) | ||
y_data, y_mask = gdf_column_to_column_mem(c_ply_y) | ||
y=Column.from_mem_views(y_data,y_mask) | ||
|
||
return f_pos,r_pos,x,y | ||
y = Column.from_mem_views(y_data, y_mask) | ||
|
||
return f_pos, r_pos, x, y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.