當前位置: 首頁>>代碼示例>>Python>>正文


Python mlab.rec2csv方法代碼示例

本文整理匯總了Python中matplotlib.mlab.rec2csv方法的典型用法代碼示例。如果您正苦於以下問題:Python mlab.rec2csv方法的具體用法?Python mlab.rec2csv怎麽用?Python mlab.rec2csv使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在matplotlib.mlab的用法示例。


在下文中一共展示了mlab.rec2csv方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_recarray_csv_roundtrip

# 需要導入模塊: from matplotlib import mlab [as 別名]
# 或者: from matplotlib.mlab import rec2csv [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']) 
開發者ID:miloharper,項目名稱:neural-network-animation,代碼行數:20,代碼來源:test_mlab.py

示例2: test_recarray_csv_roundtrip

# 需要導入模塊: from matplotlib import mlab [as 別名]
# 或者: from matplotlib.mlab import rec2csv [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']) 
開發者ID:alvarobartt,項目名稱:twitter-stock-recommendation,代碼行數:20,代碼來源:test_mlab.py

示例3: test_rec2csv_bad_shape_ValueError

# 需要導入模塊: from matplotlib import mlab [as 別名]
# 或者: from matplotlib.mlab import rec2csv [as 別名]
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) 
開發者ID:miloharper,項目名稱:neural-network-animation,代碼行數:8,代碼來源:test_mlab.py

示例4: test_recarray_csv_roundtrip

# 需要導入模塊: from matplotlib import mlab [as 別名]
# 或者: from matplotlib.mlab import rec2csv [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']) 
開發者ID:holzschu,項目名稱:python3_ios,代碼行數:17,代碼來源:test_mlab.py

示例5: test_rec2csv_bad_shape_ValueError

# 需要導入模塊: from matplotlib import mlab [as 別名]
# 或者: from matplotlib.mlab import rec2csv [as 別名]
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) 
開發者ID:holzschu,項目名稱:python3_ios,代碼行數:9,代碼來源:test_mlab.py

示例6: test_rec2csv_bad_shape_ValueError

# 需要導入模塊: from matplotlib import mlab [as 別名]
# 或者: from matplotlib.mlab import rec2csv [as 別名]
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) 
開發者ID:alvarobartt,項目名稱:twitter-stock-recommendation,代碼行數:10,代碼來源:test_mlab.py


注:本文中的matplotlib.mlab.rec2csv方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。