From 384fe89d25e85696abb2bea105ea30a7e56570a3 Mon Sep 17 00:00:00 2001 From: mkuehbach Date: Mon, 26 Feb 2024 09:32:03 +0100 Subject: [PATCH] Linting --- ifes_apt_tc_data_modeling/rng/rng_reader.py | 6 +++--- ifes_apt_tc_data_modeling/rrng/rrng_reader.py | 10 +++++----- ifes_apt_tc_data_modeling/utils/utils.py | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ifes_apt_tc_data_modeling/rng/rng_reader.py b/ifes_apt_tc_data_modeling/rng/rng_reader.py index f834724..3befe30 100644 --- a/ifes_apt_tc_data_modeling/rng/rng_reader.py +++ b/ifes_apt_tc_data_modeling/rng/rng_reader.py @@ -52,19 +52,19 @@ def evaluate_rng_range_line( raise ValueError(f"Line {line} has inconsistent line prefix!") if is_range_significant(np.float64(tmp[1]), np.float64(tmp[2])) is False: # raise ValueError(f"Line {line} insignificant range!") - return None + return info info["range"] = np.asarray([tmp[1], tmp[2]], np.float64) # line encodes multiplicity of element via array of multiplicity counts element_multiplicity = np.asarray(tmp[3:len(tmp)], np.uint32) if np.sum(element_multiplicity) < 0: # raise ValueError(f"Line {line} no element counts!") - return None + return info if np.sum(element_multiplicity) > 0: for jdx in np.arange(0, len(element_multiplicity)): if element_multiplicity[jdx] < 0: # raise ValueError(f"Line {line} no negative element counts!") - return None + raise ValueError(f"element_multiplicity[jdx] {element_multiplicity[jdx]} needs to be positive!") if element_multiplicity[jdx] > 0: symbol = column_id_to_label[jdx + 1] if symbol in get_chemical_symbols(): diff --git a/ifes_apt_tc_data_modeling/rrng/rrng_reader.py b/ifes_apt_tc_data_modeling/rrng/rrng_reader.py index 3973327..2d011a8 100644 --- a/ifes_apt_tc_data_modeling/rrng/rrng_reader.py +++ b/ifes_apt_tc_data_modeling/rrng/rrng_reader.py @@ -47,13 +47,13 @@ def evaluate_rrng_range_line(i: int, line: str) -> dict: tmp = re.split(r"[\s=]+", line) if len(tmp) < 6: # raise ValueError(f"Line {line} does not contain all required fields {len(tmp)}!") - return None + return info if tmp[0] != f"Range{i}": # raise ValueError(f"Line {line} has inconsistent line prefix {tmp[0]}!") - return None + return info if is_range_significant(np.float64(tmp[1]), np.float64(tmp[2])) is False: # raise ValueError(f"Line {line} insignificant range!") - return None + return info info["range"] = np.asarray([tmp[1], tmp[2]], np.float64) if tmp[3].lower().startswith("vol:"): @@ -83,13 +83,13 @@ def evaluate_rrng_range_line(i: int, line: str) -> dict: symbol = element_multiplicity[0] if (symbol not in chemical_symbols) or (symbol == "X"): # raise ValueError(f"WARNING::Line {line} contains an invalid chemical symbol {symbol}!") - return None + return info # if np.uint32(element_multiplicity[1]) <= 0: # raise ValueError(f"Line {line} zero or negative multiplicity !") if np.uint32(element_multiplicity[1]) >= 256: # raise ValueError(f"Line {line} unsupported high multiplicity " # f"{np.uint32(element_multiplicity)}!") - return None + return info info["atoms"] = np.append(info["atoms"], [symbol] * int(element_multiplicity[1])) return info diff --git a/ifes_apt_tc_data_modeling/utils/utils.py b/ifes_apt_tc_data_modeling/utils/utils.py index 9963949..b9a0ea7 100644 --- a/ifes_apt_tc_data_modeling/utils/utils.py +++ b/ifes_apt_tc_data_modeling/utils/utils.py @@ -225,9 +225,9 @@ def symbol_lst_to_matrix_of_nuclide_vector(method: str = "resolve_all", if not isinstance(symbol_lst, list) and all(isinstance(lst, list) for lst in symbol_lst): raise TypeError("Argument symbol_lst must be a list of lists!") if not all(len(np.shape(lst)) == 1 for lst in symbol_lst): - "One list in argument symbol_lst is not a 1d list or an empty list!" + raise ValueError("One list in argument symbol_lst is not a 1d list or an empty list!") if not all(np.shape(lst)[0] >= 1 for lst in symbol_lst): - "One list in argument symbol_lst is not a 1d list or an empty list!" + raise ValueError("One list in argument symbol_lst is not a 1d list or an empty list!") matrix = np.zeros([len(symbol_lst), MAX_NUMBER_OF_ATOMS_PER_ION]) charge = [] if (method == "resolve_ion") and ("charge_lst" in kwargs):