MCPcopy Index your code
hub / github.com/dmlc/dgl / _test_DefaultDataParser

Function _test_DefaultDataParser

tests/python/common/data/test_data.py:758–791  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

756
757
758def _test_DefaultDataParser():
759 # common csv
760 num_nodes = 5
761 num_labels = 3
762 num_dims = 2
763 node_id = np.arange(num_nodes)
764 label = np.random.randint(num_labels, size=num_nodes)
765 feat = np.random.rand(num_nodes, num_dims)
766 df = pd.DataFrame(
767 {
768 "node_id": node_id,
769 "label": label,
770 "feat": [line.tolist() for line in feat],
771 }
772 )
773
774 dt = _get_data_table(df)
775 assert np.array_equal(node_id, dt["node_id"])
776 assert np.array_equal(label, dt["label"])
777 assert np.array_equal(feat, dt["feat"])
778
779 # string consists of non-numeric values
780 df = pd.DataFrame({"label": ["a", "b", "c"]})
781 expect_except = False
782 try:
783 _get_data_table(df)
784 except:
785 expect_except = True
786 assert expect_except
787
788 # csv has index column which is ignored as it's unnamed
789 df = pd.DataFrame({"label": [1, 2, 3]})
790 dt = _get_data_table(df, True)
791 assert len(dt) == 1
792
793
794def _test_load_yaml_with_sanity_check():

Callers 1

test_csvdatasetFunction · 0.85

Calls 1

_get_data_tableFunction · 0.85

Tested by

no test coverage detected