diff --git a/jade/gui.py b/jade/gui.py index 9a2183ed..18bdb7b0 100644 --- a/jade/gui.py +++ b/jade/gui.py @@ -141,7 +141,7 @@ def mainloop(session: Session): sys.exit() inputfile = input(" MCNP input file: ") - if newlib in session.lib_manager.libraries['mcnp']: + if newlib in session.lib_manager.libraries["mcnp"]: ans = uty.translate_input(session, newlib, inputfile) if ans: print(" Translation successfully completed!\n") @@ -582,7 +582,7 @@ def pploop(session: Session): if ans: lib = to_single_pp[0] # Check active tests - to_perform = session.check_active_tests('Post-Processing') + to_perform = session.check_active_tests("Post-Processing") # For the moment no pp is foreseen for experimental benchmarks # to_perf_exp = session.check_active_tests('Post-Processing', # exp=True) @@ -707,10 +707,11 @@ def pploop(session: Session): # Execute Comparison lib_input = EXP_TAG + "-" + lib_input # Insert the exp tag - print(to_perform) for code, testname in to_perform.items(): try: - pp.compareBenchmark(session, lib_input, code, testname, exp=True) + pp.compareBenchmark( + session, lib_input, code, testname, exp=True + ) except PermissionError as e: clear_screen() print(pp_menu) diff --git a/jade/sphereoutput.py b/jade/sphereoutput.py index 95b0a208..ff4db7a2 100644 --- a/jade/sphereoutput.py +++ b/jade/sphereoutput.py @@ -23,7 +23,6 @@ """ from __future__ import annotations -# import pythoncom import math import os import shutil @@ -35,8 +34,6 @@ import pandas as pd import openpyxl -# import openpyxl -# from openpyxl.utils.dataframe import dataframe_to_rows from tqdm import tqdm from xlsxwriter.utility import xl_rowcol_to_cell @@ -54,7 +51,7 @@ class SphereOutput(BenchmarkOutput): def __init__(self, lib: str, code: str, testname: str, session: Session): """ Initialises the SphereOutput class from the general BenchmarkOutput - class, see output.py for details on how self variables are assigned + class, see output.py for details on how self variables are assigned Parameters ---------- @@ -62,7 +59,7 @@ def __init__(self, lib: str, code: str, testname: str, session: Session): library to post-process code : str code being post processed - testname : str + testname : str name of the benchmark being postprocessed session : Session Jade Session @@ -233,7 +230,7 @@ def _generate_plots(self, allzaids, globalname): outputs : dic dictionary containing the outputs for each library, for each code format: { - code1:{library1:[outputs], library2:[outputs], ...}, + code1:{library1:[outputs], library2:[outputs], ...}, code2:{library1:[outputs], library2:[outputs], ...}, ... } @@ -312,22 +309,22 @@ def _generate_plots(self, allzaids, globalname): plot.plot("Binned graph") except IndexError: print(data) - + self._build_atlas(outpath) def _get_organized_output(self): """ - Organizes the outputs for each library in each code in the + Organizes the outputs for each library in each code in the outputs object Returns: libraries: list list of all libraries to be post processed allzaids: list - list of all zaids/materials that have been run - outputs: list + list of all zaids/materials that have been run + outputs: list list of all output objects for all codes and all libraries - + """ libraries = [] outputs = [] @@ -354,9 +351,9 @@ def _read_mcnp_output(self): Dictionary of MCNP sphere output objects used in plotting, keys are material name or ZAID number results : dic Dictionary of overview of Tally values for each material/ZAID, returns either all values > 0 for - tallies with postiive values only, all Values = 0 for empty tallies, and returns the corresponding + tallies with postiive values only, all Values = 0 for empty tallies, and returns the corresponding tally bin if it finds any negative values. Contents of the "Values" worksheet. - errors : dic + errors : dic Dictionary of average errors for each tally for each material/Zaid. Contents of the "Errors" worksheet. stat_checks : dic Dictionary the MCNP statistical check results for each material/ZAID. Contents of the "Statistical @@ -407,8 +404,8 @@ def _read_mcnp_output(self): return outputs, results, errors, stat_checks def _read_serpent_output(self): - """Reads all Serpent outputs from a library - + """Reads all Serpent outputs from a library + NOT YET IMPLEMENTED Returns @@ -417,9 +414,9 @@ def _read_serpent_output(self): Dictionary of Serpent sphere output objects used in plotting, keys are material name or ZAID number results : dic Dictionary of overview of Tally values for each material/ZAID, returns either all values > 0 for - tallies with postiive values only, all Values = 0 for empty tallies, and returns the corresponding + tallies with postiive values only, all Values = 0 for empty tallies, and returns the corresponding tally bin if it finds any negative values. Contents of the "Values" worksheet. - errors : dic + errors : dic Dictionary of average errors for each tally for each material/Zaid. Contents of the "Errors" worksheet. """ # Get results @@ -442,9 +439,9 @@ def _read_openmc_output(self): Dictionary of OpenMC sphere output objects used for plotting, keys are material name or ZAID number results : dic Dictionary of overview of Tally values for each material/ZAID, returns either all values > 0 for - tallies with postiive values only, all Values = 0 for empty tallies, and returns the corresponding + tallies with postiive values only, all Values = 0 for empty tallies, and returns the corresponding tally bin if it finds any negative values. Contents of the "Values" worksheet. - errors : dic + errors : dic Dictionary of average errors for each tally for each material/Zaid. Contents of the "Errors" worksheet. """ # Get results @@ -501,7 +498,7 @@ def _generate_dataframe(self, results, errors, stat_checks=None): results (DataFrame): previous dictionary but in DataFrame form errors (DataFrame): previous dictionary but in DataFrame form stat_checks (DataFrame): previous dictionary but in DataFrame form - """ + """ # Generate DataFrames results = pd.DataFrame(results) errors = pd.DataFrame(errors) @@ -598,93 +595,17 @@ def pp_excel_single(self): if self.d1s: pass - # template = os.path.join(os.getcwd(), 'templates', 'Sphere_single.xlsx') - # outpath = os.path.join(self.excel_path, 'Sphere_single_' + - # self.lib+'.xlsx') - # """ - # # Get results - # results = [] - # errors = [] - # stat_checks = [] - # outputs = {} - # for folder in os.listdir(self.test_path): - # results_path = os.path.join(self.test_path, folder) - # pieces = folder.split('_') - # # Get zaid - # zaidnum = pieces[-2] - # # Check for material exception - # if zaidnum == 'Sphere': - # zaidnum = pieces[-1].upper() - # zaidname = self.mat_settings.loc[zaidnum, 'Name'] - # else: - # zaidname = pieces[-1] - # # Get mfile - # for file in os.listdir(results_path): - # if file[-1] == 'm': - # mfile = file - # elif file[-1] == 'o': - # ofile = file - # # Parse output - # output = SphereMCNPoutput(os.path.join(results_path, mfile), - # os.path.join(results_path, ofile)) - # outputs[zaidnum] = output - # # Adjourn raw Data - # self.raw_data[zaidnum] = output.tallydata - # # Recover statistical checks - # st_ck = output.stat_checks - # # Recover results and precisions - # res, err = output.get_single_excel_data() - # for dic in [res, err, st_ck]: - # dic['Zaid'] = zaidnum - # dic['Zaid Name'] = zaidname - # results.append(res) - # errors.append(err) - # stat_checks.append(st_ck) - - # # Generate DataFrames - # results = pd.DataFrame(results) - # errors = pd.DataFrame(errors) - # stat_checks = pd.DataFrame(stat_checks) - - # # Swap Columns and correct zaid sorting - # # results - # for df in [results, errors, stat_checks]: - # df['index'] = pd.to_numeric(df['Zaid'].values, errors='coerce') - # df.sort_values('index', inplace=True) - # del df['index'] - - # df.set_index(['Zaid', 'Zaid Name'], inplace=True) - # df.reset_index(inplace=True) - - # self.outputs = outputs - # self.results = results - # self.errors = errors - # self.stat_checks = stat_checks - # """ - # """ Excel writer removed by S. Bradnam """ - ## Write excel - # ex = SphereExcelOutputSheet(template, outpath) - ## Results - # ex.insert_df(9, 2, results, 0) - # ex.insert_df(9, 2, errors, 1) - # ex.insert_df(9, 2, stat_checks, 2) - # lib_name = self.session.conf.get_lib_name(self.lib) - # ex.wb.sheets[0].range('D1').value = lib_name - # ex.save() - def pp_excel_comparison(self): """ - Compute the data and create the excel for all libraries comparisons. - In the meantime, additional data is stored for future plots. + Compute the data and create the excel for all libraries comparisons. + In the meantime, additional data is stored for future plots. - Returns - ------- - None. + Returns + ------- + None. """ - # template = os.path.join(os.getcwd(), 'templates', - # 'Sphere_comparison.xlsx') code_outputs = {} @@ -1060,7 +981,7 @@ def pp_excel_comparison(self): def print_raw(self): """ Assigns a path and prints the post processing data as a .csv - + """ if self.mcnp: for key, data in self.raw_data["mcnp"].items(): @@ -1101,14 +1022,14 @@ def get_single_excel_data(self, tallies2pp): notes = "Negative Bins:" # Record negative bins here initial_notes_length = len(notes) # To check if notes are registered tally_list = [d for _, d in data.groupby(["Tally N."])] - heating_tallies = ['4', '6', '44', '46'] + heating_tallies = ["4", "6", "44", "46"] for tally in tally_list: tally_num = str(tally["Tally N."].iloc[0]) tally_description = tally["Tally Description"].iloc[0] mean_error = tally["Error"].mean() if tally_num in heating_tallies: - heating_res[tally_num] = tally['Value'].values[0] - if tally_num in tallies2pp: + heating_res[tally_num] = tally["Value"].values[0] + if tally_num in tallies2pp: tally_zero = tally[tally["Value"] == 0] original_length = len(tally) tally = tally[tally["Value"] < 0] @@ -1125,57 +1046,23 @@ def get_single_excel_data(self, tallies2pp): else: res = "Value > 0 for all bins" results[tally_description] = res - errors[tally_description] = mean_error - # for tally in self.mctal.tallies: - # num = str(tally.tallyNumber) - # keys[num] = tally.tallyComment[0] - # # Isolate tally - # masked = data.loc[tally.tallyComment[0]] - # print(masked) - # # Get mean error among bins, different for single bin - # if tally.ergTC == 't': - # mean_error = totbins.loc[tally.tallyComment[0]]['Error'] - # else: - # mean_error = masked['Error'].mean() - # - # if num in tallies2pp: - # masked_zero = masked[masked['Value'] == 0] - # original_length = len(masked) - # masked = masked[masked['Value'] < 0] - # if len(masked) > 0: - # res = 'Value < 0 in '+str(len(masked))+' bin(s)' - # # Get energy bins - # bins = list(masked.reset_index()['Energy'].values) - # notes = notes+'\n('+str(num)+'): ' - # for ebin in bins: - # notes = notes+str(ebin)+', ' - # notes = notes[:-2] # Clear string from excess commas - # - # elif len(masked_zero) == original_length: - # res = 'Value = 0 for all bins' - # else: - # res = 'Value > 0 for all bins' - # - # results[tally.tallyComment[0]] = res - # errors[tally.tallyComment[0]] = mean_error - - # if tally in heating_tallies: - # heating_res[tally_num] = tally['Value'].values[0] - # errors[tally_num] = mean_error + errors[tally_description] = mean_error if len(heating_res) == 4: - comp = 'Heating comparison [F4 vs F6]' + comp = "Heating comparison [F4 vs F6]" try: - results['Neutron '+comp] = ((heating_res['6'] - heating_res['4']) / - heating_res['6']) + results["Neutron " + comp] = ( + heating_res["6"] - heating_res["4"] + ) / heating_res["6"] except ZeroDivisionError: - results['Neutron '+comp] = 0 + results["Neutron " + comp] = 0 try: - results['Gamma '+comp] = ((heating_res['46'] - heating_res['44']) / - heating_res['46']) + results["Gamma " + comp] = ( + heating_res["46"] - heating_res["44"] + ) / heating_res["46"] except ZeroDivisionError: - results['Gamma '+comp] = 0 + results["Gamma " + comp] = 0 # Notes adding if len(notes) > initial_notes_length: @@ -1203,14 +1090,14 @@ def get_comparison_data(self, tallies2pp, code): if code == "openmc": binned_tallies = ["4", "14"] integral_tallies = [] - + # Acquire data data = self.tallydata.set_index(["Energy"]) totalbins = self.totalbin.set_index("Tally Description") results = [] # Store data to compare for different tallies errors = [] columns = [] # Tally names and numbers - + # Reorder tallies tallies = {} tally_list = [d for _, d in data.groupby(["Tally N."])] @@ -1237,16 +1124,17 @@ def get_comparison_data(self, tallies2pp, code): columns.append(colname) results.append(totalbins["Value"].loc[tally_description]) errors.append(totalbins["Error"].loc[tally_description]) - + # Proccess integral tallies for tally_num in integral_tallies: tally = tallies[tally_num] - tally_description = tally["Tally Description"].iloc[0] + tally_description = tally["Tally Description"].iloc[0] columns.append(tally_description) results.append(float(tally["Value"])) errors.append(float(tally["Error"])) return results, errors, columns + class SphereMCNPoutput(MCNPoutput, SphereTallyOutput): def organize_mctal(self): """ @@ -1347,19 +1235,20 @@ def organize_mctal(self): ) return df, dftotal + class SphereOpenMCoutput(OpenMCOutput, SphereTallyOutput): def _create_dataframe(self, rows): - """Creates dataframe from the data in each output passed through as + """Creates dataframe from the data in each output passed through as a list of lists from the process_tally function Args: - rows: list + rows: list list of list containing the rows of information from an output file Returns: df: DataFrame dataframe containing the information from each output - + dftotal: DataFrame dataframe containing the sum of all values and errors for each output """ @@ -1391,7 +1280,7 @@ def process_tally(self): Returns: tallydata: Dataframe see df in _create_dataframe() - + totalbin: Dataframe see dftotal in _create_dataframe() """ @@ -1773,12 +1662,12 @@ def _extract_data4plots(self, zaid, mt, lib, time): Args: zaid (str): zaid of output - mt (str): mt + mt (str): mt lib (str): library being postprocessed time (float): timestep Returns: - nflux (float): neutron flux + nflux (float): neutron flux pflux (float): proton flux sddr (float): shut down dose rate """ @@ -1791,7 +1680,7 @@ def _extract_data4plots(self, zaid, mt, lib, time): sddr = tallies[104].set_index("Time") sddr = sddr.loc["D" + self.timecols[time], "Value"] # Memorize values - print (type(nflux), type(pflux), type(sddr)) + print(type(nflux), type(pflux), type(sddr)) return nflux, pflux, sddr def _compute_single_results( @@ -2023,7 +1912,7 @@ def _parserunmcnp(self, test_path, lib): def print_raw(self): """ Assigns a path and prints the post processing data as a .csv - + """ for key, data in self.raw_data.items(): # build a folder containing each tally of the reaction diff --git a/tests/libmanager_test.py b/tests/libmanager_test.py index fd5665d0..803cb7f8 100644 --- a/tests/libmanager_test.py +++ b/tests/libmanager_test.py @@ -189,10 +189,11 @@ def test_get_zaidname(self, lm): assert name == "hydrogen" assert formula == "H-1" + # Behaviour has been modified zaid = "1000" name, formula = lm.get_zaidname(zaid) assert name == "hydrogen" - assert formula == "H-0" + assert formula == "H" def test_get_zaidnum(self, lm): zaid = "92235" diff --git a/tests/matreader_test.py b/tests/matreader_test.py index 998b459d..dcdafc22 100644 --- a/tests/matreader_test.py +++ b/tests/matreader_test.py @@ -21,7 +21,7 @@ You should have received a copy of the GNU General Public License along with JADE. If not, see . """ - +from __future__ import annotations import sys import os @@ -33,44 +33,48 @@ root = os.path.dirname(cp) sys.path.insert(1, root) -from jade.matreader import (Element, Zaid, MatCardsList) +from jade.matreader import Element, Zaid, MatCardsList, Material from jade.libmanager import LibManager import pytest import pandas as pd # Files -INP = os.path.join(cp, 'TestFiles', 'matreader', 'mat_test.i') -INP2 = os.path.join(cp, 'TestFiles', 'matreader', 'mat_test2.i') -ACTIVATION_INP = os.path.join(cp, 'TestFiles', 'matreader', 'activation.i') -XSDIR = os.path.join(cp, 'TestFiles', 'matreader', 'xsdir_mcnp6.2') +INP = os.path.join(cp, "TestFiles", "matreader", "mat_test.i") +INP2 = os.path.join(cp, "TestFiles", "matreader", "mat_test2.i") +ACTIVATION_INP = os.path.join(cp, "TestFiles", "matreader", "activation.i") +XSDIR = os.path.join(cp, "TestFiles", "matreader", "xsdir_mcnp6.2") # Other -ISOTOPES_FILE = os.path.join(root, 'jade', 'resources', 'Isotopes.txt') -ACTIVATION_FILE = os.path.join(cp, 'TestFiles', 'libmanager', - 'Activation libs.xlsx') +ISOTOPES_FILE = os.path.join(root, "jade", "resources", "Isotopes.txt") +ACTIVATION_FILE = os.path.join(cp, "TestFiles", "libmanager", "Activation libs.xlsx") # XSDIR_FILE = os.path.join(cp, 'TestFiles', 'libmanager', 'xsdir') + @pytest.fixture def LIBMAN(): df_rows = [ - ['99c', 'sda', '', XSDIR], - ['98c', 'acsdc', '', XSDIR], - ['21c', 'adsadsa', '', XSDIR], - ['31c', 'adsadas', '', XSDIR], - ['00c', 'sdas', '', XSDIR], - ['71c', 'sdasxcx', '', XSDIR], - ['81c', 'sdasxcx', 'yes', XSDIR]] + ["99c", "sda", "", XSDIR], + ["98c", "acsdc", "", XSDIR], + ["21c", "adsadsa", "", XSDIR], + ["31c", "adsadas", "", XSDIR], + ["00c", "sdas", "", XSDIR], + ["71c", "sdasxcx", "", XSDIR], + ["81c", "sdasxcx", "yes", XSDIR], + ] df_lib = pd.DataFrame(df_rows) - df_lib.columns = ['Suffix', 'Name', 'Default', 'MCNP'] + df_lib.columns = ["Suffix", "Name", "Default", "MCNP"] - return LibManager(df_lib, activationfile=ACTIVATION_FILE, - isotopes_file=ISOTOPES_FILE) + return LibManager( + df_lib, activationfile=ACTIVATION_FILE, isotopes_file=ISOTOPES_FILE + ) class TestZaid: - tests = [{'str': '1001.31c -2.3', 'res': [-2.3, '1', '001', '31c']}, - {'str': '1001.31c\t-2.3', 'res': [-2.3, '1', '001', '31c']}, - {'str': '15205 1', 'res': [1, '15', '205', None]}] + tests = [ + {"str": "1001.31c -2.3", "res": [-2.3, "1", "001", "31c"]}, + {"str": "1001.31c\t-2.3", "res": [-2.3, "1", "001", "31c"]}, + {"str": "15205 1", "res": [1, "15", "205", None]}, + ] def test_fromstring(self): """ @@ -83,9 +87,9 @@ def test_fromstring(self): """ for test in self.tests: - text = test['str'] + text = test["str"] zaid = Zaid.from_string(text) - res = test['res'] + res = test["res"] assert zaid.fraction == res[0] assert zaid.element == res[1] assert zaid.isotope == res[2] @@ -93,7 +97,7 @@ def test_fromstring(self): class TestElement: - zaid_strings = ['1001.31c -1', '1002.31c -3'] + zaid_strings = ["1001.31c -1", "1002.31c -3"] def _buildElem(self): zaids = [] @@ -111,15 +115,14 @@ def test_update_zaidinfo(self, LIBMAN): elem = self._buildElem() # Check for the correct element - elem.Z = '1' + elem.Z = "1" # Check the correct update of infos in element elem.update_zaidinfo(LIBMAN) - res = [{'fullname': 'H-1', 'ab': 25}, - {'fullname': 'H-2', 'ab': 75}] + res = [{"fullname": "H-1", "ab": 25}, {"fullname": "H-2", "ab": 75}] for zaid, checks in zip(elem.zaids, res): - assert int(zaid.ab) == checks['ab'] - assert zaid.fullname == checks['fullname'] + assert int(zaid.ab) == checks["ab"] + assert zaid.fullname == checks["fullname"] def test_get_fraction(self): """ @@ -131,6 +134,12 @@ def test_get_fraction(self): class Testmaterial: + + def test_natural_expansion(self, LIBMAN: LibManager): + material = Material.from_text(["C Header", "M1 1000.31c -2.3"]) + material.translate("31c", LIBMAN) + assert len(material.submaterials[0].zaidList) == 2 + def test_switch_fraction(self, LIBMAN): # Read a material matcard = MatCardsList.from_input(INP) @@ -141,41 +150,41 @@ def test_switch_fraction(self, LIBMAN): # -- Switch back and forth -- # this first one should do nothing - material.switch_fraction('atom', LIBMAN) + material.switch_fraction("atom", LIBMAN) unchanged = material.to_text() assert original == unchanged # switch to mass - material.switch_fraction('mass', LIBMAN) + material.switch_fraction("mass", LIBMAN) mass = material.to_text() # change again, should do nothing - material.switch_fraction('mass', LIBMAN) + material.switch_fraction("mass", LIBMAN) unchanged = material.to_text() assert unchanged == mass # go back to atom - material.switch_fraction('atom', LIBMAN) + material.switch_fraction("atom", LIBMAN) atom = material.to_text() # at last check that the inplace oprion works - material.switch_fraction('mass', LIBMAN, inplace=False) + material.switch_fraction("mass", LIBMAN, inplace=False) inplace = material.to_text() assert inplace == atom # go back to mass - material.switch_fraction('mass', LIBMAN) + material.switch_fraction("mass", LIBMAN) massnorm = material.to_text() assert massnorm == mass def test_switch_pnnl(self, LIBMAN): # --- Test the PNNL with Bismuth Germanate (BGO) --- # read the material cards - inp = os.path.join(cp, 'TestFiles', 'matreader', 'BGO_mass.i') + inp = os.path.join(cp, "TestFiles", "matreader", "BGO_mass.i") matcard = MatCardsList.from_input(inp) mass_material = matcard[0] - inp = os.path.join(cp, 'TestFiles', 'matreader', 'BGO_atom.i') + inp = os.path.join(cp, "TestFiles", "matreader", "BGO_atom.i") matcard = MatCardsList.from_input(inp) atom_material = matcard[0] # Switch the mass fraction to atomic fraction - mass_material.switch_fraction('atom', LIBMAN) + mass_material.switch_fraction("atom", LIBMAN) print(mass_material.to_text()) tolerance = 1e-5 # tolerance for the difference with respect to pnnl @@ -214,7 +223,7 @@ def test_headers(self): """ matcard = MatCardsList.from_input(INP) - headers = {'m1': 'C Header M1\n', 'm2': 'C Header M2\n', 'm102': ''} + headers = {"m1": "C Header M1\n", "m2": "C Header M2\n", "m102": ""} for key, header in headers.items(): assert matcard[key].header == header @@ -229,9 +238,11 @@ def test_subheaders(self): """ matcard = MatCardsList.from_input(INP) - headers = {'m1': ['C M1-submat1', 'C M1-Submat 2'], - 'm2': ['', 'C M2-submat1\nC second line'], - 'm102': ['']} + headers = { + "m1": ["C M1-submat1", "C M1-Submat 2"], + "m2": ["", "C M2-submat1\nC second line"], + "m102": [""], + } for key, subheaders in headers.items(): for i, submat in enumerate(matcard[key].submaterials): @@ -248,9 +259,7 @@ def test_zaidnumbers(self): """ matcard = MatCardsList.from_input(INP) - zaids = {'m1': [2, 1], - 'm2': [1, 1], - 'm102': [5]} + zaids = {"m1": [2, 1], "m2": [1, 1], "m102": [5]} for key, zaids in zaids.items(): for i, submat in enumerate(matcard[key].submaterials): @@ -261,26 +270,25 @@ def test_translation(self, LIBMAN): Test that translation works (all possile modes) """ # Dic mode 1 - newlib = {'21c': '31c', '99c': '81c'} + newlib = {"21c": "31c", "99c": "81c"} matcard = MatCardsList.from_input(ACTIVATION_INP) matcard.translate(newlib, LIBMAN) translation = matcard.to_text() - assert translation.count('31c') == 3 - assert translation.count('81c') == 3 + assert translation.count("31c") == 3 + assert translation.count("81c") == 3 # dic mode 2 - test 1 matcard = MatCardsList.from_input(ACTIVATION_INP) - newlib = {'99c': ['1001'], '21c': ['28061', '28062', '28064', '29063', - '5010']} + newlib = {"99c": ["1001"], "21c": ["28061", "28062", "28064", "29063", "5010"]} matcard.translate(newlib, LIBMAN) translation = matcard.to_text() - assert translation.count('99c') == 0 - assert translation.count('21c') == 5 - assert translation.count('81c') == 1 + assert translation.count("99c") == 0 + assert translation.count("21c") == 5 + assert translation.count("81c") == 1 # dic mode 2 - test 2 matcard = MatCardsList.from_input(ACTIVATION_INP) - newlib = {'99c': ['1001'], '21c': ['28061', '28062', '28064', '29063']} + newlib = {"99c": ["1001"], "21c": ["28061", "28062", "28064", "29063"]} try: matcard.translate(newlib, LIBMAN) assert False @@ -289,9 +297,9 @@ def test_translation(self, LIBMAN): # classic mode matcard = MatCardsList.from_input(INP2) - matcard.translate('21c', LIBMAN) + matcard.translate("21c", LIBMAN) translation = matcard.to_text() - assert translation.count('21c') == 10 + assert translation.count("21c") == 10 def test_get_info(self, LIBMAN): """