Commit f36c57e7 authored by alexander.dornheim's avatar alexander.dornheim
Browse files

Removed unnecessary semicolons in phase.py

parent 3a444585
......@@ -58,9 +58,9 @@ class Phase(Problem):
#If method_config[formulation is does not exist, i.e. not specified in
#the *_in.m file, use the product space as the default.
if 'formulation' in self.config:
formulation = self.config['formulation'];
formulation = self.config['formulation']
else:
formulation = 'product space';
formulation = 'product space'
# Set the projectors and inputs based on the types of constraints and
# experiments
......@@ -71,7 +71,7 @@ class Phase(Problem):
elif self.config['constraint'] == 'support only':
proxoperators[0] = 'P_S'
elif self.config['constraint'] == 'real and support':
proxoperators[0] ='P_S_real';
proxoperators[0] ='P_S_real'
elif self.config['constraint'] =='nonnegative and support':
proxoperators[0] ='P_SP'
elif self.config['constraint'] =='amplitude only':
......@@ -117,24 +117,24 @@ class Phase(Problem):
# The following selects the projectors for diversity diffraction not
# performed in the product space. So far only used for RCAAR.
elif self.config['experiment'] == 'diversity diffraction' and formulation == 'sequential':
proxoperators[1] = 'Approx_P_RCAAR_JWST_Poisson';
proxoperators[0] = proxoperators[1];
proxoperators[1] = 'Approx_P_RCAAR_JWST_Poisson'
proxoperators[0] = proxoperators[1]
elif self.config['experiment'] == 'JWST':
proxoperators[1] = 'Approx_P_JWST_Poisson';
proxoperators[2] = proxoperators[0];
proxoperators[0] = 'P_diag';
proxoperators[1] = 'Approx_P_JWST_Poisson'
proxoperators[2] = proxoperators[0]
proxoperators[0] = 'P_diag'
elif self.config['experiment'] == 'CDP':
proxoperators[1] = 'P_CDP';
proxoperators[2] = proxoperators[0];
proxoperators[0] = 'P_diag';
proxoperators[1] = 'P_CDP'
proxoperators[2] = proxoperators[0]
proxoperators[0] = 'P_diag'
elif self.config['experiment'] == 'ptychography':
proxoperators[1] = 'not in yet';
proxoperators[1] = 'not in yet'
elif self.config['experiment'] == 'complex':
proxoperators[1] = 'not in yet';
proxoperators[1] = 'not in yet'
elif self.config['constraint'] == 'phaselift':
proxoperators[1] ='P_PL_lowrank';
proxoperators[1] ='P_PL_lowrank'
self.config['proxoperators'] = [];
self.config['proxoperators'] = []
for prox in proxoperators:
if prox != '':
......@@ -146,10 +146,10 @@ class Phase(Problem):
# to create a new structure element.
if 'product_space_dimension' not in self.config:
self.config['product_space_dimension'] = 1;
self.config['product_space_dimension'] = 1
# set the animation program:
self.config['animation']='Phase_animation';
self.config['animation']='Phase_animation'
#
# if you are only working with two sets but
# want to do averaged projections
......@@ -159,7 +159,7 @@ class Phase(Problem):
# and adjust your input files and projectors accordingly.
# you could also do this within the data processor
self.config['TOL2'] = 1e-15;
self.config['TOL2'] = 1e-15
#To estimate the gap in the sequential formulation, we build the
# appropriate point in the product space. This allows for code reuse.
......@@ -167,43 +167,43 @@ class Phase(Problem):
# version of the function.
if formulation == 'sequential':
for j in range(self.config['product_space_dimension']):
self.config['proj_iter'] =j;
self.config['proj_iter'] =j
proj1 = self.config['proxoperators'][0](self.config)
u_1[:,:,j]= proj1.work(self.config['u_0']);
self.config['proj_iter'] = mod(j,config['product_space_dimension'])+1;
u_1[:,:,j]= proj1.work(self.config['u_0'])
self.config['proj_iter'] = mod(j,config['product_space_dimension'])+1
proj1 = self.config['proxoperators'][0](self.config)
u_1[:,:,j]= proj1.work(self.config['u_0']);
end;
u_1[:,:,j]= proj1.work(self.config['u_0'])
end
else: #i.e. formulation=='product space'
proj1 = self.config['proxoperators'][0](self.config)
u_1 = proj1.work(self.config['u_0']);
u_1 = proj1.work(self.config['u_0'])
proj2 = self.config['proxoperators'][1](self.config)
u_2 = proj2.work(u_1);
u_2 = proj2.work(u_1)
# estimate the gap in the relevant metric
if self.config['Nx'] ==1 or self.config['Ny']==1 :
tmp_gap = square(norm(u_1-u_2)/self.config['norm_rt_data']);
tmp_gap = square(norm(u_1-u_2)/self.config['norm_rt_data'])
elif self.config['product_space_dimension'] == 1:
tmp_gap = (norm(u_1-u_2)/self.config['norm_rt_data'])**2
else:
tmp_gap=0;
tmp_gap=0
for j in range(self.config['product_space_dimension']):
# compute (||P_Sx-P_Mx||/norm_data)^2:
tmp_gap = tmp_gap+(norm(u_1[:,:,j]-u_2[:,:,j])/self.config['norm_rt_data'])**2
gap_0=sqrt(tmp_gap);
gap_0=sqrt(tmp_gap)
# sets the set fattening to be a percentage of the
# initial gap to the unfattened set with
# respect to the relevant metric (KL or L2),
# that percentage given by
# input.data_ball input by the user.
self.config['data_ball']=self.config['data_ball']*gap_0;
self.config['data_ball']=self.config['data_ball']*gap_0
# the second tolerance relative to the oder of
# magnitude of the metric
self.config['TOL2'] = self.config['data_ball']*1e-15;
self.config['TOL2'] = self.config['data_ball']*1e-15
self.config['proxoperators']
self.algorithm = getattr(Algorithms, self.config['algorithm'])(self.config);
self.algorithm = getattr(Algorithms, self.config['algorithm'])(self.config)
......@@ -313,7 +313,7 @@ class Phase(Problem):
diff = u1 - self.output['u1']
#print(diff[nonz])
print("Maximum norm of difference:")
print(np.amax(abs(diff)));
print(np.amax(abs(diff)))
print("Frobenius norm of difference:")
print(norm(diff))
print("Frobenius norm of matlab u1:")
......@@ -344,7 +344,7 @@ class Phase(Problem):
print(np.array_equal(nonzero(data_mat),nonzero(data_py)))
diff = data_mat - data_py
print("Maximum norm of difference:")
print(np.amax(abs(diff)));
print(np.amax(abs(diff)))
print("Frobenius norm of difference:")
print(norm(diff))
print("Frobenius norm of matlab data:")
......@@ -363,7 +363,7 @@ class Phase(Problem):
print(np.array_equal(nonzero(S),nonzero(self.config['abs_illumination'])))
diff = S - self.config['abs_illumination']
print("Maximum norm of difference:")
print(np.amax(abs(diff)));
print(np.amax(abs(diff)))
print("Frobenius norm of difference:")
print(norm(diff))
print("Frobenius norm of matlab S:")
......
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