Skip to content

Commit 1789334

Browse files
authored
Merge pull request #143 from ModiaSim/mo_bug_fix_bool_conversion
Bug fix: Do not convert Bool or Int (without units) to FloatType
2 parents 61a7fe1 + edaf8c7 commit 1789334

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
authors = ["Hilding Elmqvist <[email protected]>", "Martin Otter <[email protected]>"]
22
name = "Modia"
33
uuid = "cb905087-75eb-5f27-8515-1ce0ec8e839e"
4-
version = "0.8.2"
4+
version = "0.8.3"
55

66
[compat]
77
DataFrames = "1"

docs/src/index.md

+6
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ functionalities of these packages.
3636

3737
## Release Notes
3838

39+
### Version 0.8.3
40+
41+
- Bug fix: Parameters that are Numbers, but not AbstractFloats, and have no unit defined,
42+
e.g. a Bool or an Int parameter, are no longer converted to FloatType in the generated Code.
43+
44+
3945
### Version 0.8.2
4046

4147
- New exported functions

src/Symbolic.jl

+7-2
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,14 @@ function addCastAndTypeCheck(ex,value,FloatType)
7979
addCastAndTypeCheckBasicValueType(ex,value,T)
8080
end
8181

82-
else
83-
# FloatType is neither Measurements nor MonteCarloMeasurements
82+
elseif valueType <: AbstractFloat || isQuantity(valueType)
83+
# FloatType is neither Measurements nor MonteCarloMeasurements and
84+
# is either an AbstractFloat or has a unit (is treated as Float)
8485
addCastAndTypeCheckBasicValueType(ex,value,T)
86+
87+
else
88+
# For example Bool or Int values: No conversion, just define the type in the code
89+
:( ($ex)::$valueType )
8590
end
8691
else
8792
# Numeric array

0 commit comments

Comments
 (0)