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

Make the type of value in NumericValue actually a number #123

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion pddl/logic/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,10 @@ class NumericValue(FunctionExpression):

def __init__(self, value: float) -> None:
"""Init the numeric value object."""
self._value = value
if (value == float(value)):
self._value = int(value)
else:
self._value = float(value)

@property
def value(self) -> float:
Expand Down
4 changes: 4 additions & 0 deletions tests/test_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,7 @@ def setup_method(self):
def test_value(self):
"""Test the name getter."""
assert self.numeric_value.value == 3

def test_value_type(self):
"""Test the name getter."""
assert isinstance(self.numeric_value.value, (float, int))