Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
199 commits
Select commit Hold shift + click to select a range
98e74b5
Add support for selecting subsets of data for calibration
RomeshA Apr 2, 2024
08bfb32
Enable specifying initial values for the y-factors
epbennetts Apr 26, 2024
4242b8b
Merge branch 'timed-initialization' into temporal_weights
epbennetts May 7, 2024
e87c855
Merge remote-tracking branch 'origin/develop' into temporal_weights
RomeshA May 28, 2024
875b2ac
Change *_time to *_year, and permit superfluous arguments
RomeshA May 31, 2024
0b4270f
Only call ASD if there are pars to adjust left after filtering
epbennetts May 31, 2024
adc6e2a
Add YAML calibration file
RomeshA Jun 3, 2024
134f1ad
Improve default handling
RomeshA Jun 3, 2024
34a3978
Update Project.calibrate() to support YAML
RomeshA Jun 3, 2024
078d405
Merge branch 'temporal_weights' of github.com:atomicateam/atomica int…
RomeshA Jun 3, 2024
d757dbc
Minor bug fix, type hints
epbennetts Jun 4, 2024
3674902
Implemented make_constant_parset option for reinitialisation node
epbennetts Jun 5, 2024
fcae52b
Bug fix: Let max_time update from yaml
epbennetts Jun 10, 2024
b58a5d4
Revert last update
epbennetts Jun 17, 2024
6855395
Fixed measurables populations not expanding properly
epbennetts Jun 17, 2024
3e5da16
Merge pull request #501 from atomicateam/enable-transfer-calibration
RomeshA Jun 28, 2024
bfbcf53
Merge pull request #502 from atomicateam/develop
RomeshA Jun 28, 2024
193418e
Add missing dependency for deployment
RomeshA Jun 29, 2024
e19dee1
Merge pull request #503 from atomicateam/develop
RomeshA Jun 30, 2024
44c766f
Implement total population calibration
phillipluong Jul 4, 2024
6472179
Enable spaces within adjustable/measurable and pop labels
epbennetts Jul 4, 2024
6dc0f8d
Slight adjustments to tvec
phillipluong Jul 5, 2024
c354ca9
Merge branch 'develop' into total_pop_calibration
phillipluong Jul 5, 2024
0cd77e1
Reduce case sensitivity
RomeshA Jul 10, 2024
773dd78
Update docstring, version and changelog
RomeshA Jul 12, 2024
e5d6857
Merge pull request #506 from atomicateam/total_pop_calibration
RomeshA Jul 12, 2024
75b697a
Prevent doubling up of print statements on save
epbennetts Jul 23, 2024
ea5b2c7
Prevent doubling up of populations in optimisation and print statements
epbennetts Jul 23, 2024
c7c6a8b
Set default value for minval in optim_args
epbennetts Jul 23, 2024
453295f
Ability to set verbose from kwargs
epbennetts Jul 23, 2024
5f0c05d
Prevent doubling up of measurables populations
epbennetts Jul 24, 2024
4779a1c
Refactoring for consistency
epbennetts Jul 24, 2024
ffa8fbf
Merge branch 'master' into temporal_weights
RomeshA Jul 26, 2024
839981e
Enable transfer calibration
RomeshA Jul 26, 2024
08617f7
Support '_from_' transfer naming in `ParameterSet.get_par()`
RomeshA Jul 26, 2024
7dfbecc
Clarify warning
RomeshA Jul 26, 2024
9c20678
Check for extra 'population' rows (this is specifically used for 'tot…
RomeshA Jul 26, 2024
d7e0563
Support _from_ syntax in yaml calibration
RomeshA Jul 26, 2024
4c90bc4
Remove unused code
RomeshA Jul 26, 2024
13c4ad1
Merge remote-tracking branch 'origin/develop' into temporal_weights
RomeshA Jul 26, 2024
4d3e6f3
Update to limit support to 'total' and make it case insensitive
RomeshA Jul 26, 2024
a5e12e4
Make warning clearer
RomeshA Jul 26, 2024
be8a3e1
Possible fix for duplicated initial values
RomeshA Jul 26, 2024
493972f
Use Atomica's copy of get_sigfigs_necessary()
RomeshA Aug 19, 2024
07999d0
Ensure output directory exists
RomeshA Aug 19, 2024
239dfd6
Merge branch 'temporal_weights' of https://github.com/atomicateam/ato…
epbennetts Aug 20, 2024
ded6fed
Rename start_year, end_year to cal_start, cal_end
epbennetts Aug 20, 2024
4fa5765
Rename year to init_year
epbennetts Aug 20, 2024
b3649b7
Enable user to set the constant parset year
epbennetts Aug 20, 2024
0b96e14
Yaml calibration testing
epbennetts Aug 20, 2024
edebd86
Enable adding a custom provenance to default values that will populat…
RomeshA Aug 21, 2024
3508a47
Merge branch 'temporal_weights' of github.com:atomicateam/atomica int…
RomeshA Aug 21, 2024
e0ad8f7
Merge branch 'temporal_weights' of https://github.com/atomicateam/ato…
epbennetts Aug 22, 2024
54e09bd
Add yaml tests
epbennetts Aug 26, 2024
02f7e21
Add yaml tests
epbennetts Aug 27, 2024
d545730
Add repeats test, update simtime test
epbennetts Aug 27, 2024
dfd04a5
Enable calibrating transfers
epbennetts Aug 27, 2024
2e0eb35
Improve float formatting
RomeshA Aug 29, 2024
6a2c097
Add validation of time aggregation type
RomeshA Aug 29, 2024
98d010b
Fix time aggregation validation
RomeshA Aug 29, 2024
44627af
Improve comment
RomeshA Aug 29, 2024
f3faa26
Process calibration inputs with parentheses
epbennetts Aug 29, 2024
519cd52
Merge branch 'temporal_weights' of github.com:atomicateam/atomica int…
RomeshA Aug 29, 2024
f903c27
Don't create databook spreadsheets unnecessarily
RomeshA Aug 29, 2024
066d4e1
Merge branch 'faster-project-init' into temporal_weights
RomeshA Aug 30, 2024
a64da57
Merge pull request #507 from atomicateam/faster-project-init
RomeshA Aug 30, 2024
837203d
Fix calibrating transfers with no to_population specified
RomeshA Aug 30, 2024
e243d6d
Finish enabling transfers in dict form
epbennetts Aug 30, 2024
bb5f09b
Fix check_optional_number TypeError
epbennetts Aug 30, 2024
bf48a2a
update cal_start and cal_end
alina-muellenmeister Sep 3, 2024
623ef38
save a copy of the yaml file
alina-muellenmeister Sep 4, 2024
eac53fd
Add guard to prevent setting time_period if YAML file is in use
RomeshA Sep 5, 2024
1162a6b
Merge remote-tracking branch 'origin/temporal_weights' into temporal_…
RomeshA Sep 5, 2024
5d93853
Clear existing initializations when loading calibrations
RomeshA Sep 5, 2024
a6b38d5
Make initialization slightly more permissive if value is 0
RomeshA Sep 6, 2024
cb78ee6
Fix a numerical precision edge case when calculating simulation time …
RomeshA Sep 9, 2024
65b9392
Merge branch 'temporal_weights' of https://github.com/atomicateam/ato…
epbennetts Sep 11, 2024
14b56c7
allow for 0 timed compartment durations
alina-muellenmeister Sep 11, 2024
ddf30ef
improve process_key()
epbennetts Sep 19, 2024
9c1e77d
Enable transfers in list format, deprecate pop space formatting
epbennetts Sep 23, 2024
ba0d0b6
Enable dict format with empty values
epbennetts Sep 23, 2024
a437acd
Improve testing of whether constant_parset is a number (not bool)
epbennetts Sep 23, 2024
5b73362
Rename initial_value to starting_y_factor
epbennetts Sep 23, 2024
fb0a4ba
Expand docstrings, add type hints
epbennetts Sep 23, 2024
b90b9ba
Make tuple conversion more explicit
epbennetts Sep 23, 2024
d844197
Fix tuple conversion
epbennetts Sep 23, 2024
89f2bf8
Improve robustness for timed compartments with 0 duration
RomeshA Sep 23, 2024
14af4d8
Update migration version package
RomeshA Sep 23, 2024
ac77d86
Merge branch 'temporal_weights' of github.com:atomicateam/atomica int…
RomeshA Sep 23, 2024
b89c19f
Update YAML tests
RomeshA Sep 24, 2024
dc2a702
Change aggregation logic for characteristics
RomeshA Sep 25, 2024
194d85a
Update default for characteristics
RomeshA Sep 25, 2024
7eb03e6
add a devtest to check numerical precision of time vector
alina-muellenmeister Oct 3, 2024
86950e5
specify dtype in np.linspace
alina-muellenmeister Oct 3, 2024
e7a8d4d
clean up dev test
alina-muellenmeister Oct 4, 2024
ab3e4ea
update assert
alina-muellenmeister Oct 4, 2024
8af5553
following Kelvin's suggestion: Updating to np.arange(), multiply by s…
alina-muellenmeister Oct 4, 2024
0491875
Merge pull request #510 from atomicateam/time_vector_precision
alina-muellenmeister Oct 10, 2024
10ade85
Make timed compartment size check more robust
RomeshA Oct 14, 2024
7acb213
Fix array length in time aggregation using Kelvin's approach
RomeshA Oct 16, 2024
641bc7c
Use exact time points when within numerical tolerance
RomeshA Oct 16, 2024
b5d0bc7
Add missing test framework
RomeshA Oct 18, 2024
b842bb6
WIP
RomeshA Oct 28, 2024
863d8df
Update default aggregation method and selection of default method
RomeshA Oct 30, 2024
e451106
Remove flake8 job, change development status
RomeshA Oct 30, 2024
f478bab
Change test result publishing version
RomeshA Oct 30, 2024
b740afa
Update date
RomeshA Oct 30, 2024
f80c2a2
Revert test path - original implementation was needed for tox
RomeshA Oct 30, 2024
cfb274c
Merge pull request #509 from atomicateam/denominator-weighting
RomeshA Oct 31, 2024
d8fa3ea
Merge remote-tracking branch 'origin/develop' into temporal_weights
RomeshA Oct 31, 2024
2b4cfcb
Handle out of bounds bins in time aggregation more explicitly without…
RomeshA Oct 31, 2024
f0246ec
Improve time aggregation to no longer interpolate unless necessary
RomeshA Nov 4, 2024
adaf5eb
Tweak text
RomeshA Nov 13, 2024
4aeeb94
Add code for a 'Databook default all' column in the framework
Rowanmh Feb 6, 2025
fdb66fe
Add hierarchical YAML test
epbennetts Feb 13, 2025
999d139
Add stripped tutorial notebooks
epbennetts Feb 13, 2025
0de5d3e
Add PNG plots
epbennetts Feb 13, 2025
99f8324
Add framework and databook
epbennetts Feb 13, 2025
3c7f70e
Add calibration scripts
epbennetts Feb 13, 2025
63220e9
Add YAML files shown in tutorial
epbennetts Feb 13, 2025
f2d4ea7
Add typhoid YAML file and calibration output
epbennetts Feb 13, 2025
eda9576
Add worked example solutions
epbennetts Feb 13, 2025
cc7ab6f
Add calibration outputs of YAML files shown in the tutorial
epbennetts Feb 13, 2025
5d8b66b
Add stripped plotting notebooks
epbennetts Feb 13, 2025
17fbfc7
Add README
epbennetts Feb 13, 2025
764b7d9
Update tutorial text
epbennetts Feb 13, 2025
95666ff
Remove extra calculations
RomeshA Feb 17, 2025
9c9b456
Resolve todos and fix links
RomeshA Feb 17, 2025
6963e52
Switch to non-sciris separate legend routine and update for matplotli…
RomeshA Feb 17, 2025
3147dd5
Increment version
RomeshA Feb 17, 2025
16cce41
Apply auto-formatting
RomeshA Feb 17, 2025
760d175
Replace with patched sciris function
RomeshA Feb 17, 2025
f8091fd
Update python version in tox.ini
RomeshA Feb 17, 2025
6af1b20
Update how path is identified
RomeshA Feb 17, 2025
aba4678
Merge pull request #500 from atomicateam/temporal_weights
RomeshA Feb 17, 2025
f6cc262
Merge branch 'master' into develop
RomeshA Feb 17, 2025
108d940
Merge pull request #511 from atomicateam/develop
RomeshA Feb 17, 2025
8111029
Merge branch 'master' into databook-default-all-column
RomeshA Feb 17, 2025
4d4fa17
Add test
RomeshA Feb 18, 2025
e16cdfa
Fix migrations
RomeshA Feb 18, 2025
5d26e89
Increment version, update logic for manually edited tables
RomeshA Feb 18, 2025
d8d5926
Update formatting
RomeshA Feb 18, 2025
23ac424
Update PyPI url
RomeshA Feb 18, 2025
aef5b47
Add version attribute
RomeshA Feb 18, 2025
13b1117
Fix typo
RomeshA Feb 18, 2025
cfd1ece
Merge pull request #512 from atomicateam/databook-default-all-column
RomeshA Feb 18, 2025
ffa16e7
Add deaths calibration to all worked example steps
epbennetts Feb 20, 2025
0e789fc
Change initialisation spelling to initialization in YAML files
epbennetts Feb 20, 2025
e30d084
Update T7 notebook
epbennetts Feb 21, 2025
a12466e
Update YAML tutorial notebooks
epbennetts Mar 4, 2025
966a7d3
YAML tutorial edits
epbennetts Mar 6, 2025
87a0d75
Update YAML documentation
epbennetts Mar 6, 2025
2628236
Consistent spelling in T7
epbennetts Mar 6, 2025
616dcd0
Fix table
RomeshA Mar 10, 2025
7ec5502
Merge pull request #516 from atomicateam/tutorials_EPB
RomeshA Mar 10, 2025
0599e8a
Merge pull request #513 from atomicateam/develop
RomeshA Mar 10, 2025
9483b7b
replace setup.py with pyproject.toml
cliffckerr May 30, 2025
8b6fc9f
update version
cliffckerr May 30, 2025
2e9ed30
update order
cliffckerr May 30, 2025
708dc0e
add gitinfo back to version module
cliffckerr May 30, 2025
784a1c9
update license date
cliffckerr May 30, 2025
256fde2
Lift numpy version restriction
RomeshA Jun 2, 2025
46a40d9
Fix RST link syntax
RomeshA Jun 2, 2025
5146fe6
Fix comment
RomeshA Jun 18, 2025
9192dc1
Adjust precision
RomeshA Jun 18, 2025
9f0626e
Merge pull request #518 from atomicateam/update-install
RomeshA Jun 18, 2025
cd1ddeb
Merge pull request #519 from atomicateam/develop
RomeshA Jun 18, 2025
ca9a4fd
Update build/deploy commands
RomeshA Jun 18, 2025
51545de
Fix issue with duplicate databook sheet names
RomeshA Jun 25, 2025
8fe80dd
Proposed solution
RomeshA Jun 27, 2025
865a5e1
Add a test (although overall suite doesn't pass yet)
RomeshA Jun 27, 2025
f634cc1
Fix error message
RomeshA Jun 27, 2025
d23d05a
Improve message
RomeshA Jun 27, 2025
e083bdc
Improve comment
RomeshA Jun 30, 2025
c7d96f2
Resolve numpy deprecation warning (plus it's a fraction faster too)
RomeshA Jul 7, 2025
3a177cb
Add function to clear TimeSeries objects
RomeshA Jul 8, 2025
62207d5
Add separate initialization tolerance
RomeshA Jul 14, 2025
fa31a9d
Improve error message
RomeshA Jul 14, 2025
4503757
Switch to more recent numpy function
RomeshA Jul 14, 2025
5a85b7f
Add additional logging level
RomeshA Jul 21, 2025
16efa1e
Update initialization method to enforce zero compartments by omitting…
RomeshA Aug 11, 2025
41297eb
Switch pipeline to main
RomeshA Aug 11, 2025
9af6d36
Allow numerical differences
RomeshA Aug 11, 2025
d41f162
Merge pull request #522 from atomicateam/init-fix
RomeshA Aug 11, 2025
e2db271
Merge pull request #523 from atomicateam/develop
RomeshA Aug 11, 2025
623feb8
Changes for tests to pass with Pandas 3
RomeshA Jan 27, 2026
b739bfd
Fix deprecated ast.Str
RomeshA Jan 27, 2026
4a75e91
Merge branch 'init-fix' into python_314_fixes
RomeshA Jan 27, 2026
3ebab73
Increment version
RomeshA Jan 27, 2026
37a0e0c
Merge pull request #524 from atomicateam/python_314_fixes
RomeshA Jan 28, 2026
e91ece0
Merge pull request #525 from atomicateam/main
RomeshA Jan 28, 2026
684ebb4
Update pyswarm syntax and version
cliffckerr May 25, 2026
2a01472
Merge branch 'develop' into fix-optimization-regression
cliffckerr May 25, 2026
22aef73
Fix pyswarm.pso() call and update pyproject.toml
RomeshA May 25, 2026
836f481
Increment version
RomeshA May 25, 2026
4ce4337
Force pyswarm 1.0.0
RomeshA May 25, 2026
e02a054
Maintain compatibility as Mac OS is installing a different version
RomeshA May 26, 2026
b365b31
Fix typo
RomeshA May 26, 2026
bd66200
Merge pull request #528 from atomicateam/fix-optimization-regression
RomeshA May 26, 2026
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
78 changes: 73 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,92 @@

This file records changes to the codebase grouped by version release. Unreleased changes are generally only present during development (relevant parts of the changelog can be written and saved in that section before a version number has been assigned)

## [1.28.5] - 2023-06-28
## [1.31.5] - 2026-05-26

- Update optimization function for compatibility with latest `pyswarm` release
- Update minimum Python version to 3.10 as previous versions are deprecated

## [1.31.4] - 2026-01-28

- Updated internal functions for Python 3.14 and Pandas 3.0.0

## [1.31.3] - 2025-08-11

- Changed initialization method to increase prioritization for characteristics with zero value. If a characteristic has a zero value, this will now automatically force included compartments to have a zero value. In practice, this means that it is less likely that frameworks will cause negative initial popsizes, so some frameworks that previously did not work will now initialize correctly.
- Added `at.TimeSeries.clear()` to reset a time series while preserving the units. This function can be useful when updating the value of databook quantities programatically.
- Added a separate numerical tolerance used for initialization (`at.model.model_settings['initialization_tolerance']`) which permits more approximate initializations while still maintaining the same numerical tolerance for the rest of the integration.
- Added another logging level (`at.VERBOSE`) which enables more targeted additional output

- *Backwards-compatibility notes*

- Some initializations might show numerical (e.g., `1e-10`) differences in their values due to the new algorithm. In a small number of cases (depending on the framework), it is possible that the updated initialization method could result in a slightly different initialization.
- The default initialization tolerance is now `1e-3` instead of `1e-6`, some models that previously raised a `BadInitialization` error will now run without error. Users should note that if it's necessary to guarantee an exact initialization, this tolerance should be reduced.

## [1.31.2] - 2025-06-26

- Fix bug in creating databook if framework 'Databook pages' sheet contains multiple code names mapping to the same full name.

## [1.31.1] - 2025-05-30

- Switched from `setup.py` to `pyproject.toml`-based installation.

## [1.31.0] - 2025-02-18

- Framework definitions of compartments, characteristics, and parameters support a new column 'databook default all'. If set to 'y', then when a databook is produced, the data entry table will only contain a record for 'All' instead of having population-specific rows. Further manual editing of the tables is supported as normal.

## [1.30.0] - 2025-02-17

- Automatic calibration can now selectively weight parts of the time series to select or prioritise a subset of time points.
- Added YAML-based calibration support to Atomica, covered in Tutorial 7 in the online documentation.

## [1.29.0] - 2024-10-30

- `ProjectSettings` now computes the simulation time vector in a more robust way to reduce edge cases where the reported `sim_dt` doesn't match the input.
- `ParameterSet.load_calibration()` now clears any existing initialization if the calibration being loaded does not contain an initialization. Previously, the absence of an 'initialization' sheet in the calibration would be treated as not making any change to the initialization. This could cause calibrations to become mixed if a calibration without an initialization was loaded after a calibration with an initialization. Now, a missing initialization sheet is treated as meaning 'no initialization' and any existing initialization will be cleared when the calibration is loaded.
- `Project.load_databook()` will no longer populate `Project.databook` when a `ProjectData` instance is supplied rather than a spreadsheet. The intention of `Project.databook` as opposed to `Project.data.to_spreadsheet()` is that the original databook may contain comments or other content that is not preserved when the databook is loaded into a `ProjectData` instance. Therefore, `Project.databook` serves as a record of the original inputs. However, in previous versions of Atomica, if a `ProjectData` instance was provided rather than a spreadsheet, `ProjectData.to_spreadsheet()` would be used to populate `Project.databook`. For large databooks, this can be computationally expensive and particularly affect the use case of passing in a preloaded databook to improve performance. Since the conversion of the `ProjectData` to a spreadsheet upon loading offers no functional difference to creating the spreadsheet from `Project.data` when required, Atomica no longer performs this conversion upfront.
- `PlotData.time_aggregate()` now only interpolates if necessary, using simulated time points as much as possible.

*Backwards-compatibility notes*

- In some edge cases, the simulation time points in the output may be different. In those cases, the difference between simulation time points in the model output would not have matched the model input, although the correct time step would have been used to calculate parameter values. In these cases, there may be an extra time point in the model output. Re-running the model should produce results that are close to the original results.
- If accessing `Project.databook`, in some cases this may now be `None` rather than an `sc.Spreadsheet()`. If that occurs, `Project.data.to_spreadsheet()` should be used to produce an equivalent spreadsheet.
- Time aggregation of `PlotData` may produce slightly different results due to the more accurate selection of time points in this version.
-
## [1.28.7] - 2024-10-29

- If aggregating characteristics with a denominator, weighted aggregations use the denominator of the quantity rather than the total population size to perform the weighting. This can be useful for quantities that are proportions of things other than the population size e.g., proportion of active infections that are diagnosed
- If aggregating characteristics with a denominator, weighted aggregation will be used by default (rather than 'average')
- Output aggregation of durations now uses 'sum' instead of 'average' by default
- If no aggregation method is specified, the aggregation method will now be selected separately for each output
- Population aggregation of non-number units now uses 'weighted' by default rather than 'average'

*Backwards-compatibility notes*

- Results obtained when aggregating characteristics with a denominator using the 'weighted' method will change. To reproduce the previous results, it is necessary to perform the population size weighting manually by removing the aggregation, then extracting the population sizes, and using those to aggregate the outputs. This is considered to be a rare use case because the updated result is a more useful weighting compared to the previous result.
- Results obtained when aggregating characteristics with a denominator _without_ explicitly specifying a method will change, because 'weighted' aggregation is now used by default.

## [1.28.6] - 2024-07-12

- Support entering `'total'` as the population name in auto-calibration measurables to calibrate aggregated values across populations in the model to aggregate values entered in the databook under a 'Total' population

## [1.28.5] - 2024-06-28

- Enable automated calibration of transfers and updated documentation to cover this feature

## [1.28.4] - 2023-05-27
## [1.28.4] - 2024-05-27

- Added an option to save initial compartment sizes inside a `ParameterSet`. Importantly, this saved representation allows setting the initial _subcompartment_ sizes for a `TimedCompartment`. It therefore offers the possibility of initializing the model in a steady state computed from a previous simulation run, that would not be possible to initialize conventionally because standard initialization uniformly distributes people into the subcompartments of a timed compartment.
- Added `ParameterSet.make_constant` to facilitate constructing copies of `ParameterSet` instances that are constant over time.

## [1.28.3] - 2023-05-16
## [1.28.3] - 2024-05-16

- Updated `at.Project()` to explicitly take in the settings arguments for `sim_start`, `sim_end`, and `sim_dt`. These are now applied after databooks are loaded, fixing a bug where these arguments would get overwritten when loading the databook.

## [1.28.2] - 2023-04-05
## [1.28.2] - 2024-04-05

- `at.calibrate` now supports passing any additional arguments into the optimization function e.g., `sc.asd` allowing additional options for customizing the optimization.

## [1.28.1] - 2023-02-05
## [1.28.1] - 2024-02-05

- Updated various Pandas operations to improve compatibility with Pandas 2.2.0
- Replaced 'probability' units with 'rate' units in many of the library example frameworks
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020 Atomica Development Team
Copyright (c) 2017 - 2025 Atomica Development Team

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Build Status](https://dev.azure.com/AtomicaTeam/Atomica/_apis/build/status/atomicateam.atomica?branchName=master)](https://dev.azure.com/AtomicaTeam/Atomica/_build/latest?definitionId=1&branchName=master)

[![PyPi version](https://badgen.net/pypi/v/atomica/)](https://pypi.com/project/atomica)
[![PyPi version](https://badgen.net/pypi/v/atomica/)](https://pypi.org/project/atomica)

Atomica is a simulation engine for compartmental models. It can be used to simulate disease epidemics, health care cascades, and many other things.

Expand Down
29 changes: 20 additions & 9 deletions atomica/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,27 @@
import sys
import logging

VERBOSE = 15
logging.addLevelName(VERBOSE, "VERBOSE")
logger = logging.getLogger("atomica")
logging.Logger.verbose = lambda self, msg, *args, **kwargs: self.log(VERBOSE, msg, *args, **kwargs)

if not logger.handlers:
# Only add handlers if they don't already exist in the module-level logger
# This means that it's possible for the user to completely customize *a* logger called 'atomica'
# prior to importing Atomica, and the user's custom logger won't be overwritten as long as it has
# at least one handler already added. The use case was originally to suppress messages on import, but since
# importing is silent now, it doesn't matter so much.
debug_handler = logging.StreamHandler(sys.stdout) # info_handler will handle all messages below WARNING sending them to STDOUT
info_handler = logging.StreamHandler(sys.stdout) # info_handler will handle all messages below WARNING sending them to STDOUT
debug_handler = logging.StreamHandler(sys.stdout) # handle all messages below WARNING sending them to STDOUT
info_handler = logging.StreamHandler(sys.stdout) # handle all messages below WARNING sending them to STDOUT
warning_handler = logging.StreamHandler(sys.stderr) # warning_handler will send all messages at or above WARNING to STDERR

debug_handler.setLevel(0) # Handle all lower levels - the output should be filtered further by setting the logger level, not the handler level
info_handler.setLevel(logging.INFO) # Handle all lower levels - the output should be filtered further by setting the logger level, not the handler level
debug_handler.setLevel(0) # Handle all levels - the output is then filtered further by setting the logger level, not the handler level
info_handler.setLevel(logging.INFO) # Handle levels INFO or higher
warning_handler.setLevel(logging.WARNING)

debug_handler.addFilter(type("ThresholdFilter", (object,), {"filter": lambda x, logRecord: logRecord.levelno < logging.INFO})()) # Display anything INFO or higher
info_handler.addFilter(type("ThresholdFilter", (object,), {"filter": lambda x, logRecord: logRecord.levelno < logging.WARNING})()) # Don't display WARNING or higher
debug_handler.addFilter(type("ThresholdFilter", (object,), {"filter": lambda x, logRecord: logRecord.levelno < logging.INFO})()) # Display only messages below the INFO level
info_handler.addFilter(type("ThresholdFilter", (object,), {"filter": lambda x, logRecord: logRecord.levelno < logging.WARNING})()) # Display only messages below WARNING (the info_handler level already rejects anything below INFO)

warning_formatter = logging.Formatter("%(levelname)s {%(filename)s:%(lineno)d} - %(message)s")
warning_handler.setFormatter(warning_formatter)
Expand All @@ -56,12 +59,16 @@
logger.addHandler(warning_handler)
logger.setLevel("INFO") # Set the overall log level

from .version import version as __version__, versiondate as __versiondate__, gitinfo as __gitinfo__

# Check scipy version
import scipy
# Get version information
from .version import version as __version__, versiondate as __versiondate__
import sciris as sc
__gitinfo__ = sc.gitinfo(__file__)
version.gitinfo = __gitinfo__ # Add back (so version.py does not require imports)


# Check scipy version
import scipy
if sc.compareversions(scipy.__version__, "1.2.1") < 0:
raise Exception(f"Atomica requires Scipy 1.2.1 or later - installed version is {scipy.__version__}")

Expand Down Expand Up @@ -95,3 +102,7 @@
from .scenarios import *
from .system import *
from .utils import *

import pathlib

rootdir = pathlib.Path(__file__).parent.parent
Loading