Skip to content

Commit dca3a23

Browse files
Remove IfElse.jl dependency; use Base.ifelse (#473)
IfElse.jl's `ifelse` is `const ifelse = Base.ifelse` on modern Julia (0.1.1), so the dependency is redundant: Symbolics registers a symbolic method on `Base.ifelse`, so `ifelse(sym_cond, a, b)` traces to a symbolic expression without IfElse. Removing IfElse also unblocks the strict Downgrade lane, which previously could resolve IfElse 0.1.0 (whose greedy `ifelse(args...) = Core.ifelse(args...)` broke symbolic conditions). - Replace `IfElse.ifelse(...)` call sites with bare `ifelse(...)`. - Drop every `using IfElse` / `import IfElse` line. - Remove IfElse from [deps] and [compat]. - In Blocks, the removed `import IfElse: ifelse` had brought `ifelse` into scope so the `Parameter` overloads in sources.jl extended it. Replace with `import Base: ifelse` so those overloads extend `Base.ifelse` instead of creating a new `Blocks.ifelse` binding that would shadow the symbolic method. - Drop the now-stale Downgrade.yml comment referencing the fntype regression. Co-authored-by: ChrisRackauckas-Claude <accounts@chrisrackauckas.com>
1 parent 776d7c7 commit dca3a23

12 files changed

Lines changed: 5 additions & 15 deletions

File tree

.github/workflows/Downgrade.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ on:
1212
- 'docs/**'
1313
jobs:
1414
test:
15-
# Runs strict (allow_reresolve=false); expected RED until fntype regression (#458/#452) is resolved.
15+
# Runs strict (allow_reresolve=false).
1616
uses: "SciML/.github/.github/workflows/downgrade.yml@v1"
1717
with:
1818
julia-version: "lts"

Project.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ authors = ["Chris Rackauckas and Julia Computing"]
66
[deps]
77
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
88
DiffEqBase = "2b5f629d-d688-5b77-993f-72d75c75574e"
9-
IfElse = "615f187c-cbe4-4ef1-ba3b-2fcf58d6d173"
109
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1110
ModelingToolkitBase = "7771a370-6774-4173-bd38-47e70ca0b839"
1211
PreallocationTools = "d236fae5-4411-538c-8e31-a6e3d9e00b46"
@@ -20,7 +19,6 @@ DataFrames = "1.7"
2019
DataInterpolations = "8"
2120
DiffEqBase = "6.190, 7"
2221
ForwardDiff = "0.10, 1"
23-
IfElse = "0.1"
2422
LinearAlgebra = "1.10"
2523
ModelingToolkit = "11"
2624
ModelingToolkitBase = "1"

src/Blocks/Blocks.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ using ModelingToolkitBase: ModelingToolkitBase, @component, @connector, @named,
66
@parameters, @unpack, System, compose, connect, extend,
77
getdefault, t_nounits as t, D_nounits as D
88
using Symbolics: Symbolics, @register_symbolic, @variables, Differential, Equation
9-
import IfElse: ifelse
9+
import Base: ifelse
1010
import ..@symcheck
1111

1212
export RealInput, RealInputArray, RealOutput, RealOutputArray, SISO

src/Electrical/Digital/sources.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ function Pulse(; name, duty_cycle = 0.5, T = 1.0)
8484
@named d = DigitalPin()
8585

8686
eqs = [
87-
d.val ~ IfElse.ifelse(t % T > duty_cycle * T, 1, 0),
87+
d.val ~ ifelse(t % T > duty_cycle * T, 1, 0),
8888
]
8989
return System(eqs, t, [], [], systems = [d], name = name)
9090
end

src/Electrical/Electrical.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ This library contains electrical components to build up analog circuits.
44
"""
55
module Electrical
66

7-
using IfElse: IfElse
87
using ModelingToolkitBase: ModelingToolkitBase, @component, @connector, @constants,
98
@named, @parameters, @unpack, Flow, System, connect, extend,
109
t_nounits as t, D_nounits as D

src/Electrical/utils.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ end
105105
@connector function DigitalPin(; name)
106106
@variables val(t) v(t) i(t)
107107
eqs = [
108-
val ~ IfElse.ifelse(
108+
val ~ ifelse(
109109
(0.0 <= v) & (v <= 0.8) | (2.0 <= v) & (v <= 5.0),
110-
IfElse.ifelse(v > 2.0, 1, 0), X
110+
ifelse(v > 2.0, 1, 0), X
111111
),
112112
]
113113
System(

src/Hydraulic/IsothermalCompressible/IsothermalCompressible.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ using Symbolics: Symbolics, @register_derivative, @register_symbolic, @variables
1111
using ...Blocks: RealInput
1212
using ...Mechanical.Translational: MechanicalPort, Mass
1313

14-
using IfElse: ifelse
15-
1614
export HydraulicPort, HydraulicFluid
1715
include("utils.jl")
1816

src/Mechanical/MultiBody2D/MultiBody2D.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
module MultiBody2D
22

3-
using IfElse: IfElse
43
using ModelingToolkitBase: ModelingToolkitBase, @component, @named, @parameters,
54
System, t_nounits as t, D_nounits as D
65
using Symbolics: Symbolics, @variables, Equation

src/Mechanical/Rotational/Rotational.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ Library to model 1-dimensional, rotational mechanical systems
33
"""
44
module Rotational
55

6-
using IfElse: IfElse
76
using ModelingToolkitBase: ModelingToolkitBase, @component, @connector, @named,
87
@parameters, @unpack, Flow, System, compose, extend, t_nounits as t, D_nounits as D
98
using Symbolics: Symbolics, @variables, Equation

src/Mechanical/TranslationalModelica/TranslationalModelica.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ Library to model 1-dimensional, translational mechanical components.
33
"""
44
module TranslationalModelica
55

6-
using IfElse: IfElse
76
using ModelingToolkitBase: ModelingToolkitBase, @component, @connector, @named,
87
@parameters, @unpack, Flow, System, compose, extend, t_nounits as t, D_nounits as D
98
using Symbolics: Symbolics, @variables, Equation

0 commit comments

Comments
 (0)