Skip to content
Merged
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
30 changes: 0 additions & 30 deletions .github/workflows/build.yml

This file was deleted.

56 changes: 56 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Build and release Python package on PyPI

on:
release:
types: [ created ]

workflow_dispatch:

jobs:
build:
name: Build package from source
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0
- name: Install Python 3
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install build tools
run: |
python3 -m pip install build --user
- name: Build package
run: |
python3 -m build
- name: Upload to CI runner
uses: actions/upload-artifact@v4
with:
name: built-package
path: dist/

pypi-publish:
name: Publish built package on PyPI
runs-on: ubuntu-latest
needs:
- build

# Specifying a GitHub environment is optional, but strongly encouraged
environment:
name: pypi
url: https://pypi.org/p/lymph-model
permissions:
# IMPORTANT: this permission is mandatory for Trusted Publishing
id-token: write
steps:
# retrieve your distributions here
- name: Download from CI runner
uses: actions/download-artifact@v4
with:
name: built-package
path: dist/
- name: Publish on PyPI
uses: pypa/gh-action-pypi-publish@release/v1
59 changes: 59 additions & 0 deletions .github/workflows/testpypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Build and release Python package on TestPyPI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:

jobs:
build:
name: Build package from source
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0
- name: Install Python 3
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install build tools
run: |
python3 -m pip install build --user
- name: Build package
run: |
python3 -m build
- name: Upload to CI runner
uses: actions/upload-artifact@v4
with:
name: built-package
path: dist/

testpypi-publish:
name: Publish built package on TestPyPI
runs-on: ubuntu-latest
needs:
- build

# Specifying a GitHub environment is optional, but strongly encouraged
environment:
name: testpypi
url: https://test.pypi.org/p/lymph-model
permissions:
# IMPORTANT: this permission is mandatory for Trusted Publishing
id-token: write
steps:
# retrieve your distributions here
- name: Download from CI runner
uses: actions/download-artifact@v4
with:
name: built-package
path: dist/
- name: Publish on PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
41 changes: 41 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,46 @@

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

## [1.3.4] - 2025-05-27

### Bug Fixes

- Don't use `or` when param may be 0.\
Since Python's expression `a = b or c` will assign `c` to `a` as soon as
`b` is "falsy", e.g. also when `b = 0.0`, I should not use this to check
if a parameter in the model is `None`.

### Documentation

- Fix misspelled repo link.
- Remove empty mixins page.
- Better reuse of README.
- Move social card to repo root.\
This is actually for LyProX: I want to display the social card of all
repos in the lycosystem on LyProX's landing page. Therefore, they all
need to be in their expected places.

### Miscellaneous Tasks

- Add year range to license.

### Testing

- Use val != 0.5 to test matrix deletion.\
0.5 is the new initial value for most parameters, so it does not make
sense to use this to check if upon changing a parameter, the transition
matrix gets deleted.

### Change

- Init most params with 0.5 instead of 0.0.\
In some cases, initializing with 0.0 may have unintended consequences.
E.g., a probability of 0.0 cannot be renormalized.

### Ci

- Use OIDC for publishing.

## [1.3.3] - 2025-03-11

### Bug Fixes
Expand Down Expand Up @@ -866,6 +906,7 @@ Almost the entire API has changed. I'd therefore recommend to have a look at the
- fix pyproject.toml typo
- add pre-commit hook to check commit msg

[1.3.4]: https://github.com/rmnldwg/lymph/compare/1.3.3...1.3.4
[1.3.3]: https://github.com/rmnldwg/lymph/compare/1.3.2...1.3.3
[1.3.2]: https://github.com/rmnldwg/lymph/compare/1.3.1...1.3.2
[1.3.1]: https://github.com/rmnldwg/lymph/compare/1.3.0...1.3.1
Expand Down
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2020 Roman Ludwig & contributors
Copyright (c) 2020 - 2025 Roman Ludwig & contributors

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 All @@ -16,4 +16,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.
29 changes: 1 addition & 28 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,34 +68,7 @@ LyProX interface

