Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add implicit noexcept from Cython<3.0.0 #440

Merged
merged 1 commit into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions aequilibrae/distribution/ipf_core.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ cdef _fratar(double[:, :] flows,
double[:] attr_factor,
int max_iter,
double toler,
int cpus):
int cpus) noexcept:

cdef double err = 1.0
cdef int iter = 0
Expand Down Expand Up @@ -99,7 +99,7 @@ cdef _fratar(double[:, :] flows,
cpdef void _total_attra(double[:, :] flows,
double[:] prod_tgt,
double[:] attr_tot,
int cpus):
int cpus) noexcept:

cdef long long i, j, jk
cdef double *local_buf
Expand Down Expand Up @@ -133,7 +133,7 @@ cpdef void _total_attra(double[:, :] flows,
cpdef void _total_prods(double[:, :] flows,
double[:] prod_tgt,
double[:] prod_tot,
int cpus)nogil:
int cpus) noexcept nogil:

cdef long long i, j
cdef long long I = flows.shape[0]
Expand All @@ -154,7 +154,7 @@ cpdef void _total_prods(double[:, :] flows,
cpdef double _factors(double[:] target,
double[:] total,
double[:] factor,
int cpus):
int cpus) noexcept:

cdef long long i, I = target.shape[0]
cdef double err = 1.0
Expand All @@ -174,7 +174,7 @@ cpdef double _factors(double[:] target,
@cython.embedsignature(True)
@cython.boundscheck(False)
cpdef double _calc_err(double[:] p_factor,
double[:] a_factor):
double[:] a_factor) noexcept:

cdef long long i, I = p_factor.shape[0]
cdef long long j, J = a_factor.shape[0]
Expand Down
18 changes: 9 additions & 9 deletions aequilibrae/paths/basic_path_finding.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ cpdef void network_loading(long classes,
long long [:] no_path,
long long [:] reached_first,
double [:, :] node_load,
long found) nogil:
long found) noexcept nogil:

cdef long long i, j, predecessor, connector, node
cdef long long zones = demand.shape[0]
Expand Down Expand Up @@ -70,7 +70,7 @@ cpdef void network_loading(long classes,
@cython.embedsignature(True)
@cython.boundscheck(False)
cdef void _copy_skims(double[:,:] skim_matrix, #Skim matrix_procedures computed from one origin to all nodes
double[:,:] final_skim_matrix) nogil: #Skim matrix_procedures computed for one origin to all other centroids only
double[:,:] final_skim_matrix) noexcept nogil: #Skim matrix_procedures computed for one origin to all other centroids only

cdef long i, j
cdef long N = final_skim_matrix.shape[0]
Expand All @@ -81,7 +81,7 @@ cdef void _copy_skims(double[:,:] skim_matrix, #Skim matrix_procedures computed
final_skim_matrix[i,j]=skim_matrix[i,j]


cdef return_an_int_view(input):
cdef int[:] return_an_int_view(input) noexcept nogil:
cdef int [:] critical_links_view = input
return critical_links_view

Expand All @@ -97,7 +97,7 @@ cdef void sl_network_loading(
double [:, :, :] sl_od_matrix,
double [:, :, :] sl_link_loading,
unsigned char [:] has_flow_mask,
long classes) nogil:
long classes) noexcept nogil:
# VARIABLES:
# selected_links: 2d memoryview. Each row corresponds to a set of selected links specified by the user
# demand: The input demand matrix for a given origin. The first index corresponds to destination,
Expand Down Expand Up @@ -169,7 +169,7 @@ cpdef void put_path_file_on_disk(unsigned int orig,
long long [:] connectors,
long long [:] all_nodes,
unsigned int [:] origins_to_write,
unsigned int [:] nodes_to_write) nogil:
unsigned int [:] nodes_to_write) noexcept nogil:
cdef long long i
cdef long long k = pred.shape[0]

Expand All @@ -188,7 +188,7 @@ cdef void blocking_centroid_flows(int action,
long long centroids,
long long [:] fs,
long long [:] temp_b_nodes,
long long [:] real_b_nodes) nogil:
long long [:] real_b_nodes) noexcept nogil:
cdef long long i

if action == 1: # We are unblocking
Expand All @@ -213,7 +213,7 @@ cdef void skim_single_path(long origin,
long long [:] conn,
double[:, :] graph_costs,
long long [:] reached_first,
long found) nogil:
long found) noexcept nogil:
cdef long long i, node, predecessor, connector, j

