From b57348b3697d5ddd2346433d91cc2c72507208a0 Mon Sep 17 00:00:00 2001 From: Ivan Usov Date: Wed, 14 Dec 2022 16:14:31 +0100 Subject: [PATCH] Apply formatting --- pyzebra/anatric.py | 6 +----- pyzebra/app/app.py | 4 ++++ pyzebra/app/cli.py | 6 ++---- pyzebra/app/handler.py | 3 +-- pyzebra/app/panel_ccl_compare.py | 2 +- pyzebra/app/panel_ccl_integrate.py | 2 +- pyzebra/app/panel_ccl_prepare.py | 6 +++--- pyzebra/app/panel_hdf_anatric.py | 4 ++-- pyzebra/app/panel_hdf_param_study.py | 8 ++------ pyzebra/app/panel_spind.py | 2 +- pyzebra/ccl_io.py | 4 ++-- pyzebra/ccl_process.py | 4 +--- pyzebra/h5.py | 9 +++++---- pyzebra/xtal.py | 11 ++++------- 14 files changed, 30 insertions(+), 41 deletions(-) diff --git a/pyzebra/anatric.py b/pyzebra/anatric.py index e50ef4b..b7ac1c0 100644 --- a/pyzebra/anatric.py +++ b/pyzebra/anatric.py @@ -2,11 +2,7 @@ import subprocess import xml.etree.ElementTree as ET -DATA_FACTORY_IMPLEMENTATION = [ - "trics", - "morph", - "d10", -] +DATA_FACTORY_IMPLEMENTATION = ["trics", "morph", "d10"] REFLECTION_PRINTER_FORMATS = [ "rafin", diff --git a/pyzebra/app/app.py b/pyzebra/app/app.py index 74c254f..5be05b2 100644 --- a/pyzebra/app/app.py +++ b/pyzebra/app/app.py @@ -31,13 +31,16 @@ bokeh_logger.setLevel(logging.WARNING) bokeh_logger.addHandler(bokeh_handler) bokeh_log_textareainput = TextAreaInput(title="server output:", height=150) + def proposal_textinput_callback(_attr, _old, _new): apply_button.disabled = False + proposal_textinput = TextInput(title="Proposal number:", name="") proposal_textinput.on_change("value_input", proposal_textinput_callback) doc.proposal_textinput = proposal_textinput + def apply_button_callback(): proposal = proposal_textinput.value.strip() if proposal: @@ -52,6 +55,7 @@ def apply_button_callback(): proposal_textinput.name = proposal_path + apply_button = Button(label="Apply", button_type="primary") apply_button.on_click(apply_button_callback) diff --git a/pyzebra/app/cli.py b/pyzebra/app/cli.py index d4ef9b9..d411ebd 100644 --- a/pyzebra/app/cli.py +++ b/pyzebra/app/cli.py @@ -39,7 +39,7 @@ def main(): ) parser.add_argument( - "--anatric-path", type=str, default=ANATRIC_PATH, help="path to anatric executable", + "--anatric-path", type=str, default=ANATRIC_PATH, help="path to anatric executable" ) parser.add_argument( @@ -49,9 +49,7 @@ def main(): help="path to Sxtal_Refgen executable", ) - parser.add_argument( - "--spind-path", type=str, default=None, help="path to spind scripts folder", - ) + parser.add_argument("--spind-path", type=str, default=None, help="path to spind scripts folder") parser.add_argument( "--args", diff --git a/pyzebra/app/handler.py b/pyzebra/app/handler.py index 334f021..aa2ec05 100644 --- a/pyzebra/app/handler.py +++ b/pyzebra/app/handler.py @@ -2,8 +2,7 @@ from bokeh.application.handlers import Handler class PyzebraHandler(Handler): - """Provides a mechanism for generic bokeh applications to build up new streamvis documents. - """ + """Provides a mechanism for generic bokeh applications to build up new streamvis documents.""" def __init__(self, anatric_path, spind_path): """Initialize a pyzebra handler for bokeh applications. diff --git a/pyzebra/app/panel_ccl_compare.py b/pyzebra/app/panel_ccl_compare.py index 5324ca7..6ce2534 100644 --- a/pyzebra/app/panel_ccl_compare.py +++ b/pyzebra/app/panel_ccl_compare.py @@ -537,7 +537,7 @@ def create(): n = len(params) fitparams = dict( - param=params, value=[None] * n, vary=[True] * n, min=[None] * n, max=[None] * n, + param=params, value=[None] * n, vary=[True] * n, min=[None] * n, max=[None] * n ) if function == "linear": diff --git a/pyzebra/app/panel_ccl_integrate.py b/pyzebra/app/panel_ccl_integrate.py index 7ca1fe7..d7d8397 100644 --- a/pyzebra/app/panel_ccl_integrate.py +++ b/pyzebra/app/panel_ccl_integrate.py @@ -517,7 +517,7 @@ def create(): n = len(params) fitparams = dict( - param=params, value=[None] * n, vary=[True] * n, min=[None] * n, max=[None] * n, + param=params, value=[None] * n, vary=[True] * n, min=[None] * n, max=[None] * n ) if function == "linear": diff --git a/pyzebra/app/panel_ccl_prepare.py b/pyzebra/app/panel_ccl_prepare.py index f7d7220..af98681 100644 --- a/pyzebra/app/panel_ccl_prepare.py +++ b/pyzebra/app/panel_ccl_prepare.py @@ -348,7 +348,7 @@ def create(): # Define resolution function def _res_fun(stt, wave, res_mult): expr = np.tan(stt / 2 * np.pi / 180) - fwhm = np.sqrt(0.4639 * expr ** 2 - 0.4452 * expr + 0.1506) * res_mult # res in deg + fwhm = np.sqrt(0.4639 * expr**2 - 0.4452 * expr + 0.1506) * res_mult # res in deg return fwhm def plot_file_callback(): @@ -598,7 +598,7 @@ def create(): ellipse_source.data.update(x=el_x, y=el_y, w=el_w, h=el_h, c=el_c) scan_source.data.update( - xs=scan_xs, ys=scan_ys, x=scan_x, y=scan_y, m=scan_m, s=scan_s, c=scan_c, l=scan_l, + xs=scan_xs, ys=scan_ys, x=scan_x, y=scan_y, m=scan_m, s=scan_s, c=scan_c, l=scan_l ) arrow1.visible = True @@ -691,7 +691,7 @@ def create(): ) k_vectors = TextAreaInput( - title="k vectors:", value="0.0 0.0 0.0\n0.5 0.0 0.0\n0.5 0.5 0.0", width=150, + title="k vectors:", value="0.0 0.0 0.0\n0.5 0.0 0.0\n0.5 0.5 0.0", width=150 ) res_mult_ni = NumericInput(title="Resolution mult:", value=10, mode="int", width=100) diff --git a/pyzebra/app/panel_hdf_anatric.py b/pyzebra/app/panel_hdf_anatric.py index 5717433..592255c 100644 --- a/pyzebra/app/panel_hdf_anatric.py +++ b/pyzebra/app/panel_hdf_anatric.py @@ -169,7 +169,7 @@ def create(): config.dataFactory_implementation = new dataFactory_implementation_select = Select( - title="DataFactory implement.:", options=DATA_FACTORY_IMPLEMENTATION, width=145, + title="DataFactory implement.:", options=DATA_FACTORY_IMPLEMENTATION, width=145 ) dataFactory_implementation_select.on_change("value", dataFactory_implementation_select_callback) @@ -200,7 +200,7 @@ def create(): config.reflectionPrinter_format = new reflectionPrinter_format_select = Select( - title="ReflectionPrinter format:", options=REFLECTION_PRINTER_FORMATS, width=145, + title="ReflectionPrinter format:", options=REFLECTION_PRINTER_FORMATS, width=145 ) reflectionPrinter_format_select.on_change("value", reflectionPrinter_format_select_callback) diff --git a/pyzebra/app/panel_hdf_param_study.py b/pyzebra/app/panel_hdf_param_study.py index a163836..26ea433 100644 --- a/pyzebra/app/panel_hdf_param_study.py +++ b/pyzebra/app/panel_hdf_param_study.py @@ -322,9 +322,7 @@ def create(): # ---- tools wheelzoomtool = WheelZoomTool(maintain_focus=False) overview_plot_x.toolbar.logo = None - overview_plot_x.add_tools( - PanTool(), BoxZoomTool(), wheelzoomtool, ResetTool(), - ) + overview_plot_x.add_tools(PanTool(), BoxZoomTool(), wheelzoomtool, ResetTool()) overview_plot_x.toolbar.active_scroll = wheelzoomtool # ---- axes @@ -360,9 +358,7 @@ def create(): # ---- tools wheelzoomtool = WheelZoomTool(maintain_focus=False) overview_plot_y.toolbar.logo = None - overview_plot_y.add_tools( - PanTool(), BoxZoomTool(), wheelzoomtool, ResetTool(), - ) + overview_plot_y.add_tools(PanTool(), BoxZoomTool(), wheelzoomtool, ResetTool()) overview_plot_y.toolbar.active_scroll = wheelzoomtool # ---- axes diff --git a/pyzebra/app/panel_spind.py b/pyzebra/app/panel_spind.py index ab8a99b..b44f7ff 100644 --- a/pyzebra/app/panel_spind.py +++ b/pyzebra/app/panel_spind.py @@ -128,7 +128,7 @@ def create(): spind_out_file = os.path.join(temp_dir, "spind.txt") spind_res = dict( - label=[], crystal_id=[], match_rate=[], matched_peaks=[], column_5=[], ub_matrix=[], + label=[], crystal_id=[], match_rate=[], matched_peaks=[], column_5=[], ub_matrix=[] ) try: with open(spind_out_file) as f_out: diff --git a/pyzebra/ccl_io.py b/pyzebra/ccl_io.py index a8d8d65..9da926e 100644 --- a/pyzebra/ccl_io.py +++ b/pyzebra/ccl_io.py @@ -175,7 +175,7 @@ def parse_1D(fileobj, data_type): # "om" -> "omega" scan["scan_motor"] = "omega" - scan["scan_motors"] = ["omega", ] + scan["scan_motors"] = ["omega"] # overwrite metadata, because it only refers to the scan center half_dist = (scan["n_points"] - 1) / 2 * scan["angle_step"] scan["omega"] = np.linspace( @@ -354,7 +354,7 @@ def export_ccl_compare(dataset1, dataset2, path, export_target, hkl_precision=2) area_n1, area_s1 = scan1["area"] area_n2, area_s2 = scan2["area"] area_n = area_n1 - area_n2 - area_s = np.sqrt(area_s1 ** 2 + area_s2 ** 2) + area_s = np.sqrt(area_s1**2 + area_s2**2) area_str = f"{area_n:10.2f}{area_s:10.2f}" ang_str = "" diff --git a/pyzebra/ccl_process.py b/pyzebra/ccl_process.py index b23a5b5..20d1be8 100644 --- a/pyzebra/ccl_process.py +++ b/pyzebra/ccl_process.py @@ -18,9 +18,7 @@ PARAM_PRECISIONS = { "ub": 0.01, } -MAX_RANGE_GAP = { - "omega": 0.5, -} +MAX_RANGE_GAP = {"omega": 0.5} MOTOR_POS_PRECISION = 0.01 diff --git a/pyzebra/h5.py b/pyzebra/h5.py index 3d5d619..3461d49 100644 --- a/pyzebra/h5.py +++ b/pyzebra/h5.py @@ -2,9 +2,10 @@ import h5py import numpy as np from lmfit.models import Gaussian2dModel, GaussianModel -META_MATRIX = ("UB", ) -META_CELL = ("cell", ) -META_STR = ("name", ) +META_MATRIX = ("UB",) +META_CELL = ("cell",) +META_STR = ("name",) + def read_h5meta(filepath): """Open and parse content of a h5meta file. @@ -137,7 +138,7 @@ def read_detector_data(filepath, cami_meta=None): else: raise ValueError("No angles that vary") - scan["scan_motors"] = [scan["scan_motor"], ] + scan["scan_motors"] = [scan["scan_motor"]] # optional parameters if "/entry1/sample/magnetic_field" in h5f: diff --git a/pyzebra/xtal.py b/pyzebra/xtal.py index dfdcb65..8a969c1 100644 --- a/pyzebra/xtal.py +++ b/pyzebra/xtal.py @@ -362,8 +362,7 @@ def angtohkl(wave, ddist, gammad, om, ch, ph, nud, x, y): def ang2hkl(wave, ddist, gammad, om, ch, ph, nud, ub, x, y): - """Calculate hkl-indices of a reflection from its position (x,y,angles) at the 2d-detector - """ + """Calculate hkl-indices of a reflection from its position (x,y,angles) at the 2d-detector""" ga, nu = det2pol(ddist, gammad, nud, x, y) z1 = z1frmd(wave, ga, om, ch, ph, nu) ubinv = np.linalg.inv(ub) @@ -373,8 +372,7 @@ def ang2hkl(wave, ddist, gammad, om, ch, ph, nud, ub, x, y): def ang2hkl_1d(wave, ddist, ga, om, ch, ph, nu, ub): - """Calculate hkl-indices of a reflection from its position (angles) at the 1d-detector - """ + """Calculate hkl-indices of a reflection from its position (angles) at the 1d-detector""" z1 = z1frmd(wave, ga, om, ch, ph, nu) ubinv = np.linalg.inv(ub) hkl = ubinv @ z1 @@ -383,8 +381,7 @@ def ang2hkl_1d(wave, ddist, ga, om, ch, ph, nu, ub): def ang_proc(wave, ddist, gammad, om, ch, ph, nud, x, y): - """Utility function to calculate ch, ph, ga, om - """ + """Utility function to calculate ch, ph, ga, om""" ga, nu = det2pol(ddist, gammad, nud, x, y) z1 = z1frmd(wave, ga, om, ch, ph, nu) ch2, ph2 = eqchph(z1) @@ -403,4 +400,4 @@ def gauss(x, *p): Gaussian function """ A, mu, sigma = p - return A * np.exp(-((x - mu) ** 2) / (2.0 * sigma ** 2)) + return A * np.exp(-((x - mu) ** 2) / (2.0 * sigma**2))