test_ctvs.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. from common import initialize_test_yml_list_measurement
  2. from view import VIEW
  3. from view.python_core import ctvs
  4. from view.python_core.overviews import generate_overview_frame
  5. import inspect
  6. import pathlib as pl
  7. import numpy as np
  8. def ctv_signatures_test():
  9. """
  10. Check if signatures of all csv functions are equal
  11. """
  12. ctv_funcs = [x for x in inspect.getmembers(ctvs) if callable(x)]
  13. for ctv_func in ctv_funcs[1:]:
  14. assert inspect.signature(ctv_func) == inspect.signature(ctv_funcs[0])
  15. def check_ctv_generic(ctv_method):
  16. test_yml, test_animal, test_measu = initialize_test_yml_list_measurement()
  17. view = VIEW()
  18. view.update_flags_from_ymlfile(test_yml)
  19. view.update_flags({"CTV_Method": ctv_method, "SO_Method": 0})
  20. view.load_measurement_data(test_animal, test_measu)
  21. view.calculate_signals()
  22. overview_frames = generate_overview_frame(flags=view.flags, p1=view.p1)
  23. overview = overview_frames[0, :, :]
  24. expected_overview_fle_path = \
  25. pl.Path(view.flags["STG_MotherOfAllFolders"]) / "test_files" / f"ctv{ctv_method}_expected.npz"
  26. expected_overview = np.load(str(expected_overview_fle_path))["expected_overview"]
  27. assert np.allclose(overview, expected_overview)
  28. def test_ctv_22():
  29. """
  30. Testing CTV 22 with FakeData
  31. """
  32. check_ctv_generic(22)
  33. def test_ctv_35():
  34. """
  35. Testing CTV 35 with FakeData
  36. """
  37. check_ctv_generic(35)
  38. if __name__ == '__main__':
  39. test_ctv_35()