Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing compat bound #37

Merged
merged 21 commits into from
Oct 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ version = "0.7.0"
Dictionaries = "85a47980-9c8c-11e8-2b9f-f7ca1fa99fb4"
JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
SnoopPrecompile = "66db9d55-30c0-4569-8b51-7e840670fc0c"

[compat]
Dictionaries = "0.3"
JuMP = "1"
SnoopPrecompile = "1"
julia = "1.6"
33 changes: 33 additions & 0 deletions src/SparseVariables.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module SparseVariables
using Dictionaries
using JuMP
using LinearAlgebra
using SnoopPrecompile

include("sparsearray.jl")
include("dictionaries.jl")
Expand All @@ -14,4 +15,36 @@ export IndexedVarArray
export insertvar!
export unsafe_insertvar!

@precompile_setup begin
# Putting some things in `setup` can reduce the size of the
# precompile file and potentially make loading faster.
rs = 1:10
is = [1, 2, 3]
sts = ["a", "b"]
sys = [:a, :b]
m = Model()

@precompile_all_calls begin
# all calls in this block will be precompiled, regardless of whether
# they belong to your package or not (on Julia 1.8 and higher)

@variable(
m,
x[r = rs, i = is, st = sts, sy = sys];
container = IndexedVarArray
)
for r in rs, i in is, st in sts, sy in sys
insertvar!(x, r, i, st, sy)
unsafe_insertvar!(x, r, i, st, sy)
end
x[:, 1, :, :]
x[10, :, :, :]
x[1, :, :, :a]
@variable(m, y[i = rs, j = rs, k = rs]; container = IndexedVarArray)
for i in rs, j in rs, k in rs
insertvar!(y, i, j, k)
end
end
end

end # module