Skip to content

Commit

Permalink
Merge pull request #2970 from DradeAW/patch-2
Browse files Browse the repository at this point in the history
Fix bug with nan values
  • Loading branch information
alejoe91 authored Jun 7, 2024
2 parents 77cc7e0 + dc37bc0 commit c58b4e6
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/spikeinterface/extractors/phykilosortextractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,22 @@ def __init__(
self.set_property(key="quality", values=cluster_info[prop_name])
else:
if load_all_cluster_properties:
# pandas loads strings as objects
# pandas loads strings with empty values as objects with NaNs
prop_dtype = None
if cluster_info[prop_name].values.dtype.kind == "O":
prop_dtype = type(cluster_info[prop_name].values[0])
values_ = cluster_info[prop_name].values.astype(prop_dtype)
for value in cluster_info[prop_name].values:
if isinstance(value, (np.floating, float)) and np.isnan(
value
): # Blank values are encoded as 'NaN'.
continue

prop_dtype = type(value)
break
if prop_dtype is not None:
values_ = cluster_info[prop_name].values.astype(prop_dtype)
else:
# Could not find a valid dtype for the column. Skip it.
continue
else:
values_ = cluster_info[prop_name].values
self.set_property(key=prop_name, values=values_)
Expand Down

0 comments on commit c58b4e6

Please sign in to comment.