Buckets:
| import math | |
| import pytest | |
| from comfy_extras.nodes_camera_angle import ( | |
| CameraAngle, | |
| MAX_ZOOM_FACTOR, | |
| MIN_ZOOM_FACTOR, | |
| SUBJECT_CENTER, | |
| SUBJECT_DISTANCE, | |
| build_camera_info, | |
| describe_camera_angle, | |
| horizontal_term, | |
| zoom_to_factor, | |
| ) | |
| def test_horizontal_term_buckets_by_45_degree_sector(angle, term): | |
| assert horizontal_term(angle) == term | |
| def test_describe_camera_angle_joins_vertical_and_distance_terms(vertical, zoom, expected): | |
| assert describe_camera_angle(0, vertical, zoom) == expected | |
| def test_zoom_maps_linearly_onto_the_lens_zoom_factor(): | |
| assert zoom_to_factor(0) == MIN_ZOOM_FACTOR | |
| assert zoom_to_factor(10) == MAX_ZOOM_FACTOR | |
| assert zoom_to_factor(5) == pytest.approx((MIN_ZOOM_FACTOR + MAX_ZOOM_FACTOR) / 2) | |
| def test_front_view_places_camera_on_positive_z_looking_at_subject_centre(): | |
| info = build_camera_info(0, 0, 0) | |
| assert info["position"] == pytest.approx({"x": 0.0, "y": 0.0, "z": SUBJECT_DISTANCE}) | |
| assert info["target"] == {"x": 0.0, "y": 0.0, "z": 0.0} | |
| assert info["cameraType"] == "perspective" | |
| assert info["zoom"] == 1.0 | |
| def test_orbit_position_follows_yaw_and_pitch_while_zoom_only_changes_the_lens(): | |
| info = build_camera_info(90, 30, 10) | |
| position = info["position"] | |
| assert position["x"] == pytest.approx(SUBJECT_DISTANCE * math.cos(math.radians(30))) | |
| assert position["y"] == pytest.approx(SUBJECT_CENTER[1] + SUBJECT_DISTANCE * math.sin(math.radians(30))) | |
| assert position["z"] == pytest.approx(0.0, abs=1e-9) | |
| assert info["zoom"] == MAX_ZOOM_FACTOR | |
| def test_execute_clamps_inputs_and_returns_camera_info_and_prompt(): | |
| result = CameraAngle.execute(horizontal_angle=400, vertical_angle=-90, zoom=99) | |
| camera_info, prompt = result.args | |
| assert prompt == "front view low-angle shot close-up" | |
| assert camera_info == build_camera_info(360, -30, 10) | |
Xet Storage Details
- Size:
- 2.62 kB
- Xet hash:
- 6b4e8b97310322ccdcdf473bb0a61a6390a7c96734ad0515de1567b87f206d2c
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.