Configuration files (Python)

Crowd and agents setup

Bideltoid breadth computation

Unit tests for the compute_bideltoid_breadth_from_multipolygon function.

Test cases cover:
  • Simple MultiPolygon with a known maximum horizontal breadth.

  • Centroid shift of the polygon (should not affect the breadth).

  • MultiPolygon containing two separated polygons.

  • Non-MultiPolygon input (should raise ValueError).

  • Degenerate case: all points vertically aligned (breadth zero).

  • Irregular polygon where the maximum horizontal breadth is not between endpoints.

test_compute_bideltoid_breadth_from_multipolygon.test_simple_horizontal_rectangle()[source]

Test a single rectangle MultiPolygon where the breadth is the rectangle's width.

Return type:

None

test_compute_bideltoid_breadth_from_multipolygon.test_breadth_includes_centroid_shift()[source]

Test that centroid shift (with respect to the Polygon of the first test) does not affect the result.

Return type:

None

test_compute_bideltoid_breadth_from_multipolygon.test_two_rectangles_same_y()[source]

Test two rectangles side by side, breadth should be distance between farthest points at same y.

Return type:

None

test_compute_bideltoid_breadth_from_multipolygon.test_single_point_vertical_line()[source]

All points have the same x, so breadth should be zero.

Return type:

None

test_compute_bideltoid_breadth_from_multipolygon.test_non_multipolygon_input()[source]

Should raise ValueError for non-MultiPolygon input.

Return type:

None

test_compute_bideltoid_breadth_from_multipolygon.test_irregular_shape()[source]

Test an irregular polygon where the max horizontal distance is not between endpoints.

Return type:

None

Chest depth computation

Unit tests for the compute_chest_depth_from_multipolygon function.

Tests cover:
  • Simple MultiPolygon with known vertical depth

  • MultiPolygon with two separated polygons

  • Degenerate case: all points on a horizontal line (depth zero)

  • Non-MultiPolygon input (error)

  • Centroid shift invariance

  • Irregular shape with known max vertical distance at similar x

test_compute_chest_depth_from_multipolygon.test_simple_vertical_rectangle()[source]

Test a single rectangle MultiPolygon where the chest depth is the rectangle's height.

Return type:

None

test_compute_chest_depth_from_multipolygon.test_two_rectangles_same_x()[source]

Test two rectangles stacked vertically, depth should be distance between farthest points at same x.

Return type:

None

test_compute_chest_depth_from_multipolygon.test_single_point_horizontal_line()[source]

All points have the same y, so depth should be zero.

Return type:

None

test_compute_chest_depth_from_multipolygon.test_non_multipolygon_input()[source]

Should raise ValueError for non-MultiPolygon input.

Return type:

None

test_compute_chest_depth_from_multipolygon.test_depth_includes_centroid_shift()[source]

Test that centroid shift (with respect to the Polygon of the first test) does not affect the result.

Return type:

None

test_compute_chest_depth_from_multipolygon.test_irregular_shape()[source]

Test an irregular polygon where the max vertical distance is not between endpoints.

Return type:

None

Moment of inertia computation

Unit tests for the compute_moment_of_inertia function.

Tests cover:
  • Correct computation for simple polygons (square)

  • Handling of MultiPolygon geometries

  • Zero and negative weight values

  • Invalid geometry type validation

  • Area scaling consistency

  • Mass distribution in composite geometries

test_compute_moment_of_inertia.test_square_polygon()[source]

Test moment of inertia for a unit square at origin.

Return type:

None

test_compute_moment_of_inertia.test_multipolygon_sum()[source]

Test that MultiPolygon sums the moments of the components.

Return type:

None

test_compute_moment_of_inertia.test_zero_weight()[source]

Test that zero weight returns zero moment.

Return type:

None

test_compute_moment_of_inertia.test_negative_weight()[source]

Test that negative weight returns negative moment.

Return type:

None

test_compute_moment_of_inertia.test_invalid_geometry_type()[source]

Test that invalid geometry raises TypeError.

Return type:

None

test_compute_moment_of_inertia.test_scaling_with_area()[source]

Test that scaling the polygon scales the moment of inertia by area^2.

Return type:

