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

Function test_assembler_calibration

tests/test_inferenceutils.py:277–301  ·  view source on GitHub ↗
(real_assemblies)

Source from the content-addressed store, hash-verified

275
276
277def test_assembler_calibration(real_assemblies):
278 with open(os.path.join(TEST_DATA_DIR, "trimouse_full.pickle"), "rb") as file:
279 data = pickle.load(file)
280 ass = inferenceutils.Assembler(data, max_n_individuals=3, n_multibodyparts=12)
281 ass.calibrate(os.path.join(TEST_DATA_DIR, "trimouse_calib.h5"))
282 assert ass._kde is not None
283 assert ass.safe_edge
284
285 assembly = real_assemblies[0][0]
286 mahal, proba = ass.calc_assembly_mahalanobis_dist(assembly, return_proba=True)
287 assert np.isclose(mahal, 19.541, atol=1e-3)
288 assert np.isclose(proba, 1, atol=1e-3)
289
290 j1 = inferenceutils.Joint(tuple(assembly.xy[0]), label=0)
291 j2 = inferenceutils.Joint(tuple(assembly.xy[1]), label=1)
292 link = inferenceutils.Link(j1, j2)
293 p = ass.calc_link_probability(link)
294 assert np.isclose(p, 0.993, atol=1e-3)
295
296 # Test empty assembly
297 assembly_ = deepcopy(assembly)
298 assembly_.data[:, :2] = np.nan
299 mahal, proba = ass.calc_assembly_mahalanobis_dist(assembly_, return_proba=True)
300 assert np.isinf(mahal)
301 assert proba == 0
302
303
304def test_find_outlier_assemblies(real_assemblies):

Callers

nothing calls this directly

Calls 4

calibrateMethod · 0.95
calc_link_probabilityMethod · 0.95
loadMethod · 0.80

Tested by

no test coverage detected