(domain, streams, obj_from_constant)
| 39 | return obj_from_constant |
| 40 | |
| 41 | def check_problem(domain, streams, obj_from_constant): |
| 42 | for action in (domain.actions + domain.axioms): |
| 43 | for p, c in Counter(action.parameters).items(): |
| 44 | if c != 1: |
| 45 | raise ValueError('Parameter [{}] for action [{}] is not unique'.format(p.name, action.name)) |
| 46 | # TODO: check that no undeclared parameters & constants |
| 47 | #action.dump() |
| 48 | |
| 49 | undeclared_predicates = set() |
| 50 | for stream in streams: |
| 51 | # TODO: domain.functions |
| 52 | facts = list(stream.domain) |
| 53 | if isinstance(stream, Stream): |
| 54 | facts.extend(stream.certified) |
| 55 | for fact in facts: |
| 56 | name = get_prefix(fact) |
| 57 | if name not in domain.predicate_dict: |
| 58 | undeclared_predicates.add(name) |
| 59 | elif len(get_args(fact)) != domain.predicate_dict[name].get_arity(): # predicate used with wrong arity: {} |
| 60 | print('Warning! predicate used with wrong arity in stream [{}]: {}'.format(stream.name, fact)) |
| 61 | # for constant in stream.constants: |
| 62 | # if constant not in obj_from_constant: |
| 63 | # raise ValueError('Undefined constant in stream [{}]: {}'.format(stream.name, constant)) |
| 64 | if undeclared_predicates: |
| 65 | print('Warning! Undeclared predicates: {}'.format( |
| 66 | sorted(undeclared_predicates))) # Undeclared predicate: {} |
| 67 | |
| 68 | def reset_globals(): |
| 69 | # TODO: maintain these dictionaries in an object |
no test coverage detected