MCPcopy Index your code
hub / github.com/DeepLabCut/DeepLabCut / test_format_training_data

Function test_format_training_data

tests/test_trainingsetmanipulation.py:57–73  ·  view source on GitHub ↗
(monkeypatch)

Source from the content-addressed store, hash-verified

55
56
57def test_format_training_data(monkeypatch):
58 fake_shape = 3, 480, 640
59 monkeypatch.setattr(
60 trainingsetmanipulation,
61 "read_image_shape_fast",
62 lambda _: fake_shape,
63 )
64 df = pd.read_hdf(os.path.join(TEST_DATA_DIR, "trimouse_calib.h5")).xs("mus1", level="individuals", axis=1)
65 guarantee_multiindex_rows(df)
66 train_inds = list(range(10))
67 _, data = format_training_data(df, train_inds, 12, "")
68 assert len(data) == len(train_inds)
69 # Check data comprise path, shape, and xy coordinates
70 assert all(len(d) == 3 for d in data)
71 assert all((d[0].size == 3 and d[0].dtype.char == "U" and d[0][0, -1].endswith(".png")) for d in data)
72 assert all(np.all(d[1] == np.array(fake_shape)[None]) for d in data)
73 assert all((d[2][0, 0].shape[1] == 3 and d[2][0, 0].dtype == np.int64) for d in data)
74
75
76def test_format_multianimal_training_data(monkeypatch):

Callers

nothing calls this directly

Calls 2

format_training_dataFunction · 0.90

Tested by

no test coverage detected