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

Next release #88

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 0 additions & 4 deletions .codacy.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12"]
python-version: ["3.11", "3.12", "3.13"]
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v4
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [ "3.11" ]
python-version: [ "3.12" ]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: "pip: Python ${{ matrix.python-version }} coverage"
uses: actions/setup-python@v5
with:
Expand All @@ -27,7 +29,7 @@ jobs:
python -m pip install pybind11 pytest
- name: Build
run: |
CFLAGS=-coverage python -m pip install .
CXXFLAGS=-coverage python -m pip install .
- name: Test
run: |
python -m pytest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/mpi-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.11"]
python-version: ["3.12"]
steps:
- uses: actions/checkout@v4
- name: "pip: Python ${{ matrix.python-version }}"
Expand Down
2 changes: 1 addition & 1 deletion codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ coverage:
threshold: 1% # leeway
patch:
default:
target: 80%
target: 75%
59 changes: 30 additions & 29 deletions docs/custom_timeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,46 @@


class AsymptoticTimeline(neworder.Timeline):
def __init__(self) -> None:
super().__init__()
self.t = 1.0
def __init__(self) -> None:
super().__init__()
self.t = 1.0

@property
def start(self) -> float:
return 0.0
@property
def start(self) -> float:
return 0.0

@property
def end(self) -> float:
return 1.0
@property
def end(self) -> float:
return 1.0

@property
def nsteps(self) -> int:
return -1
@property
def nsteps(self) -> int:
return -1

@property
def time(self) -> float:
return 1.0 - self.t
@property
def time(self) -> float:
return 1.0 - self.t

@property
def dt(self) -> float:
return self.t / 2
@property
def dt(self) -> float:
return self.t / 2

def _next(self) -> None:
self.t /= 2
def _next(self) -> None:
self.t /= 2

@property
def at_end(self) -> bool:
return False
@property
def at_end(self) -> bool:
return False


class Model(neworder.Model):
def __init__(self) -> None:
super().__init__(AsymptoticTimeline())
def __init__(self) -> None:
super().__init__(AsymptoticTimeline())

def step(self) -> None:
neworder.log(f"{self.timeline.index}: {self.timeline.time}")
if self.timeline.time > 0.99:
self.halt()

def step(self) -> None:
neworder.log(f"{self.timeline.index}: {self.timeline.time}")
if self.timeline.time > 0.99:
self.halt()

neworder.run(Model())
4 changes: 3 additions & 1 deletion docs/macros.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
}

# this is the overall record id, not a specific version
_NEWORDER_ZENODO_ID = 4031821 # search using this (or DOI 10.5281/zenodo.4031821) just doesnt work
_NEWORDER_ZENODO_ID = (
4031821 # search using this (or DOI 10.5281/zenodo.4031821) just doesnt work
)


@cache
Expand Down
1 change: 1 addition & 0 deletions examples/chapter1/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
This is a direct neworder cover version of the Basic Cohort Model from the Belanger & Sabourin book
See https://www.microsimulationandpopulationdynamics.com/
"""

import numpy as np
from person import People

Expand Down
1 change: 1 addition & 0 deletions examples/competing/model.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Competing risks - fertility & mortality
"""

# model implementation
from people import People

Expand Down
4 changes: 2 additions & 2 deletions examples/daisyworld/daisyworld.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,15 @@ def __calc_local_heating(self) -> np.ndarray[np.float64, np.dtype[np.float64]]:

# get absorbed luminosity from state
def fs(
state: np.ndarray[np.int64, np.dtype[np.int64]]
state: np.ndarray[np.int64, np.dtype[np.int64]],
) -> np.ndarray[np.float64, np.dtype[np.float64]]:
return (1.0 - self.albedo[state]) * solar_luminosity

abs_lum = fs(self.domain.state)

# get local heating from absorbed luminosity
def fl(
lum: np.ndarray[np.float64, np.dtype[np.float64]]
lum: np.ndarray[np.float64, np.dtype[np.float64]],
) -> np.ndarray[np.float64, np.dtype[np.float64]]:
return 72.0 * np.log(lum) + 80.0

Expand Down
11 changes: 10 additions & 1 deletion examples/infection/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,14 @@
# probability of dying from infection at any point during the infection
MORTALITY = 0.01

m = Infection(POINT, RADIUS, NUM_AGENTS, NUM_INFECTED, SPEED, INFECTION_RADIUS, RECOVERY_TIME, MORTALITY)
m = Infection(
POINT,
RADIUS,
NUM_AGENTS,
NUM_INFECTED,
SPEED,
INFECTION_RADIUS,
RECOVERY_TIME,
MORTALITY,
)
no.run(m)
2 changes: 1 addition & 1 deletion examples/option/black_scholes.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
""" Black-Scholes model implementations: analytic and MC """
"""Black-Scholes model implementations: analytic and MC"""

from typing import Any

Expand Down
1 change: 1 addition & 0 deletions examples/people/model.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
model.py: Population Microsimulation - births, deaths and migration by age, gender and ethnicity
"""

import time
from datetime import date

Expand Down
2 changes: 1 addition & 1 deletion examples/people/population.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
population.py: Model implementation for population microsimulation
population.py: Model implementation for population microsimulation
"""

import os
Expand Down
3 changes: 2 additions & 1 deletion examples/people/pyramid.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
""" pyramid plots """
"""pyramid plots"""

from __future__ import annotations

from typing import Any
Expand Down
1 change: 1 addition & 0 deletions examples/riskpaths/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
available at www.statcan.gc.ca/microsimulation/modgen/modgen-eng.htm'

"""

from riskpaths import RiskPaths
from visualisation import plot

Expand Down
Loading