Python matplotlib.mlab.csv2rec() Examples
The following are 12
code examples of matplotlib.mlab.csv2rec().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
matplotlib.mlab
, or try the search function
.
Example #1
Source File: test_mlab.py From neural-network-animation with MIT License | 6 votes |
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'])
Example #2
Source File: test_mlab.py From ImageFusion with MIT License | 6 votes |
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'])
Example #3
Source File: test_mlab.py From twitter-stock-recommendation with MIT License | 6 votes |
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'])
Example #4
Source File: test_mlab.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 5 votes |
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'])
Example #5
Source File: test_mlab.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 5 votes |
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
Example #6
Source File: test_mlab.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 5 votes |
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)
Example #7
Source File: plot.py From stock with Apache License 2.0 | 5 votes |
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) #收盘价走势及小波处理
Example #8
Source File: test_mlab.py From coffeegrindsize with MIT License | 5 votes |
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'])
Example #9
Source File: test_mlab.py From coffeegrindsize with MIT License | 5 votes |
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
Example #10
Source File: test_mlab.py From coffeegrindsize with MIT License | 5 votes |
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)
Example #11
Source File: test_mlab.py From twitter-stock-recommendation with MIT License | 5 votes |
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
Example #12
Source File: test_mlab.py From twitter-stock-recommendation with MIT License | 5 votes |
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)