shieru1214 commented on PR #2615:
URL: https://github.com/apache/systemds/pull/2615#issuecomment-5943790722

   This change adds  tests for `multimodal_optimizer.py`.  The new tests cover 
three parts: fusion DAG generation, constructor setup, and the optimize loop.
   
   ### Fusion DAG Generation
   
   Before this change, the three methods that generate the fusion search space 
had no active tests.
   
   - `_generate_modality_combinations`: 
`test_modality_combinations_respect_min_max_modalities` uses three modalities 
and checks the exact subsets for `max_modalities` values of 2, 3, and 5. This 
also checks the case where the maximum is larger than the number of available 
modalities.
   - `_generate_representation_combinations`: 
`test_representation_combinations_pick_one_per_modality` uses one modality with 
two representations and another with three. It checks all six possible 
combinations.
   - `_generate_fusion_dags`: 
`test_fusion_dags_contain_every_selected_representation` checks every generated 
DAG. It checks that the selected modality and representation leaves are 
present, the number of fusion nodes is correct, each fusion node has two 
inputs, and the root is a fusion node.
   - `test_fusion_dags_use_every_fusion_operator` checks that both configured 
operators, `Concatenation` and `Average`, are used. This is tested separately 
because a DAG can have the correct structure but still miss one operator.
   
   
   ### Constructor Setup
   
   The generator tests already called `__init__`, but they did not directly 
check the values created during construction. I added three tests for this part.
   
   - `test_min_modalities_clamped_to_two` checks that `min_modalities=1` is 
changed to `2`. This prevents single-modality DAGs from being treated as fusion 
DAGs.
   - `test_max_modalities_defaults_to_number_of_modalities` checks that the 
default maximum is the number of available modalities.
   - `test_k_best_representations_hold_the_cached_data` covers 
`_extract_k_best_representations`. It checks that every modality is stored by 
its ID and that the optimizer keeps the cached representation data returned by 
the unimodal results, instead of the score records.
   
   ### Optimize Loop
   
   Before this change, none of the tests called `optimize`. I added three tests 
for the main rules of this loop.
   
   - `test_stops_at_max_combinations` uses three modalities and sets 
`max_combinations=5`. It checks that `_evaluate_dag` is called exactly five 
times and that five results are stored.
   - `test_drops_failed_evaluations` makes every second evaluation return 
`None`. It checks that six evaluations are attempted but only three results are 
stored. Failed evaluations still count towards the limit, and the loop 
continues after them.
   - `test_keeps_results_and_budget_per_task` uses two tasks with a limit of 
two. It checks that each task receives two evaluations and that every result is 
stored under the correct task name.
   
   、
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to