None

Rotation

Unit tests for the rotate_vectors function.

Tests cover:
  • Rotation accuracy for standard angles (0°, 90°, 180°, 270°)

  • Non-integer and negative angle values

  • Empty dictionary handling

  • Multiple vector transformations in single operation

  • Input immutability verification

  • Error handling for invalid vector formats

test_rotate_vectors.vectors_close(vec1, vec2, tol=1e-08)[source]

Help function to compare two 2D vectors for approximate equality.

Parameters:
Returns:

True if the vectors are approximately equal, False otherwise.

Return type:

bool

test_rotate_vectors.test_rotate_0_degrees()[source]

Test rotation by 0 degrees (should return original vectors).

Return type:

None

test_rotate_vectors.test_rotate_90_degrees()[source]

Test rotation by 90 degrees.

Return type:

None

test_rotate_vectors.test_rotate_180_degrees()[source]

Test rotation by 180 degrees.

Return type:

None

test_rotate_vectors.test_rotate_270_degrees()[source]

Test rotation by 270 degrees (or -90 degrees).

Return type:

None

test_rotate_vectors.test_rotate_negative_angle()[source]

Test rotation by a negative angle.

Return type:

None

test_rotate_vectors.test_rotate_non_integer_angle()[source]

Test rotation by a non-integer angle.

Return type:

None

test_rotate_vectors.test_rotate_empty_dict()[source]

Test rotating an empty dictionary.

Return type:

None

test_rotate_vectors.test_multiple_vectors()[source]

Test rotating multiple vectors.

Return type:

None

test_rotate_vectors.test_input_not_modified()[source]

Test that input dictionary is not modified in place.

Return type:

None

test_rotate_vectors.test_invalid_vector_format()[source]

Test that invalid vector format (not a tuple of two floats) raises an error.

Return type:

None

Unit tests for the wrap_angle function.

Tests cover:
  • Canonical angles (0, 180, -180, 360, -360, 720, -720)

  • Angles just outside the bounds

  • Negative and positive values

  • Large and small angles

  • Floating point precision

test_wrap_angle.test_zero_angle()[source]

Test that 0 degrees wraps to 0.

Return type:

None

test_wrap_angle.test_positive_angles()[source]

Test wrapping of positive angles.

Return type:

None

test_wrap_angle.test_negative_angles()[source]

Test wrapping of negative angles.

Return type:

None

test_wrap_angle.test_angles_just_outside_bounds()[source]

Test angles just outside the -180 and 180 bounds.

Return type:

None

test_wrap_angle.test_large_angles()[source]

Test very large positive and negative angles.

Return type:

None

test_wrap_angle.test_floating_point_precision()[source]

Test floating point precision edge case.

Return type:

None

Unit tests for Agent rotation.

Tests cover:
  • Initial orientation state validation

  • 2D shape positioning accuracy during rotation

  • 2D 3D centroid position invariance under rotation

test_rotation.agent()[source]

Fixture to create an Agent instance for testing.

Returns:

An instance of Agent with predefined type and measures.

Return type:

Agent

test_rotation.test_initial_orientation(agent)[source]

Test that the initial orientation of the agent is 90 degrees.

Parameters:

agent (Agent) -- The agent fixture.

Return type:

None

test_rotation.test_shapes2d_center_y(agent)[source]

Test that the y-coordinates of each 2D shape center are close to 0.0.

Parameters:

agent (Agent) -- The agent fixture.

Return type:

None

test_rotation.test_rotation_and_shapes2d_center_x(agent)[source]

Test that after rotating the agent by -90°, the orientation is -90 and the x-coordinates of each 2D shape center are close to -90.

Parameters:

agent (Agent) -- The agent fixture.

Return type:

None

test_rotation.test_center_of_mass_invariance_on_rotation(agent)[source]

Test that the center of mass does not change after rotation.

Parameters:

agent (Agent) -- The agent fixture.

Return type:

None

test_rotation.test_centroid_body3d_invariance_on_rotation(agent)[source]

Test that the 3D centroid of the body does not change after rotation.

Parameters:

agent (Agent) -- The agent fixture.

Return type:

None

Translation

