Skip to content

Commit

Permalink
Merge pull request #70 from rmnldwg/release-1.0.0.a5
Browse files Browse the repository at this point in the history
Release 1.0.0.a5
  • Loading branch information
rmnldwg authored Feb 6, 2024
2 parents 12c3e8a + a51c6d5 commit 61975fe
Show file tree
Hide file tree
Showing 72 changed files with 671 additions and 271,222 deletions.
64 changes: 63 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,70 @@

All notable changes to this project will be documented in this file.

<a name="1.0.0.a5"></a>
## [1.0.0.a5] - 2024-02-06

## [Unreleased]
In this alpha release we fixed more bugs and issues that emerged during more rigorous testing.

Most notably, we backed away from storing the transition matrix in a model's instance. Because it created opaque and confusion calls to functions trying to delete them when parameters were updated.

Instead, the function computing the transition matrix is now globally cached using a hash function from the graph representation. This has the drawback of slightly more computation time when calculating the hash. But the advantage is that e.g. in a bilateral symmetric model, the transition matrix of the two sides is only ever computed once when (synched) parameters are updated.

### Bug Fixes

- (**graph**) Assume `nodes` is dictionary, not a list
- (**uni**) Update `draw_patients()` method to output LyProX style data
- (**bi**) Update bilateral data generation method to also generate LyProX style data
- (**bi**) Syntax error in `init_synchronization`
- (**uni**) Remove need for transition matrix deletion via a global cache
- (**uni**) Use cached matrices & simplify stuff
- (**uni**) Observation matrix only property, not cached anymore

### Documentation

- Fix typos & formatting errors in docstrings

### Features

- (**graph**) Implement graph hash for global cache of transition matrix
- (**helper**) Add an `arg0` cache decorator that caches based on the first argument only
- (**matrix**) Use cache for observation & diagnose matrices

### Miscellaneous Tasks

- Update dependencies & classifiers

### Refactor

- Variables inside `generate_transition()`

### Testing

- Make doctests discoverable by unittest
- Update tests to changed API
- (**uni**) Assert format & distribution of drawn patients
- (**uni**) Allow larger delta for synthetic data distribution
- (**bi**) Check bilateral data generation method
- Check the bilateral model with symmetric tumor spread
- Make sure delete & recompute synced edges' tensor work
- Adapt tests to changed `Edge` API
- (**bi**) Evaluate transition matrix recomputation
- Update tests to match new transition matrix code
- Update trinary unilateral tests

### Change

-**BREAKING** Compute transition tensor globally
-**BREAKING** Make transition matrix a method instead of a property
-**BREAKING** Make observation matrix a method instead of a property

### Ci

- Add coverage test dependency back into project

### Remove

- Unused files and directories


<a name="1.0.0.a4"></a>
Expand Down
203 changes: 0 additions & 203 deletions docs/source/_data/bilateral.csv

This file was deleted.

Binary file removed docs/source/_data/demo.hdf5
Binary file not shown.
149 changes: 0 additions & 149 deletions docs/source/_data/example.csv

This file was deleted.

Binary file removed docs/source/_data/samples.hdf5
Binary file not shown.
18 changes: 15 additions & 3 deletions lymph/diagnose_times.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,21 @@ def set_params(self, **kwargs) -> None:
warnings.warn("Distribution is not updateable, skipping...")


def draw(self) -> np.ndarray:
"""Draw sample of diagnose times from the PMF."""
return np.random.choice(a=self.support, p=self.distribution)
def draw_diag_times(
self,
num: int | None = None,
rng: np.random.Generator | None = None,
seed: int = 42,
) -> np.ndarray:
"""Draw ``num`` samples of diagnose times from the stored PMF.
A random number generator can be provided as ``rng``. If ``None``, a new one
is initialized with the given ``seed`` (or ``42``, by default).
"""
if rng is None:
rng = np.random.default_rng(seed)

return rng.choice(a=self.support, p=self.distribution, size=num)


class DistributionsUserDict(AbstractLookupDict):
Expand Down
Loading

0 comments on commit 61975fe

Please sign in to comment.