Skip to content

Commit d0db429

Browse files
committed
fix read-only errors with newer versions of pandas
1 parent e76cde3 commit d0db429

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

navis/morpho/mmetrics.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,8 @@ def segment_analysis(x: "core.NeuronObject") -> "core.NeuronObject":
292292
"""Calculate morphometric properties a neuron's segments.
293293
294294
This currently includes Strahler index, length, distance to root and
295-
tortuosity. If neuron has a radius will also calculate radius-based metrics
296-
such as volume.
295+
tortuosity. If the neuron has a radius will also calculate radius-based
296+
metrics such as volume.
297297
298298
Parameters
299299
----------
@@ -422,8 +422,9 @@ def segment_analysis(x: "core.NeuronObject") -> "core.NeuronObject":
422422

423423
# Get radii for each cylinder
424424
r1 = nodes.index.map(radii).values
425-
r2 = nodes.parent_id.map(radii).values
426-
r2[np.isnan(r2)] = 0
425+
r2 = nodes.parent_id.map(radii) # Note we keep the Series here to avoid "read-only" errors when trying to replace NaNs
426+
r2.iloc[np.isnan(r2)] = 0
427+
r2 = r2.values
427428

428429
# Get the height for each node -> parent cylinder
429430
h = parent_dist(x, root_dist=0)

navis/nbl/nblast_funcs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ def nblast_smart(query: Union[Dotprops, NeuronList],
550550
columns=scr.columns, index=scr.index)
551551
_ = np.arange(mask.shape[0])
552552
for N in range(t):
553-
mask.values[_, srt[:, N]] = True
553+
mask.iloc[_, srt[:, N]] = True
554554

555555
# Calculate self-hits for full neurons
556556
query_self_hits = np.array([nb.calc_self_hit(n) for n in query_dps])

0 commit comments

Comments
 (0)