handle empty adjanceny array (#1647)

This commit is contained in:
Nils Nemitz 2021-03-22 13:14:19 +09:00 committed by GitHub
parent d74bbe3bf6
commit a1eca4e2dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -55,7 +55,9 @@ class GraphItem(GraphicsObject):
""" """
if 'adj' in kwds: if 'adj' in kwds:
self.adjacency = kwds.pop('adj') self.adjacency = kwds.pop('adj')
if self.adjacency is not None and self.adjacency.dtype.kind not in 'iu': if hasattr(self.adjacency, '__len__') and len(self.adjacency) == 0:
self.adjacency = None
elif self.adjacency is not None and self.adjacency.dtype.kind not in 'iu':
raise Exception("adjacency must be None or an array of either int or unsigned type.") raise Exception("adjacency must be None or an array of either int or unsigned type.")
self._update() self._update()
if 'pos' in kwds: if 'pos' in kwds:
@ -140,8 +142,3 @@ class GraphItem(GraphicsObject):
def pixelPadding(self): def pixelPadding(self):
return self.scatter.pixelPadding() return self.scatter.pixelPadding()