@@ -58,7 +58,7 @@ def calc_delta_r(x_predicted,y_predicted,x_true,y_true):
58
58
for perm in it .permutations (a [num_halos - 2 ],num_halos ):
59
59
which_true_halos = []
60
60
which_predicted_halos = []
61
- for j in range (num_halos ): #loop through all the true halos with the
61
+ for j in xrange (num_halos ): #loop through all the true halos with the
62
62
63
63
distances_perm [count ,j ]= np .sqrt ((x_true [j ]- x_predicted [int (perm [j ])])** 2 \
64
64
+ (y_true [j ]- y_predicted [int (perm [j ])])** 2 )
@@ -141,7 +141,7 @@ def convert_to_360(angle, x_in, y_in):
141
141
theta: the angle in the range 0:2pi
142
142
"""
143
143
n = len (x_in )
144
- for i in range (n ):
144
+ for i in xrange (n ):
145
145
if x_in [i ] < 0 and y_in [i ] > 0 :
146
146
angle [i ] = angle [i ]+ mt .pi
147
147
elif x_in [i ] < 0 and y_in [i ] < 0 :
@@ -204,7 +204,7 @@ def main_score( nhalo_all, x_true_all, y_true_all, x_ref_all, y_ref_all, sky_pre
204
204
205
205
x_predicted = np .array ([],dtype = float )
206
206
y_predicted = np .array ([],dtype = float )
207
- for i in range (nhalo ):
207
+ for i in xrange (nhalo ):
208
208
x_predicted = np .append (x_predicted ,float (sky [0 ])) #get the predicted values
209
209
y_predicted = np .append (y_predicted ,float (sky [1 ]))
210
210
#The solution file for the test data provides masses
@@ -271,9 +271,9 @@ def main_score( nhalo_all, x_true_all, y_true_all, x_ref_all, y_ref_all, sky_pre
271
271
W1 = 1. / 1000. #Weight the av_r such that < 1 is a good score > 1 is not so good.
272
272
W2 = 1.
273
273
metric = W1 * av_r + W2 * angle_vec #Weighted metric, weights TBD
274
- print ( 'Your average distance in pixels you are away from the true halo is' , av_r )
275
- print ( 'Your average angular vector is' , angle_vec )
276
- print ( 'Your score for the training data is' , metric )
274
+ print 'Your average distance in pixels you are away from the true halo is' , av_r
275
+ print 'Your average angular vector is' , angle_vec
276
+ print 'Your score for the training data is' , metric
277
277
return metric
278
278
279
279
@@ -316,9 +316,10 @@ def main(user_fname, fname):
316
316
#first input would be
317
317
#a float, if succeed it
318
318
#is not a header
319
- print ( 'THE INPUT FILE DOES NOT APPEAR TO HAVE A HEADER' )
319
+ print 'THE INPUT FILE DOES NOT APPEAR TO HAVE A HEADER'
320
320
except :
321
- print ('THE INPUT FILE APPEARS TO HAVE A HEADER, SKIPPING THE FIRST LINE' )
321
+ print 'THE INPUT FILE APPEARS TO HAVE A HEADER, SKIPPING THE FIRST LINE'
322
+
322
323
skip_header = sky_prediction .next ()
323
324
324
325
@@ -330,7 +331,7 @@ def main(user_fname, fname):
330
331
if does_it_exist > 0 : #If it does then find the matching solutions to the sky_id
331
332
selectskyinsolutions = true_sky_id .index (sky_id )- 1
332
333
else : #Otherwise exit
333
- print ( 'Sky_id does not exist, formatting problem: ' ,sky_id )
334
+ print 'Sky_id does not exist, formatting problem: ' ,sky_id
334
335
sys .exit (2 )
335
336
336
337
@@ -341,7 +342,7 @@ def main(user_fname, fname):
341
342
342
343
x_predicted = np .array ([],dtype = float )
343
344
y_predicted = np .array ([],dtype = float )
344
- for i in range (nhalo ):
345
+ for i in xrange (nhalo ):
345
346
x_predicted = np .append (x_predicted ,float (sky [2 * i + 1 ])) #get the predicted values
346
347
y_predicted = np .append (y_predicted ,float (sky [2 * i + 2 ]))
347
348
#The solution file for the test data provides masses
@@ -408,9 +409,9 @@ def main(user_fname, fname):
408
409
W1 = 1. / 1000. #Weight the av_r such that < 1 is a good score > 1 is not so good.
409
410
W2 = 1.
410
411
metric = W1 * av_r + W2 * angle_vec #Weighted metric, weights TBD
411
- print ( 'Your average distance in pixels you are away from the true halo is' , av_r )
412
- print ( 'Your average angular vector is' , angle_vec )
413
- print ( 'Your score for the training data is' , metric )
412
+ print 'Your average distance in pixels you are away from the true halo is' , av_r
413
+ print 'Your average angular vector is' , angle_vec
414
+ print 'Your score for the training data is' , metric
414
415
415
416
416
417
if __name__ == "__main__" :
0 commit comments