From dc59caa6fa3c0b283262c2e5ba19a963ec5572b4 Mon Sep 17 00:00:00 2001 From: melodiemonod Date: Thu, 18 Jul 2024 17:36:35 +0100 Subject: [PATCH 01/10] template paper --- paper/paper.md | 107 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 paper/paper.md diff --git a/paper/paper.md b/paper/paper.md new file mode 100644 index 0000000..40b1b79 --- /dev/null +++ b/paper/paper.md @@ -0,0 +1,107 @@ +--- +title: '\texttt{TorchSurv}: A Lightweight Package for Deep Survival Analysis' +tags: + - Python + - radiomics + - medical imaging +authors: + - name: Alex Zwanenburg + orcid: 0000-0002-0342-9545 + affiliation: "1, 2" + - name: Steffen Löck + orcid: 0000-0002-7017-3738 + affiliation: "2, 3, 4" +affiliations: + - name: "National Center for Tumor Diseases Dresden (NCT/UCC), Germany: German Cancer Research Center (DKFZ), Heidelberg, Germany; Faculty of Medicine and University Hospital Carl Gustav Carus, TUD Dresden University of Technology, Dresden, Germany; Helmholtz-Zentrum Dresden-Rossendorf (HZDR), Dresden, Germany" + index: 1 + - name: OncoRay – National Center for Radiation Research in Oncology, Faculty of Medicine and University Hospital Carl + Gustav Carus, TUD Dresden University of Technology, Helmholtz-Zentrum Dresden-Rossendorf, Dresden, Germany + index: 2 + - name: German Cancer Consortium (DKTK), Partner Site Dresden, and German Cancer Research Center (DKFZ), Heidelberg, Germany + index: 3 + - name: Department of Radiotherapy and Radiation Oncology, Faculty of Medicine and University Hospital Carl Gustav Carus, TUD Dresden University of Technology, Dresden, Germany + index: 4 +date: 7 February 2024 +bibliography: paper.bib +--- + +# Summary + +The forces on stars, galaxies, and dark matter under external gravitational +fields lead to the dynamical evolution of structures in the universe. The orbits +of these bodies are therefore key to understanding the formation, history, and +future state of galaxies. The field of "galactic dynamics," which aims to model +the gravitating components of galaxies to study their structure and evolution, +is now well-established, commonly taught, and frequently used in astronomy. +Aside from toy problems and demonstrations, the majority of problems require +efficient numerical tools, many of which require the same base code (e.g., for +performing numerical orbit integration). + +# Statement of need + +`Gala` is an Astropy-affiliated Python package for galactic dynamics. Python +enables wrapping low-level languages (e.g., C) for speed without losing +flexibility or ease-of-use in the user-interface. The API for `Gala` was +designed to provide a class-based and user-friendly interface to fast (C or +Cython-optimized) implementations of common operations such as gravitational +potential and force evaluation, orbit integration, dynamical transformations, +and chaos indicators for nonlinear dynamics. `Gala` also relies heavily on and +interfaces well with the implementations of physical units and astronomical +coordinate systems in the `Astropy` package [@astropy] (`astropy.units` and +`astropy.coordinates`). + +`Gala` was designed to be used by both astronomical researchers and by +students in courses on gravitational dynamics or astronomy. It has already been +used in a number of scientific publications [@Pearson:2017] and has also been +used in graduate courses on Galactic dynamics to, e.g., provide interactive +visualizations of textbook material [@Binney:2008]. The combination of speed, +design, and support for Astropy functionality in `Gala` will enable exciting +scientific explorations of forthcoming data releases from the *Gaia* mission +[@gaia] by students and experts alike. + +# Mathematics + +Single dollars ($) are required for inline mathematics e.g. $f(x) = e^{\pi/x}$ + +Double dollars make self-standing equations: + +$$\Theta(x) = \left\{\begin{array}{l} +0\textrm{ if } x < 0\cr +1\textrm{ else} +\end{array}\right.$$ + +You can also use plain \LaTeX for equations +\begin{equation}\label{eq:fourier} +\hat f(\omega) = \int_{-\infty}^{\infty} f(x) e^{i\omega x} dx +\end{equation} +and refer to \autoref{eq:fourier} from text. + +# Citations + +Citations to entries in paper.bib should be in +[rMarkdown](http://rmarkdown.rstudio.com/authoring_bibliographies_and_citations.html) +format. + +If you want to cite a software repository URL (e.g. something on GitHub without a preferred +citation) then you can do it with the example BibTeX entry below for @fidgit. + +For a quick reference, the following citation commands can be used: +- `@author:2001` -> "Author et al. (2001)" +- `[@author:2001]` -> "(Author et al., 2001)" +- `[@author1:2001; @author2:2001]` -> "(Author1 et al., 2001; Author2 et al., 2002)" + +# Figures + +Figures can be included like this: +![Caption for example figure.\label{fig:example}](figure.png) +and referenced from text using \autoref{fig:example}. + +Figure sizes can be customized by adding an optional second parameter: +![Caption for example figure.](figure.png){ width=20% } + +# Acknowledgements + +We acknowledge contributions from Brigitta Sipocz, Syrtis Major, and Semyeong +Oh, and support from Kathryn Johnston during the genesis of this project. + +# References From 95d70f388ddf1d82e4d77930c429e1a18375c156 Mon Sep 17 00:00:00 2001 From: melodiemonod Date: Thu, 18 Jul 2024 17:36:48 +0100 Subject: [PATCH 02/10] template paper --- paper/paper.bib | 59 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 paper/paper.bib diff --git a/paper/paper.bib b/paper/paper.bib new file mode 100644 index 0000000..72e3977 --- /dev/null +++ b/paper/paper.bib @@ -0,0 +1,59 @@ +@article{Pearson:2017, + url = {http://adsabs.harvard.edu/abs/2017arXiv170304627P}, + Archiveprefix = {arXiv}, + Author = {{Pearson}, S. and {Price-Whelan}, A.~M. and {Johnston}, K.~V.}, + Eprint = {1703.04627}, + Journal = {ArXiv e-prints}, + Keywords = {Astrophysics - Astrophysics of Galaxies}, + Month = mar, + Title = {{Gaps in Globular Cluster Streams: Pal 5 and the Galactic Bar}}, + Year = 2017 +} + +@book{Binney:2008, + url = {http://adsabs.harvard.edu/abs/2008gady.book.....B}, + Author = {{Binney}, J. and {Tremaine}, S.}, + Booktitle = {Galactic Dynamics: Second Edition, by James Binney and Scott Tremaine.~ISBN 978-0-691-13026-2 (HB).~Published by Princeton University Press, Princeton, NJ USA, 2008.}, + Publisher = {Princeton University Press}, + Title = {{Galactic Dynamics: Second Edition}}, + Year = 2008 +} + +@article{gaia, + author = {{Gaia Collaboration}}, + title = "{The Gaia mission}", + journal = {Astronomy and Astrophysics}, + archivePrefix = "arXiv", + eprint = {1609.04153}, + primaryClass = "astro-ph.IM", + keywords = {space vehicles: instruments, Galaxy: structure, astrometry, parallaxes, proper motions, telescopes}, + year = 2016, + month = nov, + volume = 595, + doi = {10.1051/0004-6361/201629272}, + url = {http://adsabs.harvard.edu/abs/2016A%26A...595A...1G}, +} + +@article{astropy, + author = {{Astropy Collaboration}}, + title = "{Astropy: A community Python package for astronomy}", + journal = {Astronomy and Astrophysics}, + archivePrefix = "arXiv", + eprint = {1307.6212}, + primaryClass = "astro-ph.IM", + keywords = {methods: data analysis, methods: miscellaneous, virtual observatory tools}, + year = 2013, + month = oct, + volume = 558, + doi = {10.1051/0004-6361/201322068}, + url = {http://adsabs.harvard.edu/abs/2013A%26A...558A..33A} +} + +@misc{fidgit, + author = {A. M. Smith and K. Thaney and M. Hahnel}, + title = {Fidgit: An ungodly union of GitHub and Figshare}, + year = {2020}, + publisher = {GitHub}, + journal = {GitHub repository}, + url = {https://github.com/arfon/fidgit} +} \ No newline at end of file From 8a9292d7f9727db0d8a8f0d7d50d2747df853036 Mon Sep 17 00:00:00 2001 From: melodiemonod Date: Thu, 18 Jul 2024 17:39:15 +0100 Subject: [PATCH 03/10] Revert "template paper" This reverts commit 95d70f388ddf1d82e4d77930c429e1a18375c156. --- paper/paper.bib | 59 ------------------------------------------------- 1 file changed, 59 deletions(-) delete mode 100644 paper/paper.bib diff --git a/paper/paper.bib b/paper/paper.bib deleted file mode 100644 index 72e3977..0000000 --- a/paper/paper.bib +++ /dev/null @@ -1,59 +0,0 @@ -@article{Pearson:2017, - url = {http://adsabs.harvard.edu/abs/2017arXiv170304627P}, - Archiveprefix = {arXiv}, - Author = {{Pearson}, S. and {Price-Whelan}, A.~M. and {Johnston}, K.~V.}, - Eprint = {1703.04627}, - Journal = {ArXiv e-prints}, - Keywords = {Astrophysics - Astrophysics of Galaxies}, - Month = mar, - Title = {{Gaps in Globular Cluster Streams: Pal 5 and the Galactic Bar}}, - Year = 2017 -} - -@book{Binney:2008, - url = {http://adsabs.harvard.edu/abs/2008gady.book.....B}, - Author = {{Binney}, J. and {Tremaine}, S.}, - Booktitle = {Galactic Dynamics: Second Edition, by James Binney and Scott Tremaine.~ISBN 978-0-691-13026-2 (HB).~Published by Princeton University Press, Princeton, NJ USA, 2008.}, - Publisher = {Princeton University Press}, - Title = {{Galactic Dynamics: Second Edition}}, - Year = 2008 -} - -@article{gaia, - author = {{Gaia Collaboration}}, - title = "{The Gaia mission}", - journal = {Astronomy and Astrophysics}, - archivePrefix = "arXiv", - eprint = {1609.04153}, - primaryClass = "astro-ph.IM", - keywords = {space vehicles: instruments, Galaxy: structure, astrometry, parallaxes, proper motions, telescopes}, - year = 2016, - month = nov, - volume = 595, - doi = {10.1051/0004-6361/201629272}, - url = {http://adsabs.harvard.edu/abs/2016A%26A...595A...1G}, -} - -@article{astropy, - author = {{Astropy Collaboration}}, - title = "{Astropy: A community Python package for astronomy}", - journal = {Astronomy and Astrophysics}, - archivePrefix = "arXiv", - eprint = {1307.6212}, - primaryClass = "astro-ph.IM", - keywords = {methods: data analysis, methods: miscellaneous, virtual observatory tools}, - year = 2013, - month = oct, - volume = 558, - doi = {10.1051/0004-6361/201322068}, - url = {http://adsabs.harvard.edu/abs/2013A%26A...558A..33A} -} - -@misc{fidgit, - author = {A. M. Smith and K. Thaney and M. Hahnel}, - title = {Fidgit: An ungodly union of GitHub and Figshare}, - year = {2020}, - publisher = {GitHub}, - journal = {GitHub repository}, - url = {https://github.com/arfon/fidgit} -} \ No newline at end of file From fa1d306da463327e7e17f6bea3c119fb13f01395 Mon Sep 17 00:00:00 2001 From: melodiemonod Date: Thu, 18 Jul 2024 17:40:07 +0100 Subject: [PATCH 04/10] Revert "template paper" This reverts commit dc59caa6fa3c0b283262c2e5ba19a963ec5572b4. --- paper/paper.md | 107 ------------------------------------------------- 1 file changed, 107 deletions(-) delete mode 100644 paper/paper.md diff --git a/paper/paper.md b/paper/paper.md deleted file mode 100644 index 40b1b79..0000000 --- a/paper/paper.md +++ /dev/null @@ -1,107 +0,0 @@ ---- -title: '\texttt{TorchSurv}: A Lightweight Package for Deep Survival Analysis' -tags: - - Python - - radiomics - - medical imaging -authors: - - name: Alex Zwanenburg - orcid: 0000-0002-0342-9545 - affiliation: "1, 2" - - name: Steffen Löck - orcid: 0000-0002-7017-3738 - affiliation: "2, 3, 4" -affiliations: - - name: "National Center for Tumor Diseases Dresden (NCT/UCC), Germany: German Cancer Research Center (DKFZ), Heidelberg, Germany; Faculty of Medicine and University Hospital Carl Gustav Carus, TUD Dresden University of Technology, Dresden, Germany; Helmholtz-Zentrum Dresden-Rossendorf (HZDR), Dresden, Germany" - index: 1 - - name: OncoRay – National Center for Radiation Research in Oncology, Faculty of Medicine and University Hospital Carl - Gustav Carus, TUD Dresden University of Technology, Helmholtz-Zentrum Dresden-Rossendorf, Dresden, Germany - index: 2 - - name: German Cancer Consortium (DKTK), Partner Site Dresden, and German Cancer Research Center (DKFZ), Heidelberg, Germany - index: 3 - - name: Department of Radiotherapy and Radiation Oncology, Faculty of Medicine and University Hospital Carl Gustav Carus, TUD Dresden University of Technology, Dresden, Germany - index: 4 -date: 7 February 2024 -bibliography: paper.bib ---- - -# Summary - -The forces on stars, galaxies, and dark matter under external gravitational -fields lead to the dynamical evolution of structures in the universe. The orbits -of these bodies are therefore key to understanding the formation, history, and -future state of galaxies. The field of "galactic dynamics," which aims to model -the gravitating components of galaxies to study their structure and evolution, -is now well-established, commonly taught, and frequently used in astronomy. -Aside from toy problems and demonstrations, the majority of problems require -efficient numerical tools, many of which require the same base code (e.g., for -performing numerical orbit integration). - -# Statement of need - -`Gala` is an Astropy-affiliated Python package for galactic dynamics. Python -enables wrapping low-level languages (e.g., C) for speed without losing -flexibility or ease-of-use in the user-interface. The API for `Gala` was -designed to provide a class-based and user-friendly interface to fast (C or -Cython-optimized) implementations of common operations such as gravitational -potential and force evaluation, orbit integration, dynamical transformations, -and chaos indicators for nonlinear dynamics. `Gala` also relies heavily on and -interfaces well with the implementations of physical units and astronomical -coordinate systems in the `Astropy` package [@astropy] (`astropy.units` and -`astropy.coordinates`). - -`Gala` was designed to be used by both astronomical researchers and by -students in courses on gravitational dynamics or astronomy. It has already been -used in a number of scientific publications [@Pearson:2017] and has also been -used in graduate courses on Galactic dynamics to, e.g., provide interactive -visualizations of textbook material [@Binney:2008]. The combination of speed, -design, and support for Astropy functionality in `Gala` will enable exciting -scientific explorations of forthcoming data releases from the *Gaia* mission -[@gaia] by students and experts alike. - -# Mathematics - -Single dollars ($) are required for inline mathematics e.g. $f(x) = e^{\pi/x}$ - -Double dollars make self-standing equations: - -$$\Theta(x) = \left\{\begin{array}{l} -0\textrm{ if } x < 0\cr -1\textrm{ else} -\end{array}\right.$$ - -You can also use plain \LaTeX for equations -\begin{equation}\label{eq:fourier} -\hat f(\omega) = \int_{-\infty}^{\infty} f(x) e^{i\omega x} dx -\end{equation} -and refer to \autoref{eq:fourier} from text. - -# Citations - -Citations to entries in paper.bib should be in -[rMarkdown](http://rmarkdown.rstudio.com/authoring_bibliographies_and_citations.html) -format. - -If you want to cite a software repository URL (e.g. something on GitHub without a preferred -citation) then you can do it with the example BibTeX entry below for @fidgit. - -For a quick reference, the following citation commands can be used: -- `@author:2001` -> "Author et al. (2001)" -- `[@author:2001]` -> "(Author et al., 2001)" -- `[@author1:2001; @author2:2001]` -> "(Author1 et al., 2001; Author2 et al., 2002)" - -# Figures - -Figures can be included like this: -![Caption for example figure.\label{fig:example}](figure.png) -and referenced from text using \autoref{fig:example}. - -Figure sizes can be customized by adding an optional second parameter: -![Caption for example figure.](figure.png){ width=20% } - -# Acknowledgements - -We acknowledge contributions from Brigitta Sipocz, Syrtis Major, and Semyeong -Oh, and support from Kathryn Johnston during the genesis of this project. - -# References From 42a95a555f2f9d0c8d29dcb42523fa4e5a072002 Mon Sep 17 00:00:00 2001 From: corolth1 Date: Mon, 29 Jul 2024 13:59:49 -0400 Subject: [PATCH 05/10] safer eval model --- src/torchsurv/loss/momentum.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/torchsurv/loss/momentum.py b/src/torchsurv/loss/momentum.py index 67596c6..545cbf0 100644 --- a/src/torchsurv/loss/momentum.py +++ b/src/torchsurv/loss/momentum.py @@ -162,7 +162,7 @@ def forward( self.memory_k.append(self.survtuple(*list(estimate))) return loss - @torch.no_grad() + @torch.no_grad() # deactivates autograd def infer(self, inputs: torch.Tensor) -> torch.Tensor: """Evaluate data with target network @@ -183,8 +183,8 @@ def infer(self, inputs: torch.Tensor) -> torch.Tensor: [ 0.9771, -0.8513]]) """ - self.target.eval() # Disable training tricks (augmentation, dropout, etc..) - return self.target(inputs) + with self.target.eval(): # notify all your layers that you are in eval mode + return self.target(inputs) def _bank_loss(self) -> torch.Tensor: """computer the negative loss likelyhood from memory bank""" From 3e3051ac1ef9bcf4ebade82856ad18ea9ebcb13a Mon Sep 17 00:00:00 2001 From: corolth1 Date: Mon, 29 Jul 2024 14:08:28 -0400 Subject: [PATCH 06/10] reverted change --- src/torchsurv/loss/momentum.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/torchsurv/loss/momentum.py b/src/torchsurv/loss/momentum.py index 545cbf0..8cab479 100644 --- a/src/torchsurv/loss/momentum.py +++ b/src/torchsurv/loss/momentum.py @@ -183,8 +183,8 @@ def infer(self, inputs: torch.Tensor) -> torch.Tensor: [ 0.9771, -0.8513]]) """ - with self.target.eval(): # notify all your layers that you are in eval mode - return self.target(inputs) + self.target.eval() # notify all your layers that you are in eval mode + return self.target(inputs) def _bank_loss(self) -> torch.Tensor: """computer the negative loss likelyhood from memory bank""" From 056042917e3ee09aca38e1b1fc1f2a97ae8c2a20 Mon Sep 17 00:00:00 2001 From: Thibaud Coroller <14895385+tcoroller@users.noreply.github.com> Date: Wed, 31 Jul 2024 13:48:29 -0400 Subject: [PATCH 07/10] added badge conda (#47) --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 48ee8f3..968b2d5 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ ![CodeQC](https://github.com/Novartis/torchsurv/actions/workflows/codeqc.yml/badge.svg?branch=main) ![Docs](https://github.com/Novartis/torchsurv/actions/workflows/docs.yml/badge.svg?branch=main) [![PyPI - Version](https://img.shields.io/pypi/v/torchsurv)](https://pypi.org/project/torchsurv/) +[![Conda](https://img.shields.io/conda/v/conda-forge/torchsurv?label=conda&color=success)](https://anaconda.org/conda-forge/torchsurv) [![arXiv](https://img.shields.io/badge/arXiv-2404.10761-f9f107.svg)](https://arxiv.org/abs/2404.10761) [![Documentation](https://img.shields.io/badge/GithubPage-Sphinx-blue)](https://opensource.nibr.com/torchsurv/) [![Downloads](https://static.pepy.tech/badge/torchsurv)](https://pepy.tech/project/torchsurv) @@ -236,4 +237,4 @@ If you use this project in academic work or publications, we appreciate citing i primaryClass={cs.LG}, doi={https://doi.org/10.48550/arXiv.2404.10761} } -``` \ No newline at end of file +``` From 41f5911b95e0ff1c1c23dd0ae17b66635ec1fdba Mon Sep 17 00:00:00 2001 From: Thibaud Coroller <14895385+tcoroller@users.noreply.github.com> Date: Wed, 31 Jul 2024 14:18:40 -0400 Subject: [PATCH 08/10] Added conda information --- README.md | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 968b2d5..656e576 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,14 @@ ![CodeQC](https://github.com/Novartis/torchsurv/actions/workflows/codeqc.yml/badge.svg?branch=main) ![Docs](https://github.com/Novartis/torchsurv/actions/workflows/docs.yml/badge.svg?branch=main) -[![PyPI - Version](https://img.shields.io/pypi/v/torchsurv)](https://pypi.org/project/torchsurv/) -[![Conda](https://img.shields.io/conda/v/conda-forge/torchsurv?label=conda&color=success)](https://anaconda.org/conda-forge/torchsurv) -[![arXiv](https://img.shields.io/badge/arXiv-2404.10761-f9f107.svg)](https://arxiv.org/abs/2404.10761) +[![PyPI - Version](https://img.shields.io/pypi/v/torchsurv?)](https://pypi.org/project/torchsurv/) +[![Conda](https://img.shields.io/conda/v/conda-forge/torchsurv?label=conda)](https://anaconda.org/conda-forge/torchsurv) +[![arXiv](https://img.shields.io/badge/arXiv-2404.10761-f9f107.svg?)](https://arxiv.org/abs/2404.10761) [![Documentation](https://img.shields.io/badge/GithubPage-Sphinx-blue)](https://opensource.nibr.com/torchsurv/) -[![Downloads](https://static.pepy.tech/badge/torchsurv)](https://pepy.tech/project/torchsurv) +[![PyPI Downloads](https://img.shields.io/pypi/dm/torchsurv.svg?label=PyPI%20downloads)]( +https://pypi.org/project/torchsurv/) +[![Conda Downloads](https://img.shields.io/conda/dn/conda-forge/torchsurv.svg?label=Conda%20downloads)]( +https://anaconda.org/conda-forge/torchsurv) `TorchSurv` is a Python package that serves as a companion tool to perform deep survival modeling within the `PyTorch` environment. Unlike existing libraries that impose specific parametric forms on users, `TorchSurv` enables the use of custom `PyTorch`-based deep survival models. With its lightweight design, minimal input requirements, full `PyTorch` backend, and freedom from restrictive survival model parameterizations, `TorchSurv` facilitates efficient survival model implementation, particularly beneficial for high-dimensional input data scenarios. @@ -43,15 +46,23 @@ cindex.compare(cindexB) ## Installation and dependencies -First, install the package: +First, install the package using either [PyPI]([https://pypi.org/](https://pypi.org/project/torchsurv/)) or [Conda]([https://anaconda.org/anaconda/conda](https://anaconda.org/conda-forge/torchsurv)) + +- Using conda (`recommended`) +```bash +conda install conda-forge::torchsurv +``` +- Using PyPI ```bash pip install torchsurv ``` -or for local installation (from package root / clone of this git repository): +- Using for local installation (`latest version`) ```bash +git clone +cd pip install -e . ``` From 015e45d36235184f936eee4153f27571a5abb3b4 Mon Sep 17 00:00:00 2001 From: corolth1 Date: Fri, 9 Aug 2024 13:57:02 -0400 Subject: [PATCH 09/10] clamped log_hazard to prevent torch.Inf --- src/torchsurv/loss/weibull.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/torchsurv/loss/weibull.py b/src/torchsurv/loss/weibull.py index 7f166ff..926488a 100644 --- a/src/torchsurv/loss/weibull.py +++ b/src/torchsurv/loss/weibull.py @@ -226,6 +226,9 @@ def log_hazard( >>> for t in torch.tensor([100.0, 150.0]): log_hazard(log_params, time=t) # Subject-specific log hazard at multiple new times tensor([ 1.1280, -0.0372, -3.9767, 1.0757]) tensor([ 1.2330, -0.1062, -4.1680, 1.1999]) + >>> log_params *= 1e2 # Increase scale + >>> log_hazard(log_params, time, all_times = False) # Check for Torch.Inf values + tensor([-1.0000e+10, -2.3197e+01, -6.8385e+01, -1.0000e+10]) """ log_scale, log_shape = _check_log_shape(log_params).unbind(1) @@ -247,11 +250,13 @@ def log_hazard( f"Dimension mismatch: 'time' ({len(time)}) does not match the length of 'log_params' ({len(log_params)})." ) - return ( + return torch.clamp( log_shape - log_scale + torch.expm1(log_shape) - * (torch.log(torch.clip(time, 1e-100, torch.inf)) - log_scale) + * (torch.log(torch.clip(time, 1e-100, torch.inf)) - log_scale), + min=-TORCH_CLAMP_VALUE, + max=TORCH_CLAMP_VALUE, ) From 4e4d8fb4294ad15de0ce629ba0b5163d1264fbdc Mon Sep 17 00:00:00 2001 From: "Peter Krusche (Novartis)" Date: Thu, 26 Sep 2024 16:57:35 +0200 Subject: [PATCH 10/10] try fix CI builds (#53) * try fix builds * partial rollback * fix build dependency * make formatting mandatory & reformat kaplan meier test * add unreleased note * edited * adding sphinx-issues for Changelog links * reverted change --------- Co-authored-by: corolth1 --- .github/workflows/build-release.yml | 2 +- .github/workflows/codeqc.yml | 4 ++-- dev/environment.yml | 2 +- docs/CHANGELOG.md | 10 ++++++++++ tests/test_kaplan_meier.py | 6 +++--- 5 files changed, 17 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 324137e..cd773c9 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -27,7 +27,7 @@ jobs: run: python -m twine check dist/* - name: Upload artifact - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: Python-package path: dist diff --git a/.github/workflows/codeqc.yml b/.github/workflows/codeqc.yml index 15108a6..b9cdf09 100644 --- a/.github/workflows/codeqc.yml +++ b/.github/workflows/codeqc.yml @@ -46,8 +46,8 @@ jobs: shell: bash -l {0} run: | conda activate torchsurv - ./dev/codeqc.sh - + ./dev/codeqc.sh check + - name: Tests shell: bash -l {0} run: | diff --git a/dev/environment.yml b/dev/environment.yml index 51ba6c2..4e00bbd 100644 --- a/dev/environment.yml +++ b/dev/environment.yml @@ -3,7 +3,7 @@ channels: - conda-forge - pytorch dependencies: - - build=0.7.0 + - python-build=1.2.2 - pep517=0.13.0 - numpy=1.26.4 - pandas=2.2.0 diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 1762da4..a78e8e3 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,6 +1,16 @@ Change log ========= +Version 0.1.3 (unreleased) +-------------------------- + +* Tutorial dataset error on momentum.ipynb #50 +* Fix issue #48 - log_hazard returns torch.Inf +* Fix warning with Spearman correlation #41 +* Added in-depth statistical background to link AUC to C-index #39 +* Created Conda Forge version #47 +* Updated CICD builds #53 + Version 0.1.2 ------------- diff --git a/tests/test_kaplan_meier.py b/tests/test_kaplan_meier.py index cfff910..62e0a5d 100644 --- a/tests/test_kaplan_meier.py +++ b/tests/test_kaplan_meier.py @@ -208,9 +208,9 @@ def test_kaplan_meier_prediction_error_raised(self): for batch in batch_container.batches: (train_time, train_event, test_time, *_) = batch - train_event[ - -1 - ] = False # if last event is censoring, the last KM is > 0 and it cannot predict beyond this time + train_event[-1] = ( + False # if last event is censoring, the last KM is > 0 and it cannot predict beyond this time + ) km = KaplanMeierEstimator() km(train_event, train_time, censoring_dist=False)