From 307b104c3164bb9fb65c7e9891d7c0bb5e95bf0b Mon Sep 17 00:00:00 2001 From: mrava87 Date: Sat, 23 Nov 2024 22:17:48 +0300 Subject: [PATCH] feat: flush all prints in solver --- pylops_mpi/optimization/cls_basic.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pylops_mpi/optimization/cls_basic.py b/pylops_mpi/optimization/cls_basic.py index 457b3af..db7349a 100644 --- a/pylops_mpi/optimization/cls_basic.py +++ b/pylops_mpi/optimization/cls_basic.py @@ -1,6 +1,7 @@ from typing import List, Optional, Tuple, Union -import numpy as np +import sys import time +import numpy as np from pylops.optimization.basesolver import Solver from pylops.utils import NDArray @@ -40,6 +41,7 @@ def _print_setup(self, xcomplex: bool = False) -> None: else: head1 = " Itn x[0] r2norm" print(head1) + sys.stdout.flush() def _print_step(self, x: Union[DistributedArray, StackedDistributedArray]) -> None: if isinstance(x, StackedDistributedArray): @@ -47,6 +49,7 @@ def _print_step(self, x: Union[DistributedArray, StackedDistributedArray]) -> No strx = f"{x[0]:1.2e} " if np.iscomplexobj(x.local_array) else f"{x[0]:11.4e} " msg = f"{self.iiter:6g} " + strx + f"{self.cost[self.iiter]:11.4e}" print(msg) + sys.stdout.flush() def setup( self, @@ -281,6 +284,7 @@ def _print_setup(self, xcomplex: bool = False) -> None: else: head1 = " Itn x[0] r1norm r2norm" print(head1) + sys.stdout.flush() def _print_step(self, x: Union[DistributedArray, StackedDistributedArray]) -> None: if isinstance(x, StackedDistributedArray): @@ -292,6 +296,7 @@ def _print_step(self, x: Union[DistributedArray, StackedDistributedArray]) -> No + f"{self.cost[self.iiter]:11.4e} {self.cost1[self.iiter]:11.4e}" ) print(msg) + sys.stdout.flush() def setup(self, y: Union[DistributedArray, StackedDistributedArray],