Unit tests for Agent translation mechanics across dimensional spaces.

Tests cover:
  • Agent's initial position is set correctly

  • Agent's position is correctly updated after translation of the 2D shapes in x and y directions

  • Agent's 3D body centroid is correctly updated after translation in x and y directions

  • Agent's 3D body centroid and lowest height are correctly updated after translation in z direction

test_translation.agent()[source]

Fixture to create an Agent instance for testing.

Returns:

An instance of Agent with predefined type and measures.

Return type:

Agent

test_translation.test_initial_position(agent)[source]

Test that the agent's initial position is set correctly.

Parameters:

agent (Agent) -- The agent fixture.

Return type:

None

test_translation.test_translate_position(agent)[source]

Test that the agent's position is correctly updated after translation of the 2D shapes.

Parameters:

agent (Agent) -- The agent fixture.

Return type:

None

test_translation.test_translate_body3d_xy(agent)[source]

Test that the agent's 3D body centroid is correctly updated after translation in x and y.

Parameters:

agent (Agent) -- The agent fixture.

Return type:

None

test_translation.test_translate_body3d_z(agent)[source]

Test that the agent's 3D body centroid and lowest altitude are correctly updated after translation in z.

Parameters:

agent (Agent) -- The agent fixture.

Return type:

None

Single agent

Unit tests for the measuring methods of Agent 2D and 3D shapes.

Tests cover:
  • Correctness of 2D measurements (chest depth, bideltoid breadth) under rotation and translation

  • Correctness of 3D measurements (height, chest depth, bideltoid breadth) under rotation and translation

  • Validation of the smallest 3D height value after transformations

  • Consistency of measurements after multiple geometric operations

test_measuring_agent.agent()[source]

Fixture to create an Agent instance for testing.

Returns:

An instance of Agent with predefined type and measures.

Return type:

Agent

test_measuring_agent.test_shapes2d_chest_depth(agent)[source]

Test that the 2D chest depth is correct.

Parameters:

agent (Agent) -- The agent fixture.

Return type:

None

test_measuring_agent.test_shapes2d_bideltoid_breadth(agent)[source]

Test that the 2D bideltoid breadth is correct.

Parameters:

agent (Agent) -- The agent fixture.

Return type:

None

test_measuring_agent.test_shapes3d_height(agent)[source]

Test that the 3D height is correct (in centimeters).

Parameters:

agent (Agent) -- The agent fixture.

Return type:

None

test_measuring_agent.test_shapes3d_smallest_height(agent)[source]

Test that the smallest height in the 3D shapes is 0.0.

Parameters:

agent (Agent) -- The agent fixture.

Return type:

None

test_measuring_agent.test_shapes3d_bideltoid_and_chest_depth(agent)[source]

Test that the 3D bideltoid breadth and chest depth are correct (in centimeters).

Parameters:

agent (Agent) -- The agent fixture.

Return type:

None

Crowd with custom statistics

Unit tests for the Crowd class configuration and statistical validation.

Tests cover:
  • Agent population initialization count

  • Anthropometric statistic validation (means, proportions)

test_crowd_with_custom_statistics.crowd()[source]

Fixture to create a Crowd instance with predefined measures and agents.

Returns:

An instance of Crowd with agents created and packed.

Return type:

Crowd

test_crowd_with_custom_statistics.test_crowd_number_of_agents(crowd)[source]

Test that the crowd contains the expected number of agents.

Parameters:

crowd (Crowd) -- The crowd fixture.

Return type:

None

test_crowd_with_custom_statistics.test_crowd_statistics_means_and_proportion(crowd)[source]

Test that measured crowd statistics are close to the expected values.

Parameters:

crowd (Crowd) -- The crowd fixture.

Return type:

None

Backup

Utilitary functions

Unit tests for the from_string_to_tuple function.

Tests cover:
  • Valid string inputs (with and without parentheses, extra spaces, negative numbers, scientific notation)

  • Handling of leading/trailing whitespace

  • Invalid inputs (non-string, wrong number of elements, non-numeric values, empty string)

  • Error message validation for incorrect formats

test_from_string_to_tuple.test_valid_input_no_parentheses()[source]

Test valid input without parentheses.

Return type:

