Skip to content

Commit 64ea76d

Browse files
Fix deprecated argument in 'scipy.sparse.linalg.cg' (#7897)
Fixes #7896 ### Description - 'scipy.sparse.linalg.cg' keyword argument `tol` is deprecated in favor of `rtol` and will be removed in SciPy v1.14.0. Until then, if set, it will override `rtol`. So update to use `rtol` in `cg`. - Drop python 3.8 test in packaging and premerge-gpu-test. ### Types of changes <!--- Put an `x` in all the boxes that apply, and remove the not applicable items --> - [x] Non-breaking change (fix or new feature that would not break existing functionality). - [ ] Breaking change (fix or new feature that would cause existing functionality to change). - [ ] New tests added to cover the changes. - [ ] Integration tests passed locally by running `./runtests.sh -f -u --net --coverage`. - [ ] Quick tests passed locally by running `./runtests.sh --quick --unittests --disttests`. - [ ] In-line docstrings updated. - [ ] Documentation updated, tested `make html` command in the `docs/` folder. --------- Signed-off-by: YunLiu <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 3b9683c commit 64ea76d

File tree

9 files changed

+23
-18
lines changed

9 files changed

+23
-18
lines changed

.github/workflows/pythonapp.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ jobs:
2929
opt: ["codeformat", "pytype", "mypy"]
3030
steps:
3131
- uses: actions/checkout@v4
32-
- name: Set up Python 3.8
32+
- name: Set up Python 3.9
3333
uses: actions/setup-python@v5
3434
with:
35-
python-version: '3.8'
35+
python-version: '3.9'
3636
- name: cache weekly timestamp
3737
id: pip-cache
3838
run: |
@@ -45,6 +45,7 @@ jobs:
4545
key: ${{ runner.os }}-pip-${{ steps.pip-cache.outputs.datew }}
4646
- name: Install dependencies
4747
run: |
48+
find /opt/hostedtoolcache/* -maxdepth 0 ! -name 'Python' -exec rm -rf {} \;
4849
python -m pip install --upgrade pip wheel
4950
python -m pip install -r requirements-dev.txt
5051
- name: Lint and type check
@@ -130,10 +131,10 @@ jobs:
130131
- uses: actions/checkout@v4
131132
with:
132133
fetch-depth: 0
133-
- name: Set up Python 3.8
134+
- name: Set up Python 3.9
134135
uses: actions/setup-python@v5
135136
with:
136-
python-version: '3.8'
137+
python-version: '3.9'
137138
- name: cache weekly timestamp
138139
id: pip-cache
139140
run: |
@@ -211,10 +212,10 @@ jobs:
211212
runs-on: ubuntu-latest
212213
steps:
213214
- uses: actions/checkout@v4
214-
- name: Set up Python 3.8
215+
- name: Set up Python 3.9
215216
uses: actions/setup-python@v5
216217
with:
217-
python-version: '3.8'
218+
python-version: '3.9'
218219
- name: cache weekly timestamp
219220
id: pip-cache
220221
run: |

docs/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ itk>=5.2
66
nibabel
77
parameterized
88
scikit-image>=0.19.0
9-
scipy>=1.7.1
9+
scipy>=1.12.0; python_version >= '3.9'
1010
tensorboard
1111
commonmark==0.9.1
1212
recommonmark==0.6.0

monai/data/ultrasound_confidence_map.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
__all__ = ["UltrasoundConfidenceMap"]
2020

2121
cv2, _ = optional_import("cv2")
22-
csc_matrix, _ = optional_import("scipy.sparse", "1.7.1", min_version, "csc_matrix")
23-
spsolve, _ = optional_import("scipy.sparse.linalg", "1.7.1", min_version, "spsolve")
24-
cg, _ = optional_import("scipy.sparse.linalg", "1.7.1", min_version, "cg")
25-
hilbert, _ = optional_import("scipy.signal", "1.7.1", min_version, "hilbert")
22+
csc_matrix, _ = optional_import("scipy.sparse", "1.12.0", min_version, "csc_matrix")
23+
spsolve, _ = optional_import("scipy.sparse.linalg", "1.12.0", min_version, "spsolve")
24+
cg, _ = optional_import("scipy.sparse.linalg", "1.12.0", min_version, "cg")
25+
hilbert, _ = optional_import("scipy.signal", "1.12.0", min_version, "hilbert")
2626
ruge_stuben_solver, _ = optional_import("pyamg", "5.0.0", min_version, "ruge_stuben_solver")
2727

2828

@@ -285,7 +285,7 @@ def _solve_linear_system(self, lap, rhs):
285285
lap_sparse = lap.tocsr()
286286
ml = ruge_stuben_solver(lap_sparse, coarse_solver="pinv")
287287
m = ml.aspreconditioner(cycle="V")
288-
x, _ = cg(lap, rhs, tol=self.cg_tol, maxiter=self.cg_maxiter, M=m)
288+
x, _ = cg(lap, rhs, rtol=self.cg_tol, maxiter=self.cg_maxiter, M=m)
289289
else:
290290
x = spsolve(lap, rhs)
291291

monai/optimizers/lr_finder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ def plot(
524524
# Plot the LR with steepest gradient
525525
if steepest_lr:
526526
lr_at_steepest_grad, loss_at_steepest_grad = self.get_steepest_gradient(skip_start, skip_end)
527-
if lr_at_steepest_grad is not None:
527+
if lr_at_steepest_grad is not None and loss_at_steepest_grad is not None:
528528
ax.scatter(
529529
lr_at_steepest_grad,
530530
loss_at_steepest_grad,

requirements-dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
-r requirements-min.txt
33
pytorch-ignite==0.4.11
44
gdown>=4.7.3
5-
scipy>=1.7.1
5+
scipy>=1.12.0; python_version >= '3.9'
66
itk>=5.2
77
nibabel
88
pillow!=8.3.0 # https://github.com/python-pillow/Pillow/issues/5571

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
torch>=1.9
2-
numpy>=1.20,<2.0
2+
numpy>=1.20,<=1.26.0

setup.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ all =
4949
nibabel
5050
ninja
5151
scikit-image>=0.14.2
52-
scipy>=1.7.1
52+
scipy>=1.12.0; python_version >= '3.9'
5353
pillow
5454
tensorboard
5555
gdown>=4.7.3
@@ -92,7 +92,7 @@ ninja =
9292
skimage =
9393
scikit-image>=0.14.2
9494
scipy =
95-
scipy>=1.7.1
95+
scipy>=1.12.0; python_version >= '3.9'
9696
pillow =
9797
pillow!=8.3.0
9898
tensorboard =

tests/test_ultrasound_confidence_map_transform.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@
2020
from PIL import Image
2121

2222
from monai.transforms import UltrasoundConfidenceMapTransform
23+
from monai.utils import optional_import
2324
from tests.utils import assert_allclose
2425

26+
_, has_scipy = optional_import("scipy")
27+
2528
TEST_INPUT = np.array(
2629
[
2730
[1, 2, 3, 23, 13, 22, 5, 1, 2, 3],
@@ -482,6 +485,7 @@
482485
)
483486

484487

488+
@unittest.skipUnless(has_scipy, "Requires scipy")
485489
class TestUltrasoundConfidenceMapTransform(unittest.TestCase):
486490

487491
def setUp(self):

tests/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ def run_process(self, func, local_rank, args, kwargs, results):
475475
if self.verbose:
476476
os.environ["NCCL_DEBUG"] = "INFO"
477477
os.environ["NCCL_DEBUG_SUBSYS"] = "ALL"
478-
os.environ["NCCL_BLOCKING_WAIT"] = str(1)
478+
os.environ["TORCH_NCCL_BLOCKING_WAIT"] = str(1)
479479
os.environ["OMP_NUM_THREADS"] = str(1)
480480
os.environ["WORLD_SIZE"] = str(self.nproc_per_node * self.nnodes)
481481
os.environ["RANK"] = str(self.nproc_per_node * self.node_rank + local_rank)

0 commit comments

Comments
 (0)