Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove type checking in Predicate.__call__ #127

Merged
merged 1 commit into from
Jan 4, 2025
Merged

fix: remove type checking in Predicate.__call__ #127

merged 1 commit into from
Jan 4, 2025

Conversation

marcofavorito
Copy link
Member

@marcofavorito marcofavorito commented Jan 4, 2025

Proposed changes

This commit removes a check on the types of the new terms passed as arguments to Predicate.call. The reason is that the check is not "complete": for example, the check returns false when a new term whose types are a subset of the types of the term being replaced, while the correct result is true.

More fundamentally, the problem is that the class Predicate, in its current state, does not have information on the type hierarchy of the domain the predicate belongs to. Having this check here adds more problems than benefits. The final type check will be performed when instantiating the Domain class while leaving the flexibility to the user to instantiate temporary predicate objects, even with terms whose type is incompatible with the target type hierarchy of the PDDL domain.

Therefore, rather than having a half-working feature, it is better to remove it altogether. The idea is still relevant, but it may require a distinction between 'PredicateDefinition' (which has a pointer to the domain or the type hierarchy) and 'Predicate' (the actual instance of the predicate definition, with only constants).

Fixes

Partially addresses issues in #98

Types of changes

What types of changes does your code introduce?
Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist

Put an x in the boxes that apply.

  • I have read the CONTRIBUTING doc
  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works

Further comments

Given that there are different overlapping issues regarding validation, I propose to address them in a separate refactoring as attempted in #84 (relatively soon).

This commit removes a check on the types of the new terms passed as arguments to
Predicate.__call__. The reason is that the check is not "complete": for example,
the check returns false when a new term whose types are a subset of the types of
the term being replaced, while the correct result is true.

More fundamentally, the problem is that the class Predicate, in its current
state, does not have information on the type hierarchy of the domain the
predicate belongs to. Having this check here adds more problems than benefits.
The final type check will be performed when instantiating the Domain class while
leaving the flexibility to the user to instantiate temporary predicate objects,
even with terms whose type is incompatible with the target type hierarchy of the
PDDL domain.

Therefore, rather than having a half-working feature, it is better to remove it
altogether. The idea is still relevant, but it may require a distinction between
'PredicateDefinition' (which has a pointer to the domain or the type hierarchy)
and 'Predicate' (the actual instance of the predicate definition, with only
constants).
@marcofavorito marcofavorito requested a review from haz January 4, 2025 15:29
@codecov-commenter
Copy link

codecov-commenter commented Jan 4, 2025

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.12%. Comparing base (8da9fec) to head (5d5908f).

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #127      +/-   ##
==========================================
- Coverage   88.12%   88.12%   -0.01%     
==========================================
  Files          24       24              
  Lines        1752     1751       -1     
  Branches      233      232       -1     
==========================================
- Hits         1544     1543       -1     
  Misses        148      148              
  Partials       60       60              
Flag Coverage Δ
unittests 88.12% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
pddl/logic/predicates.py 94.44% <ø> (-0.07%) ⬇️

Copy link
Contributor

@haz haz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I think this puts a higher emphasis on getting #84 done up. Optional type hierarchy passed into the predicate call makes sense, and the validation can be triggered if it's not None.

@haz haz merged commit c11b68e into main Jan 4, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants