Ejemplo n.º 1
0
def test_ContinuoustoCategory_chained_float_fixed():
    nc = 6
    nr = 1000000
    delta = 0.1
    farr = np.arange(0, (nr * delta * nc), delta, dtype=float).reshape(nr, nc)
    toDataFrame(farr, labels=[]).toContinuousCategory(quantile=False,
                                                      nbin=3,
                                                      drop=False)
Ejemplo n.º 2
0
def test_toDatetimeComponents_make_4feature():
    from datetime import datetime, timedelta

    darr = np.arange(datetime(1751, 7, 1), datetime(2015, 7, 1),
                     timedelta(days=1)).reshape(24106, 4)
    rc = 24106
    cc = 52
    assert toDataFrame(
        darr, labels=[]).toDatetimeComponents(inplace=False).shape == (rc, cc)
Ejemplo n.º 3
0
def test_toDataFrame_csr_kinky():
    r = 3
    c = 3
    indptr = np.array([0, 2, 3, 6])
    indices = np.array([0, 2, 2, 0, 1, 2])
    data = np.array([1, 2, 3, 4, 5, 6])
    csr = scipy.sparse.csr_matrix((data, indices, indptr),
                                  shape=(3, 3)).todense()
    assert toDataFrame(csr, labels=[]).toDataFrame().shape == (r, c)
Ejemplo n.º 4
0
def test_toDatetimeComponents_make_1feature():
    from datetime import datetime, timedelta

    rc = 94598
    cc = 1
    acc = 13
    darr = np.arange(datetime(1751, 7, 1), datetime(2010, 7, 1),
                     timedelta(days=1)).reshape(rc, cc)
    assert toDataFrame(
        darr, labels=[]).toDatetimeComponents(inplace=False).shape == (rc, acc)
Ejemplo n.º 5
0
def test_2d_named_kinky(X, cnv):
    assert toDataFrame(X, labels=cnv).toDataFrame().columns[2] == cnv[2]
Ejemplo n.º 6
0
def test_2d_named_too_many_args(X, cnv):
    with pytest.raises(TypeError):
        toDataFrame(X, cnv, cnv, X, 5, 6).columns[2] == cnv[2]
Ejemplo n.º 7
0
def test_toDataFrame_list_1d():
    assert len(toDataFrame([[1, 2, 3]]).columns) == 3
Ejemplo n.º 8
0
def test_df_labels_set(X, cnv):
    assert (toDataFrame(pd.DataFrame(X, columns=cnv),
                        labels=cnv).columns == cnv).all()
Ejemplo n.º 9
0
def test_3dArray_numpy(X):
    with pytest.raises(ValueError):
        toDataFrame(np.reshape(X, (-1, -1, 1)))
Ejemplo n.º 10
0
def test_Class_init_BadArg():
    with pytest.raises(TypeError):
        toDataFrame(fred=1)
Ejemplo n.º 11
0
def test_toDataFrame_series():
    r = 100
    c = 1
    arr = np.ndarray(shape=(r), dtype=float, order="F")
    s = pd.Series(arr)
    assert toDataFrame(s, labels=[]).shape == (r, c)
Ejemplo n.º 12
0
def test_toDataFrame_array3d_error():
    r = 100
    c = 10
    arr = np.ndarray(shape=(2, r, c), dtype=float, order="F")
    with pytest.raises(PasoError):
        assert toDataFrame(arr, labels=[]).shape == (r, c)
Ejemplo n.º 13
0
def test_toDataFrame_array():
    r = 100
    c = 10
    arr = np.ndarray(shape=(r, c), dtype=float, order="F")
    assert toDataFrame(arr).shape == (r, c)
Ejemplo n.º 14
0
def test_toDataFrame_list_2d():
    assert toDataFrame([[1, 2, 3], [4, 5, 5]]).shape == (2, 3)
Ejemplo n.º 15
0
def test_Blank_Arg_Transform():
    with pytest.raises(TypeError):
        toDataFrame()
Ejemplo n.º 16
0
def test_Empty_list_Arg_Transform():
    with pytest.raises(PasoError):
        toDataFrame([])
Ejemplo n.º 17
0
def test_2d_numpy_labels_method_(X, cn):
    assert toDataFrame(X, labels=cn).toDataFrame().columns[1] == "k"
Ejemplo n.º 18
0
def test_ContinuoustoCategory_chained_float_unique_1_ERROR():
    farr = np.ndarray(shape=(1000000, 4), dtype=float, order="F")
    with pytest.raises(IndexError):
        toDataFrame(farr, labels=[]).toContinuousCategory(drop=False)
Ejemplo n.º 19
0
def test_2d_numpy_labels_default(X, cn):
    assert toDataFrame(X).columns[1] == "c_1"
Ejemplo n.º 20
0
def test_1d_numpy_bad_arg(y, cn):
    with pytest.raises(PasoError):
        toDataFrame(y)
Ejemplo n.º 21
0
def test_toDataFrame_list():
    assert len(toDataFrame([1, 2, 3], labels=[]).columns) == 1