haive.agents.common.models.grade.binary ======================================= .. py:module:: haive.agents.common.models.grade.binary .. autoapi-nested-parse:: Binary grading model for pass/fail evaluations. This module implements a binary grading system suitable for pass/fail, yes/no, correct/incorrect, and similar binary evaluations. Classes ------- .. autoapisummary:: haive.agents.common.models.grade.binary.BinaryGrade Module Contents --------------- .. py:class:: BinaryGrade(/, **data) Bases: :py:obj:`haive.agents.common.models.grade.base.Grade` Binary grading model for pass/fail evaluations. This grade model represents simple binary outcomes such as pass/fail, yes/no, correct/incorrect, acceptable/unacceptable, etc. .. attribute:: value The binary grade value (True for pass/yes, False for fail/no) .. attribute:: grade_type Always GradeType.BINARY .. rubric:: Example .. code-block:: python # Passing grade grade = BinaryGrade( value=True, justification="Response correctly identifies all key concepts", confidence=0.95 ) # Failing grade grade = BinaryGrade( value=False, justification="Response contains factual errors and misses main points", confidence=0.88 ) # Using string values (automatically converted) grade = BinaryGrade( value="pass", # Converted to True justification="Meets minimum requirements" ) Create a new model by parsing and validating input data from keyword arguments. Raises [`ValidationError`][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model. `self` is explicitly positional-only to allow `self` as a field name. .. py:method:: convert_value_to_bool(v) :classmethod: Convert various representations to boolean. Accepts boolean values, strings, and numbers and converts them to appropriate boolean values for grading. :param v: Value to convert to boolean :returns: Boolean representation of the value :raises ValueError: If the value cannot be converted to a meaningful boolean .. py:method:: create_fail(justification, confidence = 1.0, **kwargs) :classmethod: Convenience method to create a failing grade. :param justification: Explanation for the failing grade :param confidence: Confidence level (default 1.0) :param \*\*kwargs: Additional parameters for the grade :returns: BinaryGrade instance with value=False .. py:method:: create_pass(justification, confidence = 1.0, **kwargs) :classmethod: Convenience method to create a passing grade. :param justification: Explanation for the passing grade :param confidence: Confidence level (default 1.0) :param \*\*kwargs: Additional parameters for the grade :returns: BinaryGrade instance with value=True .. py:method:: flip() Create a new BinaryGrade with the opposite value. Useful for creating inverse grades or testing scenarios. :returns: New BinaryGrade instance with flipped value .. py:method:: get_display_value() Get a human-readable display value. :returns: "Pass" for True, "Fail" for False .. py:method:: get_emoji_representation() Get an emoji representation of the grade. :returns: ✅ for pass, ❌ for fail .. py:method:: get_normalized_score() Get the grade as a normalized score between 0.0 and 1.0. :returns: 1.0 for True (pass), 0.0 for False (fail) .. py:method:: is_passing(threshold = None) Determine if the grade represents a passing score. For binary grades, this simply returns the boolean value. The threshold parameter is ignored for binary grades. :param threshold: Ignored for binary grades :returns: The boolean value of the grade .. py:method:: to_display_string() Convert grade to a human-readable display string. :returns: Formatted string representation of the binary grade .. py:method:: validate_grade_value(value) Validate that a value can be converted to binary. :param value: The value to validate :returns: True if the value can be converted to boolean, False otherwise