<s> '''<STR_LIT>''' <EOL> from combi . _python_toolbox import misc_tools <EOL> from . roundings import ( Rounding , roundings , LOW , LOW_IF_BOTH , <EOL> LOW_OTHERWISE_HIGH , HIGH , HIGH_IF_BOTH , <EOL> HIGH_OTHERWISE_LOW , EXACT , CLOSEST , CLOSEST_IF_BOTH , <EOL> BOTH ) <EOL> from . functions import ( binary_search , binary_search_by_index , <EOL> make_both_data_into_preferred_rounding , <EOL> _binary_search_both ) <EOL> class BinarySearchProfile ( object ) : <EOL> '''<STR_LIT>''' <EOL> @ misc_tools . limit_positional_arguments ( <NUM_LIT:4> ) <EOL> def __init__ ( self , sequence , value , function = misc_tools . identity_function , <EOL> both = None ) : <EOL> '''<STR_LIT>''' <EOL> if both is None : <EOL> both = _binary_search_both ( sequence , value , function = function ) <EOL> self . results = { } <EOL> '''<STR_LIT>''' <EOL> for rounding in roundings : <EOL> self . results [ rounding ] = make_both_data_into_preferred_rounding ( <EOL> both , value , function = function , rounding = rounding <EOL> ) <EOL> none_count = list ( both ) . count ( None ) <EOL> self . all_empty = ( none_count == <NUM_LIT:2> ) <EOL> '''<STR_LIT>''' <EOL> self . one_side_empty = ( none_count == <NUM_LIT:1> ) <EOL> '''<STR_LIT>''' <EOL> self . is_surrounded = ( none_count == <NUM_LIT:0> ) <EOL> '''<STR_LIT>''' <EOL> self . had_to_compromise = { <EOL> LOW_OTHERWISE_HIGH : <EOL> self . results [ LOW_OTHERWISE_HIGH ] is not self . results [ LOW ] , <EOL> HIGH_OTHERWISE_LOW : <EOL> self . results [ HIGH_OTHERWISE_LOW ] is not self . results [ HIGH ] , <EOL> } <EOL> '''<STR_LIT>''' <EOL> self . got_none_because_no_item_on_other_side = { <EOL> LOW_IF_BOTH : <EOL> self . results [ LOW_IF_BOTH ] is not self . results [ LOW ] , <EOL> HIGH_IF_BOTH : <EOL> self . results [ HIGH_IF_BOTH ] is not self . results [ HIGH ] , <EOL> CLOSEST_IF_BOTH : <EOL> self . results [ CLOSEST_IF_BOTH ] is not self . results [ CLOSEST ] , <EOL> } <EOL> '''<STR_LIT>''' <EOL> for d in [ self . had_to_compromise , <EOL> self . got_none_because_no_item_on_other_side ] : <EOL> for rounding in roundings : <EOL> if rounding not in d : <EOL> d [ rounding ] = None </s>
