fix: Resolve remaining numpy array comparison errors in MultiDongle

- Fix ambiguous truth value error in get_latest_inference_result method
- Fix ambiguous truth value error in postprocess function
- Replace direct array evaluation with explicit length checks
- Use proper None checks instead of truthy evaluation on numpy arrays

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Masonmason 2025-07-17 10:11:38 +08:00
parent 0a70df4098
commit e97fd7a025

View File

@ -426,7 +426,7 @@ class MultiDongle:
retrieval_successful = False
break
if retrieval_successful and inf_node_output_list:
if retrieval_successful and len(inf_node_output_list) > 0:
# Process output nodes
if output_descriptor.header.num_output_node == 1:
raw_output_array = inf_node_output_list[0].flatten()
@ -690,7 +690,7 @@ def postprocess(raw_model_output: list) -> float:
Post-processes the raw model output.
Assumes the model output is a list/array where the first element is the desired probability.
"""
if raw_model_output and len(raw_model_output) > 0:
if raw_model_output is not None and len(raw_model_output) > 0:
probability = raw_model_output[0]
return float(probability)
return 0.0 # Default or error value