Skip to content

Commit d879158

Browse files
Merge pull request #689 from AayushSabharwal/as/type-piracy
refactor: remove type-pirated functions
2 parents 28028fe + 402b347 commit d879158

File tree

3 files changed

+1
-41
lines changed

3 files changed

+1
-41
lines changed

Project.toml

+1-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ ProgressLogging = "33c8b6b6-d38a-422a-b730-caa89a2f386c"
1616
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
1717
SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
1818
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
19-
SymbolicIndexingInterface = "2efcf032-c050-4f8e-a9bb-153293bab1f5"
2019
TerminalLoggers = "5d786b92-1e48-4d6f-9151-6b4477ca9bed"
2120

2221
[weakdeps]
@@ -57,10 +56,9 @@ Printf = "1.10"
5756
ProgressLogging = "0.1"
5857
Reexport = "1.2"
5958
ReverseDiff = "1.14"
60-
SciMLBase = "< 2.23.0"
59+
SciMLBase = "2.23.0"
6160
SparseArrays = "1.10"
6261
SparseDiffTools = "2.14"
63-
SymbolicIndexingInterface = "0.3.2"
6462
Symbolics = "5.12"
6563
TerminalLoggers = "0.1"
6664
Tracker = "0.2.29"

src/Optimization.jl

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ end
1313

1414
using Logging, ProgressLogging, ConsoleProgressMonitor, TerminalLoggers, LoggingExtras
1515
using ArrayInterface, Base.Iterators, SparseArrays, LinearAlgebra
16-
using SymbolicIndexingInterface
1716
using Pkg
1817

1918
import SciMLBase: OptimizationProblem,

src/cache.jl

-37
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,3 @@
1-
2-
function Base.getproperty(cache::SciMLBase.AbstractOptimizationCache, x::Symbol)
3-
if x in (:u0, :p)
4-
return getfield(cache.reinit_cache, x)
5-
end
6-
return getfield(cache, x)
7-
end
8-
9-
SciMLBase.has_reinit(cache::SciMLBase.AbstractOptimizationCache) = true
10-
function SciMLBase.reinit!(cache::SciMLBase.AbstractOptimizationCache; p = missing,
11-
u0 = missing)
12-
if p === missing && u0 === missing
13-
p, u0 = cache.p, cache.u0
14-
else # at least one of them has a value
15-
if p === missing
16-
p = cache.p
17-
end
18-
if u0 === missing
19-
u0 = cache.u0
20-
end
21-
if (eltype(p) <: Pair && !isempty(p)) || (eltype(u0) <: Pair && !isempty(u0)) # one is a non-empty symbolic map
22-
hasproperty(cache.f, :sys) && hasfield(typeof(cache.f.sys), :ps) ||
23-
throw(ArgumentError("This cache does not support symbolic maps with `remake`, i.e. it does not have a symbolic origin." *
24-
" Please use `remake` with the `p` keyword argument as a vector of values, paying attention to parameter order."))
25-
hasproperty(cache.f, :sys) && hasfield(typeof(cache.f.sys), :states) ||
26-
throw(ArgumentError("This cache does not support symbolic maps with `remake`, i.e. it does not have a symbolic origin." *
27-
" Please use `remake` with the `u0` keyword argument as a vector of values, paying attention to state order."))
28-
p, u0 = SciMLBase.process_p_u0_symbolic(cache, p, u0)
29-
end
30-
end
31-
32-
cache.reinit_cache.p = p
33-
cache.reinit_cache.u0 = u0
34-
35-
return cache
36-
end
37-
381
struct OptimizationCache{F, RC, LB, UB, LC, UC, S, O, D, P, C} <:
392
SciMLBase.AbstractOptimizationCache
403
f::F

0 commit comments

Comments
 (0)