The above mentioned data can also be explored interactively using our online interface `LyProX <https://lyprox.org>`_ `(GitHub repo) <https://github.com/rmnldwg/lyprox>`_.





























.. SEPARATOR

References
==========
Expand Down
8 changes: 0 additions & 8 deletions docs/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,6 @@ Detailed API

graph
models
mixins
components
types
utils


Index & search
--------------

* :ref:`genindex`
* :ref:`search`
3 changes: 0 additions & 3 deletions docs/source/badges.rst

This file was deleted.

3 changes: 0 additions & 3 deletions docs/source/explanation.rst

This file was deleted.

21 changes: 4 additions & 17 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
.. image:: ./_static/github-social-card.png
:width: 800 px

.. include:: badges.rst

----

.. include:: explanation.rst
.. include:: ../../README.rst
:end-before: .. SEPARATOR

----

Expand All @@ -15,20 +9,13 @@ Documentation

.. toctree::
:maxdepth: 3
:caption: Content

install
quickstart
api
license


Index & search
--------------

* :ref:`genindex`
* :ref:`search`

----

.. include:: refs.rst
.. include:: ../../README.rst
:start-after: .. SEPARATOR
12 changes: 0 additions & 12 deletions docs/source/mixins.rst

This file was deleted.

2 changes: 0 additions & 2 deletions docs/source/refs.rst

This file was deleted.

File renamed without changes
5 changes: 4 additions & 1 deletion lymph/diagnosis_times.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,10 @@ def set_params(self, *args: float, **kwargs: float) -> tuple[float]:

for name, value in self._func.keywords.items():
first, args = popfirst(args)
self._func.keywords[name] = first or kwargs.get(name, value)
if first is not None:
self._func.keywords[name] = first
else:
self._func.keywords[name] = kwargs.get(name, value)
if hasattr(self, "_frozen"):
del self._frozen

Expand Down
8 changes: 4 additions & 4 deletions lymph/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def __init__(
self,
parent: Tumor | LymphNodeLevel,
child: LymphNodeLevel,
spread_prob: float = 0.0,
spread_prob: float = 0.5,
micro_mod: float = 1.0,
) -> None:
"""Create a new edge between two nodes.
Expand Down Expand Up @@ -362,7 +362,7 @@ def set_micro_mod(self, new_micro_mod: float | None) -> None:
def get_spread_prob(self) -> float:
"""Return the spread probability."""
if not hasattr(self, "_spread_prob"):
self._spread_prob = 0.0
self._spread_prob = 0.5
return self._spread_prob

def set_spread_prob(self, new_spread_prob: float | None) -> None:
Expand Down Expand Up @@ -433,7 +433,7 @@ def set_params(self, *args, **kwargs) -> tuple[float]:
0.4
"""
first, args = popfirst(args)
value = first or self.get_spread_prob()
value = first if first is not None else self.get_spread_prob()

if self.is_growth:
self.set_spread_prob(kwargs.get("growth", value))
Expand All @@ -446,7 +446,7 @@ def set_params(self, *args, **kwargs) -> tuple[float]:
and not self.is_growth
):
first, args = popfirst(args)
value = first or self.get_micro_mod()
value = first if first is not None else self.get_micro_mod()
self.set_micro_mod(kwargs.get("micro", value))

return args
Expand Down
8 changes: 5 additions & 3 deletions lymph/models/midline.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@ def __init__(
other_children["unknown"] = self.unknown

if use_mixing:
self.mixing_param = 0.0
self.mixing_param = 0.5

self.midext_prob = 0.0
self.midext_prob = 0.5

diagnosis_times.Composite.__init__(
self,
Expand Down Expand Up @@ -489,7 +489,9 @@ def set_params(
"""
last_param_idx = self.get_num_dims() - 1
before, last, after = utils.popat(args, idx=last_param_idx)
self.midext_prob = kwargs.get("midext_prob", last) or self.midext_prob
if kwargs.get("midext_prob", last) is not None:
self.midext_prob = kwargs.get("midext_prob", last)

args = self.set_spread_params(*(before + after), **kwargs)
return self.set_distribution_params(*args, **kwargs)

Expand Down
Loading
Loading