boofun.testing

Testing utilities and validation tools for BooFun library.

This module provides comprehensive testing tools for Boolean function analysis, including property validation, representation consistency checks, and performance testing.

Functions

quick_validate(function[, verbose])

Quick validation of a Boolean function.

validate_representation(representation[, n_vars])

Quick validation of a representation implementation.

Classes

BooleanFunctionValidator(function[, verbose])

Comprehensive validator for Boolean function implementations.

PerformanceProfiler()

Performance profiler for Boolean function operations.

PropertyTestSuite()

Comprehensive test suite for Boolean function properties.

RepresentationTester(representation)

Specialized tester for Boolean function representations.

class boofun.testing.BooleanFunctionValidator(function: BooleanFunction, verbose: bool = False)[source]

Comprehensive validator for Boolean function implementations.

Validates correctness, consistency, and performance of Boolean functions across different representations and operations.

__init__(function: BooleanFunction, verbose: bool = False)[source]

Initialize validator.

Parameters:
  • function – Boolean function to validate

  • verbose – Whether to print detailed validation messages

validate_all() Dict[str, Any][source]

Run comprehensive validation suite.

Returns:

Dictionary with validation results

validate_basic_properties() Dict[str, Any][source]

Validate basic Boolean function properties.

validate_representation_consistency() Dict[str, Any][source]

Validate consistency across different representations.

validate_evaluation_correctness() Dict[str, Any][source]

Validate evaluation correctness.

validate_space_handling() Dict[str, Any][source]

Validate space conversion and handling.

validate_edge_cases() Dict[str, Any][source]

Validate handling of edge cases.

print_validation_report() None[source]

Print detailed validation report.

class boofun.testing.RepresentationTester(representation: BooleanFunctionRepresentation)[source]

Specialized tester for Boolean function representations.

Tests individual representations for correctness, performance, and compliance with the representation interface.

__init__(representation: BooleanFunctionRepresentation)[source]

Initialize representation tester.

Parameters:

representation – Representation to test

test_interface_compliance(n_vars: int = 3) Dict[str, Any][source]

Test that representation implements required interface methods.

test_create_empty(n_vars: int = 3) Dict[str, Any][source]

Test create_empty method.

test_storage_requirements(n_vars_range: List[int] = [1, 2, 3, 4]) Dict[str, Any][source]

Test storage requirements computation.

class boofun.testing.PropertyTestSuite[source]

Comprehensive test suite for Boolean function properties.

Tests various mathematical properties and their detection algorithms.

__init__()[source]

Initialize property test suite.

test_known_functions() Dict[str, Any][source]

Test property detection on functions with known properties.

class boofun.testing.PerformanceProfiler[source]

Performance profiler for Boolean function operations.

Measures timing and memory usage of various operations.

__init__()[source]

Initialize performance profiler.

profile_evaluation(function: BooleanFunction, n_trials: int = 1000) Dict[str, Any][source]

Profile evaluation performance.

boofun.testing.quick_validate(function: BooleanFunction, verbose: bool = False) bool[source]

Quick validation of a Boolean function.

Parameters:
  • function – Function to validate

  • verbose – Whether to print detailed results

Returns:

True if validation passed, False otherwise

boofun.testing.validate_representation(representation: BooleanFunctionRepresentation, n_vars: int = 3) Dict[str, Any][source]

Quick validation of a representation implementation.

This is a utility function for validating representation implementations, not a pytest test.

Parameters:
  • representation – Representation to validate

  • n_vars – Number of variables for testing

Returns:

Validation results dictionary