From ca7b4580fa3987840385a5db55083a827648b82c Mon Sep 17 00:00:00 2001 From: Tom Mudway Date: Mon, 7 Dec 2020 17:55:51 -0500 Subject: [PATCH 1/3] Added option to use "None" for adj in setData This allows you to easily create code to toggle lines on or off by setting to the appropriate array if on, or None if off. Currently you have to have 2 seperate setData calls, one with adj and one without --- pyqtgraph/graphicsItems/GraphItem.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyqtgraph/graphicsItems/GraphItem.py b/pyqtgraph/graphicsItems/GraphItem.py index c80138fb..ee5207e9 100644 --- a/pyqtgraph/graphicsItems/GraphItem.py +++ b/pyqtgraph/graphicsItems/GraphItem.py @@ -55,7 +55,7 @@ class GraphItem(GraphicsObject): """ if 'adj' in kwds: self.adjacency = kwds.pop('adj') - if self.adjacency.dtype.kind not in 'iu': + if self.adjacency.dtype.kind not in 'iu' and self.adjacency is not None: raise Exception("adjacency array must have int or unsigned type.") self._update() if 'pos' in kwds: From 983a3769e7287565f8b9c502905a4dbc6d04b5b0 Mon Sep 17 00:00:00 2001 From: Ogi Moore Date: Sun, 31 Jan 2021 22:32:56 -0800 Subject: [PATCH 2/3] Check for None first --- pyqtgraph/graphicsItems/GraphItem.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyqtgraph/graphicsItems/GraphItem.py b/pyqtgraph/graphicsItems/GraphItem.py index ee5207e9..c2cb1254 100644 --- a/pyqtgraph/graphicsItems/GraphItem.py +++ b/pyqtgraph/graphicsItems/GraphItem.py @@ -55,7 +55,7 @@ class GraphItem(GraphicsObject): """ if 'adj' in kwds: self.adjacency = kwds.pop('adj') - if self.adjacency.dtype.kind not in 'iu' and self.adjacency is not None: + if self.adjacency is not None and self.adjacency.dtype.kind not in 'iu': raise Exception("adjacency array must have int or unsigned type.") self._update() if 'pos' in kwds: From 89d20119fe51dfa26019a2dc27b38b5b1b60452a Mon Sep 17 00:00:00 2001 From: Ogi Moore Date: Sun, 31 Jan 2021 22:36:59 -0800 Subject: [PATCH 3/3] Update docstring and error message --- pyqtgraph/graphicsItems/GraphItem.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyqtgraph/graphicsItems/GraphItem.py b/pyqtgraph/graphicsItems/GraphItem.py index c2cb1254..0c279b30 100644 --- a/pyqtgraph/graphicsItems/GraphItem.py +++ b/pyqtgraph/graphicsItems/GraphItem.py @@ -32,7 +32,7 @@ class GraphItem(GraphicsObject): **Arguments:** pos (N,2) array of the positions of each node in the graph. adj (M,2) array of connection data. Each row contains indexes - of two nodes that are connected. + of two nodes that are connected or None to hide lines pen The pen to use when drawing lines between connected nodes. May be one of: @@ -56,7 +56,7 @@ class GraphItem(GraphicsObject): if 'adj' in kwds: self.adjacency = kwds.pop('adj') if self.adjacency is not None and self.adjacency.dtype.kind not in 'iu': - raise Exception("adjacency array must have int or unsigned type.") + raise Exception("adjacency must be None or an array of either int or unsigned type.") self._update() if 'pos' in kwds: self.pos = kwds['pos']