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
3 changes: 2 additions & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ jobs:
if: ${{ matrix.python-version == '3.12' }}
run: |
python -m pip install --upgrade pip
pip install git+https://github.com/litebird/litebird_sim.git@b7144f8
pip install git+https://github.com/litebird/litebird_sim.git
pip install deprecated

- name: Install BrahMap
run: |
Expand Down
18 changes: 14 additions & 4 deletions brahmap/math/linalg.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,23 @@ def cg(
_type_
_description_
"""
A, M, x, b, postprocess = scipy.sparse.linalg._isolve.utils.make_system(
temp_tuple = scipy.sparse.linalg._isolve.utils.make_system(
A,
M,
x0,
b,
)

# Starting from SciPy 1.16.0, `make_system` returns 4 objects instead of 5.
# Even in earlier versions, only the first 4 objects were needed for our
# use. The following unpacking ensures compatibility across all versions.
# This logic can be simplified once support for versions below 1.16.0 is
# dropped.
A = temp_tuple[0]
M = temp_tuple[1]
x = temp_tuple[2]
b = temp_tuple[3]

if parallel:
norm_function: Callable = parallel_norm
else:
Expand All @@ -91,7 +101,7 @@ def cg(
)

if b_norm == 0:
return postprocess(b), 0
return b, 0

dotprod = np.vdot if np.iscomplexobj(x) else np.dot

Expand All @@ -105,7 +115,7 @@ def cg(

for iteration in range(maxiter):
if norm_residual < atol:
return postprocess(x), 0
return x, 0

z = M * r
rho_cur = dotprod(r, z)
Expand All @@ -129,4 +139,4 @@ def cg(
callback(x, r, norm_residual)

else:
return postprocess(x), maxiter
return x, maxiter
4 changes: 2 additions & 2 deletions tests/test_noise_ops_toeplitz.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ def test_Strang_precond(self, precond_type):

class TestNoiseOps_Toeplitz_F32(NoiseOps_Toeplitz):
dtype = np.float32
rtol = 1.0e-4
atol = 1.0e-5
rtol = 1.0e-3
atol = 1.0e-4


class TestNoiseOps_Toeplitz_F64(NoiseOps_Toeplitz):
Expand Down
Loading