diff --git a/CHANGELOG.md b/CHANGELOG.md
index 98091849..b8ac3693 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 ## unreleased
 
 ### Fixed
+- Fix to handle spectra with empty peak arrays. [#598](https://github.com/matchms/matchms/issues/598)
 - Fix instability introduced in CosineGreedy by `np.argsort`. [#595](https://github.com/matchms/matchms/issues/595)
 
 ### Changed
diff --git a/matchms/Spectrum.py b/matchms/Spectrum.py
index 7d2bba6e..08855d9b 100644
--- a/matchms/Spectrum.py
+++ b/matchms/Spectrum.py
@@ -105,10 +105,12 @@ class Spectrum:
         return int.from_bytes(bytearray(combined_hash, 'utf-8'), 'big')
 
     def __repr__(self):
+        precursor_mz_str = f"{self.get('precursor_mz', 0.0):.2f}"
         num_peaks = len(self.peaks)
+        if num_peaks == 0:
+            return f"Spectrum(precursor m/z={precursor_mz_str}, no fragments)"
         min_mz = min(self.peaks.mz)
         max_mz = max(self.peaks.mz)
-        precursor_mz_str = f"{self.get('precursor_mz', 0.0):.2f}"
         return f"Spectrum(precursor m/z={precursor_mz_str}, {num_peaks} fragments between {min_mz:.1f} and {max_mz:.1f})"
 
     def __str__(self):

diff --git a/tests/test_spectrum.py b/tests/test_spectrum.py
index b6874122..d6428758 100644
--- a/tests/test_spectrum.py
+++ b/tests/test_spectrum.py
@@ -141,6 +141,16 @@ def test_spectrum_to_dict_matchms_style(spectrum: Spectrum):
     assert spectrum_dict == expected_dict
 
 
+def test_spectrum_repr_and_str_method():
+    # Test the __repr__ and __str__ methods.
+    spectrum = Spectrum(mz=np.array([1., 2., 3.]), intensities=np.array([0, 0.5, 1.]))
+    assert repr(spectrum) == str(spectrum) == "Spectrum(precursor m/z=0.00, 3 fragments between 1.0 and 3.0)"
+
+    # Test if spectra with empty peak arrays are handled correctly:
+    spectrum = Spectrum(mz=np.array([]), intensities=np.array([]))
+    assert repr(spectrum) == str(spectrum) == "Spectrum(precursor m/z=0.00, no fragments)"
+
+
 def test_spectrum_hash(spectrum: Spectrum):
     assert hash(spectrum) == 382278160858921722, "Expected different hash."
     assert spectrum.metadata_hash() == "78c223faa157cc130390", \

Fix generating empty spectrums
**Describe the bug**

The following code generate an empty spectrum

```
s = Spectrum(np.array([1.]), np.array([1.]))
processing = SpectrumProcessor(
    [
        lambda spec: select_by_mz(spec, 20, 30)
    ]
)
processing.process_spectrums([s])

```

 It raises an error when trying to print the spectra, but I assume this can casue other problems. (I found one while trying to compute scores using this spectra.

```
ValueError: min() arg is an empty sequence
```

**To Reproduce**
Code above.

**Expected behavior**
It should not break, I guess empty spectrum is find in some cases, when processing data.

**Desktop (please complete the following information):**
 - OS: Windows
 - Version python3.11.2 ,  matchms:0.24.0




tests/test_spectrum.py::test_spectrum_repr_and_str_method
tests/test_spectrum.py::test_spectrum_getters_return_copies tests/test_spectrum.py::test_spectrum_getters tests/test_spectrum.py::test_spectrum_metadata_harmonization[input_dict0-expected_dict0] tests/test_spectrum.py::test_spectrum_metadata_harmonization[input_dict1-expected_dict1] tests/test_spectrum.py::test_spectrum_metadata_harmonization[input_dict2-expected_dict2] tests/test_spectrum.py::test_comparing_spectra_with_metadata tests/test_spectrum.py::test_comparing_spectra_with_arrays tests/test_spectrum.py::test_spectrum_to_dict tests/test_spectrum.py::test_spectrum_to_dict_matchms_style tests/test_spectrum.py::test_spectrum_hash tests/test_spectrum.py::test_spectrum_hash_mz_sensitivity tests/test_spectrum.py::test_spectrum_hash_intensity_sensitivity tests/test_spectrum.py::test_spectrum_hash_metadata_sensitivity tests/test_spectrum.py::test_spectrum_clone[True] tests/test_spectrum.py::test_spectrum_clone[False] tests/test_spectrum.py::test_metadata_default_filtering[input_dict0-True-expected0] tests/test_spectrum.py::test_metadata_default_filtering[input_dict1-True-expected1] tests/test_spectrum.py::test_metadata_default_filtering[input_dict2-True-expected2] tests/test_spectrum.py::test_metadata_default_filtering[input_dict3-False-expected3] tests/test_spectrum.py::test_metadata_default_filtering[input_dict4-True-expected4] tests/test_spectrum.py::test_metadata_default_filtering[input_dict5-True-expected5] tests/test_spectrum.py::test_metadata_default_filtering[input_dict6-True-expected6] tests/test_spectrum.py::test_metadata_default_filtering[input_dict7-True-expected7] tests/test_spectrum.py::test_metadata_default_filtering[input_dict8-True-expected8] tests/test_spectrum.py::test_metadata_default_filtering[input_dict9-True-expected9] tests/test_spectrum.py::test_metadata_default_filtering[input_dict10-True-expected10] tests/test_spectrum.py::test_metadata_default_filtering[input_dict11-True-expected11] tests/test_spectrum.py::test_spectrum_plot_same_peak_height tests/test_spectrum.py::test_spectrum_plot tests/test_spectrum.py::test_spectrum_mirror_plot