None

test_from_string_to_tuple.test_valid_input_with_parentheses()[source]

Test valid input with parentheses.

Return type:

None

test_from_string_to_tuple.test_valid_input_with_spaces()[source]

Test valid input with extra spaces.

Return type:

None

test_from_string_to_tuple.test_valid_input_negative_numbers()[source]

Test valid input with negative numbers.

Return type:

None

test_from_string_to_tuple.test_valid_input_scientific_notation()[source]

Test valid input with scientific notation.

Return type:

None

test_from_string_to_tuple.test_invalid_input_not_a_string()[source]

Test that non-string input raises ValueError.

Return type:

None

test_from_string_to_tuple.test_invalid_input_wrong_number_of_elements()[source]

Test that input with wrong number of elements raises ValueError.

Return type:

None

test_from_string_to_tuple.test_invalid_input_non_numeric()[source]

Test that non-numeric elements raise ValueError.

Return type:

None

test_from_string_to_tuple.test_invalid_input_empty_string()[source]

Test that empty string raises ValueError.

Return type:

None

test_from_string_to_tuple.test_valid_input_trailing_comma_spaces()[source]

Test input with trailing and leading whitespace and parentheses.

Return type:

None

Materials parameters

Test the loading and saving of material parameters in XML format.

test_backup_materials.materials_dict()[source]

Fixture to provide material parameters for testing.

Returns:

A dictionary containing material parameters, including intrinsic properties and binary contact properties between different materials.

Return type:

MaterialsDataType

test_backup_materials.test_materials_dict_to_xml_and_back(materials_dict_fixture, tmp_path, request)[source]

Test the loading and saving of material parameters in XML format.

This test converts a dictionary to XML, saves it to a temporary file, reads it back, and ensures that the parsed dictionary matches the original.

Parameters:
  • materials_dict_fixture (MaterialsDataType) -- A fixture containing material parameters for testing.

  • tmp_path (Path) -- A temporary directory provided by pytest for file operations.

  • request (SubRequest) -- The pytest request object used to access fixtures.

Return type:

None

Boundaries parameters

Test the loading and saving of boundaries parameters in XML format.

test_backup_boundaries.boundaries_dict_two_walls()[source]

Provide a fixture containing boundary data for a geometry with two walls.

Returns:

A dictionary representing the geometry data, including dimensions and wall properties such as material ID and corner coordinates.

Return type:

GeometryDataType

test_backup_boundaries.boundaries_dict_one_wall()[source]

Provide a fixture containing boundary data for a geometry with one wall.

Returns:

A dictionary representing the geometry data, including dimensions and wall properties such as material ID and corner coordinates.

Return type:

GeometryDataType

test_backup_boundaries.test_geometry_dict_to_xml_and_back(boundaries_dict, tmp_path, request)[source]

Test the loading and saving of boundaries parameters in XML format.

Parameters:
  • boundaries_dict (GeometryDataType) -- A dictionary representing the geometry data, including dimensions and wall properties such as material ID and corner coordinates.

  • tmp_path (Path) -- Temporary directory for XML file storage.

  • request (SubRequest) -- The pytest request object used to access fixtures.

Return type:

None

Static parameters

Test the loading and saving of static parameters for pedestrians in XML format.

test_backup_static.crowd_static_dict()[source]

Fixture to provide static parameters for pedestrians.

Returns:

A dictionary containing static parameters for two pedestrians.

Return type:

StaticCrowdDataType

test_backup_static.test_static_parameters_pedestrians_dict_to_xml_and_back(crowd_static_dict_fixture, tmp_path, request)[source]

Test the loading and saving of static parameters for pedestrians in XML format.

This test converts a dictionary to XML format, saves it to a temporary file, reads it back from the file, and ensures that the parsed dictionary matches the original.

Parameters:
  • crowd_static_dict_fixture (StaticCrowdDataType) -- A fixture providing static parameters for pedestrians.

  • tmp_path (Path) -- A pytest fixture providing a temporary directory for file operations.

  • request (SubRequest) -- The pytest request object used to access fixtures.

Return type:

None

Dynamic parameters

Test the loading and saving of dynamic parameters in XML format.

