MCPcopy Index your code
hub / github.com/pathwaycom/pathway / test_flatten

Function test_flatten

python/pathway/tests/test_common.py:1002–1024  ·  view source on GitHub ↗
(dtype: Any)

Source from the content-addressed store, hash-verified

1000
1001@pytest.mark.parametrize("dtype", [np.int64, np.float64])
1002def test_flatten(dtype: Any):
1003 df = pd.DataFrame(
1004 {
1005 "array": [
1006 np.array([1, 2], dtype=dtype),
1007 np.array([], dtype=dtype),
1008 np.array([3, 4], dtype=dtype),
1009 np.array([10, 11, 12], dtype=dtype),
1010 np.array([4, 5, 6, 1, 2], dtype=dtype),
1011 ],
1012 "other": [-1, -2, -3, -4, -5],
1013 }
1014 )
1015 expected_df = pd.DataFrame(
1016 {
1017 "array": np.array([1, 2, 3, 4, 10, 11, 12, 4, 5, 6, 1, 2], dtype=dtype),
1018 "other": [-1, -1, -3, -3, -4, -4, -4, -5, -5, -5, -5, -5],
1019 }
1020 )
1021 t1 = table_from_pandas(df)
1022 t1 = t1.flatten(t1.array)
1023 expected = table_from_pandas(expected_df)
1024 assert_table_equality_wo_index(t1, expected)
1025
1026
1027@pytest.mark.parametrize("dtype", [np.int64, np.float64])

Callers

nothing calls this directly

Calls 2

table_from_pandasFunction · 0.90
flattenMethod · 0.80

Tested by

no test coverage detected