From 1ee60a125073da21282f766426dfa01750a4edc3 Mon Sep 17 00:00:00 2001 From: Tom Kazimiers Date: Mon, 16 Jul 2018 00:17:16 -0400 Subject: [PATCH] Treenode back-end: make node insertion slighlty more robust It seems to happen in very rare cases that a passed in radius or confidence is NaN. Handling these situations more gracefully is use ful to mitigate this behavior. It should still be checked why such situations happen, but they shouldn't prevent node creation. --- django/applications/catmaid/control/treenode.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/django/applications/catmaid/control/treenode.py b/django/applications/catmaid/control/treenode.py index b59d3cbf5e..da17e809ab 100644 --- a/django/applications/catmaid/control/treenode.py +++ b/django/applications/catmaid/control/treenode.py @@ -279,9 +279,11 @@ def insert_new_treenode(parent_id=None, skeleton_id=None): new_treenode.location_x = float(x) new_treenode.location_y = float(y) new_treenode.location_z = float(z) - new_treenode.radius = int(radius) + new_radius = int(radius if (radius and not math.isnan(radius)) else 0) + new_treenode.radius = new_radius new_treenode.skeleton_id = skeleton_id - new_treenode.confidence = int(confidence) + new_confidence = int(confidence if not math.isnan(confidence) and (confidence or confidence is 0) else 5) + new_treenode.confidence = new_confidence if parent_id: new_treenode.parent_id = parent_id new_treenode.save()