Skip to content

Commit

Permalink
Fix issue 247
Browse files Browse the repository at this point in the history
PyQtGraph's ErrorBarItem's setData method requires numpy arrays, but
ndscan was passing in lists, causing an AttributeError when the size
method was called.
  • Loading branch information
lochsh authored and oitg-bulldozer[bot] committed Jul 16, 2021
1 parent 9d46a98 commit a657fe8
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions ndscan/plots/xy_1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ def __init__(self, view_box, data_name, data_item, error_bar_name, error_bar_ite

def update(self, x_data, data):
def channel(name):
return data.get("channel_" + name, [])
return np.array(data.get("channel_" + name, []))

x_data = np.array(x_data)
y_data = channel(self.data_name)
num_to_show = min(len(x_data), len(y_data))

Expand All @@ -44,16 +45,13 @@ def channel(name):
return

if self.plot_left_to_right:
x_data = np.array(x_data)
order = np.argsort(x_data[:num_to_show])

y_data = np.array(y_data)
self.data_item.setData(x_data[order], y_data[order])
if self.num_current_points == 0:
self.view_box.addItem(self.data_item)

if self.error_bar_item:
y_err = np.array(y_err)
self.error_bar_item.setData(x=x_data[order],
y=y_data[order],
height=y_err[order])
Expand All @@ -67,7 +65,7 @@ def channel(name):
if self.error_bar_item:
self.error_bar_item.setData(x=x_data[:num_to_show],
y=y_data[:num_to_show],
height=(2 * np.array(y_err[:num_to_show])))
height=(2 * y_err[:num_to_show]))
if self.num_current_points == 0:
self.view_box.addItem(self.error_bar_item)

Expand Down

0 comments on commit a657fe8

Please sign in to comment.