From 4bafbe0f43424114441f42c2d815a398bd233740 Mon Sep 17 00:00:00 2001 From: haavard Date: Mon, 2 Sep 2024 13:34:08 +0200 Subject: [PATCH 1/6] Update python version --- .github/workflows/publish_pypi.yml | 2 +- .github/workflows/pythonpackage.yml | 6 +++--- setup.py | 5 +---- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/.github/workflows/publish_pypi.yml b/.github/workflows/publish_pypi.yml index e073abe..e6bea8c 100644 --- a/.github/workflows/publish_pypi.yml +++ b/.github/workflows/publish_pypi.yml @@ -12,7 +12,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v1 with: - python-version: 3.7 + python-version: 3.9 - name: Install dependencies run: | python -m pip install --upgrade pip diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 4009f1b..7f85bbd 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -14,15 +14,15 @@ jobs: max-parallel: 4 fail-fast: false matrix: - python-version: [3.6, 3.7, 3.8] + python-version: [3.8, 3.9, 3.10] config: - { os: ubuntu-latest, torch-version: "torch==1.5.0+cpu -f https://download.pytorch.org/whl/torch_stable.html"} - { os: windows-latest, torch-version: "torch==1.5.0+cpu -f https://download.pytorch.org/whl/torch_stable.html"} - { os: macOS-latest, torch-version: "torch"} steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v1 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies diff --git a/setup.py b/setup.py index a9baaa9..28b6040 100644 --- a/setup.py +++ b/setup.py @@ -51,9 +51,6 @@ 'Intended Audience :: Developers', 'License :: OSI Approved :: BSD License', 'Natural Language :: English', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.6', ], - python_requires='>=3.6' + python_requires='>=3.8' ) From 8e8370d516be21dceacaf0a90575093b17c4f8a7 Mon Sep 17 00:00:00 2001 From: haavard Date: Mon, 2 Sep 2024 13:54:46 +0200 Subject: [PATCH 2/6] Fix items and monotonic increasing --- pycox/evaluation/eval_surv.py | 2 +- pycox/models/cox_time.py | 2 +- pycox/models/data.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pycox/evaluation/eval_surv.py b/pycox/evaluation/eval_surv.py index 5e16753..9ad5d8c 100644 --- a/pycox/evaluation/eval_surv.py +++ b/pycox/evaluation/eval_surv.py @@ -33,7 +33,7 @@ def __init__(self, surv, durations, events, censor_surv=None, censor_durations=N self.censor_surv = censor_surv self.censor_durations = censor_durations self.steps = steps - assert pd.Series(self.index_surv).is_monotonic + assert pd.Series(self.index_surv).is_monotonic_increasing @property def censor_surv(self): diff --git a/pycox/models/cox_time.py b/pycox/models/cox_time.py index 12b9cde..e663d67 100644 --- a/pycox/models/cox_time.py +++ b/pycox/models/cox_time.py @@ -94,7 +94,7 @@ def compute_expg_at_risk(ix, t): [self.duration_col] .loc[lambda x: x <= max_duration] .drop_duplicates(keep='first')) - at_risk_sum = (pd.Series([compute_expg_at_risk(ix, t) for ix, t in times.iteritems()], + at_risk_sum = (pd.Series([compute_expg_at_risk(ix, t) for ix, t in times.items()], index=times.values) .rename('at_risk_sum')) events = (df diff --git a/pycox/models/data.py b/pycox/models/data.py index a89b431..52fbafd 100644 --- a/pycox/models/data.py +++ b/pycox/models/data.py @@ -35,7 +35,7 @@ def make_at_risk_dict(durations): allidx = durations.index.values keys = durations.drop_duplicates(keep='first') at_risk_dict = dict() - for ix, t in keys.iteritems(): + for ix, t in keys.items(): at_risk_dict[t] = allidx[ix:] return at_risk_dict From a444bc7dfcd49121662372c06534795fc9663bf3 Mon Sep 17 00:00:00 2001 From: haavard Date: Mon, 2 Sep 2024 14:49:16 +0200 Subject: [PATCH 3/6] Cannot fillna for integer type --- pycox/models/data.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pycox/models/data.py b/pycox/models/data.py index 52fbafd..e2f0c5d 100644 --- a/pycox/models/data.py +++ b/pycox/models/data.py @@ -15,7 +15,6 @@ def sample_alive_from_dates(dates, at_risk_dict, n_control=1): lengths = np.array([at_risk_dict[x].shape[0] for x in dates]) # Can be moved outside idx = (np.random.uniform(size=(n_control, dates.size)) * lengths).astype('int') samp = np.empty((dates.size, n_control), dtype=int) - samp.fill(np.nan) for it, time in enumerate(dates): samp[it, :] = at_risk_dict[time][idx[:, it]] From 842403b54e5f317f8b50665ef2365c9d810944f4 Mon Sep 17 00:00:00 2001 From: haavard Date: Mon, 2 Sep 2024 14:57:04 +0200 Subject: [PATCH 4/6] Update torch version --- .github/workflows/pythonpackage.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 7f85bbd..9a3db60 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -16,8 +16,8 @@ jobs: matrix: python-version: [3.8, 3.9, 3.10] config: - - { os: ubuntu-latest, torch-version: "torch==1.5.0+cpu -f https://download.pytorch.org/whl/torch_stable.html"} - - { os: windows-latest, torch-version: "torch==1.5.0+cpu -f https://download.pytorch.org/whl/torch_stable.html"} + - { os: ubuntu-latest, torch-version: "torch --index-url https://download.pytorch.org/whl/cpu"} + - { os: windows-latest, torch-version: "torch"} - { os: macOS-latest, torch-version: "torch"} steps: - uses: actions/checkout@v4 From 2f1a45b1fdb8808213ee7880fcb21fb772b30842 Mon Sep 17 00:00:00 2001 From: haavard Date: Mon, 2 Sep 2024 15:50:51 +0200 Subject: [PATCH 5/6] Fix version bug --- .github/workflows/pythonpackage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 9a3db60..e21b99a 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -14,7 +14,7 @@ jobs: max-parallel: 4 fail-fast: false matrix: - python-version: [3.8, 3.9, 3.10] + python-version: ['3.8', '3.9', '3.10'] config: - { os: ubuntu-latest, torch-version: "torch --index-url https://download.pytorch.org/whl/cpu"} - { os: windows-latest, torch-version: "torch"} From 9bfa885007a241eee41638da6849ce32afa45285 Mon Sep 17 00:00:00 2001 From: haavard Date: Wed, 4 Sep 2024 14:32:11 +0200 Subject: [PATCH 6/6] =?UTF-8?q?Bump=20version:=200.2.3=20=E2=86=92=200.3.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pycox/__init__.py | 2 +- setup.cfg | 2 +- setup.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pycox/__init__.py b/pycox/__init__.py index 2c90bb9..5649ef9 100644 --- a/pycox/__init__.py +++ b/pycox/__init__.py @@ -4,7 +4,7 @@ __author__ = """Haavard Kvamme""" __email__ = 'haavard.kvamme@gmail.com' -__version__ = '0.2.3' +__version__ = '0.3.0' import pycox.datasets import pycox.evaluation diff --git a/setup.cfg b/setup.cfg index 42dbbc8..07b86b5 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.2.3 +current_version = 0.3.0 commit = True tag = False diff --git a/setup.py b/setup.py index 28b6040..1853b5a 100644 --- a/setup.py +++ b/setup.py @@ -33,7 +33,7 @@ setup( name='pycox', - version='0.2.3', + version='0.3.0', description="Survival analysis with PyTorch", long_description=long_description, long_description_content_type='text/markdown',