diff --git a/.github/workflows/cron-tests.yml b/.github/workflows/cron-tests.yml index 2cf155cba..e22b45243 100644 --- a/.github/workflows/cron-tests.yml +++ b/.github/workflows/cron-tests.yml @@ -19,12 +19,12 @@ jobs: fail-fast: true matrix: os: [ubuntu-latest, macos-latest] # TODO: re-enable windows-latest - python: [3.7, 3.8, 3.9] + python: ['3.8', '3.9', '3.10'] include: # These set options for each python version. So, for example, when any - # python 3.7 job in the matrix runs, it should use this toxenv - - python: 3.7 - toxenv: py37-test + # python 3.10 job in the matrix runs, it should use this toxenv + - python: '3.10' + toxenv: py310-test - python: 3.9 toxenv: py39-test-cov diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d6c650f76..ceb533f9f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -27,6 +27,11 @@ jobs: python: 3.9 toxenv: py39-test-cov + - name: Python 3.10 + os: ubuntu-latest + python: '3.10' + toxenv: py310-test + # Has to happen on ubuntu because galpy is finnicky on macOS - name: Python 3.9 with all optional dependencies os: ubuntu-latest @@ -39,10 +44,10 @@ jobs: python: 3.9 toxenv: nogsl - - name: Python 3.7 with oldest supported version of all dependencies + - name: Python 3.8 with oldest supported version of all dependencies os: ubuntu-latest - python: 3.7 - toxenv: py37-test-oldestdeps + python: 3.8 + toxenv: py38-test-oldestdeps # Mac and Windows: - name: Python 3.9 standard tests (macOS) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 413e808f1..e3a59c8d0 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -10,7 +10,7 @@ on: env: CIBW_BUILD: "cp3?-*" - CIBW_SKIP: "*-win32 *-manylinux_i686 cp35-* cp36-*" + CIBW_SKIP: "*-win32 *-manylinux_i686 cp35-* cp36-* cp37-*" CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014 jobs: @@ -47,7 +47,7 @@ jobs: - name: Build wheels run: | - python -m pip install cibuildwheel==1.6.3 + python -m pip install cibuildwheel python -m cibuildwheel --output-dir wheelhouse - uses: actions/upload-artifact@v2 diff --git a/gala/dynamics/lyapunov/dop853_lyapunov.pyx b/gala/dynamics/lyapunov/dop853_lyapunov.pyx index 847574554..b9893650e 100644 --- a/gala/dynamics/lyapunov/dop853_lyapunov.pyx +++ b/gala/dynamics/lyapunov/dop853_lyapunov.pyx @@ -20,7 +20,7 @@ from ...potential.potential.cpotential cimport CPotentialWrapper from ...potential.frame.cframe cimport CFrameWrapper cdef extern from "frame/src/cframe.h": - ctypedef struct CFrame: + ctypedef struct CFrameType: pass cdef extern from "potential/src/cpotential.h": @@ -29,10 +29,10 @@ cdef extern from "potential/src/cpotential.h": cdef extern from "dopri/dop853.h": ctypedef void (*FcnEqDiff)(unsigned n, double x, double *y, double *f, - CPotential *p, CFrame *fr, unsigned norbits, + CPotential *p, CFrameType *fr, unsigned norbits, unsigned nbody, void *args) nogil void Fwrapper (unsigned ndim, double t, double *w, double *f, - CPotential *p, CFrame *fr, unsigned norbits, unsigned nbody) + CPotential *p, CFrameType *fr, unsigned norbits, unsigned nbody) double six_norm (double *x) cpdef dop853_lyapunov_max(hamiltonian, double[::1] w0, @@ -62,7 +62,7 @@ cpdef dop853_lyapunov_max(hamiltonian, double[::1] w0, # whoa, so many dots CPotential cp = ((hamiltonian.potential.c_instance)).cpotential - CFrame cf = ((hamiltonian.frame.c_instance)).cframe + CFrameType cf = ((hamiltonian.frame.c_instance)).cframe void *args @@ -139,7 +139,7 @@ cpdef dop853_lyapunov_max_dont_save(hamiltonian, double[::1] w0, # whoa, so many dots CPotential cp = ((hamiltonian.potential.c_instance)).cpotential - CFrame cf = ((hamiltonian.frame.c_instance)).cframe + CFrameType cf = ((hamiltonian.frame.c_instance)).cframe void *args diff --git a/gala/dynamics/mockstream/mockstream.pyx b/gala/dynamics/mockstream/mockstream.pyx index 4a29baf86..8beb5e0dd 100644 --- a/gala/dynamics/mockstream/mockstream.pyx +++ b/gala/dynamics/mockstream/mockstream.pyx @@ -27,7 +27,7 @@ from cpython.exc cimport PyErr_CheckSignals from ...integrate.cyintegrators.dop853 cimport (dop853_step, dop853_helper_save_all) from ...potential.potential.cpotential cimport CPotentialWrapper, CPotential -from ...potential.frame.cframe cimport CFrameWrapper, CFrame +from ...potential.frame.cframe cimport CFrameWrapper, CFrameType from ...potential.potential.builtin.cybuiltin import NullWrapper from ...potential import Hamiltonian @@ -43,11 +43,11 @@ __all__ = ['mockstream_dop853', 'mockstream_dop853_animate'] cdef extern from "dopri/dop853.h": ctypedef void (*FcnEqDiff)(unsigned n, double x, double *y, double *f, - CPotential *p, CFrame *fr, + CPotential *p, CFrameType *fr, unsigned norbits, unsigned nbody, void *args) nogil void Fwrapper_direct_nbody(unsigned ndim, double t, double *w, double *f, - CPotential *p, CFrame *fr, + CPotential *p, CFrameType *fr, unsigned norbits, unsigned nbody, void *args) nogil @@ -94,7 +94,7 @@ cpdef mockstream_dop853(nbody, double[::1] time, # whoa, so many dots CPotential cp = ((nbody.H.potential.c_instance)).cpotential - CFrame cf = ((nbody.H.frame.c_instance)).cframe + CFrameType cf = ((nbody.H.frame.c_instance)).cframe # for the test particles CPotentialWrapper null_wrapper = NullWrapper(1., [], @@ -215,7 +215,7 @@ cpdef mockstream_dop853_animate(nbody, double[::1] t, # whoa, so many dots CPotential cp = ((nbody.H.potential.c_instance)).cpotential - CFrame cf = ((nbody.H.frame.c_instance)).cframe + CFrameType cf = ((nbody.H.frame.c_instance)).cframe int nbodies = nbody._c_w0.shape[0] # includes the progenitor double [:, ::1] nbody_w0 = nbody._c_w0 diff --git a/gala/dynamics/nbody/nbody.pyx b/gala/dynamics/nbody/nbody.pyx index b24fb4820..2e9b803f8 100644 --- a/gala/dynamics/nbody/nbody.pyx +++ b/gala/dynamics/nbody/nbody.pyx @@ -27,7 +27,7 @@ from ...integrate.cyintegrators.dop853 cimport (dop853_helper, dop853_helper_save_all) cdef extern from "frame/src/cframe.h": - ctypedef struct CFrame: + ctypedef struct CFrameType: pass cdef extern from "potential/src/cpotential.h": @@ -36,10 +36,10 @@ cdef extern from "potential/src/cpotential.h": cdef extern from "dopri/dop853.h": ctypedef void (*FcnEqDiff)(unsigned n, double x, double *y, double *f, - CPotential *p, CFrame *fr, unsigned norbits, + CPotential *p, CFrameType *fr, unsigned norbits, unsigned nbody, void *args) nogil void Fwrapper_direct_nbody(unsigned ndim, double t, double *w, double *f, - CPotential *p, CFrame *fr, unsigned norbits, + CPotential *p, CFrameType *fr, unsigned norbits, unsigned nbody, void *args) cpdef direct_nbody_dop853(double [:, ::1] w0, double[::1] t, @@ -67,7 +67,7 @@ cpdef direct_nbody_dop853(double [:, ::1] w0, double[::1] t, void *args CPotential *c_particle_potentials[MAX_NBODY] CPotential cp = ((hamiltonian.potential.c_instance)).cpotential - CFrame cf = ((hamiltonian.frame.c_instance)).cframe + CFrameType cf = ((hamiltonian.frame.c_instance)).cframe # Some input validation: if not isinstance(hamiltonian, Hamiltonian): diff --git a/gala/integrate/cyintegrators/dop853.pxd b/gala/integrate/cyintegrators/dop853.pxd index a73e2a7e0..03afb4873 100644 --- a/gala/integrate/cyintegrators/dop853.pxd +++ b/gala/integrate/cyintegrators/dop853.pxd @@ -1,7 +1,7 @@ # cython: language_level=3 cdef extern from "frame/src/cframe.h": - ctypedef struct CFrame: + ctypedef struct CFrameType: pass cdef extern from "potential/src/cpotential.h": @@ -10,20 +10,20 @@ cdef extern from "potential/src/cpotential.h": cdef extern from "dopri/dop853.h": ctypedef void (*FcnEqDiff)(unsigned n, double x, double *y, double *f, - CPotential *p, CFrame *fr, unsigned norbits, + CPotential *p, CFrameType *fr, unsigned norbits, unsigned nbody, void *args) nogil -cdef void dop853_step(CPotential *cp, CFrame *cf, FcnEqDiff F, +cdef void dop853_step(CPotential *cp, CFrameType *cf, FcnEqDiff F, double *w, double t1, double t2, double dt0, int ndim, int norbits, int nbody, void *args, double atol, double rtol, int nmax) except * -cdef dop853_helper(CPotential *cp, CFrame *cf, FcnEqDiff F, +cdef dop853_helper(CPotential *cp, CFrameType *cf, FcnEqDiff F, double[:,::1] w0, double[::1] t, int ndim, int norbits, int nbody, void *args, int ntimes, double atol, double rtol, int nmax, int progress) -cdef dop853_helper_save_all(CPotential *cp, CFrame *cf, FcnEqDiff F, +cdef dop853_helper_save_all(CPotential *cp, CFrameType *cf, FcnEqDiff F, double[:,::1] w0, double[::1] t, int ndim, int norbits, int nbody, void *args, int ntimes, double atol, double rtol, int nmax, diff --git a/gala/integrate/cyintegrators/dop853.pyx b/gala/integrate/cyintegrators/dop853.pyx index 3dcfc8327..385259dd4 100644 --- a/gala/integrate/cyintegrators/dop853.pyx +++ b/gala/integrate/cyintegrators/dop853.pyx @@ -22,7 +22,7 @@ from ...potential.potential.cpotential cimport CPotentialWrapper from ...potential.frame.cframe cimport CFrameWrapper cdef extern from "frame/src/cframe.h": - ctypedef struct CFrame: + ctypedef struct CFrameType: pass cdef extern from "potential/src/cpotential.h": @@ -33,14 +33,14 @@ cdef extern from "potential/src/cpotential.h": cdef extern from "dopri/dop853.h": ctypedef void (*FcnEqDiff)(unsigned n, double x, double *y, double *f, - CPotential *p, CFrame *fr, unsigned norbits, + CPotential *p, CFrameType *fr, unsigned norbits, unsigned nbody, void *args) nogil ctypedef void (*SolTrait)(long nr, double xold, double x, double* y, unsigned n, int* irtrn) # See dop853.h for full description of all input parameters int dop853 (unsigned n, FcnEqDiff fn, - CPotential *p, CFrame *fr, unsigned n_orbits, unsigned nbody, + CPotential *p, CFrameType *fr, unsigned n_orbits, unsigned nbody, void *args, double x, double* y, double xend, double* rtoler, double* atoler, int itoler, SolTrait solout, @@ -49,7 +49,7 @@ cdef extern from "dopri/dop853.h": long nstiff, unsigned nrdens, unsigned* icont, unsigned licont) void Fwrapper (unsigned ndim, double t, double *w, double *f, - CPotential *p, CFrame *fr, unsigned norbits) + CPotential *p, CFrameType *fr, unsigned norbits) cdef extern from "stdio.h": ctypedef struct FILE @@ -59,7 +59,7 @@ cdef void solout(long nr, double xold, double x, double* y, unsigned n, int* irt # TODO: see here for example in FORTRAN: http://www.unige.ch/~hairer/prog/nonstiff/dr_dop853.f pass -cdef void dop853_step(CPotential *cp, CFrame *cf, FcnEqDiff F, +cdef void dop853_step(CPotential *cp, CFrameType *cf, FcnEqDiff F, double *w, double t1, double t2, double dt0, int ndim, int norbits, int nbody, void *args, double atol, double rtol, int nmax) except *: @@ -80,7 +80,7 @@ cdef void dop853_step(CPotential *cp, CFrame *cf, FcnEqDiff F, elif res == -4: raise RuntimeError("The problem is probably stiff (interrupted).") -cdef dop853_helper(CPotential *cp, CFrame *cf, FcnEqDiff F, +cdef dop853_helper(CPotential *cp, CFrameType *cf, FcnEqDiff F, double[:, ::1] w0, double[::1] t, int ndim, int norbits, int nbody, void *args, int ntimes, double atol, double rtol, int nmax, int progress): @@ -128,7 +128,7 @@ cdef dop853_helper(CPotential *cp, CFrame *cf, FcnEqDiff F, return w -cdef dop853_helper_save_all(CPotential *cp, CFrame *cf, FcnEqDiff F, +cdef dop853_helper_save_all(CPotential *cp, CFrameType *cf, FcnEqDiff F, double[:, ::1] w0, double[::1] t, int ndim, int norbits, int nbody, void *args, int ntimes, double atol, double rtol, int nmax, @@ -207,7 +207,7 @@ cpdef dop853_integrate_hamiltonian(hamiltonian, double[:, ::1] w0, double[::1] t # whoa, so many dots CPotential cp = ((hamiltonian.potential.c_instance)).cpotential - CFrame cf = ((hamiltonian.frame.c_instance)).cframe + CFrameType cf = ((hamiltonian.frame.c_instance)).cframe # 0 below is for nbody - we ignore that in this test particle integration all_w = dop853_helper_save_all(&cp, &cf, Fwrapper, diff --git a/gala/integrate/cyintegrators/dopri/dop853.c b/gala/integrate/cyintegrators/dopri/dop853.c index c01d98423..7de6a1128 100644 --- a/gala/integrate/cyintegrators/dopri/dop853.c +++ b/gala/integrate/cyintegrators/dopri/dop853.c @@ -78,7 +78,7 @@ static double max_d (double a, double b) } /* max_d */ -static double hinit (unsigned n, FcnEqDiff fcn, CPotential *p, CFrame *fr, unsigned norbits, unsigned nbody, void *args, +static double hinit (unsigned n, FcnEqDiff fcn, CPotential *p, CFrameType *fr, unsigned norbits, unsigned nbody, void *args, double x, double* y, double posneg, double* f0, double* f1, double* yy1, int iord, double hmax, double* atoler, double* rtoler, int itoler) @@ -155,7 +155,7 @@ static double hinit (unsigned n, FcnEqDiff fcn, CPotential *p, CFrame *fr, unsig /* core integrator */ -static int dopcor (unsigned n, FcnEqDiff fcn, CPotential *p, CFrame *fr, unsigned norbits, unsigned nbody, void *args, +static int dopcor (unsigned n, FcnEqDiff fcn, CPotential *p, CFrameType *fr, unsigned norbits, unsigned nbody, void *args, double x, double* y, double xend, double hmax, double h, double* rtoler, double* atoler, int itoler, FILE* fileout, SolTrait solout, int iout, @@ -695,7 +695,7 @@ static int dopcor (unsigned n, FcnEqDiff fcn, CPotential *p, CFrame *fr, unsigne /* front-end */ int dop853 - (unsigned n, FcnEqDiff fcn, CPotential *p, CFrame *fr, unsigned norbits, unsigned nbody, void *args, + (unsigned n, FcnEqDiff fcn, CPotential *p, CFrameType *fr, unsigned norbits, unsigned nbody, void *args, double x, double* y, double xend, double* rtoler, double* atoler, int itoler, SolTrait solout, int iout, FILE* fileout, double uround, double safe, double fac1, double fac2, double beta, double hmax, double h, @@ -977,7 +977,7 @@ double contd8 (unsigned ii, double x) /* ADDED BY APW */ void Fwrapper (unsigned full_ndim, double t, double *w, double *f, - CPotential *p, CFrame *fr, unsigned norbits, unsigned na, + CPotential *p, CFrameType *fr, unsigned norbits, unsigned na, void *args) { /* na can be ignored here - used in nbody wrapper below */ @@ -991,7 +991,7 @@ void Fwrapper (unsigned full_ndim, double t, double *w, double *f, } void Fwrapper_direct_nbody (unsigned full_ndim, double t, double *w, double *f, - CPotential *p, CFrame *fr, + CPotential *p, CFrameType *fr, unsigned norbits, unsigned nbody, void *args) { /* Here, the extra args are actually the array of CPotential objects that diff --git a/gala/integrate/cyintegrators/dopri/dop853.h b/gala/integrate/cyintegrators/dopri/dop853.h index 564038c5f..d220ac2c8 100644 --- a/gala/integrate/cyintegrators/dopri/dop853.h +++ b/gala/integrate/cyintegrators/dopri/dop853.h @@ -188,7 +188,7 @@ nfcnRead Number of function calls. #include "hamiltonian/src/chamiltonian.h" typedef void (*FcnEqDiff)(unsigned n, double x, double *y, double *f, - CPotential *p, CFrame *fr, unsigned norbits, + CPotential *p, CFrameType *fr, unsigned norbits, unsigned nbody, void *args); typedef void (*SolTrait)(long nr, double xold, double x, double* y, unsigned n, int* irtrn); @@ -197,7 +197,7 @@ extern int dop853 (unsigned n, /* dimension of the system <= UINT_MAX-1*/ FcnEqDiff fcn, /* function computing the value of f(x,y) */ CPotential *p, /* ADDED BY ADRN: parameters for gradient function */ - CFrame *fr, /* ADDED BY ADRN: reference frame */ + CFrameType *fr, /* ADDED BY ADRN: reference frame */ unsigned n_orbits, /* ADDED BY ADRN: total number of orbits, i.e. bodies */ unsigned n_body, /* ADDED BY ADRN: number of nbody particles */ void *args, /* ADDED BY ADRN: a container for other stuff */ @@ -239,10 +239,10 @@ extern double xRead (void); /* ADDED BY APW */ extern void Fwrapper (unsigned ndim, double t, double *w, double *f, - CPotential *p, CFrame *fr, + CPotential *p, CFrameType *fr, unsigned norbits, unsigned nbody, void *args); extern void Fwrapper_direct_nbody(unsigned ndim, double t, double *w, double *f, - CPotential *p, CFrame *fr, + CPotential *p, CFrameType *fr, unsigned norbits, unsigned nbody, void *args); // here args becomes the particle potentials extern double six_norm (double *x); /* Needed for Lyapunov */ diff --git a/gala/integrate/cyintegrators/leapfrog.pyx b/gala/integrate/cyintegrators/leapfrog.pyx index 5274b4b0e..5e37b054b 100644 --- a/gala/integrate/cyintegrators/leapfrog.pyx +++ b/gala/integrate/cyintegrators/leapfrog.pyx @@ -17,7 +17,7 @@ from ...potential.potential.cpotential cimport CPotentialWrapper from ...potential.frame import StaticFrame cdef extern from "frame/src/cframe.h": - ctypedef struct CFrame: + ctypedef struct CFrameType: pass cdef extern from "potential/src/cpotential.h": diff --git a/gala/integrate/cyintegrators/ruth4.pyx b/gala/integrate/cyintegrators/ruth4.pyx index 32ce86981..c6f62e6ed 100644 --- a/gala/integrate/cyintegrators/ruth4.pyx +++ b/gala/integrate/cyintegrators/ruth4.pyx @@ -17,7 +17,7 @@ from ...potential.potential.cpotential cimport CPotentialWrapper from ...potential.frame import StaticFrame cdef extern from "frame/src/cframe.h": - ctypedef struct CFrame: + ctypedef struct CFrameType: pass cdef extern from "potential/src/cpotential.h": diff --git a/gala/potential/frame/builtin/frames.pyx b/gala/potential/frame/builtin/frames.pyx index e2c83aa92..d05b7171f 100644 --- a/gala/potential/frame/builtin/frames.pyx +++ b/gala/potential/frame/builtin/frames.pyx @@ -24,7 +24,7 @@ cdef extern from "src/funcdefs.h": ctypedef void (*hessianfunc)(double t, double *pars, double *q, int n_dim, double *hess) nogil cdef extern from "frame/src/cframe.h": - ctypedef struct CFrame: + ctypedef struct CFrameType: energyfunc energy gradientfunc gradient hessianfunc hessian @@ -50,7 +50,7 @@ __all__ = ['StaticFrame', 'ConstantRotatingFrame'] cdef class StaticFrameWrapper(CFrameWrapper): def __init__(self, list params): - cdef CFrame cf + cdef CFrameType cf self.init(params) @@ -87,7 +87,7 @@ cdef class ConstantRotatingFrameWrapper2D(CFrameWrapper): def __init__(self, list params): cdef: - CFrame cf + CFrameType cf assert len(params) == 1 self._params = np.array([params[0]], dtype=np.float64) @@ -104,7 +104,7 @@ cdef class ConstantRotatingFrameWrapper3D(CFrameWrapper): def __init__(self, list params): cdef: - CFrame cf + CFrameType cf assert len(params) == 3 self._params = np.array([params[0], params[1], params[2]], diff --git a/gala/potential/frame/cframe.pxd b/gala/potential/frame/cframe.pxd index f39ab9298..8570d4757 100644 --- a/gala/potential/frame/cframe.pxd +++ b/gala/potential/frame/cframe.pxd @@ -1,15 +1,15 @@ # cython: language_level=3 cdef extern from "frame/src/cframe.h": - ctypedef struct CFrame: + ctypedef struct CFrameType: pass - double frame_hamiltonian(CFrame *fr, double t, double *qp, int n_dim) nogil - void frame_gradient(CFrame *fr, double t, double *qp, int n_dim, double *dH) nogil - void frame_hessian(CFrame *fr, double t, double *qp, int n_dim, double *d2H) nogil + double frame_hamiltonian(CFrameType *fr, double t, double *qp, int n_dim) nogil + void frame_gradient(CFrameType *fr, double t, double *qp, int n_dim, double *dH) nogil + void frame_hessian(CFrameType *fr, double t, double *qp, int n_dim, double *d2H) nogil cdef class CFrameWrapper: - cdef CFrame cframe + cdef CFrameType cframe cdef double[::1] _params cpdef init(self, list parameters) cpdef energy(self, double[:,::1] w, double[::1] t) diff --git a/gala/potential/frame/cframe.pyx b/gala/potential/frame/cframe.pyx index 26b9b8be6..7d95c3e03 100644 --- a/gala/potential/frame/cframe.pyx +++ b/gala/potential/frame/cframe.pyx @@ -31,7 +31,7 @@ cdef class CFrameWrapper: """ cdef: int n, ndim, i - CFrame cf = self.cframe + CFrameType cf = self.cframe n, ndim = _validate_pos_arr(w) cdef double [::1] pot = np.zeros(n) @@ -51,7 +51,7 @@ cdef class CFrameWrapper: """ cdef: int n, ndim, i - CFrame cf = self.cframe + CFrameType cf = self.cframe n, ndim = _validate_pos_arr(w) cdef double[:, ::1] dH = np.zeros((n, ndim)) @@ -71,7 +71,7 @@ cdef class CFrameWrapper: """ cdef: int n, ndim, i - CFrame cf = self.cframe + CFrameType cf = self.cframe n, ndim = _validate_pos_arr(w) cdef double[:, :, ::1] d2H = np.zeros((n, ndim, ndim)) diff --git a/gala/potential/frame/src/cframe.c b/gala/potential/frame/src/cframe.c index c4beccb13..f8d10f0a0 100644 --- a/gala/potential/frame/src/cframe.c +++ b/gala/potential/frame/src/cframe.c @@ -1,15 +1,15 @@ #include "frame/src/cframe.h" -double frame_hamiltonian(CFrame *fr, double t, double *qp, int n_dim) { +double frame_hamiltonian(CFrameType *fr, double t, double *qp, int n_dim) { double v = (fr->energy)(t, (fr->parameters), qp, n_dim); return v; } -void frame_gradient(CFrame *fr, double t, double *qp, int n_dim, double *dH) { +void frame_gradient(CFrameType *fr, double t, double *qp, int n_dim, double *dH) { (fr->gradient)(t, (fr->parameters), qp, n_dim, dH); } -void frame_hessian(CFrame *fr, double t, double *qp, int n_dim, double *d2H) { +void frame_hessian(CFrameType *fr, double t, double *qp, int n_dim, double *d2H) { // TODO: not implemented!! // TODO: can I just add in the terms from the frame here? // (fr->hessian)(t, (fr->parameters), qp, n_dim, d2H); diff --git a/gala/potential/frame/src/cframe.h b/gala/potential/frame/src/cframe.h index a15008cb6..92ddf2521 100644 --- a/gala/potential/frame/src/cframe.h +++ b/gala/potential/frame/src/cframe.h @@ -2,9 +2,9 @@ #ifndef _CFRAME_H #define _CFRAME_H - typedef struct _CFrame CFrame; + // typedef struct CFrameType CFrame; - struct _CFrame { + typedef struct { // arrays of pointers to each of the function types above energyfunc energy; gradientfunc gradient; @@ -14,9 +14,9 @@ // pointer to the parameter array double *parameters; - }; + } CFrameType; #endif -extern double frame_hamiltonian(CFrame *fr, double t, double *qp, int n_dim); -extern void frame_gradient(CFrame *fr, double t, double *qp, int n_dim, double *dH); -extern void frame_hessian(CFrame *fr, double t, double *qp, int n_dim, double *d2H); +extern double frame_hamiltonian(CFrameType *fr, double t, double *qp, int n_dim); +extern void frame_gradient(CFrameType *fr, double t, double *qp, int n_dim, double *dH); +extern void frame_hessian(CFrameType *fr, double t, double *qp, int n_dim, double *d2H); diff --git a/gala/potential/hamiltonian/src/chamiltonian.c b/gala/potential/hamiltonian/src/chamiltonian.c index e7d0775e7..02f49f1b6 100644 --- a/gala/potential/hamiltonian/src/chamiltonian.c +++ b/gala/potential/hamiltonian/src/chamiltonian.c @@ -2,7 +2,7 @@ #include "potential/src/cpotential.h" #include "frame/src/cframe.h" -double hamiltonian_value(CPotential *p, CFrame *fr, double t, double *qp) { +double hamiltonian_value(CPotential *p, CFrameType *fr, double t, double *qp) { double v = 0; int i; @@ -16,7 +16,7 @@ double hamiltonian_value(CPotential *p, CFrame *fr, double t, double *qp) { return v; } -void hamiltonian_gradient(CPotential *p, CFrame *fr, double t, double *qp, double *dH) { +void hamiltonian_gradient(CPotential *p, CFrameType *fr, double t, double *qp, double *dH) { int i; for (i=0; i < 2*(p->n_dim); i++) { @@ -33,7 +33,7 @@ void hamiltonian_gradient(CPotential *p, CFrame *fr, double t, double *qp, doubl } } -void hamiltonian_hessian(CPotential *p, CFrame *fr, double t, double *qp, double *d2H) { +void hamiltonian_hessian(CPotential *p, CFrameType *fr, double t, double *qp, double *d2H) { int i; for (i=0; i < p->n_components; i++) { diff --git a/gala/potential/hamiltonian/src/chamiltonian.h b/gala/potential/hamiltonian/src/chamiltonian.h index d9f08b9b7..fdcf47131 100644 --- a/gala/potential/hamiltonian/src/chamiltonian.h +++ b/gala/potential/hamiltonian/src/chamiltonian.h @@ -1,6 +1,6 @@ #include "potential/src/cpotential.h" #include "frame/src/cframe.h" -extern double hamiltonian_value(CPotential *p, CFrame *fr, double t, double *q); -extern void hamiltonian_gradient(CPotential *p, CFrame *fr, double t, double *q, double *grad); -extern void hamiltonian_hessian(CPotential *p, CFrame *fr, double t, double *q, double *hess); +extern double hamiltonian_value(CPotential *p, CFrameType *fr, double t, double *q); +extern void hamiltonian_gradient(CPotential *p, CFrameType *fr, double t, double *q, double *grad); +extern void hamiltonian_hessian(CPotential *p, CFrameType *fr, double t, double *q, double *hess); diff --git a/gala/potential/scf/tests/test_accp_fortran.py b/gala/potential/scf/tests/test_accp_fortran.py index c17eaff7f..ad2726a18 100644 --- a/gala/potential/scf/tests/test_accp_fortran.py +++ b/gala/potential/scf/tests/test_accp_fortran.py @@ -2,7 +2,7 @@ # Standard library import os -from math import factorial +from math import factorial as _factorial # Third-party from astropy.constants import G as _G @@ -22,13 +22,19 @@ allow_module_level=True) +def factorial(x): + return _factorial(int(x)) + + @pytest.mark.parametrize("basename", [ 'simple-hernquist', 'multi-hernquist', 'simple-nonsph', 'random', 'wang-zhao', ]) def test_density(basename): pos_path = os.path.abspath(get_pkg_data_filename('data/positions.dat.gz')) - coeff_path = os.path.abspath(get_pkg_data_filename('data/{0}.coeff'.format(basename))) - accp_path = os.path.abspath(get_pkg_data_filename('data/{0}-accp.dat.gz'.format(basename))) + coeff_path = os.path.abspath( + get_pkg_data_filename(f'data/{basename}.coeff')) + accp_path = os.path.abspath( + get_pkg_data_filename(f'data/{basename}-accp.dat.gz')) xyz = np.ascontiguousarray(np.loadtxt(pos_path, skiprows=1).T) coeff = np.atleast_2d(np.loadtxt(coeff_path, skiprows=1)) diff --git a/gala/potential/scf/tests/test_computecoeff_fortran.py b/gala/potential/scf/tests/test_computecoeff_fortran.py index 2bfcfe182..26435731c 100644 --- a/gala/potential/scf/tests/test_computecoeff_fortran.py +++ b/gala/potential/scf/tests/test_computecoeff_fortran.py @@ -2,7 +2,7 @@ # Standard library import os -from math import factorial +from math import factorial as _factorial # Third-party from astropy.utils.data import get_pkg_data_filename @@ -20,6 +20,10 @@ # Compare coefficients computed with Fortran to Biff +def factorial(x): + return _factorial(int(x)) + + @pytest.mark.parametrize("basename", [ 'hernquist' ]) diff --git a/setup.cfg b/setup.cfg index f5e271bba..a1776c763 100644 --- a/setup.cfg +++ b/setup.cfg @@ -9,19 +9,19 @@ license_file = LICENSE url = http://gala.adrian.pw/ edit_on_github = False github_project = adrn/gala -python_requires = ">=3.7" +python_requires = ">=3.8" [options] zip_safe = False packages = find: install_requires = - numpy>=1.17 + numpy>=1.20 astropy>=4.2 pyyaml cython>=0.29 - scipy>=1.2 + scipy>=1.6 packaging -python_requires = >=3.7 +python_requires = >=3.8 setup_requires = setuptools_scm extension-helpers diff --git a/tox.ini b/tox.ini index d8cf21a7c..55ad58cd5 100644 --- a/tox.ini +++ b/tox.ini @@ -2,7 +2,7 @@ [tox] envlist = - py{37,38,39}-test{,-extradeps,-devdeps,-oldestdeps}{,-cov} + py{38,39,310}-test{,-extradeps,-devdeps,-oldestdeps}{,-cov} codestyle nogsl @@ -42,10 +42,10 @@ description = deps = # The oldestdeps factor is intended to be used to install the oldest # versions of all dependencies that have a minimum version. - oldestdeps: numpy==1.18.* - oldestdeps: matplotlib==3.0.* - oldestdeps: scipy==1.4.* - oldestdeps: astropy==4.0.* + oldestdeps: numpy==1.20.* + oldestdeps: matplotlib==3.4.* + oldestdeps: scipy==1.6.* + oldestdeps: astropy==4.2.* devdeps: :NIGHTLY:numpy devdeps: git+https://github.com/astropy/astropy.git#egg=astropy