diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 3f41cab..38428f7 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -12,44 +12,39 @@ on: jobs: test: - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} strategy: matrix: + os: [ubuntu-latest, macos-latest] python-version: ['3.10', '3.11', '3.12'] steps: - uses: actions/checkout@v4 - - name: Setup system - run: | - sudo apt-get update - sudo apt-get install libnetcdff-dev netcdf-bin - - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - - uses: actions/cache@v3 + - uses: actions/cache@v4 id: cache-virtualenv with: path: ${{ env.pythonLocation }} key: ${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }} - name: Build MORS - if: steps.cache-virtualenv.outputs.cache-hit != 'true' run: | python -m pip install -e .[develop] - uses: actions/cache@v3 id: cache-fwl-data with: - path: /home/runner/work/fwl_data + path: $HOME/work/fwl_data key: fwl-data-1 - name: Test with pytest run: | - export FWL_DATA="/home/runner/work/fwl_data" + export FWL_DATA="$HOME/work/fwl_data" coverage run -m pytest - name: Report coverage diff --git a/src/mors/parameters.py b/src/mors/parameters.py index 03e7781..c1d0de0 100644 --- a/src/mors/parameters.py +++ b/src/mors/parameters.py @@ -18,7 +18,7 @@ def SetDefaultParameters(paramsDefault): """Sets up the default parameters.""" # Time integration solver parameters - paramsDefault['TimeIntegrationMethod'] = 'Rosenbrock' # options are 'ForwardEuler', 'RungeKutta4', 'RungeKuttaFehlberg', 'Rosenbrock' + paramsDefault['TimeIntegrationMethod'] = 'ForwardEuler' # options are 'ForwardEuler', 'RungeKutta4', 'RungeKuttaFehlberg', 'Rosenbrock' paramsDefault['nStepMax'] = 10**6 # maximum number of timesteps to allow before error paramsDefault['DeltaDesired'] = 1.0e-5 # desired Delta value to use in numerical solvers such as Runge-Kutta-Fehlberg and Rosenbrock paramsDefault['AgeMinDefault'] = 1.0 # Myr - default age to start evolutionary tracks diff --git a/src/mors/stellarevo.py b/src/mors/stellarevo.py index cef9ab5..279f734 100644 --- a/src/mors/stellarevo.py +++ b/src/mors/stellarevo.py @@ -331,7 +331,7 @@ def _ReadEvolutionTrack(starEvoDir,evoModels,Mstar,MstarFilenameMiddle): dRcoredt[:] = _CalculateGradient( Age , Rcore ) # Round mass and ages to nDecValue decimal places as specified at top of file - Mstar = round( Mstar , nDecValue ) + Mstar = np.round( Mstar , decimals=nDecValue ) Age = np.round( Age , decimals=nDecValue ) # Add all quantities to the dictionary @@ -496,7 +496,7 @@ def _LoadTrack(Mstar,ModelData): """Takes stellar mass and model data dictionary, returns dictionary with track for this mass.""" # Round mass to nDecValue decimal places specified at top of this file - Mstar = round( Mstar , nDecValue ) + Mstar = np.round( Mstar , decimals=nDecValue ) # Make sure within mass limit _CheckMassLimit( ModelData['MstarAll'] , Mstar ) @@ -728,7 +728,7 @@ def _CheckAgeLimit(AgeArray,Age): """Takes age track and an age, outputs error and stops code if age is not within limits.""" # Round the age to decimal places determined by nDecValue at top of file - Age = round( Age , nDecValue ) + Age = np.round( Age , decimals=nDecValue ) # Do check if not ( AgeArray[0] <= Age <= AgeArray[-1] ): @@ -747,17 +747,13 @@ def _CheckMassLimit(MstarArray,Mstar): def _Interpolate2D(Z1,Z2,Z,Xarray1,Xarray2,X,Yarray1,Yarray2): """Takes two sets of 1D arrays for corresponding X and Y values, returns interpolated Y value corresponding to input X.""" - # Round the input values to decimal places determined by nDecValue at top of file - Z = round( Z , nDecValue ) - # Do interpolations to get Y at X for both tracks Y1 = _Interpolate1D( Xarray1 , Yarray1 , X ) Y2 = _Interpolate1D( Xarray2 , Yarray2 , X ) # Do linear interpolation between Y1 and Y2 in Z direction - mInterp = ( Y2 - Y1 ) / ( Z2 - Z1 ) - cInterp = Y1 - mInterp * Z1 - Y = mInterp * Z + cInterp + delta = (Z-Z1)/(Z2-Z1) + Y = Y2*delta + Y1*(1-delta) return Y @@ -766,9 +762,6 @@ def _Interpolate1D(Xarray,Yarray,X): # Note that it is assumed here that Xarray is in ascending order and this won't work if it is not - # Round the input values to decimal places determined by nDecValue at top of file - X = round( X , nDecValue ) - # Make sure X is in limits if not ( Xarray[0] <= X <= Xarray[-1] ): raise Exception("input value "+str(X)+" is not within limits of "+str(Xarray[0])+" to "+str(Xarray[-1])) @@ -785,9 +778,8 @@ def _Interpolate1D(Xarray,Yarray,X): else: # Do linear interpolation - mInterp = ( Yarray[iMax] - Yarray[iMin] ) / ( Xarray[iMax] - Xarray[iMin] ) - cInterp = Yarray[iMin] - mInterp * Xarray[iMin] - Y = mInterp * X + cInterp + delta = (X-Xarray[iMin])/(Xarray[iMax]-Xarray[iMin]) + Y = Yarray[iMax]*delta + Yarray[iMin]*(1-delta) return Y diff --git a/tests/test_spada.py b/tests/test_spada.py index 5dcda46..4959c0e 100644 --- a/tests/test_spada.py +++ b/tests/test_spada.py @@ -3,8 +3,10 @@ from numpy.testing import assert_allclose TEST_DATA = ( - ((0.128, 45.2, 8.5e1),(0.21263373, 1.68612613e+31, 1.74497354e+28)), - ((1.113, 17.7, 3.2e3),(1.16581856, 6.81769993e+33, 7.95296357e+28)), + ((0.128, 45.2, 8.5e1),(0.21263373, 1.68612614e+31, 1.73275380e+28)), + ((1.113, 17.7, 3.2e3),(1.16581827, 6.81769926e+33, 7.94292986e+28)), + ((0.995, 1.005, 1.0e4),(1.48904952e+00, 7.80667546e+33, 3.22933432e+28)), + ((1.000, 1.00, 1.0e4),(1.52583342e+00, 8.13191736e+33, 3.38245392e+28)), ) @pytest.mark.parametrize("inp,expected", TEST_DATA)