本文整理汇总了Python中matplotlib.mlab.csv2rec方法的典型用法代码示例。如果您正苦于以下问题:Python mlab.csv2rec方法的具体用法?Python mlab.csv2rec怎么用?Python mlab.csv2rec使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.mlab
的用法示例。
在下文中一共展示了mlab.csv2rec方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_recarray_csv_roundtrip
# 需要导入模块: from matplotlib import mlab [as 别名]
# 或者: from matplotlib.mlab import csv2rec [as 别名]
def test_recarray_csv_roundtrip(self):
expected = np.recarray((99,),
[(str('x'), np.float),
(str('y'), np.float),
(str('t'), np.float)])
# initialising all values: uninitialised memory sometimes produces
# floats that do not round-trip to string and back.
expected['x'][:] = np.linspace(-1e9, -1, 99)
expected['y'][:] = np.linspace(1, 1e9, 99)
expected['t'][:] = np.linspace(0, 0.01, 99)
mlab.rec2csv(expected, self.fd)
self.fd.seek(0)
actual = mlab.csv2rec(self.fd)
assert_allclose(expected['x'], actual['x'])
assert_allclose(expected['y'], actual['y'])
assert_allclose(expected['t'], actual['t'])
示例2: test_recarray_csv_roundtrip
# 需要导入模块: from matplotlib import mlab [as 别名]
# 或者: from matplotlib.mlab import csv2rec [as 别名]
def test_recarray_csv_roundtrip(tempcsv):
expected = np.recarray((99,),
[(str('x'), float),
(str('y'), float),
(str('t'), float)])
# initialising all values: uninitialised memory sometimes produces
# floats that do not round-trip to string and back.
expected['x'][:] = np.linspace(-1e9, -1, 99)
expected['y'][:] = np.linspace(1, 1e9, 99)
expected['t'][:] = np.linspace(0, 0.01, 99)
with pytest.warns(MatplotlibDeprecationWarning):
mlab.rec2csv(expected, tempcsv)
tempcsv.seek(0)
actual = mlab.csv2rec(tempcsv)
assert_allclose(expected['x'], actual['x'])
assert_allclose(expected['y'], actual['y'])
assert_allclose(expected['t'], actual['t'])
示例3: test_recarray_csv_roundtrip
# 需要导入模块: from matplotlib import mlab [as 别名]
# 或者: from matplotlib.mlab import csv2rec [as 别名]
def test_recarray_csv_roundtrip(tempcsv):
expected = np.recarray((99,), [('x', float), ('y', float), ('t', float)])
# initialising all values: uninitialised memory sometimes produces
# floats that do not round-trip to string and back.
expected['x'][:] = np.linspace(-1e9, -1, 99)
expected['y'][:] = np.linspace(1, 1e9, 99)
expected['t'][:] = np.linspace(0, 0.01, 99)
with pytest.warns(MatplotlibDeprecationWarning):
mlab.rec2csv(expected, tempcsv)
tempcsv.seek(0)
actual = mlab.csv2rec(tempcsv)
assert_allclose(expected['x'], actual['x'])
assert_allclose(expected['y'], actual['y'])
assert_allclose(expected['t'], actual['t'])
示例4: test_csv2rec_names_with_comments
# 需要导入模块: from matplotlib import mlab [as 别名]
# 或者: from matplotlib.mlab import csv2rec [as 别名]
def test_csv2rec_names_with_comments(tempcsv):
tempcsv.write('# comment\n1,2,3\n4,5,6\n')
tempcsv.seek(0)
with pytest.warns(MatplotlibDeprecationWarning):
array = mlab.csv2rec(tempcsv, names='a,b,c')
assert len(array) == 2
assert len(array.dtype) == 3
示例5: test_csv2rec_dates
# 需要导入模块: from matplotlib import mlab [as 别名]
# 或者: from matplotlib.mlab import csv2rec [as 别名]
def test_csv2rec_dates(tempcsv, input, kwargs):
tempcsv.write(input)
expected = [datetime.datetime(2014, 1, 11, 0, 0),
datetime.datetime(1976, 3, 5, 0, 0, 1),
datetime.datetime(1983, 7, 9, 17, 17, 34),
datetime.datetime(2054, 6, 20, 14, 31, 45),
datetime.datetime(2000, 10, 31, 11, 50, 23)]
tempcsv.seek(0)
with pytest.warns(MatplotlibDeprecationWarning):
array = mlab.csv2rec(tempcsv, names='a', **kwargs)
assert_array_equal(array['a'].tolist(), expected)
示例6: plotClosePrice
# 需要导入模块: from matplotlib import mlab [as 别名]
# 或者: from matplotlib.mlab import csv2rec [as 别名]
def plotClosePrice(plt, stock_name, stock_code, dataPath):
fh = open(dataPath + '\\' + stock_code +".csv", 'r')
r = mlab.csv2rec(fh); fh.close()
r.sort()
prices = r.adj_close
plt.plot(r.date, prices)
#收盘价走势及小波处理