From 383f8236cd09f3ce974196b88f36aad12d89bffb Mon Sep 17 00:00:00 2001 From: Christopher Mayes <31023527+ChristopherMayes@users.noreply.github.com> Date: Wed, 29 May 2024 10:49:34 -0700 Subject: [PATCH] linting --- pmd_beamphysics/fields/fieldmesh.py | 9 ++++---- pmd_beamphysics/interfaces/lucretia.py | 2 +- pmd_beamphysics/labels.py | 32 +++++++++++++------------- pmd_beamphysics/readers.py | 3 +-- pmd_beamphysics/writers.py | 2 +- setup.py | 2 +- 6 files changed, 24 insertions(+), 26 deletions(-) diff --git a/pmd_beamphysics/fields/fieldmesh.py b/pmd_beamphysics/fields/fieldmesh.py index 78bea06..868b835 100644 --- a/pmd_beamphysics/fields/fieldmesh.py +++ b/pmd_beamphysics/fields/fieldmesh.py @@ -1,6 +1,6 @@ -from pmd_beamphysics.units import dimension, dimension_name, SI_symbol, pg_units +from pmd_beamphysics.units import pg_units -from pmd_beamphysics.readers import component_data, expected_record_unit_dimension, field_record_components, decode_attrs, field_paths, component_from_alias, load_field_attrs, component_alias +from pmd_beamphysics.readers import component_data, expected_record_unit_dimension, field_record_components, field_paths, component_from_alias, load_field_attrs, component_alias from pmd_beamphysics.writers import write_pmd_field, pmd_field_init @@ -11,7 +11,7 @@ from pmd_beamphysics.interfaces.ansys import read_ansys_ascii_3d_fields from pmd_beamphysics.interfaces.astra import write_astra_1d_fieldmap, read_astra_3d_fieldmaps, write_astra_3d_fieldmaps, astra_1d_fieldmap_data from pmd_beamphysics.interfaces.gpt import write_gpt_fieldmesh -from pmd_beamphysics.interfaces.impact import create_impact_solrf_fieldmap_fourier, create_impact_solrf_ele +from pmd_beamphysics.interfaces.impact import create_impact_solrf_ele from pmd_beamphysics.interfaces.superfish import write_superfish_t7, read_superfish_t7 from pmd_beamphysics.fields.expansion import expand_fieldmesh_from_onaxis @@ -23,7 +23,6 @@ import numpy as np from copy import deepcopy import os -import functools c_light = 299792458. @@ -446,7 +445,7 @@ def from_ansys_ascii_3d(cls, *, """ if frequency is None: - raise ValueError(f"Please provide a frequency") + raise ValueError("Please provide a frequency") data = read_ansys_ascii_3d_fields(efile, hfile, frequency=frequency) return cls(data=data) diff --git a/pmd_beamphysics/interfaces/lucretia.py b/pmd_beamphysics/interfaces/lucretia.py index e7bdcc4..4e8ceca 100644 --- a/pmd_beamphysics/interfaces/lucretia.py +++ b/pmd_beamphysics/interfaces/lucretia.py @@ -67,7 +67,7 @@ def lucretia_to_data(filename, ele_name='BEGINNING', t_ref=0, exclude_dead_parti elif (len(ele_list) == 1): ele_name = ele_list[0] - mdat = sio.loadmat(filename); + mdat = sio.loadmat(filename) coords = mdat['bstore'][ele_name][0,0]['Bunch'][0,0]['x'][0,0] charges = mdat['bstore'][ele_name][0,0]['Bunch'][0,0]['Q'][0,0][0] diff --git a/pmd_beamphysics/labels.py b/pmd_beamphysics/labels.py index 7d2c896..e2e7fff 100644 --- a/pmd_beamphysics/labels.py +++ b/pmd_beamphysics/labels.py @@ -1,4 +1,4 @@ -from pmd_beamphysics.units import pg_units, parse_bunching_str, nice_array +from pmd_beamphysics.units import parse_bunching_str, nice_array TEXLABEL = { @@ -36,20 +36,20 @@ 'gamma': r'\gamma', 'theta': r'\theta', 'charge': 'Q', - 'twiss_alpha_x' : 'Twiss\ '+r'\alpha_x', - 'twiss_beta_x' : 'Twiss\ '+r'\beta_x', - 'twiss_gamma_x' : 'Twiss\ '+r'\gamma_x', - 'twiss_eta_x' : 'Twiss\ '+r'\eta_x', - 'twiss_etap_x' : 'Twiss\ '+r"\eta'_x", - 'twiss_emit_x' : 'Twiss\ '+r'\epsilon_{x}', - 'twiss_norm_emit_x' : 'Twiss\ '+r'\epsilon_{n, x}', - 'twiss_alpha_y' : 'Twiss\ '+r'\alpha_y', - 'twiss_beta_y' : 'Twiss\ '+r'\beta_y', - 'twiss_gamma_y' : 'Twiss\ '+r'\gamma_y', - 'twiss_eta_y' : 'Twiss\ '+r'\eta_y', - 'twiss_etap_y' : 'Twiss\ '+r"\eta'_y", - 'twiss_emit_y' : 'Twiss\ '+r'\epsilon_{y}', - 'twiss_norm_emit_y' : 'Twiss\ '+r'\epsilon_{n, y}', + 'twiss_alpha_x' : r'Twiss\ '+r'\alpha_x', + 'twiss_beta_x' : r'Twiss\ '+r'\beta_x', + 'twiss_gamma_x' : r'Twiss\ '+r'\gamma_x', + 'twiss_eta_x' : r'Twiss\ '+r'\eta_x', + 'twiss_etap_x' : r'Twiss\ '+r"\eta'_x", + 'twiss_emit_x' : r'Twiss\ '+r'\epsilon_{x}', + 'twiss_norm_emit_x' : r'Twiss\ '+r'\epsilon_{n, x}', + 'twiss_alpha_y' : r'Twiss\ '+r'\alpha_y', + 'twiss_beta_y' : r'Twiss\ '+r'\beta_y', + 'twiss_gamma_y' : r'Twiss\ '+r'\gamma_y', + 'twiss_eta_y' : r'Twiss\ '+r'\eta_y', + 'twiss_etap_y' : r'Twiss\ '+r"\eta'_y", + 'twiss_emit_y' : r'Twiss\ '+r'\epsilon_{y}', + 'twiss_norm_emit_y' : r'Twiss\ '+r'\epsilon_{n, y}', # 'species_charge', # 'weight', 'average_current': r'I_{av}', @@ -122,7 +122,7 @@ def texlabel(key: str): if key.startswith('bunching'): wavelength = parse_bunching_str(key) x, _, prefix = nice_array(wavelength) - return f'\mathrm{{bunching~at}}~{x:.1f}~\mathrm{{ {prefix}m }}' + return fr'\mathrm{{bunching~at}}~{x:.1f}~\mathrm{{ {prefix}m }}' return None diff --git a/pmd_beamphysics/readers.py b/pmd_beamphysics/readers.py index 7b63e14..4efdaf8 100644 --- a/pmd_beamphysics/readers.py +++ b/pmd_beamphysics/readers.py @@ -1,8 +1,7 @@ -from .units import dimension, dimension_name, SI_symbol, pg_units, c_light, e_charge +from .units import dimension, dimension_name, SI_symbol, c_light, e_charge from .tools import decode_attrs, decode_attr -import h5py import numpy as np #----------------------------------------- diff --git a/pmd_beamphysics/writers.py b/pmd_beamphysics/writers.py index 0a153b6..6abc8de 100644 --- a/pmd_beamphysics/writers.py +++ b/pmd_beamphysics/writers.py @@ -1,6 +1,6 @@ import numpy as np -from .units import unit, pg_units +from .units import pg_units from .readers import component_from_alias, load_field_attrs from .tools import fstr, encode_attrs diff --git a/setup.py b/setup.py index 49a2c4d..36e2ce7 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ import versioneer from setuptools import setup, find_packages -from os import path, environ +from os import path cur_dir = path.abspath(path.dirname(__file__))