LIBRARY
Math.Tests.IntegerToBoolean
Converts constant and time-varying Integer signals to Boolean by threshold.
Chains Constant(2.0) → RealToInteger → IntegerToBoolean(threshold=1) and verifies that the output is true (1) since 2 >= 1. A second chain feeds a sine wave (amplitude 3) through RealToInteger into IntegerToBoolean(threshold=1) so the Integer signal moves across the threshold and the Boolean output toggles.
Usage
BlockComponents.Math.Tests.IntegerToBoolean()
Behavior
Source
dyad
"""
Converts constant and time-varying Integer signals to Boolean by threshold.
Chains Constant(2.0) → RealToInteger → IntegerToBoolean(threshold=1) and
verifies that the output is true (1) since 2 >= 1. A second chain feeds a sine
wave (amplitude 3) through RealToInteger into IntegerToBoolean(threshold=1) so
the Integer signal moves across the threshold and the Boolean output toggles.
"""
test component IntegerToBoolean
"Constant source providing a value that rounds to 2"
c1 = BlockComponents.Sources.Constant(k = 2.0) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 20, "y1": 20, "x2": 120, "y2": 120, "rot": 0}
},
"tags": []
}
}
"RealToInteger adapter to produce Integer signal"
r2i = BlockComponents.Math.RealToInteger() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 160, "y1": 20, "x2": 260, "y2": 120, "rot": 0}
},
"tags": []
}
}
"IntegerToBoolean block under test"
i2b = BlockComponents.Math.IntegerToBoolean(threshold = 1) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 310, "y1": 20, "x2": 410, "y2": 120, "rot": 0}
},
"tags": []
}
}
"Sine source sweeping across the threshold"
sine = BlockComponents.Sources.Sine(amplitude = 3, frequency = 1) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 20, "y1": 140, "x2": 120, "y2": 240, "rot": 0}
},
"tags": []
}
}
"RealToInteger adapter for the second chain"
r2i_2 = BlockComponents.Math.RealToInteger() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 160, "y1": 140, "x2": 260, "y2": 240, "rot": 0}
},
"tags": []
}
}
"Second IntegerToBoolean block driven by the sine chain"
i2b_2 = BlockComponents.Math.IntegerToBoolean(threshold = 1) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 300, "y1": 140, "x2": 400, "y2": 240, "rot": 0}
},
"tags": []
}
}
relations
connect(c1.y, r2i.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
connect(r2i.y, i2b.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
connect(sine.y, r2i_2.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
connect(r2i_2.y, i2b_2.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
metadata {
"Dyad": {
"icons": {"default": "dyad://BlockComponents/Example.svg"},
"tests": {
"case1": {"stop": 1, "expect": {"signals": ["i2b.y", "i2b_2.y", "r2i_2.y", "sine.y"]}}
}
}
}
endFlattened Source
dyad
"""
Converts constant and time-varying Integer signals to Boolean by threshold.
Chains Constant(2.0) → RealToInteger → IntegerToBoolean(threshold=1) and
verifies that the output is true (1) since 2 >= 1. A second chain feeds a sine
wave (amplitude 3) through RealToInteger into IntegerToBoolean(threshold=1) so
the Integer signal moves across the threshold and the Boolean output toggles.
"""
test component IntegerToBoolean
"Constant source providing a value that rounds to 2"
c1 = BlockComponents.Sources.Constant(k = 2.0) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 20, "y1": 20, "x2": 120, "y2": 120, "rot": 0}
},
"tags": []
}
}
"RealToInteger adapter to produce Integer signal"
r2i = BlockComponents.Math.RealToInteger() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 160, "y1": 20, "x2": 260, "y2": 120, "rot": 0}
},
"tags": []
}
}
"IntegerToBoolean block under test"
i2b = BlockComponents.Math.IntegerToBoolean(threshold = 1) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 310, "y1": 20, "x2": 410, "y2": 120, "rot": 0}
},
"tags": []
}
}
"Sine source sweeping across the threshold"
sine = BlockComponents.Sources.Sine(amplitude = 3, frequency = 1) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 20, "y1": 140, "x2": 120, "y2": 240, "rot": 0}
},
"tags": []
}
}
"RealToInteger adapter for the second chain"
r2i_2 = BlockComponents.Math.RealToInteger() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 160, "y1": 140, "x2": 260, "y2": 240, "rot": 0}
},
"tags": []
}
}
"Second IntegerToBoolean block driven by the sine chain"
i2b_2 = BlockComponents.Math.IntegerToBoolean(threshold = 1) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 300, "y1": 140, "x2": 400, "y2": 240, "rot": 0}
},
"tags": []
}
}
relations
connect(c1.y, r2i.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
connect(r2i.y, i2b.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
connect(sine.y, r2i_2.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
connect(r2i_2.y, i2b_2.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
metadata {
"Dyad": {
"icons": {"default": "dyad://BlockComponents/Example.svg"},
"tests": {
"case1": {"stop": 1, "expect": {"signals": ["i2b.y", "i2b_2.y", "r2i_2.y", "sine.y"]}}
}
}
}
endTest Cases
Test Case case1
julia
pltjulia
pltjulia
pltjulia
pltRelated
Examples
Experiments
Analyses
Tests