[770c98]: / Tests / test_calibration_upperbody.any

Download this file

111 lines (75 with data), 3.3 kB

//fatal_warnings = True
//ignore_errors = [
//    "Muscle without strength  :  The muscle is unrealistically long or short",
//    "Close to singular position",
//    "Muscle calibration :  Insufficient Lmt interval",
//    "The tendon/fiber length was calibrated but with issues",
//    "'Set Value' operation on this value-object has broken symbolic dependency",
//    "Calibration operation has broken one or more symbolic dependencies",
//]
//define = (
//   [
//    {'BM_CALIBRATION_TYPE':'1'},
//    {'BM_CALIBRATION_TYPE':'2'},
//   ]
//)
//
#include "libdef.any"

#ifndef TEST_NAME
  #define BM_CALIBRATION_TYPE 2
  #define TEST_NAME "test_calibration_upperbody.any_1"
#endif


#define BM_ARM_SHOULDER_RHYTHM ON

#define BM_ARM_MUSCLES_RIGHT _MUSCLES_3E_HILL_
#define BM_ARM_MUSCLES_LEFT _MUSCLES_3E_HILL_

#define BM_TRUNK_LUMBAR_LIGAMENTS OFF
#define BM_TRUNK_CERVICAL_MUSCLES OFF

#define BM_LEG_LEFT OFF
#define BM_LEG_RIGHT OFF



Main = 
{
  #include "<ANYBODY_PATH_BODY>/HumanModel.any"  

  AnyOperation& RunTest = Main.HumanModel.Calibration.CalibrationSequence;

  AnyObjectPtrArray muscles_from_cal_studies = unique(flattenptr(ObjSearchRecursive(&Main.HumanModel.Calibration, "MuscleArr")));
  AnyObjectPtrArray muscles_right = unique(flattenptr(ObjSearchRecursive(&Main.HumanModel.BodyModel.Right.ShoulderArm.Mus, "*", "AnyMuscle")));
  AnyObjectPtrArray muscles_left = unique(flattenptr(ObjSearchRecursive(&Main.HumanModel.BodyModel.Left.ShoulderArm.Mus, "*", "AnyMuscle")));
  AnyObjectPtrArray muscles_from_model = arrcat(muscles_right, muscles_left);
  
  AnyInt test_all_mus_in_cal = expect(
    eqfun(
      NumElemOf(muscles_from_cal_studies),
      NumElemOf(muscles_from_model)
    ),
    "The number of muscles in the calibration studies do not match the number of muscles in the model!"
  );
};




/*

# Test Documentation: 

The test framework pytest is used to run tests. 

Test files are identified by prefixing `test_` to the file names. Such files 
will be collected automatically by the Pytest framework.

To run the test type the following at the command prompt:

> pytest


## Test specifications

The first part of the `test_xxx.any` can include specifications for the test framework. 
Things such as define and part statements or certain errors to ignore.

The specification section must be commented with //. The test will execute that part of 
the file as python code. So the code must be valid python code except for the leading //


### Specifying define statements:

The following specifications are supported:

* define 
* path
* expected_errors
* ignore_errors 
* expect_errors


// Note. Since this test example include a main file from another
// application it also alters the ANYBODY_PATH_MAINFILEDIR and 
// ANYBODY_PATH_MAINFILE preprocessor flags. 
//
// If these flags are important to the model they must be mocked by the
// test framework. This can be done by adding the following test directives
// to the top of the test file.


## 

//path = {'ANYBODY_PATH_MAINFILEDIR':'../Application/Examples/StandingModel',
//        'ANYBODY_PATH_MAINFILE':'../Application/Examples/StandingModel/StandingModel.Main.any' }
//

*/