Ejemplo n.º 1
0
    def next_results(self, verbose=False):
        assert not self.enumerated
        start_time = time.time()
        start_history = len(self.history)
        new_values, new_facts = self._next_outputs()
        self._check_output_values(new_values)
        self._check_wild_facts(new_facts)
        if verbose:
            self.dump_new_values(new_values)
            self.dump_new_facts(new_facts)

        objects = [
            objects_from_values(output_values) for output_values in new_values
        ]
        new_objects = list(
            filter(lambda o: o not in self.previous_outputs, objects))
        self.previous_outputs.update(
            new_objects)  # Only counting new outputs as successes
        new_results = [
            self.get_result(output_objects,
                            list_index=list_index,
                            optimistic=False)
            for list_index, output_objects in enumerate(new_objects)
        ]
        if start_history <= len(self.history) - 1:
            self.update_statistics(start_time, new_results)
        new_facts = list(map(obj_from_value_expression, new_facts))
        self.successful |= any(r.is_successful() for r in new_results)
        self.num_calls += 1  # Must be after get_result
        #if self.external.is_test and self.successful:
        #    # Set of possible test stream outputs is exhausted (excluding wild)
        #   self.enumerated = True
        return new_results, new_facts
Ejemplo n.º 2
0
    def next_results(self, verbose=False):
        assert not self.enumerated
        start_time = time.time()
        start_history = len(self.history)
        new_values, new_facts = self._next_outputs()
        self._check_output_values(new_values)
        self._check_wild_facts(new_facts)
        if verbose:
            if (not new_values and VERBOSE_FAILURES) or \
                    (new_values and self.info.verbose):
                print('iter={}, outs={}) {}:{}->{}'.format(
                    self.num_calls, len(new_values), self.external.name,
                    str_from_object(self.get_input_values()), str_from_object(new_values)))
            if VERBOSE_WILD and new_facts:
                # TODO: format all_new_facts
                print('iter={}, facts={}) {}:{}->{}'.format(
                    self.num_calls, self.external.name, str_from_object(self.get_input_values()),
                    new_facts, len(new_facts)))

        objects = [objects_from_values(output_values) for output_values in new_values]
        new_objects = list(filter(lambda o: o not in self.previous_outputs, objects))
        self.previous_outputs.update(new_objects) # Only counting new outputs as successes
        new_results = [self.get_result(output_objects, list_index=list_index, optimistic=False)
                       for list_index, output_objects in enumerate(new_objects)]
        if start_history < len(self.history):
            self.update_statistics(start_time, new_results)
        new_facts = list(map(obj_from_value_expression, new_facts))
        self.successful |= any(r.is_successful() for r in new_results)
        self.num_calls += 1 # Must be after get_result
        #if self.external.is_test() and self.successful:
        #    # Set of possible test stream outputs is exhausted (excluding wild)
        #   self.enumerated = True
        return new_results, new_facts
Ejemplo n.º 3
0
 def static_opt_gen_fn(*input_values):
     instance = stream.get_instance(objects_from_values(input_values))
     if all(
             evaluation_from_fact(f) in evaluations
             for f in instance.get_domain()):
         return
     for output_values in stream.opt_gen_fn(*input_values):
         yield output_values
Ejemplo n.º 4
0
 def static_fn(*input_values):
     instance = stream.get_instance(objects_from_values(input_values))
     if all(
             evaluation_from_fact(f) in evaluations
             for f in instance.get_domain()):
         return None
     return tuple(
         FutureValue(stream.name, input_values, o) for o in stream.outputs)