Skip to content

Commit

Permalink
Added fix to array lifetimes
Browse files Browse the repository at this point in the history
  • Loading branch information
jrenaud90 committed Dec 2, 2024
1 parent 0991337 commit edebeaa
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#### v0.12.1 (2024-12-02)

Fixes:
* Added fix so that arrays returned by `WrapCySolverResult` class are not destroyed when class is. Instead they are managed by python's garbage collector once they are held by a python variable.

Tests:
* Added test to check that arrays stay alive after underlying `WrapCySolverResult` class is destroyed.
Expand Down
4 changes: 2 additions & 2 deletions CyRK/cy/cysolver_api.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,11 @@ cdef class WrapCySolverResult:

@property
def t(self):
return np.asarray(self.time_view, dtype=np.float64, order='C')
return np.copy(np.asarray(self.time_view, dtype=np.float64, order='C'))

@property
def y(self):
return np.asarray(self.y_view, dtype=np.float64, order='C').reshape((self.size, self.num_dy)).T
return np.copy(np.asarray(self.y_view, dtype=np.float64, order='C')).reshape((self.size, self.num_dy)).T

@property
def size(self):
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name='CyRK'
version = '0.12.0'
version = '0.12.1'
description='Runge-Kutta ODE Integrator Implemented in Cython and Numba.'
authors= [
{name = 'Joe P. Renaud', email = '[email protected]'}
Expand Down

0 comments on commit edebeaa

Please sign in to comment.