对于电生理学数据分析集,我需要绘制一个大的2D阵列(昏暗的约20.000 x 120)点.我曾经在我的PyQt应用程序中嵌入了一个Matplotlib小部件,但是寻找其他解决方案因为绘图花了很长时间.尽管如此,使用pyqtgraph绘制数据也需要比预期更长的时间,这可能是因为它在每次使用plot()函数时都会重新绘制小部件.
绘制大型数组的最佳做法是什么?
pyqtgraph的例子虽然广泛,但对我没有太大的帮助......
import pyqtgraph as pg
view = pg.GraphicsLayoutWidget()
w1 = view.addPlot()
for n in data:
w1.plot(n)
Run Code Online (Sandbox Code Playgroud)
要么
w1.plot(data)
Run Code Online (Sandbox Code Playgroud)
最后一条规则生成ValueError:操作数无法与形状一起广播(10)(10,120)
提前致谢....
我想将包含二进制数据的字符串对象插入到MySQL blob列中.但是,我不断收到MySQL语法错误.
我做了一个小脚本用于调试目的:
import MySQLdb
import array
import random
conn = MySQLdb.connect(host="localhost", user="u", passwd="p", db="cheese")
cur = conn.cursor()
a = array.array('f')
for n in range(1,5):
a.append(random.random())
bd = a.tostring()
print type(bd) # gives str
query = '''INSERT INTO cheese (data) VALUES (%s)''' % bd
cur.execute(query)
Run Code Online (Sandbox Code Playgroud)
结果(但不是每次......)
ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near '?fJ\x95<=
\xad9>\xf3\xec\xe5>)' at line 1")
Run Code Online (Sandbox Code Playgroud)
这个问题显然归结为MySQL不喜欢的二进制数据中的某些字符.是否存在将二进制数据放入MySQL数据库的故障安全方法?