From c9bb4ccd156de99e07fff6288abf34ece0d969a5 Mon Sep 17 00:00:00 2001 From: AlexKurek Date: Fri, 2 Aug 2024 11:43:01 +0200 Subject: [PATCH] Fix Python 3 compatibility, remove some unused modules 732 passed, 1 skipped in 225.68s (0:03:45) --- devel/brighter-fatter/bf_plots_07aug18.py | 1 - devel/brighter-fatter/bf_plots_20Oct17.py | 1 - .../csl_flats/Flat_Correlations_18Apr18.py | 42 +++++++++---------- ...orrelations_Varying_Flux_Errors_18Apr18.py | 6 +-- devel/lsst/treering_flat.py | 2 - devel/lsst/treering_flat_csl_18apr18.py | 2 - devel/lsst/treering_skybg2.py | 1 - devel/modules/atmValidate/firstKick.py | 1 - .../atmValidate/firstKick_screen_scale.py | 1 - devel/modules/atmValidate/screen_plot.py | 2 - devel/modules/atmValidate/screen_scale.py | 1 - devel/modules/atmValidate/secondKick.py | 1 - devel/modules/atmValidate/vonKarman.py | 1 - .../modules/corrfuncs/test_cf_interpolant.py | 1 - devel/modules/lensing_engine_interpolants.py | 12 +++--- setup.py | 1 - 16 files changed, 29 insertions(+), 47 deletions(-) diff --git a/devel/brighter-fatter/bf_plots_07aug18.py b/devel/brighter-fatter/bf_plots_07aug18.py index 92a51d9887..f3568feaca 100644 --- a/devel/brighter-fatter/bf_plots_07aug18.py +++ b/devel/brighter-fatter/bf_plots_07aug18.py @@ -34,7 +34,6 @@ import sys import os import math -import numpy import logging import time import galsim diff --git a/devel/brighter-fatter/bf_plots_20Oct17.py b/devel/brighter-fatter/bf_plots_20Oct17.py index cc0f8ab05f..fbe5efb757 100644 --- a/devel/brighter-fatter/bf_plots_20Oct17.py +++ b/devel/brighter-fatter/bf_plots_20Oct17.py @@ -34,7 +34,6 @@ import sys import os import math -import numpy import logging import time import galsim diff --git a/devel/lsst/csl_flats/Flat_Correlations_18Apr18.py b/devel/lsst/csl_flats/Flat_Correlations_18Apr18.py index c87eb7bff1..521e99c1b1 100644 --- a/devel/lsst/csl_flats/Flat_Correlations_18Apr18.py +++ b/devel/lsst/csl_flats/Flat_Correlations_18Apr18.py @@ -1,19 +1,19 @@ -# Copyright (c) 2012-2023 by the GalSim developers team on GitHub -# https://github.com/GalSim-developers -# -# This file is part of GalSim: The modular galaxy image simulation toolkit. -# https://github.com/GalSim-developers/GalSim -# -# GalSim is free software: redistribution and use in source and binary forms, -# with or without modification, are permitted provided that the following -# conditions are met: -# -# 1. Redistributions of source code must retain the above copyright notice, this -# list of conditions, and the disclaimer given in the accompanying LICENSE -# file. -# 2. Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions, and the disclaimer given in the documentation -# and/or other materials provided with the distribution. +# Copyright (c) 2012-2023 by the GalSim developers team on GitHub +# https://github.com/GalSim-developers +# +# This file is part of GalSim: The modular galaxy image simulation toolkit. +# https://github.com/GalSim-developers/GalSim +# +# GalSim is free software: redistribution and use in source and binary forms, +# with or without modification, are permitted provided that the following +# conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions, and the disclaimer given in the accompanying LICENSE +# file. +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions, and the disclaimer given in the documentation +# and/or other materials provided with the distribution. # @@ -23,7 +23,7 @@ import pyfits as pf from pylab import * -import os, sys, glob, time +import sys, glob, time import numpy as np @@ -37,12 +37,12 @@ edges[:,0:xmin] = True edges[:,xmax:-1] = True edge_mask = np.ma.make_mask(edges) -print edges.sum() +print (edges.sum()) mydir = "/Users/cslage/Research/LSST/code/galsim-developers-18apr18/GalSim/devel/lsst/flats/" series = int(sys.argv[1]) even_patterns = sort(glob.glob(mydir+'flat_%d_*.fits*'%series))[0::2] odd_patterns = sort(glob.glob(mydir+'flat_%d_*.fits*'%series))[1::2] -print "There are %d even patterns and %d oddpatterns"%(len(even_patterns), len(odd_patterns)) +print ("There are %d even patterns and %d oddpatterns"%(len(even_patterns), len(odd_patterns))) sys.stdout.flush() numfiles = len(even_patterns) @@ -101,7 +101,7 @@ sum121=(sub1*sub2).sum() corr = (sum121 - sum11*sum21/npixused1)/npixused1 - print "For file %d, NumDataPoints = %d, ii = %d, jj = %d,Cij = %.2f"%(n, npixused1, l, k, corr) + print ("For file %d, NumDataPoints = %d, ii = %d, jj = %d,Cij = %.2f"%(n, npixused1, l, k, corr)) file = open(filename,'a') if k==0 and l==0: line = '%d %d %d %f %f\n'%(l,k,n,corr,avemed) @@ -111,6 +111,6 @@ file.close() time_finish = time.time() elapsed = time_finish - time_start - print "Elapsed time for file %d = %.2f"%(n,elapsed) + print ("Elapsed time for file %d = %.2f"%(n,elapsed)) sys.stdout.flush() diff --git a/devel/lsst/csl_flats/Plot_Correlations_Varying_Flux_Errors_18Apr18.py b/devel/lsst/csl_flats/Plot_Correlations_Varying_Flux_Errors_18Apr18.py index 9f6974e928..fb5ecbd9e8 100644 --- a/devel/lsst/csl_flats/Plot_Correlations_Varying_Flux_Errors_18Apr18.py +++ b/devel/lsst/csl_flats/Plot_Correlations_Varying_Flux_Errors_18Apr18.py @@ -24,9 +24,7 @@ import matplotlib matplotlib.use("PDF") -import pyfits as pf from pylab import * -import sys, glob, time from scipy import stats covsteps = 6 @@ -67,7 +65,7 @@ fluxes[i] += float(items[4]) numfluxvalues += 1 except Exception as e: - print "Exception of type %s and args = \n"%type(e).__name__, e.args + print ("Exception of type %s and args = \n"%type(e).__name__, e.args) break fluxes[i] /= float(numfluxvalues) # calculate the average flux in ADU @@ -104,7 +102,7 @@ reduced_cov[ii,jj] = 1.0 + slope * flux_value else: reduced_cov[ii,jj] = slope * flux_value - print "ii = %d, jj = %d, slope = %g, reduced_cov = %.4f"%(ii,jj,slope, reduced_cov[ii,jj]) + print ("ii = %d, jj = %d, slope = %g, reduced_cov = %.4f"%(ii,jj,slope, reduced_cov[ii,jj])) if ii < 3 and jj < 3: plotnum = 3 * ii + jj + 1 subplot(3,3,plotnum) diff --git a/devel/lsst/treering_flat.py b/devel/lsst/treering_flat.py index 8ceabd068c..2b341dc5ab 100644 --- a/devel/lsst/treering_flat.py +++ b/devel/lsst/treering_flat.py @@ -18,9 +18,7 @@ from __future__ import print_function -import sys import time -import numpy as np import galsim # Put the salient numbers up here so they are easy to adjust. diff --git a/devel/lsst/treering_flat_csl_18apr18.py b/devel/lsst/treering_flat_csl_18apr18.py index 48443f4aee..b56367ef30 100644 --- a/devel/lsst/treering_flat_csl_18apr18.py +++ b/devel/lsst/treering_flat_csl_18apr18.py @@ -18,9 +18,7 @@ from __future__ import print_function -import sys import time -import numpy as np import galsim # Put the salient numbers up here so they are easy to adjust. diff --git a/devel/lsst/treering_skybg2.py b/devel/lsst/treering_skybg2.py index 99ae7a35ab..dc9bda267c 100644 --- a/devel/lsst/treering_skybg2.py +++ b/devel/lsst/treering_skybg2.py @@ -18,7 +18,6 @@ from __future__ import print_function -import sys import time import numpy as np import galsim diff --git a/devel/modules/atmValidate/firstKick.py b/devel/modules/atmValidate/firstKick.py index 3733072fbf..b32f466bcf 100644 --- a/devel/modules/atmValidate/firstKick.py +++ b/devel/modules/atmValidate/firstKick.py @@ -41,7 +41,6 @@ """ -import warnings import os import numpy as np import galsim diff --git a/devel/modules/atmValidate/firstKick_screen_scale.py b/devel/modules/atmValidate/firstKick_screen_scale.py index 7fb156a255..7937783a49 100644 --- a/devel/modules/atmValidate/firstKick_screen_scale.py +++ b/devel/modules/atmValidate/firstKick_screen_scale.py @@ -34,7 +34,6 @@ import matplotlib import matplotlib.pyplot as plt -from matplotlib.figure import Figure from matplotlib.backends.backend_agg import FigureCanvasAgg from astropy.utils.console import ProgressBar diff --git a/devel/modules/atmValidate/screen_plot.py b/devel/modules/atmValidate/screen_plot.py index daaafe73cd..29e769c78c 100644 --- a/devel/modules/atmValidate/screen_plot.py +++ b/devel/modules/atmValidate/screen_plot.py @@ -28,8 +28,6 @@ import matplotlib import matplotlib.pyplot as plt -from matplotlib.figure import Figure -from matplotlib.backends.backend_agg import FigureCanvasAgg from astropy.utils.console import ProgressBar diff --git a/devel/modules/atmValidate/screen_scale.py b/devel/modules/atmValidate/screen_scale.py index 8df56c9323..d1287273f9 100644 --- a/devel/modules/atmValidate/screen_scale.py +++ b/devel/modules/atmValidate/screen_scale.py @@ -29,7 +29,6 @@ import matplotlib import matplotlib.pyplot as plt -from matplotlib.figure import Figure from matplotlib.backends.backend_agg import FigureCanvasAgg from astropy.utils.console import ProgressBar diff --git a/devel/modules/atmValidate/secondKick.py b/devel/modules/atmValidate/secondKick.py index 2336da3140..3a5b3a9b56 100644 --- a/devel/modules/atmValidate/secondKick.py +++ b/devel/modules/atmValidate/secondKick.py @@ -39,7 +39,6 @@ import matplotlib import matplotlib.pyplot as plt -from matplotlib.figure import Figure from matplotlib.backends.backend_agg import FigureCanvasAgg from astropy.utils.console import ProgressBar diff --git a/devel/modules/atmValidate/vonKarman.py b/devel/modules/atmValidate/vonKarman.py index fe3709af63..9992847767 100644 --- a/devel/modules/atmValidate/vonKarman.py +++ b/devel/modules/atmValidate/vonKarman.py @@ -42,7 +42,6 @@ import matplotlib import matplotlib.pyplot as plt -from matplotlib.figure import Figure from matplotlib.backends.backend_agg import FigureCanvasAgg from astropy.utils.console import ProgressBar diff --git a/devel/modules/corrfuncs/test_cf_interpolant.py b/devel/modules/corrfuncs/test_cf_interpolant.py index 91d3a2a8d7..768e54dd7d 100644 --- a/devel/modules/corrfuncs/test_cf_interpolant.py +++ b/devel/modules/corrfuncs/test_cf_interpolant.py @@ -23,7 +23,6 @@ used to describe correlation functions. See the discussion at https://github.com/GalSim-developers/GalSim/pull/452#discussion-diff-5701561 """ -import numpy as np import matplotlib.pyplot as plt import galsim diff --git a/devel/modules/lensing_engine_interpolants.py b/devel/modules/lensing_engine_interpolants.py index b81e0d23ff..ebb84aa5b4 100644 --- a/devel/modules/lensing_engine_interpolants.py +++ b/devel/modules/lensing_engine_interpolants.py @@ -95,7 +95,7 @@ def check_dir(dir): """ try: os.makedirs(dir) - print "Created directory %s for outputs"%dir + print ("Created directory %s for outputs"%dir) except OSError: if os.path.isdir(dir): # It was already a directory. @@ -156,7 +156,7 @@ def generate_ps_cutoff_plots(ell, ps, theory_ps, # Write to file. outfile = ps_plot_prefix + interpolant + '_grid_cutoff_' + type + '.png' plt.savefig(outfile) - print "Wrote power spectrum (grid cutoff) plot to file %r"%outfile + print ("Wrote power spectrum (grid cutoff) plot to file %r"%outfile) def generate_ps_plots(ell, ps, interpolated_ps, interpolant, ps_plot_prefix, @@ -257,7 +257,7 @@ def generate_ps_plots(ell, ps, interpolated_ps, interpolant, ps_plot_prefix, # Write to file. outfile = ps_plot_prefix + interpolant + '_' + type + '.png' plt.savefig(outfile) - print "Wrote power spectrum plots to file %r"%outfile + print ("Wrote power spectrum plots to file %r"%outfile) def generate_cf_cutoff_plots(th, cf, nocutoff_th, nocutoff_cf, interpolant, cf_plot_prefix, type='p'): @@ -303,7 +303,7 @@ def generate_cf_cutoff_plots(th, cf, nocutoff_th, nocutoff_cf, interpolant, cf_p # Write to file. outfile = cf_plot_prefix + interpolant + '_grid_cutoff_' + type + '.png' plt.savefig(outfile) - print "Wrote correlation function (grid cutoff) plots to file %r"%outfile + print ("Wrote correlation function (grid cutoff) plots to file %r"%outfile) def generate_cf_plots(th, cf, interpolated_cf, interpolant, cf_plot_prefix, dth, type='p', theory_raw=None, theory_binned=None, theory_rand=None): @@ -380,7 +380,7 @@ def generate_cf_plots(th, cf, interpolated_cf, interpolant, cf_plot_prefix, # Write to file. outfile = cf_plot_prefix + interpolant + '_' + type + '.png' plt.savefig(outfile) - print "Wrote correlation function plots to file %r"%outfile + print ("Wrote correlation function plots to file %r"%outfile) def write_ps_output(ell, ps, interpolated_ps, interpolant, ps_plot_prefix, type='EE'): """Routine to write final power spectra to file. @@ -405,7 +405,7 @@ def write_ps_output(ell, ps, interpolated_ps, interpolant, ps_plot_prefix, type= # Make ascii output. outfile = ps_plot_prefix + interpolant + '_' + type + '.dat' np.savetxt(outfile, np.column_stack((ell, ps, interpolated_ps)), fmt='%12.4e') - print "Wrote ascii output to file %r"%outfile + print ("Wrote ascii output to file %r"%outfile) # Set up a FITS table for output file. ell_col = pyfits.Column(name='ell', format='1D', array=ell) diff --git a/setup.py b/setup.py index 368ede98bd..8cddd558fb 100644 --- a/setup.py +++ b/setup.py @@ -16,7 +16,6 @@ # and/or other materials provided with the distribution. # import sys,os,glob,re -import platform import ctypes import ctypes.util import types