# sets all skims to infinity
Expand Down Expand Up @@ -250,7 +250,7 @@ cpdef void skim_multiple_fields(long origin,
double[:, :] graph_costs,
long long [:] reached_first,
long found,
double [:,:] final_skims) nogil:
double [:,:] final_skims) noexcept nogil:
cdef long long i, node, predecessor, connector, j

# sets all skims to infinity
Expand Down Expand Up @@ -295,7 +295,7 @@ cpdef int path_finding(long origin,
long long [:] pred,
long long [:] ids,
long long [:] connectors,
long long [:] reached_first) nogil:
long long [:] reached_first) noexcept nogil:

cdef unsigned int N = graph_costs.shape[0]
cdef unsigned int M = pred.shape[0]
Expand Down
6 changes: 3 additions & 3 deletions aequilibrae/paths/bpr.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ cpdef void bpr_cython(double[:] congested_time,
double [:] fftime,
double[:] alpha,
double [:] beta,
int cores):
int cores) noexcept:
cdef long long i
cdef long long l = congested_time.shape[0]

Expand All @@ -53,12 +53,12 @@ cpdef void dbpr_cython(double[:] deltaresult,
double [:] fftime,
double[:] alpha,
double [:] beta,
int cores):
int cores) noexcept:
cdef long long i
cdef long long l = deltaresult.shape[0]

for i in prange(l, nogil=True, num_threads=cores):
if link_flows[i] > 0:
deltaresult[i] = fftime[i] * (alpha[i] * beta[i] * (pow(link_flows[i] / capacity[i], beta[i]-1)))/ capacity[i]
else:
deltaresult[i] = fftime[i]
deltaresult[i] = fftime[i]
4 changes: 2 additions & 2 deletions aequilibrae/paths/bpr2.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ cpdef void bpr2_cython(double[:] congested_time,
double [:] fftime,
double[:] alpha,
double [:] beta,
int cores):
int cores) noexcept:
cdef long long i
cdef long long l = congested_time.shape[0]

Expand All @@ -58,7 +58,7 @@ cpdef void dbpr2_cython(double[:] deltaresult,
double [:] fftime,
double[:] alpha,
double [:] beta,
int cores):
int cores) noexcept:
cdef long long i
cdef long long l = deltaresult.shape[0]

Expand Down
4 changes: 2 additions & 2 deletions aequilibrae/paths/conical.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ cpdef void conical_cython(double[:] congested_time,
double [:] fftime,
double[:] alpha,
double [:] beta,
int cores):
int cores) noexcept:
cdef long long i
cdef long long l = congested_time.shape[0]

Expand All @@ -57,7 +57,7 @@ cpdef void dconical_cython(double[:] deltaresult,
double [:] fftime,
double[:] alpha,
double [:] beta,
int cores):
int cores) noexcept:
cdef long long i
cdef long long l = deltaresult.shape[0]

Expand Down
4 changes: 2 additions & 2 deletions aequilibrae/paths/graph_building.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ cdef long long _build_compressed_graph(long long[:] link_idx,
long long[:] all_links,
long long[:] compressed_dir,
long long[:] compressed_a_node,
long long[:] compressed_b_node) nogil:
long long[:] compressed_b_node) noexcept nogil:
cdef:
long long slink = 0
long long pre_link, n, first_node, lnk, lidx, a_node, b_node
Expand Down Expand Up @@ -93,7 +93,7 @@ cdef long long _build_compressed_graph(long long[:] link_idx,
@cython.wraparound(False)
@cython.embedsignature(True)
@cython.boundscheck(False)
cdef void _back_fill(long long[:] links_index, long long max_node):
cdef void _back_fill(long long[:] links_index, long long max_node) noexcept:
cdef Py_ssize_t i

for i in range(max_node + 1, 0, -1):
Expand Down
4 changes: 2 additions & 2 deletions aequilibrae/paths/inrets.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ cpdef void inrets_cython(double[:] congested_time,
double [:] fftime,
double[:] alpha,
double [:] beta,
int cores):
int cores) noexcept:
cdef long long i
cdef long long l = congested_time.shape[0]

Expand All @@ -60,7 +60,7 @@ cpdef void dinrets_cython(double[:] deltaresult,
double [:] fftime,
double[:] alpha,
double [:] beta,
int cores):
int cores) noexcept:
cdef long long i
cdef long long l = deltaresult.shape[0]

