def in_file(self, target: Union[str, "Isotope"]): target = Isotope.name(target) try: self.__getitem__(target) return True except Exception: return False
def __getitem__(self, target: Union[str, "Isotope"]) -> KadonisReaction: target = Isotope.name(target) try: return self.df[ (self.df["Z"] == target.charge_number) & (self.df["A"] == target.mass_number)].Reaction.iloc[0] except IndexError: raise Exception(str(target) + " Not found in file")
def __init__( self, target: Union[str, Isotope], rr: List[real], err: List[real], temp: Tuple[real] = (5, 8, 10, 15, 20, 25, 30, 40, 50, 60, 80, 100), temp_units: str = "KeV", label: str = "Kadonis", colour: str = "C2", ): product = copy.deepcopy(Isotope.name(target)) product.mass_number += 1 super().__init__(["n", target], [product]) self.rr = rr self.err = err self.temperature = temp self.temp_unit = temp_units self.label = label self.colour = colour
def get_n_gamma(self, target: Union[Isotope, str]) -> ReaclibReaction: """Gets reaction from target Isotope, matches __getitem__ method in the Kadonis class Parameters ---------- target : [Isotope, str] Returns ------- ReaclibReaction """ target = Isotope.name(target) try: return self.df[(self.df.Chapter == 4) & (self.df.E0 == "n") & (self.df.E1 == str(target).lower())].Reaction.iloc[0] except IndexError: raise Exception(str(target) + " Not found in file")
def __init__(self, targets: iso_list_type, products: iso_list_type) -> None: self.targets = [Isotope.name(t) for t in targets] self.products = [Isotope.name(t) for t in products]
def test_full_name(self): assert Isotope.name("Ne20").full_name == "Neon-20"
def test_eq(self): assert Isotope.name("Ne20") == "Ne20" and "ne20" and "20Ne" assert Isotope.name("O12") != "NE20"
def test_class_re_input_to_name(self): assert str(Isotope.name(Isotope(7, 14))) == "N14"
def test_name(self): for n, n_out in zip(self.names, self.names_out): isotope = Isotope.name(n) assert str(isotope) == n_out