Skip to content

Commit

Permalink
float value is accepted for initial value with integer type
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinksyTRD committed Nov 22, 2022
1 parent 427feca commit b282ff5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions nbs/03_Simulation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@
" raise TypeError(f'Expected a bool, got {type(value)}')\n",
" return OspBoolean(value=bool(value))\n",
" if type_var == osp_parser_sys.VariableType.Integer:\n",
" if not isinstance(value, int):\n",
" raise TypeError(f'Expected an int, got {type(value)}')\n",
" if not isinstance(value, int) and not isinstance(value, float):\n",
" raise TypeError(f'Expected an int or float, got {type(value)}')\n",
" return OspInteger(value=int(value))\n",
" if type_var == osp_parser_sys.VariableType.String:\n",
" if not isinstance(value, str):\n",
Expand Down
4 changes: 2 additions & 2 deletions pycosim/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ def convert_value_to_osp_type(
raise TypeError(f'Expected a bool, got {type(value)}')
return OspBoolean(value=bool(value))
if type_var == osp_parser_sys.VariableType.Integer:
if not isinstance(value, int):
raise TypeError(f'Expected an int, got {type(value)}')
if not isinstance(value, int) and not isinstance(value, float):
raise TypeError(f'Expected an int or float, got {type(value)}')
return OspInteger(value=int(value))
if type_var == osp_parser_sys.VariableType.String:
if not isinstance(value, str):
Expand Down
2 changes: 1 addition & 1 deletion settings.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
### Python library ###
repo = pycosim
lib_name = %(repo)s
version = 0.4.1
version = 0.4.2
min_python = 3.8
license = MIT

Expand Down

0 comments on commit b282ff5

Please sign in to comment.