Expand Down
26 changes: 13 additions & 13 deletions aequilibrae/paths/parallel_numpy.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def sum_axis1(totals, multiples, cores):
@cython.boundscheck(False)
cpdef void sum_axis1_cython(double[:] totals,
double[:, :] multiples,
int cores):
int cores) noexcept:
cdef long long i, j
cdef long long l = totals.shape[0]
cdef long long k = multiples.shape[1]
Expand Down Expand Up @@ -41,7 +41,7 @@ def sum_a_times_b_minus_c(array1, array2, array3, cores):
cpdef double sum_a_times_b_minus_c_cython(double[:] array1,
double[:] array2,
double[:] array3,
int cores):
int cores) noexcept:
cdef long long i
cdef double row_result
cdef double result = 0.0
Expand Down Expand Up @@ -72,7 +72,7 @@ cpdef void linear_combination_cython_1d(double stepsize,
double[:] results,
double[:] array1,
double[:] array2,
int cores):
int cores) noexcept:
cdef long long i
cdef long long l = results.shape[0]

Expand All @@ -99,7 +99,7 @@ cpdef void linear_combination_cython(double stepsize,
double[:, :] results,
double[:, :] array1,
double[:, :] array2,
int cores):
int cores) noexcept:
cdef long long i, j
cdef long long l = results.shape[0]
cdef long long k = results.shape[1]
Expand Down Expand Up @@ -129,7 +129,7 @@ cpdef void linear_combination_skims_cython(double stepsize,
double[:, :,:] results,
double[:, :, :] array1,
double[:, :, :] array2,
int cores):
int cores) noexcept:
cdef long long i, j, k
cdef long long a = results.shape[0]
cdef long long b = results.shape[1]
Expand Down Expand Up @@ -163,7 +163,7 @@ cpdef void triple_linear_combination_cython(double [:] stepsizes,
double[:, :] array1,
double[:, :] array2,
double[:, :] array3,
int cores):
int cores) noexcept:
cdef long long i, j
cdef long long l = results.shape[0]
cdef long long k = results.shape[1]
Expand Down Expand Up @@ -193,7 +193,7 @@ cpdef void triple_linear_combination_cython_skims(double [:] stepsizes,
double[:, :, :] array1,
double[:, :, :] array2,
double[:, :, :] array3,
int cores):
int cores) noexcept:
cdef long long i, j, k
cdef long long a = results.shape[0]
cdef long long b = results.shape[1]
Expand All @@ -220,7 +220,7 @@ def copy_one_dimension(target, source, cores):
@cython.boundscheck(False)
cpdef void copy_one_dimension_cython(double[:] target,
double[:] source,
int cores):
int cores) noexcept:
cdef long long i
cdef long long l = target.shape[0]

Expand All @@ -243,7 +243,7 @@ def copy_two_dimensions(target, source, cores):
@cython.boundscheck(False)
cpdef void copy_two_dimensions_cython(double[:, :] target,
double[:, :] source,
int cores):
int cores) noexcept:
cdef long long i, j
cdef long long l = target.shape[0]
cdef long long k = target.shape[1]
Expand All @@ -269,7 +269,7 @@ def copy_three_dimensions(target, source, cores):
@cython.boundscheck(False)
cpdef void copy_three_dimensions_cython(double[:, :, :] target,
double[:, :, :] source,
int cores):
int cores) noexcept:
cdef long long i, j, k
cdef long long a = target.shape[0]
cdef long long b = target.shape[1]
Expand Down Expand Up @@ -298,7 +298,7 @@ def assign_link_loads(actual_links, compressed_links, crosswalk, cores):
cpdef void assign_link_loads_cython(double[:, :] actual,
double[:, :] compressed,
long long[:] crosswalk,
int cores):
int cores) noexcept:
cdef long long i, j, k
cdef long long links = actual.shape[0]
cdef long long n = actual.shape[1]
Expand All @@ -322,7 +322,7 @@ def aggregate_link_costs(actual_costs, compressed_costs, crosswalk):
@cython.boundscheck(False)
cpdef void aggregate_link_costs_cython(double[:] actual,
double[:] compressed,
long long[:] crosswalk):
long long[:] crosswalk) noexcept:
cdef long long i, j, k
cdef long long links = actual.shape[0]
cdef long long c_l = compressed.shape[0]
Expand All @@ -333,4 +333,4 @@ cpdef void aggregate_link_costs_cython(double[:] actual,
for i in range(links):
k = crosswalk[i]
if k < c_l:
compressed[k] += actual[i]
compressed[k] += actual[i]
2 changes: 1 addition & 1 deletion aequilibrae/paths/path_file_saving.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ cpdef void save_path_file(long origin_index,
long long [:] conn,
string path_file,
string index_file,
bool write_feather):
bool write_feather) noexcept:

cdef long long class_, node, predecessor, connector, ctr
cdef vector[long long] path_data
Expand Down
Loading