Commit a84d4174 authored by Matthijs's avatar Matthijs
Browse files

support for a tqdm progress bar. Simply pass the correct function through the...

support for a tqdm progress bar. Simply pass the correct function through the config dictionary. (i.e. tqdm_notebook if using jupyter notebook or tqdm if working through the console.
parent c9f25702
......@@ -9,7 +9,7 @@ def nd_norm_difference(arr1: ndarray, arr2: ndarray, norm_factor: float = 1.):
"""
Root-sum-square norm of the difference of 2 numpy arrays, equal to Frobenius norm for arr.ndim == 2
"""
return sqrt(sum((arr1 - arr2) ** 2)) / norm_factor
return sqrt(sum(abs(arr1 - arr2) ** 2)) / norm_factor
def phase_offset_compensated_norm(arr1: ndarray, arr2: ndarray, norm_factor: float = 1.,
......@@ -98,7 +98,6 @@ class SimpleAlgorithm:
:param maxiter:
:return:
"""
##### PREPROCESSING
config = self.config
norm_data = self.norm_data
......@@ -134,9 +133,14 @@ class SimpleAlgorithm:
shadow = self.prox1.work(u)
##### LOOP
if 'tqdm_progressbar' in self.config and self.config['tqdm_progressbar'] is not None:
pbar = self.config['tqdm_progressbar'](total=maxiter)
while iter < maxiter and change[iter] >= tol:
iter += 1
config['iter'] = iter
if 'tqdm_progressbar' in self.config and self.config['tqdm_progressbar'] is not None:
pbar.update()
# makes call to algorithm:
config['u'] = u
u_new = self.evaluate(u)
......
from numpy import zeros_like, unravel_index
from numpy import zeros_like, unravel_index, sum
import numpy as np
from .proxoperators import ProxOperator
......@@ -23,6 +23,7 @@ class P_Sparsity(ProxOperator):
if 'sparsity_support' in config:
self.support = config['sparsity_support'].real.astype(np.uint)
assert (sum(self.support) > 0), 'Invalid empty sparsity_support given'
else:
self.support = 1
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment