Skip to content

Commit

Permalink
improved error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
jrenaud90 committed Oct 6, 2023
1 parent b3d800b commit 61711ae
Show file tree
Hide file tree
Showing 13 changed files with 242 additions and 240 deletions.
4 changes: 3 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ New Features:
Performance:
- Changing RK variables back to stack-allocated c-arrays rather than malloc arrays.
- Improved how `CySolver` and `cyrk_ode` expected size is calculated and how much it grows with each concat.
- Files now compile across multiple threads during installation.

Other Changes:
- Moved some common constants for both `CySolver` and `cyrk_ode` out of their files and into `cy.common`.
- Added more meaningful memory error messages to `CySolver`.
- Added more meaningful memory error messages to cython files.
- Memory allocations (or reallocations) are now performed by helper functions in CyRK.utils.
- Better future-proofed package structure (mainifests, gitignores, etc.).

#### v0.8.2 (2023-09-25)
Expand Down
6 changes: 1 addition & 5 deletions CyRK/array/interp.pyx
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
# distutils: language = c++
# cython: boundscheck=False, wraparound=False, nonecheck=False, cdivision=True, initializedcheck=False
import cython
from cython.parallel import parallel, prange
cimport cython

cimport openmp
from cython.parallel import prange

import numpy as np

Expand Down
12 changes: 9 additions & 3 deletions CyRK/cy/common.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import cython
from libc.math cimport INFINITY as INF
from libc.float cimport DBL_EPSILON as EPS
from libc.stdint cimport SIZE_MAX, INT32_MAX
from cpython.mem cimport PyMem_Malloc, PyMem_Realloc, PyMem_Free
from cpython.mem cimport PyMem_Free

from CyRK.utils.utils cimport allocate_mem, reallocate_mem
from CyRK.array.interp cimport interp_array_ptr, interp_complex_array_ptr

# # Integration Constants
Expand Down Expand Up @@ -47,13 +49,17 @@ cdef void interpolate(

# Build a pointer array that will contain only 1 y for all ts in time_domain_full
cdef double_numeric* array_slice_ptr
array_slice_ptr = <double_numeric *> PyMem_Malloc(t_len_full * sizeof(double_numeric))
array_slice_ptr = <double_numeric *> allocate_mem(
t_len_full * sizeof(double_numeric),
'array_slice_ptr (common.interpolate)')
if not array_slice_ptr:
raise MemoryError()

# Build a pointer that will store the interpolated values for 1 y at a time; size of self.len_t_eval
cdef double_numeric* interpolated_array_slice_ptr
interpolated_array_slice_ptr = <double_numeric *> PyMem_Malloc(t_len_reduced * sizeof(double_numeric))
interpolated_array_slice_ptr = <double_numeric *> allocate_mem(
t_len_reduced * sizeof(double_numeric),
'interpolated_array_slice_ptr (common.interpolate)')
if not interpolated_array_slice_ptr:
raise MemoryError()

Expand Down
Loading

0 comments on commit 61711ae

Please sign in to comment.