Skip to content

Commit

Permalink
convert numpy objects to float
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasscheid committed Oct 29, 2023
1 parent 37163f1 commit 806a553
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion psm_utils/io/idxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,8 @@ def _update_peptide_hit(self, peptide_hit: oms.PeptideHit, psm: PSM) -> None:

for feature, value in psm.rescoring_features.items():
if feature not in RESCORING_FEATURE_LIST:
peptide_hit.setMetaValue(feature, value)
# Convert numpy objects to floats since pyopenms does not support numpy objects to be added
peptide_hit.setMetaValue(feature, float(value))

def _create_new_ids(self, psm_dict: dict) -> None:
"""
Expand Down Expand Up @@ -532,6 +533,9 @@ def _add_meta_values_from_dict(self, peptide_hit: oms.PeptideHit, d: dict) -> No
"""Add meta values inplace to :py:class:`~pyopenms.PeptideHit` from a dictionary."""
if d is not None:
for key, value in d.items():
# Convert numpy objects to floats since pyopenms does not support numpy objects to be added
if not isinstance(value, str):
value = float(value)
peptide_hit.setMetaValue(key, value)


Expand Down

0 comments on commit 806a553

Please sign in to comment.