ete
ete copied to clipboard
data type issues on staple_layouts from LayoutBarplot branch
I noticed the following lines which contains data type error in regards to properties fetching in https://github.com/etetoolkit/ete/blob/LayoutBarplot/ete4/smartview/renderer/layouts/staple_layouts.py
line 57
prop = node.props.get(p)
if type(prop) in [int, float]:
vals[metric][1] = min(minval, prop)
vals[metric][2] = max(maxval, prop)
elif prop is None or prop == "":
return
else:
uniqvals.add(prop)
prop
will be string
at the first place when fetch from the node, so I would suggest:
prop = node.props.get(p)
try:
prop = float(prop) # prop by default is string
if type(prop) in [int, float]:
vals[metric][1] = min(minval, prop)
vals[metric][2] = max(maxval, prop)
elif prop is None or prop == "":
return
else:
uniqvals.add(prop)
except:
pass
- line 109 the same issue,
return node.props.get(self.size_prop, 0) / maxval * self.width
should be:
return float(node.props.get(self.size_prop, 0)) / maxval * self.width