Repository: PlasmaPy/PlasmaPy

Issue:
Make `Particle.ionize(numpy.inf)` return the nucleus of an atom
When `numpy.inf` is provided to the `ionize` method of a `Particle` object, we should make it so that it returns the nucleus of the atom.  This would be a handy shortcut.  An example usage:

```pycon
>>> from plasmapy.particles import Particle
>>> import numpy as np
>>> helium = Particle("He-4 0+")
>>> helium.ionize(np.inf)
Particle("He-4 2+")
```

Discussion:
github-actions[bot]: Thank you for submitting this pull request (PR)! ✨ PlasmaPy depends on contributors like you, so we deeply appreciate it!

  The bottom of this page shows several checks that are run for every PR. ✅ Don't worry if something broke! We break stuff all the time. 😅 Click on "Details" to learn why a check didn't pass. Please also feel free to ask for help. We do that all the time as well! 🌸 We invite you to our weekly [**community meeting**](https://www.plasmapy.org/meetings/weekly) (2 pm ET on most Tuesdays) and [**office hours**](https://www.plasmapy.org/meetings/office_hours) (3 pm ET on most Thursdays).

  After this PR is marked as ready for review, someone should stop by to provide a code review and offer suggestions soon. 👥 If we don't provide a review within a few days, please feel free to send us a reminder. 🎗

  [**PlasmaPy's contributor guide**](https://docs.plasmapy.org/en/latest/contributing/index.html) has information on:

   - 🌱 [Getting ready to contribute](https://docs.plasmapy.org/en/latest/contributing/getting_ready.html#getting-ready-to-contribute)
   - 🔧 [Code contribution workflow](https://docs.plasmapy.org/en/latest/contributing/workflow.html#code-contribution-workflow)
   - 📜 [Adding a changelog entry](https://docs.plasmapy.org/en/latest/contributing/changelog_guide.html#adding-a-changelog-entry)
   - 💻 [Coding tips and guidelines](https://docs.plasmapy.org/en/latest/contributing/coding_guide.html#coding-guide)
   - 📚 [Writing documentation](https://docs.plasmapy.org/en/latest/contributing/doc_guide.html#writing-documentation)
   - 🧪 [Writing tests](https://docs.plasmapy.org/en/latest/contributing/testing_guide.html#testing-guide)

  > [!TIP]
  > 📚 For a documentation preview, click on *Details* next to **docs/readthedocs.org:plasmapy**. For cryptic documentation errors, see the [documentation troubleshooting guide](https://docs.plasmapy.org/en/latest/contributing/doc_guide.html#troubleshooting).

  > [!HINT]
  > 🧹 Automatically fix most **pre-commit.ci** failures by commenting [`pre-commit.ci autofix`](https://github.com/PlasmaPy/PlasmaPy/pull/1500#issuecomment-1216865989) below. For other failures, please see the [pre-commit troubleshooting guide](https://docs.plasmapy.org/en/stable/contributing/pre-commit.html#troubleshooting-pre-commit-failures).

  We thank you once again! 🌌
codecov[bot]: ## [Codecov](https://app.codecov.io/gh/PlasmaPy/PlasmaPy/pull/2800?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PlasmaPy) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 95.16%. Comparing base [(`bc851f7`)](https://app.codecov.io/gh/PlasmaPy/PlasmaPy/commit/bc851f78a8ab7765a6532a8b2601d97d47828cf0?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PlasmaPy) to head [(`62bbf28`)](https://app.codecov.io/gh/PlasmaPy/PlasmaPy/commit/62bbf28972ce1af737dbd1393eeb4c792968771d?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PlasmaPy).

<details><summary>Additional details and impacted files</summary>


```diff
@@           Coverage Diff           @@
##             main    #2800   +/-   ##
=======================================
  Coverage   95.16%   95.16%           
=======================================
  Files         107      107           
  Lines        9608     9613    +5     
  Branches     2225     2227    +2     
=======================================
+ Hits         9143     9148    +5     
  Misses        277      277           
  Partials      188      188           
```

</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/PlasmaPy/PlasmaPy/pull/2800?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PlasmaPy).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PlasmaPy).

PrestonXPitzer: pre-commit.ci autofix
ShelleySugiharto: also! I saw that you fixed the pre commit, but I was told that you need to do it again since you made changes after :)
PrestonXPitzer: pre-commit.ci autofix

Patch:
diff --git a/CITATION.cff b/CITATION.cff
index 9c3618d2..b60a77bf 100644
--- a/CITATION.cff
+++ b/CITATION.cff
@@ -157,6 +157,8 @@ authors:
   family-names: Choudhary
   alias: martha889
 
+- alias: cicciope
+
 - given-names: Christian
   family-names: Clauss
   alias: cclauss
@@ -457,6 +459,11 @@ authors:
 
 - alias: nrb1234
 
+- given-names: Carlos
+  family-names: Ortiz
+  affiliation: University of Wisconsin
+  alias: ciortiz
+
 - given-names: Oscar
   alias: 0scvr
 
@@ -489,6 +496,12 @@ authors:
   family-names: Pérez
   alias: RoberTnf
 
+- given-names: Preston
+  family-names: Pitzer
+  affiliation : Virginia Tech
+  orcid : https://orcid.org/0009-0007-0655-1347
+  alias: PrestonPitzerVT
+
 - given-names: Ramiz
   family-names: Qudsi
   affiliation: Boston University
diff --git a/changelog/2800.feature.rst b/changelog/2800.feature.rst
new file mode 100644
index 00000000..a79c94a1
--- /dev/null
+++ b/changelog/2800.feature.rst
@@ -0,0 +1,1 @@
+Added the option to pass |inf| to the `~plasmapy.particles.particle_class.Particle.ionize` method of |Particle|, which returns the nucleus of the particle.
diff --git a/docs/getting_started.rst b/docs/getting_started.rst
index d10df08f..5952f8fb 100644
--- a/docs/getting_started.rst
+++ b/docs/getting_started.rst
@@ -1,9 +1,9 @@
 Getting Started 🦥
 ==================
 
-This page includes example 🚀 notebooks intended for new users of PlasmaPy ✨,
-including notebooks that introduce `astropy.units` and
-`plasmapy.particles`...
+This page includes example 🚀 notebooks intended for new users 👶 of
+PlasmaPy ✨, including notebooks that introduce `astropy.units` and
+`plasmapy.particles`.
 
 .. nbgallery::
 
diff --git a/docs/install.rst b/docs/install.rst
index 917ddc78..9e1a73e2 100644
--- a/docs/install.rst
+++ b/docs/install.rst
@@ -1,8 +1,8 @@
 .. _plasmapy-install:
 
-*******************
-Installing PlasmaPy
-*******************
+**********************
+Installing PlasmaPy ☀️
+**********************
 
 .. note::
 
diff --git a/src/plasmapy/particles/particle_class.py b/src/plasmapy/particles/particle_class.py
index 570e2679..00089533 100644
--- a/src/plasmapy/particles/particle_class.py
+++ b/src/plasmapy/particles/particle_class.py
@@ -2,7 +2,7 @@
 
 from __future__ import annotations
 
-from typing import Any
+from typing import Any, Literal
 
 __all__ = [
     "AbstractParticle",
@@ -1793,7 +1793,9 @@ def is_ion(self) -> bool:
         """
         return self.is_category("ion")
 
-    def ionize(self, n: int = 1, inplace: bool = False) -> Particle | None:
+    def ionize(
+        self, n: int | Literal[np.inf] = 1, inplace: bool = False
+    ) -> Particle | None:
         """
         Create a new |Particle| instance corresponding to the current
         |Particle| after being ionized ``n`` times.
@@ -1822,6 +1824,8 @@ def ionize(self, n: int = 1, inplace: bool = False) -> Particle | None:
             A new |Particle| object that has been ionized ``n`` times
             relative to the original |Particle|.  If ``inplace`` is
             `False`, instead return `None`.
+            If |inf| is passed as ``n``, the particle will be fully ionized,
+            and the result will be the nucleus of the ion.
 
         Raises
         ------
@@ -1851,6 +1855,13 @@ def ionize(self, n: int = 1, inplace: bool = False) -> Particle | None:
                 f"Cannot ionize {self.symbol} because it is not a "
                 f"neutral atom or ion."
             )
+
+        if np.isinf(n):
+            if inplace:
+                self.__init__(self.nucleus.symbol)
+                return None
+            else:
+                return self.nucleus
         assumed_charge_number = (
             self.charge_number
             if self.is_category(any_of={"charged", "uncharged"})
@@ -1861,6 +1872,7 @@ def ionize(self, n: int = 1, inplace: bool = False) -> Particle | None:
                 f"The particle {self.symbol} is already fully "
                 f"ionized and cannot be ionized further."
             )
+
         if not isinstance(n, Integral):
             raise TypeError("n must be a positive integer.")
         if n <= 0:


Test patch:
diff --git a/tests/particles/test_particle_class.py b/tests/particles/test_particle_class.py
index bcf315a8..a894c9e9 100644
--- a/tests/particles/test_particle_class.py
+++ b/tests/particles/test_particle_class.py
@@ -1695,3 +1695,14 @@ def test_isotope_ion_electron_binding_energy() -> None:
     assert C_12.electron_binding_energy == C_13.electron_binding_energy
     assert C_12.electron_binding_energy == C_14.electron_binding_energy
     assert C_13.electron_binding_energy == C_14.electron_binding_energy
+
+
+def test_infinite_ionization() -> None:
+    helium = Particle("He-4 0+")
+    h_nucleus = helium.ionize(n=np.inf)
+    helium.ionize(n=np.inf, inplace=True)
+    assert h_nucleus == helium
+    assert h_nucleus == Particle("He-4 2+")
+    helium = Particle("He-4 0+")
+    pytest.raises(TypeError, helium.ionize, n=0.5)
+    pytest.raises(ValueError, helium.ionize, n=-1)