Repository: idaholab/MontePy

Issue:
Simplify Isotope repr
Let's say we have an O-16 `Isotope` in the 01c xslib. Currently,

```python
>>> str(o16)
' O-16  (01c)'
>>> repr(o16)
'ZAID=8016, Z=8, A=16, element=oxygen, library=01c'
```

`__repr__` is mostly used for debugging and logging purposes and should remain simple.


**Describe the solution you'd like**

Move the current `__repr__` to `__str__`, and do the following instead:

```python
>>> repr(o16)
'Isotope(8016.01c)'
```

**Describe alternatives you've considered**
I think the `Isotope({self.ZAID})` is best, because ZAID is the most widely used convention in MCNP [citation needed]. However, the new MCNP6.3.1 style would be acceptable as well:

```python
>>> repr(o16)
'Isotope(O-16.01c)'
```

Single or double quotes around the identifier may be preferable as well: `Isotope(". . .")` or `Isotope('. . .')`


**Additional context**
More broadly, the `__repr__` functions should be simplified throughout MontePy to be brief and to show the class name. I'm targeting this one first because of #472.



Discussion:

Patch:
diff --git a/doc/source/changelog.rst b/doc/source/changelog.rst
index d8e1bd36..796e498f 100644
--- a/doc/source/changelog.rst
+++ b/doc/source/changelog.rst
@@ -10,6 +10,10 @@ MontePy Changelog
 * Fixed bug with appending and renumbering numbered objects from other MCNP problems (:issue:`466`).
 * Fixed bug with dynamic typing and the parsers that only appear in edge cases (:issue:`461`).
 
+**Code Quality**
+
+* Simpler ``Isotope`` representation (:issue:`473`).
+
 
 0.3.2
 --------------
diff --git a/montepy/data_inputs/isotope.py b/montepy/data_inputs/isotope.py
index f682fe95..5324ee17 100644
--- a/montepy/data_inputs/isotope.py
+++ b/montepy/data_inputs/isotope.py
@@ -168,8 +168,8 @@ class Isotope:
             raise TypeError("library must be a string")
         self._library = library
 
-    def __str__(self):
-        return f"{self.element.symbol:>2}-{self.A:<3} ({self._library})"
+    def __repr__(self):
+        return f"{self.__class__.__name__}({repr(self.nuclide_str())})"
 
     def mcnp_str(self):
         """
@@ -182,6 +182,10 @@ class Isotope:
         """
         return f"{self.ZAID}.{self.library}" if self.library else self.ZAID
 
+    def nuclide_str(self):
+        suffix = f".{self._library}" if self._library else ""
+        return f"{self.element.symbol}-{self.A}{suffix}"
+
     def get_base_zaid(self):
         """
         Get the ZAID identifier of the base isotope this is an isomer of.
@@ -193,8 +197,9 @@ class Isotope:
         """
         return self.Z * 1000 + self.A
 
-    def __repr__(self):
-        return f"ZAID={self.ZAID}, Z={self.Z}, A={self.A}, element={self.element}, library={self.library}"
+    def __str__(self):
+        suffix = f" ({self._library})" if self._library else ""
+        return f"{self.element.symbol:>2}-{self.A:<3}{suffix}"
 
     def __hash__(self):
         return hash(self._ZAID)


Test patch:
diff --git a/tests/test_material.py b/tests/test_material.py
index feb51472..839d3869 100644
--- a/tests/test_material.py
+++ b/tests/test_material.py
@@ -99,16 +99,17 @@ class testMaterialClass(TestCase):
         in_str = "M20 1001.80c 0.5 8016.80c 0.4 94239.80c 0.1"
         input_card = Input([in_str], BlockType.DATA)
         material = Material(input_card)
-        answers = """MATERIAL: 20 fractions: atom
+        answers = """\
+MATERIAL: 20 fractions: atom
  H-1   (80c) 0.5
  O-16  (80c) 0.4
 Pu-239 (80c) 0.1
 """
         output = repr(material)
         print(output)
-        self.assertEqual(output, answers)
+        assert output == answers
         output = str(material)
-        self.assertEqual(output, "MATERIAL: 20, ['hydrogen', 'oxygen', 'plutonium']")
+        assert output == "MATERIAL: 20, ['hydrogen', 'oxygen', 'plutonium']"
 
     def test_material_sort(self):
         in_str = "M20 1001.80c 0.5 8016.80c 0.5"
@@ -245,14 +246,18 @@ class TestIsotope(TestCase):
 
     def test_isotope_str(self):
         isotope = Isotope("1001.80c")
-        self.assertEqual(isotope.mcnp_str(), "1001.80c")
-        self.assertEqual(str(isotope), " H-1   (80c)")
-        self.assertEqual(
-            repr(isotope), "ZAID=1001, Z=1, A=1, element=hydrogen, library=80c"
-        )
+        assert isotope.mcnp_str() == "1001.80c"
+        assert isotope.nuclide_str() == "H-1.80c"
+        assert repr(isotope) == "Isotope('H-1.80c')"
+        assert str(isotope) == " H-1   (80c)"
         isotope = Isotope("94239.80c")
-        self.assertEqual(isotope.mcnp_str(), "94239.80c")
-        self.assertEqual(str(isotope), "Pu-239 (80c)")
+        assert isotope.nuclide_str() == "Pu-239.80c"
+        assert isotope.mcnp_str() == "94239.80c"
+        assert repr(isotope) == "Isotope('Pu-239.80c')"
+        isotope = Isotope("95642")
+        assert isotope.nuclide_str() == "Am-242"
+        assert isotope.mcnp_str() == "95642"
+        assert repr(isotope) == "Isotope('Am-242')"
 
 
 class TestThermalScattering(TestCase):