From d1d9057ab41c7976b392670010d7342607741171 Mon Sep 17 00:00:00 2001 From: Kevin Lewis Date: Thu, 4 Jul 2024 13:10:47 -0400 Subject: [PATCH 1/3] Remove pass --- hexrd/cli/fit_grains.py | 1 - hexrd/distortion/distortionabc.py | 2 -- hexrd/distortion/registry.py | 2 -- hexrd/findorientations.py | 9 --------- hexrd/fitgrains.py | 8 +------- hexrd/fitting/calibration/calibrator.py | 6 ------ hexrd/fitting/calibration/laue.py | 5 ----- hexrd/fitting/calibration/multigrain.py | 4 ---- hexrd/fitting/grains.py | 2 -- hexrd/grainmap/nfutil.py | 2 -- hexrd/imageseries/baseclass.py | 2 -- hexrd/imageseries/load/framecache.py | 2 -- hexrd/imageseries/load/hdf5.py | 3 --- hexrd/imageseries/load/imagefiles.py | 2 -- hexrd/imageseries/load/registry.py | 2 -- hexrd/imageseries/omega.py | 2 -- hexrd/imageseries/process.py | 2 -- hexrd/imageseries/save.py | 4 ---- hexrd/instrument/detector.py | 11 +---------- hexrd/instrument/hedm_instrument.py | 14 -------------- hexrd/material/crystallography.py | 1 - hexrd/material/material.py | 10 ---------- hexrd/material/spacegroup.py | 16 ---------------- hexrd/material/symbols.py | 3 --- hexrd/projections/spherical.py | 1 - hexrd/rotations.py | 7 ------- hexrd/transforms/old_xfcapi.py | 2 -- hexrd/transforms/xf.py | 8 -------- hexrd/valunits.py | 4 ---- hexrd/wppf/texture.py | 1 - scripts/calibrate_from_powder.py | 3 --- scripts/calibrate_from_powder.py.bak | 5 +---- scripts/calibrate_from_rotation_series.py | 7 ------- scripts/calibration_mockup.py | 4 ---- scripts/powder_calibration.py | 3 --- scripts/tiffs_from_h5.py | 1 - 36 files changed, 3 insertions(+), 158 deletions(-) diff --git a/hexrd/cli/fit_grains.py b/hexrd/cli/fit_grains.py index e4527a9a6..77b0781b0 100644 --- a/hexrd/cli/fit_grains.py +++ b/hexrd/cli/fit_grains.py @@ -335,7 +335,6 @@ def execute(args, parser): gid_list = None if args.grains is not None: gid_list = [int(i) for i in args.grains.split(',')] - pass fit_results = fit_grains( cfg, diff --git a/hexrd/distortion/distortionabc.py b/hexrd/distortion/distortionabc.py index 0744b8783..c1ae2a473 100644 --- a/hexrd/distortion/distortionabc.py +++ b/hexrd/distortion/distortionabc.py @@ -8,9 +8,7 @@ class DistortionABC(metaclass=abc.ABCMeta): @abc.abstractmethod def apply(self, xy_in): """Apply distortion mapping""" - pass @abc.abstractmethod def apply_inverse(self, xy_in): """Apply inverse distortion mapping""" - pass diff --git a/hexrd/distortion/registry.py b/hexrd/distortion/registry.py index 1be2fb8a1..a36f2f7d0 100644 --- a/hexrd/distortion/registry.py +++ b/hexrd/distortion/registry.py @@ -20,5 +20,3 @@ def register(cls, acls): """Register adapter class""" if acls.__name__ != 'DistortionBase': cls.distortion_registry[acls.maptype] = acls - - pass # end class diff --git a/hexrd/findorientations.py b/hexrd/findorientations.py index 5c1b6ba87..863b3fdff 100755 --- a/hexrd/findorientations.py +++ b/hexrd/findorientations.py @@ -131,9 +131,6 @@ def generate_orientation_fibers(cfg, eta_ome): ome_c = eta_ome.omeEdges[0] + (0.5 + coms[i][ispot][0])*del_ome eta_c = eta_ome.etaEdges[0] + (0.5 + coms[i][ispot][1])*del_eta input_p.append(np.hstack([this_hkl, this_tth, eta_c, ome_c])) - pass - pass - pass # do the mapping start = timeit.default_timer() @@ -155,7 +152,6 @@ def generate_orientation_fibers(cfg, eta_ome): discretefiber_reduced, input_p, chunksize=chunksize ), total=ntotal ): - pass print(_.shape) ''' pool.close() @@ -352,8 +348,6 @@ def quat_distance(x, y): qbar[:, i] = rot.quatAverageCluster( qfib_r[:, cl == i + 1], qsym ).flatten() - pass - pass if algorithm in ('dbscan', 'ort-dbscan') and qbar.size/4 > 1: logger.info("\tchecking for duplicate orientations...") @@ -374,10 +368,7 @@ def quat_distance(x, y): tmp[:, i] = rot.quatAverageCluster( qbar[:, cl == i + 1].reshape(4, npts), qsym ).flatten() - pass qbar = tmp - pass - pass logger.info("clustering took %f seconds", timeit.default_timer() - start) logger.info( diff --git a/hexrd/fitgrains.py b/hexrd/fitgrains.py index db53d387b..2afb3180e 100644 --- a/hexrd/fitgrains.py +++ b/hexrd/fitgrains.py @@ -184,8 +184,7 @@ def fit_grain_FF_reduced(grain_id): culled_results[det_key] = [presults[i] for i in np.where(idx)[0]] num_refl_tot += len(valid_refl_ids) num_refl_valid += sum(valid_refl_ids) - - pass # now we have culled data + # now we have culled data # CAVEAT: completeness from pullspots only; incl saturated and overlaps # @@ -220,8 +219,6 @@ def fit_grain_FF_reduced(grain_id): plane_data.latVecOps['B'], plane_data.wavelength, ome_period, simOnly=False, return_value_flag=2) - pass # end conditional on fit - pass # end tolerance looping if refit is not None: # first get calculated x, y, ome from previous solution @@ -279,7 +276,6 @@ def fit_grain_FF_reduced(grain_id): ] num_refl_valid += sum(idx_new) - pass # only execute fit if left with enough reflections if num_refl_valid > 12: @@ -297,8 +293,6 @@ def fit_grain_FF_reduced(grain_id): plane_data.latVecOps['B'], plane_data.wavelength, ome_period, simOnly=False, return_value_flag=2) - pass - pass # close refit conditional return grain_id, completeness, chisq, grain_params diff --git a/hexrd/fitting/calibration/calibrator.py b/hexrd/fitting/calibration/calibrator.py index 6264b1d14..730395491 100644 --- a/hexrd/fitting/calibration/calibrator.py +++ b/hexrd/fitting/calibration/calibrator.py @@ -8,7 +8,6 @@ class Calibrator(ABC): @abstractmethod def type(self): """The type of the calibrator""" - pass @abstractmethod def create_lmfit_params(self, current_params): @@ -25,7 +24,6 @@ def create_lmfit_params(self, current_params): for the lattice parameters. The Laue calibrator creates lmfit parameters for crystal parameters. """ - pass @abstractmethod def update_from_lmfit_params(self, params_dict): @@ -38,7 +36,6 @@ def update_from_lmfit_params(self, params_dict): For example, the powder calibrator will update the lattice parameters on the material. The Laue calibrator will update crystal parameters. """ - pass @abstractmethod def residual(self, calibration_data=None): @@ -48,7 +45,6 @@ def residual(self, calibration_data=None): the calibration class instead, in which case, calibration_data can be `None`. """ - pass @property @abstractmethod @@ -73,10 +69,8 @@ def calibration_picks(self): string of the hkl. And "picks" are either a list of points (powder) or a single point (laue). The picks are in cartesian coordinates. """ - pass @calibration_picks.setter @abstractmethod def calibration_picks(self, val): """Setter for calibration_picks. See getter docs for details.""" - pass diff --git a/hexrd/fitting/calibration/laue.py b/hexrd/fitting/calibration/laue.py index 131d68bfe..5a6e4d835 100644 --- a/hexrd/fitting/calibration/laue.py +++ b/hexrd/fitting/calibration/laue.py @@ -209,7 +209,6 @@ def autopick_points(self, raw_img_dict, tth_tol=5., eta_tol=5., valid_hkls = hkls[gid][:, valid_refl] valid_angs = angles[gid][valid_refl, :] valid_energy = energy[gid][valid_refl] - # pass # make patches refl_patches = xrdutil.make_reflection_patches( @@ -291,7 +290,6 @@ def autopick_points(self, raw_img_dict, tth_tol=5., eta_tol=5., # else: closest_peak_idx = 0 - pass # end multipeak conditional # coms = coms[closest_peak_idx] # @@ -338,7 +336,6 @@ def autopick_points(self, raw_img_dict, tth_tol=5., eta_tol=5., gaussian_2d_int, [[0., 2.*y0], [0., 2.*x0]], args=fit_par) - pass com_angs = np.hstack([ tth_edges[0] + (0.5 + coms[1])*delta_tth, eta_edges[0] + (0.5 + coms[0])*delta_eta @@ -382,14 +379,12 @@ def autopick_points(self, raw_img_dict, tth_tol=5., eta_tol=5., # spot_intensity = np.nan max_intensity = np.nan - pass reflInfoList.append([peakId, valid_hkls[:, iRefl], (spot_intensity, max_intensity), valid_energy[iRefl], valid_angs[iRefl, :], meas_angs[iRefl, :], meas_xy[iRefl, :]]) - pass reflInfo = np.array( [tuple(i) for i in reflInfoList], dtype=reflInfo_dtype) diff --git a/hexrd/fitting/calibration/multigrain.py b/hexrd/fitting/calibration/multigrain.py index c677c625d..92dccb728 100644 --- a/hexrd/fitting/calibration/multigrain.py +++ b/hexrd/fitting/calibration/multigrain.py @@ -250,7 +250,6 @@ def sxcal_obj_func(plist_fit, plist_full, xy_unwarped[det_key][ig] = panel.distortion.apply( xy_unwarped[det_key][ig] ) - pass # transform G-vectors: # 1) convert inv. stretch tensor from MV notation in to 3x3 @@ -286,8 +285,6 @@ def sxcal_obj_func(plist_fit, plist_full, calc_omes[det_key].append(calc_omes_tmp) calc_xy[det_key].append(calc_xy_tmp) - pass - pass # return values if sim_only: @@ -311,7 +308,6 @@ def sxcal_obj_func(plist_fit, plist_full, calc_xy_all.append(np.vstack(calc_xy[det_key])) meas_omes_all.append(np.hstack(meas_omes[det_key])) calc_omes_all.append(np.hstack(calc_omes[det_key])) - pass meas_xy_all = np.vstack(meas_xy_all) calc_xy_all = np.vstack(calc_xy_all) meas_omes_all = np.hstack(meas_omes_all) diff --git a/hexrd/fitting/grains.py b/hexrd/fitting/grains.py index 659173aac..a407f8781 100644 --- a/hexrd/fitting/grains.py +++ b/hexrd/fitting/grains.py @@ -218,7 +218,6 @@ def objFuncFitGrain(gFit, gFull, gFlag, meas_omes = meas_xyo[:, 2] xy_unwarped = panel.distortion.apply(meas_xyo[:, :2]) meas_xyo = np.vstack([xy_unwarped.T, meas_omes]).T - pass # append to meas_omes meas_xyo_all.append(meas_xyo) @@ -251,7 +250,6 @@ def objFuncFitGrain(gFit, gFull, gFlag, # append to xy dict calc_xy_dict[det_key] = calc_xy - pass # stack results to concatenated arrays calc_omes_all = np.hstack([calc_omes_dict[k] for k in det_keys_ordered]) diff --git a/hexrd/grainmap/nfutil.py b/hexrd/grainmap/nfutil.py index f35c1c02f..81bca353d 100644 --- a/hexrd/grainmap/nfutil.py +++ b/hexrd/grainmap/nfutil.py @@ -47,7 +47,6 @@ logging.info(f'{rank=} {world_size=} {hostname=}') except ImportError: logging.warning(f'mpi4py failed to load on {hostname=}. MPI is disabled.') - pass # Import of image loading, this should probably be done properly with preprocessed frame-cache binaries @@ -809,7 +808,6 @@ def evaluate_diffraction_angles(experiment, controller=None): distortion=None) all_angles.append(sim_results[2]) controller.update(i + 1) - pass controller.finish(subprocess) return all_angles diff --git a/hexrd/imageseries/baseclass.py b/hexrd/imageseries/baseclass.py index a99e0e490..729c8af37 100644 --- a/hexrd/imageseries/baseclass.py +++ b/hexrd/imageseries/baseclass.py @@ -39,5 +39,3 @@ def shape(self): @property def metadata(self): return self._adapter.metadata - - pass # end class diff --git a/hexrd/imageseries/load/framecache.py b/hexrd/imageseries/load/framecache.py index 20fbd632a..b6435942d 100644 --- a/hexrd/imageseries/load/framecache.py +++ b/hexrd/imageseries/load/framecache.py @@ -135,5 +135,3 @@ def __iter__(self): #@memoize def __len__(self): return self._nframes - - pass # end class diff --git a/hexrd/imageseries/load/hdf5.py b/hexrd/imageseries/load/hdf5.py index 074c9f7b9..c573531e6 100644 --- a/hexrd/imageseries/load/hdf5.py +++ b/hexrd/imageseries/load/hdf5.py @@ -55,7 +55,6 @@ def __del__(self): self.close() except(Exception): warnings.warn("HDF5ImageSeries could not close h5 file") - pass def __getitem__(self, key): if self._ndim == 2: @@ -138,5 +137,3 @@ def shape(self): return self.__image_dataset.shape else: return self.__image_dataset.shape[1:] - - pass # end class diff --git a/hexrd/imageseries/load/imagefiles.py b/hexrd/imageseries/load/imagefiles.py index e49628515..532d2c006 100644 --- a/hexrd/imageseries/load/imagefiles.py +++ b/hexrd/imageseries/load/imagefiles.py @@ -234,8 +234,6 @@ def _load_data(self, filename, frame=None): return _process_data(filename, data) - pass # end class - class FileInfo(object): """class for managing individual file information""" diff --git a/hexrd/imageseries/load/registry.py b/hexrd/imageseries/load/registry.py index 3bcb1270e..f87315f45 100644 --- a/hexrd/imageseries/load/registry.py +++ b/hexrd/imageseries/load/registry.py @@ -9,5 +9,3 @@ def register(cls, acls): """Register adapter class""" if acls.__name__ != 'ImageSeriesAdapter': cls.adapter_registry[acls.format] = acls - - pass # end class diff --git a/hexrd/imageseries/omega.py b/hexrd/imageseries/omega.py index 7875a9f3b..f0a61ef2d 100644 --- a/hexrd/imageseries/omega.py +++ b/hexrd/imageseries/omega.py @@ -213,8 +213,6 @@ def save_omegas(self, fname): """ np.save(fname, self.omegas) - pass # end class - class OmegaSeriesError(Exception): def __init__(self, value): diff --git a/hexrd/imageseries/process.py b/hexrd/imageseries/process.py index c2101fc79..f95835b41 100644 --- a/hexrd/imageseries/process.py +++ b/hexrd/imageseries/process.py @@ -146,5 +146,3 @@ def addop(self, key, func): def oplist(self): """list of operations to apply""" return self._oplist - - pass # end class diff --git a/hexrd/imageseries/save.py b/hexrd/imageseries/save.py index 187b5fc67..092d30aa6 100644 --- a/hexrd/imageseries/save.py +++ b/hexrd/imageseries/save.py @@ -62,8 +62,6 @@ def register(cls, wcls): def getwriter(cls, name): """return instance associated with name""" return cls.writer_registry[name] - # - pass # end class class Writer(object, metaclass=_RegisterWriter): @@ -193,8 +191,6 @@ def h5opts(self): return d - pass # end class - class WriteFrameCache(Writer): """write frame cache imageseries diff --git a/hexrd/instrument/detector.py b/hexrd/instrument/detector.py index cec8c186d..82784105d 100644 --- a/hexrd/instrument/detector.py +++ b/hexrd/instrument/detector.py @@ -91,7 +91,6 @@ def cart_to_angles(self, xy_data, rmat_s=None, tvec_s=None, DESCRIPTION. """ - pass @abstractmethod def angles_to_cart(self, tth_eta, @@ -126,12 +125,10 @@ def angles_to_cart(self, tth_eta, The (n, 2) array on the n input coordinates in the . """ - pass @abstractmethod def cart_to_dvecs(self, xy_data): """Convert cartesian coordinates to dvectors""" - pass @abstractmethod def pixel_angles(self, origin=ct.zeros_3): @@ -152,7 +149,7 @@ def beam_position(self): returns the coordinates of the beam in the cartesian detector frame {Xd, Yd, Zd}. NaNs if no intersection. """ - pass + @property def extra_config_kwargs(self): @@ -735,7 +732,6 @@ def config_dict(self, chi=0, tvec=ct.zeros_3, # !!! can't write None to hdf5; substitute with zeros panel_buffer = np.r_[0., 0.] ''' - pass det_dict['buffer'] = panel_buffer det_dict.update(self.extra_config_kwargs) @@ -1227,7 +1223,6 @@ def make_powder_rings( valid_ang.append(patch_valid_angs) valid_xy.append(patch_valid_xys) map_indices.append(patch_is_on) - pass # ??? is this option necessary? if full_output: return valid_ang, valid_xy, tth_ranges, map_indices, eta_edges @@ -1527,10 +1522,8 @@ def simulate_laue_pattern(self, crystal_data, wlen >= lmin[i], wlen <= lmax[i]) validEnergy = validEnergy | in_energy_range - pass else: validEnergy = np.logical_and(wlen >= lmin, wlen <= lmax) - pass # index for valid reflections keepers = np.where(np.logical_and(on_panel, validEnergy))[0] @@ -1541,8 +1534,6 @@ def simulate_laue_pattern(self, crystal_data, angles[iG][keepers, :] = tth_eta[keepers, :] dspacing[iG, keepers] = dsp[keepers] energy[iG, keepers] = ct.keVToAngstrom(wlen[keepers]) - pass # close conditional on valids - pass # close loop on grains return xy_det, hkls_in, angles, dspacing, energy @staticmethod diff --git a/hexrd/instrument/hedm_instrument.py b/hexrd/instrument/hedm_instrument.py index 5f080cec7..af2c106dd 100644 --- a/hexrd/instrument/hedm_instrument.py +++ b/hexrd/instrument/hedm_instrument.py @@ -486,7 +486,6 @@ def pixel_resolution(instr): max_eta = min(max_eta, np.min(angps[:, 1])) min_tth = max(min_tth, np.max(angps[:, 0])) min_eta = max(min_eta, np.max(angps[:, 1])) - pass med_tth, med_eta = np.median(np.vstack(ang_ps_full), axis=0).flatten() return (min_tth, med_tth, max_tth), (min_eta, med_eta, max_eta) @@ -1163,7 +1162,6 @@ def extract_polar_maps(self, plane_data, imgser_dict, except ValueError: raise RuntimeError(f"hklID '{input_hklID}' is invalid") tth_ranges = tth_ranges[idx] - pass # end of active_hkls handling delta_eta = eta_edges[1] - eta_edges[0] ncols_eta = len(eta_edges) - 1 @@ -1922,7 +1920,6 @@ def pull_spots(self, plane_data, grain_params, tmp > threshold ) patch_data_raw.append(tmp) - pass patch_data_raw = np.stack(patch_data_raw, axis=0) compl.append(contains_signal) @@ -1965,7 +1962,6 @@ def pull_spots(self, plane_data, grain_params, ) else: closest_peak_idx = 0 - pass # end multipeak conditional coms = coms[closest_peak_idx] # meas_omes = \ # ome_edges[0] + (0.5 + coms[0])*delta_ome @@ -2019,10 +2015,8 @@ def pull_spots(self, plane_data, grain_params, ).flatten() # FIXME: why is this suddenly necessary??? meas_xy = meas_xy.squeeze() - pass # end num_peaks > 0 else: patch_data = patch_data_raw - pass # end contains_signal if peak_id < 0: # The peak is invalid. @@ -2046,8 +2040,6 @@ def pull_spots(self, plane_data, grain_params, xyc_arr, ijs, frame_indices, patch_data, ang_centers[i_pt], xy_centers[i_pt], meas_angs, meas_xy) - pass # end conditional on write output - pass # end conditional on check only if return_spot_list: # Full output @@ -2069,12 +2061,9 @@ def pull_spots(self, plane_data, grain_params, ] patch_output.append(_patch_output) iRefl += 1 - pass # end patch conditional - pass # end patch loop output[detector_id] = patch_output if filename is not None and output_format.lower() == 'text': writer.close() - pass # end detector loop if filename is not None and output_format.lower() == 'hdf5': writer.close() return compl, output @@ -2450,7 +2439,6 @@ def __init__(self, image_series_dict, instrument, plane_data, [this_det_ims.omega_to_frame(ome)[0] != -1 for ome in ome_centers] ) - pass # end multi-wedge case # ???: need to pass a threshold? eta_mapping, etas = instrument.extract_polar_maps( @@ -2542,7 +2530,6 @@ def omegas(self): def save(self, filename): xrdutil.EtaOmeMaps.save_eta_ome_maps(self, filename) - pass # end of class: GenerateEtaOmeMaps def _generate_ring_params(tthr, ptth, peta, eta_edges, delta_eta): @@ -2811,7 +2798,6 @@ def _extract_ring_line_positions(iter_args, instr_cfg, panel, eta_tol, npdiv, fit_data.append(result) else: ims_data.append(p_img) - pass # close image loop if not collapse_tth: output = [ang_data, ims_data] if do_fitting: diff --git a/hexrd/material/crystallography.py b/hexrd/material/crystallography.py index 2ab5b1738..63beb532f 100644 --- a/hexrd/material/crystallography.py +++ b/hexrd/material/crystallography.py @@ -1854,7 +1854,6 @@ def getFriedelPair(tth0, eta0, *ome0, **kwargs): ) gHat_l = np.dot(rchi, tmp_gvec[:, i].reshape(3, 1)) tmp_eta[i] = np.arctan2(gHat_l[1], gHat_l[0]) - pass eta_min[goodOnes] = tmp_eta # everybody back to DEGREES! diff --git a/hexrd/material/material.py b/hexrd/material/material.py index 825af8b17..19ee27b62 100644 --- a/hexrd/material/material.py +++ b/hexrd/material/material.py @@ -233,7 +233,6 @@ def __str__(self): s = 'Material: %s\n' % self.name if self.description: s += ' description: %s\n' % self.description - pass s += ' plane Data: %s' % str(self.planeData) return s @@ -1400,12 +1399,6 @@ def _set_atomdata(self, atomtype, atominfo, U, charge): self._newUnitcell() self.invalidate_structure_factor() - # - # ========== Methods - # - # - pass # end class - # # -----------------------------------------------END CLASS: Material @@ -1506,7 +1499,6 @@ def get_hkl_strings(pdata): if len(sys.argv) == 1: print("need argument: materials.cfg") sys.exit() - pass ml = loadMaterialList(sys.argv[1]) @@ -1514,5 +1506,3 @@ def get_hkl_strings(pdata): print((' from file: ', sys.argv[1])) for m in ml: print(m) - pass - pass diff --git a/hexrd/material/spacegroup.py b/hexrd/material/spacegroup.py index 3efb7212c..9425ce6d5 100644 --- a/hexrd/material/spacegroup.py +++ b/hexrd/material/spacegroup.py @@ -132,8 +132,6 @@ def _set_sgnum(self, v): pglg = _pgDict[k] self._pointGroup = pglg[0] self._laueGroup = pglg[1] - pass - pass return @@ -1299,10 +1297,7 @@ def _buildDict(hstr): n = int(nstr) if n not in d: d[n] = hstr - pass di[hstr] = n - pass - pass return d, di @@ -1926,10 +1921,6 @@ def iroot(n): return int(floor(sqrt(n))) # integer square root l = iroot(rem) if l*l == rem: hkls += [(h, k, l), (h, k, -l)] - pass - pass - pass - pass return hkls @@ -1954,7 +1945,6 @@ def testHKLs(): for hkl in myHKLs: ss = hkl[0]**2 + hkl[1]**2 + hkl[2]**2 print((hkl, ss)) - pass # # 2. Ruby (sg 167) @@ -1968,7 +1958,6 @@ def testHKLs(): for hkl in myHKLs: ss = hkl[0]**2 + hkl[1]**2 + hkl[2]**2 print((hkl, ss)) - pass # # Test Generic HKLs # @@ -1977,7 +1966,6 @@ def testHKLs(): hkls = _getHKLsBySS(ss) print(' number of hkls: ', len(hkls)) print(hkls) - pass return @@ -2001,7 +1989,3 @@ def testHKLs(): except: print(('failed for space group number: ', n)) print(('Hall symbol: ', lookupHall[n])) - pass - pass - # - pass diff --git a/hexrd/material/symbols.py b/hexrd/material/symbols.py index 6f34afc8d..0119d4ba9 100644 --- a/hexrd/material/symbols.py +++ b/hexrd/material/symbols.py @@ -1259,10 +1259,7 @@ def _buildDict(hstr): hstr = hstr.replace(" ", "") if n not in d: d[n] = hstr - pass di[hstr] = n - pass - pass return d, di diff --git a/hexrd/projections/spherical.py b/hexrd/projections/spherical.py index 50d7031ea..e0a35fe56 100644 --- a/hexrd/projections/spherical.py +++ b/hexrd/projections/spherical.py @@ -23,7 +23,6 @@ def __init__(self, mapping='stereographic', vector_type='d', self.invert_z = False elif self._vector_type == 'q': self.invert_z = True - pass self._output_dim = output_dim self._rmat = rmat diff --git a/hexrd/rotations.py b/hexrd/rotations.py index fc3cfcff2..94fb7da88 100644 --- a/hexrd/rotations.py +++ b/hexrd/rotations.py @@ -586,7 +586,6 @@ def rotMatOfExpMap_opt(expMap): numObjs = expMap.shape[1] if numObjs == 1: # case of single point W = np.reshape(W, [1, 3, 3]) - pass C1 = np.tile( np.reshape(C1, [numObjs, 1]), @@ -600,8 +599,6 @@ def rotMatOfExpMap_opt(expMap): for i in range(3): for j in range(3): W2[:, i, j] = np.sum(W[:, i, :]*W[:, :, j], 1) - pass - pass rmat = C1*W + C2 * W2 rmat[:, 0, 0] += 1. @@ -1447,12 +1444,10 @@ def mapAngle(ang, *args, **kwargs): while lbi.sum() > 0: ang[lbi] = ang[lbi] + period lbi = ang < lb - pass ubi = ang > ub while ubi.sum() > 0: ang[ubi] = ang[ubi] - period ubi = ang > ub - pass retval = ang else: retval = mod(ang + 0.5*period, period) - 0.5*period @@ -1923,5 +1918,3 @@ def testRotMatOfExpMap(numpts): dd = np.absolute(d2 - d1) print('maximum difference between results') print(np.max(dd, 0).max()) - - pass diff --git a/hexrd/transforms/old_xfcapi.py b/hexrd/transforms/old_xfcapi.py index b3afa8432..56308ab47 100644 --- a/hexrd/transforms/old_xfcapi.py +++ b/hexrd/transforms/old_xfcapi.py @@ -480,12 +480,10 @@ def mapAngle(ang, *args, **kwargs): while lbi.sum() > 0: ang[lbi] = ang[lbi] + period lbi = ang < lb - pass ubi = ang > ub while ubi.sum() > 0: ang[ubi] = ang[ubi] - period ubi = ang > ub - pass retval = ang else: retval = np.mod(ang + 0.5*period, period) - 0.5*period diff --git a/hexrd/transforms/xf.py b/hexrd/transforms/xf.py index a8bb4c091..6200d6402 100644 --- a/hexrd/transforms/xf.py +++ b/hexrd/transforms/xf.py @@ -203,7 +203,6 @@ def gvecToDetectorXY(gVec_c, dVec_l[:, ipt] = np.dot( makeBinaryRotMat(adm_gVec_l[:, ipt]), -bHat_l ).squeeze() - pass # ############################################################### # displacement vector calculation @@ -226,7 +225,6 @@ def gvecToDetectorXY(gVec_c, # put feasible transformed gVecs into return array retval[:, canDiffract] = P2_d - pass return retval[:2, :].T @@ -480,7 +478,6 @@ def oscillAnglesOfHKLs(hkls, chi, rMat_c, bMat, wavelength, ) ) tmp_eta[i] = np.arctan2(gVec_e[1], gVec_e[0]) - pass eta0[goodOnes_s] = tmp_eta[:numGood_s] eta1[goodOnes_s] = tmp_eta[numGood_s:] @@ -492,7 +489,6 @@ def oscillAnglesOfHKLs(hkls, chi, rMat_c, bMat, wavelength, np.vstack([tTh0.flatten(), eta1.flatten(), ome1.flatten()]),) else: retval = (ome0.flatten(), ome1.flatten()) - pass return retval @@ -621,7 +617,6 @@ def polarRebin(thisFrame, log.write(msg) else: print(msg) - pass rhoI = startRho - 10*deltaRho rhoF = stopRho + 10*deltaRho @@ -633,7 +628,6 @@ def polarRebin(thisFrame, log.write(msg) else: print(msg) - pass # import pdb;pdb.set_trace() etaI1 = rowEta[i] - 10.5*deltaEta @@ -811,12 +805,10 @@ def mapAngle(ang, *args, **kwargs): while lbi.sum() > 0: ang[lbi] = ang[lbi] + period lbi = ang < lb - pass ubi = ang > ub while ubi.sum() > 0: ang[ubi] = ang[ubi] - period ubi = ang > ub - pass retval = ang else: retval = np.mod(ang + 0.5*period, period) - 0.5*period diff --git a/hexrd/valunits.py b/hexrd/valunits.py index 112310bd6..3dd0b9462 100644 --- a/hexrd/valunits.py +++ b/hexrd/valunits.py @@ -70,8 +70,6 @@ class UNames(object): keV = 'keV' J = 'J' - pass - cv_dict = { (UNames.degrees, UNames.radians): math.pi/180.0, @@ -130,7 +128,6 @@ def __init__(self, name, unitType, value, unit): # # Original checked if unit is of unitType # - pass # end init def __str__(self): tmpl = """item named "%s" representing %g %s""" @@ -336,4 +333,3 @@ def testConversions(): print((' in ', u, ': ', v.getVal(u))) return testConversions() - pass # end of tests diff --git a/hexrd/wppf/texture.py b/hexrd/wppf/texture.py index 6bf205990..33c5e9f07 100644 --- a/hexrd/wppf/texture.py +++ b/hexrd/wppf/texture.py @@ -1062,7 +1062,6 @@ def initialize_crystal_dir(self, if samplingtype.lower() == "fem": msg = "sampling type FEM not implemented yet." raise ValueError(msg) - pass @property def sample_dir(self): diff --git a/scripts/calibrate_from_powder.py b/scripts/calibrate_from_powder.py index fccf64140..6a94a47e0 100644 --- a/scripts/calibrate_from_powder.py +++ b/scripts/calibrate_from_powder.py @@ -225,9 +225,7 @@ def make_matl(mat_name, sgnum, lparms, hkl_ssq_max=50): tmp.append( np.hstack([xy_meas.squeeze(), tth_meas, tth0[i_ring], eta_ref]) ) - pass rhs[det_key].append(np.vstack(tmp)) - pass rhs[det_key] = np.array(rhs[det_key]) # %% plot fit poistions @@ -533,7 +531,6 @@ def multipanel_powder_objfunc(param_list, data_dict, instr): else: good_patch = [px, py] ax2.plot(px, py, 'm.', markersize=0.1) - pass ax2.plot(good_patch[0], good_patch[1], 'c.', markersize=0.1) aext = np.degrees( [np.min(rp[0][0]), diff --git a/scripts/calibrate_from_powder.py.bak b/scripts/calibrate_from_powder.py.bak index 6dfdc2cf2..1bc9cc24b 100644 --- a/scripts/calibrate_from_powder.py.bak +++ b/scripts/calibrate_from_powder.py.bak @@ -234,9 +234,7 @@ for det_key in det_keys: tmp.append( np.hstack([xy_meas.squeeze(), tth_meas, tth0[i_ring], eta_ref]) ) - pass rhs[det_key].append(np.vstack(tmp)) - pass rhs[det_key] = np.array(rhs[det_key]) # %% plot fit poistions @@ -528,7 +526,6 @@ while delta_r > 0.1: tmp.append( np.hstack([xy_meas.squeeze(), tth_meas, tth0[i_ring], eta_ref]) ) - pass rhs[det_key].append(np.vstack(tmp)) initial_guess = np.array(x0) @@ -633,7 +630,7 @@ for rp in rpatches: else: good_patch = [px, py] ax2.plot(px, py, 'm.', markersize=0.1) - pass + ax2.plot(good_patch[0], good_patch[1], 'c.', markersize=0.1) aext = np.degrees( [np.min(rp[0][0]), diff --git a/scripts/calibrate_from_rotation_series.py b/scripts/calibrate_from_rotation_series.py index db1dd0996..e255ce272 100644 --- a/scripts/calibrate_from_rotation_series.py +++ b/scripts/calibrate_from_rotation_series.py @@ -224,7 +224,6 @@ def calibrate_instrument_from_sx( # !!! use jj to do distortion... if panel.distortion is not None: pass - pass return fit_params, resd, sim_final @@ -274,7 +273,6 @@ def sxcal_obj_func(plist_fit, plist_full, param_flags, dparams = dparams_all[jj:jj + len_these_dps] jj += len_these_dps xy_unwarped[det_key] = dfunc(xy_unwarped[det_key], dparams) - pass meas_omes[det_key] = xyo_det[det_key][:, 2] # get these panel params for convenience @@ -316,7 +314,6 @@ def sxcal_obj_func(plist_fit, plist_full, param_flags, calc_xy[det_key] = calc_xy_tmp ii += 6 - pass # return values if sim_only: @@ -336,7 +333,6 @@ def sxcal_obj_func(plist_fit, plist_full, param_flags, calc_xy_all.append(calc_xy[det_key]) meas_omes_all.append(meas_omes[det_key]) calc_omes_all.append(calc_omes[det_key]) - pass meas_xy_all = np.vstack(meas_xy_all) calc_xy_all = np.vstack(calc_xy_all) meas_omes_all = np.hstack(meas_omes_all) @@ -404,7 +400,6 @@ def parse_reflection_tables(cfg, instr, grain_id, refit_idx=None): hkls[det_key] = gtable[idx, 2:5] meas_omes = gtable[idx, 12].reshape(sum(idx), 1) xyo_det[det_key] = np.hstack([gtable[idx, -2:], meas_omes]) - pass return hkls, xyo_det, idx_0 @@ -435,7 +430,6 @@ def parse_reflection_tables(cfg, instr, grain_id, refit_idx=None): max_pix_size = max(max_pix_size, max(panel.pixel_size_col, panel.pixel_size_col) ) - pass # grab omega period # !!! data should be consistent @@ -546,7 +540,6 @@ def parse_reflection_tables(cfg, instr, grain_id, refit_idx=None): # for det_key, panel in instr.detectors.iteritems(): # hkls_refit = hkls[det_key][idx_new[det_key], :] # xyo_det_refit = xyo_det[det_key][idx_0[det_key], :] -# pass # update calibration crystal params grain_parameters[:3] = params[5:8] diff --git a/scripts/calibration_mockup.py b/scripts/calibration_mockup.py index 38c4a2c81..a5065c3ed 100644 --- a/scripts/calibration_mockup.py +++ b/scripts/calibration_mockup.py @@ -280,11 +280,8 @@ def _extract_powder_lines(self): eta_ref] ) ) - pass rhs[det_key].append(np.vstack(tmp)) - pass rhs[det_key] = np.vstack(rhs[det_key]) - pass return rhs def residual(self, reduced_params, data_dict): @@ -428,7 +425,6 @@ def residual(self, reduced_params, data_dict): cf[ii + 2] = False cf[ii + 6:ii + 9] = True ii += 12 - pass instr.calibration_flags = cf # powder calibrator diff --git a/scripts/powder_calibration.py b/scripts/powder_calibration.py index d0ece0e34..5fac2db3f 100644 --- a/scripts/powder_calibration.py +++ b/scripts/powder_calibration.py @@ -219,11 +219,8 @@ def _extract_powder_lines(self): eta_ref] ) ) - pass rhs[det_key].append(np.vstack(tmp)) - pass rhs[det_key] = np.vstack(rhs[det_key]) - pass return rhs def residual(self, reduced_params, data_dict): diff --git a/scripts/tiffs_from_h5.py b/scripts/tiffs_from_h5.py index 95a47d457..b1c326851 100644 --- a/scripts/tiffs_from_h5.py +++ b/scripts/tiffs_from_h5.py @@ -62,4 +62,3 @@ os.path.join(image_dir, tiff_fname), ims[i] ) - pass From 586fa7d624f972876ee6df8ff32fb06333e6cd44 Mon Sep 17 00:00:00 2001 From: Kevin Lewis Date: Fri, 5 Jul 2024 11:00:19 -0400 Subject: [PATCH 2/3] raising NotImplementedError on abstract methods --- hexrd/distortion/distortionabc.py | 2 ++ hexrd/fitting/calibration/calibrator.py | 6 ++++++ hexrd/instrument/detector.py | 22 +++++++++++++--------- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/hexrd/distortion/distortionabc.py b/hexrd/distortion/distortionabc.py index c1ae2a473..f2eb2882a 100644 --- a/hexrd/distortion/distortionabc.py +++ b/hexrd/distortion/distortionabc.py @@ -8,7 +8,9 @@ class DistortionABC(metaclass=abc.ABCMeta): @abc.abstractmethod def apply(self, xy_in): """Apply distortion mapping""" + raise NotImplementedError @abc.abstractmethod def apply_inverse(self, xy_in): """Apply inverse distortion mapping""" + raise NotImplementedError diff --git a/hexrd/fitting/calibration/calibrator.py b/hexrd/fitting/calibration/calibrator.py index 730395491..de9634b67 100644 --- a/hexrd/fitting/calibration/calibrator.py +++ b/hexrd/fitting/calibration/calibrator.py @@ -8,6 +8,7 @@ class Calibrator(ABC): @abstractmethod def type(self): """The type of the calibrator""" + raise NotImplementedError @abstractmethod def create_lmfit_params(self, current_params): @@ -24,6 +25,7 @@ def create_lmfit_params(self, current_params): for the lattice parameters. The Laue calibrator creates lmfit parameters for crystal parameters. """ + raise NotImplementedError @abstractmethod def update_from_lmfit_params(self, params_dict): @@ -36,6 +38,7 @@ def update_from_lmfit_params(self, params_dict): For example, the powder calibrator will update the lattice parameters on the material. The Laue calibrator will update crystal parameters. """ + raise NotImplementedError @abstractmethod def residual(self, calibration_data=None): @@ -45,6 +48,7 @@ def residual(self, calibration_data=None): the calibration class instead, in which case, calibration_data can be `None`. """ + raise NotImplementedError @property @abstractmethod @@ -69,8 +73,10 @@ def calibration_picks(self): string of the hkl. And "picks" are either a list of points (powder) or a single point (laue). The picks are in cartesian coordinates. """ + raise NotImplementedError @calibration_picks.setter @abstractmethod def calibration_picks(self, val): """Setter for calibration_picks. See getter docs for details.""" + raise NotImplementedError diff --git a/hexrd/instrument/detector.py b/hexrd/instrument/detector.py index 82784105d..6b8851f17 100644 --- a/hexrd/instrument/detector.py +++ b/hexrd/instrument/detector.py @@ -57,7 +57,7 @@ class Detector: @property @abstractmethod def detector_type(self): - pass + raise NotImplementedError @abstractmethod def cart_to_angles(self, xy_data, rmat_s=None, tvec_s=None, @@ -91,6 +91,7 @@ def cart_to_angles(self, xy_data, rmat_s=None, tvec_s=None, DESCRIPTION. """ + raise NotImplementedError @abstractmethod def angles_to_cart(self, tth_eta, @@ -125,22 +126,24 @@ def angles_to_cart(self, tth_eta, The (n, 2) array on the n input coordinates in the . """ + raise NotImplementedError @abstractmethod def cart_to_dvecs(self, xy_data): """Convert cartesian coordinates to dvectors""" + raise NotImplementedError @abstractmethod def pixel_angles(self, origin=ct.zeros_3): - pass + raise NotImplementedError @abstractmethod def pixel_tth_gradient(self, origin=ct.zeros_3): - pass + raise NotImplementedError @abstractmethod def pixel_eta_gradient(self, origin=ct.zeros_3): - pass + raise NotImplementedError @property @abstractmethod @@ -149,6 +152,7 @@ def beam_position(self): returns the coordinates of the beam in the cartesian detector frame {Xd, Yd, Zd}. NaNs if no intersection. """ + raise NotImplementedError @property @@ -727,11 +731,11 @@ def config_dict(self, chi=0, tvec=ct.zeros_3, elif panel_buffer is None: # still None on self # !!! this gets handled by unwrap_dict_to_h5 now - ''' - if style.lower() == 'hdf5': - # !!! can't write None to hdf5; substitute with zeros - panel_buffer = np.r_[0., 0.] - ''' + + # if style.lower() == 'hdf5': + # # !!! can't write None to hdf5; substitute with zeros + # panel_buffer = np.r_[0., 0.] + pass det_dict['buffer'] = panel_buffer det_dict.update(self.extra_config_kwargs) From a0db9dabf6e013a7bfea47e6fee895ad2bb04cd6 Mon Sep 17 00:00:00 2001 From: Kevin Lewis Date: Fri, 5 Jul 2024 13:03:33 -0400 Subject: [PATCH 3/3] Remove empty returns --- hexrd/material/spacegroup.py | 4 ---- scripts/calibrate_from_rotation_series.py | 4 +--- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/hexrd/material/spacegroup.py b/hexrd/material/spacegroup.py index 9425ce6d5..1d296d3d5 100644 --- a/hexrd/material/spacegroup.py +++ b/hexrd/material/spacegroup.py @@ -133,8 +133,6 @@ def _set_sgnum(self, v): self._pointGroup = pglg[0] self._laueGroup = pglg[1] - return - sgnum = property(_get_sgnum, _set_sgnum, None, "Space group number") @@ -1967,8 +1965,6 @@ def testHKLs(): print(' number of hkls: ', len(hkls)) print(hkls) - return - if __name__ == '__main__': # diff --git a/scripts/calibrate_from_rotation_series.py b/scripts/calibrate_from_rotation_series.py index e255ce272..174233d9a 100644 --- a/scripts/calibrate_from_rotation_series.py +++ b/scripts/calibrate_from_rotation_series.py @@ -221,9 +221,7 @@ def calibrate_instrument_from_sx( panel.tilt = fit_params[ii:ii + 3] panel.tvec = fit_params[ii + 3:ii + 6] ii += 6 - # !!! use jj to do distortion... - if panel.distortion is not None: - pass + # !!! use jj to do distortion? return fit_params, resd, sim_final