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

Added support for float input in scientific notation and removed float rounding. #711

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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 WDL/Value.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ def __init__(self, value: float, expr: "Optional[Expr.Base]" = None) -> None:
super().__init__(Type.Float(), value, expr)

def __str__(self) -> str:
return "{:.6f}".format(self.value)
# converting to string using repr to retain the float value as is and eliminating rounding.
return repr(self.value)


class Int(Base):
Expand Down Expand Up @@ -549,6 +550,8 @@ def from_json(type: Type.Base, value: Any) -> Base:
return Int(value)
if isinstance(type, (Type.Float, Type.Any)) and isinstance(value, (float, int)):
return Float(float(value))
if isinstance(type, (Type.Float, Type.Any)) and "e" in value.lower():
return Float(float(value))
if isinstance(type, Type.File) and isinstance(value, str):
return File(value)
if isinstance(type, Type.Directory) and isinstance(value, str):
Expand Down