ete icon indicating copy to clipboard operation
ete copied to clipboard

data type issues on staple_layouts from LayoutBarplot branch

Open dengzq1234 opened this issue 2 years ago • 0 comments

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
  1. 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

dengzq1234 avatar Jan 06 '23 17:01 dengzq1234