Skip to content

Commit e9bbecc

Browse files
authored
Merge pull request #118 from PyLops/solver-sysout
feat: flush all prints in solver
2 parents 1351e7a + 307b104 commit e9bbecc

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

pylops_mpi/optimization/cls_basic.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from typing import List, Optional, Tuple, Union
2-
import numpy as np
2+
import sys
33
import time
4+
import numpy as np
45

56
from pylops.optimization.basesolver import Solver
67
from pylops.utils import NDArray
@@ -40,13 +41,15 @@ def _print_setup(self, xcomplex: bool = False) -> None:
4041
else:
4142
head1 = " Itn x[0] r2norm"
4243
print(head1)
44+
sys.stdout.flush()
4345

4446
def _print_step(self, x: Union[DistributedArray, StackedDistributedArray]) -> None:
4547
if isinstance(x, StackedDistributedArray):
4648
x = x.distarrays[0]
4749
strx = f"{x[0]:1.2e} " if np.iscomplexobj(x.local_array) else f"{x[0]:11.4e} "
4850
msg = f"{self.iiter:6g} " + strx + f"{self.cost[self.iiter]:11.4e}"
4951
print(msg)
52+
sys.stdout.flush()
5053

5154
def setup(
5255
self,
@@ -281,6 +284,7 @@ def _print_setup(self, xcomplex: bool = False) -> None:
281284
else:
282285
head1 = " Itn x[0] r1norm r2norm"
283286
print(head1)
287+
sys.stdout.flush()
284288

285289
def _print_step(self, x: Union[DistributedArray, StackedDistributedArray]) -> None:
286290
if isinstance(x, StackedDistributedArray):
@@ -292,6 +296,7 @@ def _print_step(self, x: Union[DistributedArray, StackedDistributedArray]) -> No
292296
+ f"{self.cost[self.iiter]:11.4e} {self.cost1[self.iiter]:11.4e}"
293297
)
294298
print(msg)
299+
sys.stdout.flush()
295300

296301
def setup(self,
297302
y: Union[DistributedArray, StackedDistributedArray],

0 commit comments

Comments
 (0)