Python matplotlib.mlab.rec2csv() Examples

The following are 10 code examples of matplotlib.mlab.rec2csv(). 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 vote down vote up
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 vote down vote up
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 vote down vote up
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 neural-network-animation with MIT License 5 votes vote down vote up
def test_rec2csv_bad_shape_ValueError(self):
        bad = np.recarray((99, 4), [(str('x'), np.float),
                                    (str('y'), np.float)])

        # the bad recarray should trigger a ValueError for having ndim > 1.
        assert_raises(ValueError, mlab.rec2csv, bad, self.fd) 
Example #5
Source File: test_mlab.py    From python3_ios with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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 #6
Source File: test_mlab.py    From python3_ios with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_rec2csv_bad_shape_ValueError(tempcsv):
    bad = np.recarray((99, 4), [('x', float), ('y', float)])

    # the bad recarray should trigger a ValueError for having ndim > 1.
    with pytest.warns(MatplotlibDeprecationWarning):
        with pytest.raises(ValueError):
            mlab.rec2csv(bad, tempcsv) 
Example #7
Source File: test_mlab.py    From ImageFusion with MIT License 5 votes vote down vote up
def test_rec2csv_bad_shape_ValueError(self):
        bad = np.recarray((99, 4), [(str('x'), np.float),
                                    (str('y'), np.float)])

        # the bad recarray should trigger a ValueError for having ndim > 1.
        assert_raises(ValueError, mlab.rec2csv, bad, self.fd) 
Example #8
Source File: test_mlab.py    From coffeegrindsize with MIT License 5 votes vote down vote up
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 vote down vote up
def test_rec2csv_bad_shape_ValueError(tempcsv):
    bad = np.recarray((99, 4), [('x', float), ('y', float)])

    # the bad recarray should trigger a ValueError for having ndim > 1.
    with pytest.warns(MatplotlibDeprecationWarning):
        with pytest.raises(ValueError):
            mlab.rec2csv(bad, tempcsv) 
Example #10
Source File: test_mlab.py    From twitter-stock-recommendation with MIT License 5 votes vote down vote up
def test_rec2csv_bad_shape_ValueError(tempcsv):
    bad = np.recarray((99, 4), [(str('x'), float),
                                (str('y'), float)])

    # the bad recarray should trigger a ValueError for having ndim > 1.
    with pytest.warns(MatplotlibDeprecationWarning):
        with pytest.raises(ValueError):
            mlab.rec2csv(bad, tempcsv)