diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 725657a6..e6235f07 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,12 +11,12 @@ repos: - id: check-yaml - id: check-added-large-files - repo: https://github.com/pycqa/isort - rev: 7.0.0 + rev: 8.0.1 hooks: - id: isort args: [--profile, black, --filter-files] - repo: https://github.com/PyCQA/autoflake - rev: v2.3.1 + rev: v2.3.3 hooks: - id: autoflake - repo: https://github.com/asottile/pyupgrade @@ -24,7 +24,7 @@ repos: hooks: - id: pyupgrade - repo: https://github.com/psf/black-pre-commit-mirror - rev: 25.12.0 + rev: 26.3.1 hooks: - id: black language_version: python3 diff --git a/ppafm/cli/fitting/fitting.py b/ppafm/cli/fitting/fitting.py index f71138c3..f7a4f66e 100755 --- a/ppafm/cli/fitting/fitting.py +++ b/ppafm/cli/fitting/fitting.py @@ -188,7 +188,7 @@ def comp_msd(x=[]): parser.add_option( "--nobounds", action="store_true", help="Skipf the first optimization step with bounds", default=False) # fmt: on - (options, args) = parser.parse_args() + options, args = parser.parse_args() opt_dict = vars(options) parameters.apply_options(opt_dict) # setting up all the options according to their x_new, bounds = set_fit_dict(opt=opt_dict) diff --git a/ppafm/cli/fitting/plotLine.py b/ppafm/cli/fitting/plotLine.py index 0a2c78ce..57c54418 100755 --- a/ppafm/cli/fitting/plotLine.py +++ b/ppafm/cli/fitting/plotLine.py @@ -54,7 +54,7 @@ def selectLine(BIGarray, MIN, MAX, startingPoint, endPoint, nsteps): parser.add_option( "--nodisp", action="store_true", default=False, help="Do NOT show the " "plots on the screen", ) # fmt: on -(options, args) = parser.parse_args() +options, args = parser.parse_args() opt_dict = vars(options) if options.points == []: sys.exit("Error!! The '-p' or '--points' argument is required\npython plotLine.py -p XMINxYMINxZMIN XMAXxYMAXxZMAX") diff --git a/ppafm/cli/fitting/plotZ.py b/ppafm/cli/fitting/plotZ.py index 1c012976..1cd36e1f 100755 --- a/ppafm/cli/fitting/plotZ.py +++ b/ppafm/cli/fitting/plotZ.py @@ -21,12 +21,8 @@ def find_minimum(array, precision=0.0001): i += 1 -HELP_MSG = ( - """Use this program in the following way: -""" - + os.path.basename(main.__file__) - + """ -p "X1xY1" [-p "X2xY2" ...] """ -) +HELP_MSG = """Use this program in the following way: +""" + os.path.basename(main.__file__) + """ -p "X1xY1" [-p "X2xY2" ...] """ # fmt: off parser = OptionParser() @@ -42,7 +38,7 @@ def find_minimum(array, precision=0.0001): # parser.add_option( "--yrange", action="store", type="float", help="y positions of the tip range (min,max,n) [A]", nargs=3) # fmt: on -(options, args) = parser.parse_args() +options, args = parser.parse_args() opt_dict = vars(options) print(options) if options.npy: diff --git a/ppafm/cli/plot_results.py b/ppafm/cli/plot_results.py index f1fdf829..a5d68c60 100644 --- a/ppafm/cli/plot_results.py +++ b/ppafm/cli/plot_results.py @@ -279,7 +279,7 @@ def main(argv=None): os.makedirs(dir_name_amplitude) if parameters.tiltedScan: - (f_out, lvec, _, atomic_info_or_head) = io.load_vec_field(dirname + "/OutF", data_format=args.output_format) + f_out, lvec, _, atomic_info_or_head = io.load_vec_field(dirname + "/OutF", data_format=args.output_format) dfs = common.Fz2df_tilt( f_out, parameters.scanTilt, @@ -292,7 +292,7 @@ def main(argv=None): lvec_df[0] = lvec_df[0] + lvec_df[3] / lvec_3_norm * amplitude / 2 lvec_df[3] = lvec_df[3] / lvec_3_norm * (lvec_3_norm - amplitude) else: - (fzs, lvec, _, atomic_info_or_head) = io.load_scal_field(dirname + "/OutFz", data_format=args.output_format) + fzs, lvec, _, atomic_info_or_head = io.load_scal_field(dirname + "/OutFz", data_format=args.output_format) if applied_bias: r_tip = parameters.Rtip for iz, z in enumerate(tip_positions_z): diff --git a/ppafm/cli/utilities/cube2xsf.py b/ppafm/cli/utilities/cube2xsf.py index 42ddfcfc..7f4ef85e 100755 --- a/ppafm/cli/utilities/cube2xsf.py +++ b/ppafm/cli/utilities/cube2xsf.py @@ -19,7 +19,7 @@ parser.add_option( "-i", "--input", action="store", type="string", help="input file") parser.add_option( "-o", "--output", action="store", type="string", help="output file") # fmt: on - (options, args) = parser.parse_args() + options, args = parser.parse_args() if options.input == None: sys.exit("ERROR!!! Please, specify the input file with the '-i' option \n\n" + HELP_MSG) diff --git a/ppafm/cli/utilities/extract_densities.py b/ppafm/cli/utilities/extract_densities.py index c816a5cb..5e53a907 100755 --- a/ppafm/cli/utilities/extract_densities.py +++ b/ppafm/cli/utilities/extract_densities.py @@ -20,7 +20,7 @@ parser.add_option( "--dz", action="store", type="float", help="use dz with step", default=-0.1 ) parser.add_option( "--plot", action="store_false" , help="plot extracted ?", default=True ) # fmt: on -(options, args) = parser.parse_args() +options, args = parser.parse_args() fname, fext = os.path.splitext(options.i) fext = fext[1:] diff --git a/ppafm/cli/utilities/fitPauli.py b/ppafm/cli/utilities/fitPauli.py index c154c29f..fd527eef 100644 --- a/ppafm/cli/utilities/fitPauli.py +++ b/ppafm/cli/utilities/fitPauli.py @@ -33,7 +33,7 @@ parser.add_option( "--not_plot", action="store_false" , help="do not-plot the lines above atoms", default= True ) parser.add_option( "--debug", action="store_true" , help="plot and pr. all lines and data from fit",default= False ) # fmt: on -(options, args) = parser.parse_args() +options, args = parser.parse_args() # ====== functions diff --git a/ppafm/cli/utilities/plotQuad.py b/ppafm/cli/utilities/plotQuad.py index b9ca4419..ea192a6b 100755 --- a/ppafm/cli/utilities/plotQuad.py +++ b/ppafm/cli/utilities/plotQuad.py @@ -16,7 +16,7 @@ parser.add_option( "-i", action="store", type="string", help="input file", default='OutFz' ) parser.add_option("-f","--data_format" , action="store", type="string", help="Specify the output format of the vector and scalar field. Supported formats are: xsf,npy", default="xsf") # fmt: on -(options, args) = parser.parse_args() +options, args = parser.parse_args() try: points = np.genfromtxt(options.p) diff --git a/ppafm/cli/utilities/plotZcurves.py b/ppafm/cli/utilities/plotZcurves.py index 8c82a513..e53d5815 100755 --- a/ppafm/cli/utilities/plotZcurves.py +++ b/ppafm/cli/utilities/plotZcurves.py @@ -16,7 +16,7 @@ parser.add_option( "--iz", action="store", type="int", help="z-slice index to plot legend", default=15 ) parser.add_option("-f","--data_format" , action="store", type="string", help="Specify the output format of the vector and scalar field. Supported formats are: xsf,npy", default="xsf") # fmt: on -(options, args) = parser.parse_args() +options, args = parser.parse_args() try: points = np.genfromtxt(options.p) diff --git a/ppafm/cli/utilities/xsf2png.py b/ppafm/cli/utilities/xsf2png.py index a0e5d5de..8dd6c8f4 100755 --- a/ppafm/cli/utilities/xsf2png.py +++ b/ppafm/cli/utilities/xsf2png.py @@ -31,7 +31,7 @@ parser.add_option( "--atoms", action="store", type="string", default='input_plot.xyz', help="xyz geometry file", ) parser.add_option( "--bonds", action="store_true", default=False, help="plot bonds to images" ) # fmt: on -(options, args) = parser.parse_args() +options, args = parser.parse_args() atoms = None diff --git a/ppafm/fieldFFT.py b/ppafm/fieldFFT.py index 9bf7e14c..76a9fe16 100644 --- a/ppafm/fieldFFT.py +++ b/ppafm/fieldFFT.py @@ -31,7 +31,7 @@ def getSize(inp_axis, dims, sampleSize): def getMGrid(dims, dd): "returns coordinate arrays X, Y, Z" - (dx, dy, dz) = dd + dx, dy, dz = dd XYZ = np.mgrid[0 : dims[0], 0 : dims[1], 0 : dims[2]].astype(float) # fmt: off xshift = dims[0]//2; xshift_ = xshift; diff --git a/ppafm/io.py b/ppafm/io.py index 260546e3..5658c9d2 100644 --- a/ppafm/io.py +++ b/ppafm/io.py @@ -560,9 +560,7 @@ def _orthoLvec(sh, dd): return [[0, 0, 0], [sh[2] * dd[0], 0, 0], [0, sh[1] * dd[1], 0], [0, 0, sh[0] * dd[2]]] -XSF_HEAD_DEFAULT = ( - headScan -) = """ +XSF_HEAD_DEFAULT = headScan = """ ATOMS 1 0.0 0.0 0.0 @@ -934,8 +932,7 @@ def load_scal_field(fname, data_format="xsf"): #end """ -DEFAULT_POV_HEAD = ( - """ +DEFAULT_POV_HEAD = """ // *********************************************** // Camera & other global settings // *********************************************** @@ -950,9 +947,7 @@ def load_scal_field(fname, data_format="xsf"): up < 0, Zoom, 0 > look_at < .0.0, 0.0, 0.0 > } -""" - + DEFAULT_POV_HEAD_NO_CAM -) +""" + DEFAULT_POV_HEAD_NO_CAM def makePovCam(pos, up=[0.0, 1.0, 0.0], rg=[-1.0, 0.0, 0.0], fw=[0.0, 0.0, 100.0], lpos=[0.0, 0.0, -100.0], W=10.0, H=10.0): diff --git a/ppafm/ml/CorrectionLoop.py b/ppafm/ml/CorrectionLoop.py index e7c4ef49..de0c28e6 100644 --- a/ppafm/ml/CorrectionLoop.py +++ b/ppafm/ml/CorrectionLoop.py @@ -14,7 +14,6 @@ """ - import numpy as np from .. import common as PPU @@ -475,7 +474,7 @@ def Job_CorrectionLoop(simulator, atoms, bonds, geom_fname="input.xyz", nstep=10 parser = OptionParser() parser.add_option("-j", "--job", action="store", type="string", help="[train/loop]") - (options, args) = parser.parse_args() + options, args = parser.parse_args() logger.info(" UNIT_TEST START : CorrectionLoop ... ")