test_backup_dynamic.dynamical_parameters_crowd()[source]

Fixture to provide dynamic parameters for the crowd.

Returns:

A dictionary containing dynamic parameters for two agents.

Return type:

DynamicCrowdDataType

test_backup_dynamic.test_dynamic_parameters_dict_to_xml_and_back(dynamical_parameters_crowd_dict, tmp_path, request)[source]

Test the loading and saving of dynamic parameters in XML format.

This test converts a dictionary to XML, saves it to a temporary file, reads it back, and ensures that the parsed dictionary matches the original.

Parameters:
  • dynamical_parameters_crowd_dict (DynamicCrowdDataType) -- A dictionary containing dynamic parameters for two agents.

  • tmp_path (Path) -- Temporary directory for XML file storage.

  • request (SubRequest) -- The pytest request object used to access fixtures.

Return type:

None

All backup files in a zip files

Test the integrity of the crowd data saved in a zip file.

test_backup_zip.crowd_fixture()[source]

Initialize and set up the Crowd object.

This fixture creates a Crowd instance, initializes agents, and packs them with forces.

Returns:

An initialized Crowd object.

Return type:

Crowd

test_backup_zip.output_zip_path_fixture(crowd_fixture)[source]

Save crowd data to a zip file and return the path.

Parameters:

crowd_fixture (Crowd) -- The Crowd object containing simulation data.

Returns:

The path to the saved zip file.

Return type:

Path

test_backup_zip.original_data_dicts_fixture(crowd_fixture)[source]

Retrieve original data dictionaries from the Crowd object.

This fixture collects static, materials, dynamic, and geometry parameters from the Crowd object.

Parameters:

crowd_fixture (Crowd) -- The Crowd object containing simulation data.

Returns:

A dictionary containing original simulation data categorized by type. Keys include "static", "materials", "dynamic", "geometry" and "interactions".

Return type:

dict[str, StaticCrowdDataType | MaterialsDataType | DynamicCrowdDataType | GeometryDataType | InteractionsDataType]

test_backup_zip.loaded_xml_data_fixture(output_zip_path_fixture)[source]

Extract XML content from the zip file.

This fixture reads XML files from the zip archive and categorizes them based on their content type.

Parameters:

output_zip_path_fixture (Path) -- The path to the zip file containing XML data.

Returns:

A dictionary containing XML content categorized by type. Keys include "static", "materials", "dynamic", and "geometry". Values are the raw XML content as bytes or None if not found.

Return type:

dict[str, Optional[bytes]]

test_backup_zip.test_crowd_data_integrity(key, parse_function, original_data_dicts_fixture, loaded_xml_data_fixture)[source]

Test that the parsed XML data matches the original data dictionaries.

Parameters:
  • key (str) -- The key representing a specific type of data (e.g., static, materials).

  • parse_function (Callable[[Optional[bytes]], dict[str, StaticCrowdDataType | MaterialsDataType |) -- DynamicCrowdDataType | GeometryDataType]] The function used to parse the XML data into a dictionary.

  • original_data_dicts_fixture (dict[str, StaticCrowdDataType | MaterialsDataType | DynamicCrowdDataType |) -- GeometryDataType ] The original data dictionaries categorized by type.

  • loaded_xml_data_fixture (dict[str, Optional[bytes]]) -- The XML data loaded from the zip file categorized by type.

Return type:

None

Interaction parameters

Test the loading and saving of interactions parameters in XML format.

test_backup_interactions.crowd(request)[source]

Fixture creating Crowd instances with parameterized agent counts and packing states.

Parameters:

request (pytest.FixtureRequest) -- Contains tuple of (agent_count, should_pack) parameters.

Returns:

Configured instance with agents and optional force packing.

Return type:

Crowd

test_backup_interactions.test_interactions_dict_xml_roundtrip(crowd, tmp_path)[source]

Test the loading and saving of interactions parameters in XML format.

There are 4 scenarios:
  • 1 agent (packed/unpacked)

  • 3 agents (packed/unpacked)

Parameters:
  • crowd (Crowd) -- The crowd fixture with agents and optional packing.

  • tmp_path (Path) -- Temporary directory for XML file storage.

Return type:

None