Skip to content

Commit

Permalink
Fix non-const module shortcuts
Browse files Browse the repository at this point in the history
  • Loading branch information
blegat committed Apr 16, 2024
1 parent 9caa369 commit 59dca38
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 21 deletions.
2 changes: 1 addition & 1 deletion docs/src/examples/utils/Tree.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ using LinearAlgebra, Plots, Colors

# The main package [Dionysos](https://github.com/dionysos-dev/Dionysos.jl) provides most important data structures that we will need.
using Dionysos
UT = Dionysos.Utils
const UT = Dionysos.Utils

# We define the underlying metric between node states
distance(E1::UT.Ellipsoid, E2::UT.Ellipsoid) = UT.pointCenterDistance(E1, E2.c)
Expand Down
2 changes: 1 addition & 1 deletion src/domain/domain.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Domain

using StaticArrays, Plots
using ..Utils
UT = Utils
const UT = Utils

abstract type DomainType{N, T} end

Expand Down
13 changes: 3 additions & 10 deletions src/domain/domain_list.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,11 @@ function add_set!(domain, unionSetArray::UT.LazyUnionSetArray, incl_mode::INCL_M
end
end

# For some reason that I fail to see, Julia's inference fails and the loop
# then allocates for every iteration if the content of this function is
# just copy-pasted to `add_set!`
function _add_set!(domain, ranges)
for pos in Iterators.product(ranges...)
add_pos!(domain, pos)
end
end

function add_set!(domain, rect::UT.HyperRectangle, incl_mode::INCL_MODE)
rectI = get_pos_lims(domain.grid, rect, incl_mode)
return _add_set!(domain, _ranges(rectI))
for pos in Iterators.product(_ranges(rectI)...)
add_pos!(domain, pos)
end
end

function get_subset_pos(domain::DomainList, rect::UT.HyperRectangle, incl_mode::INCL_MODE)
Expand Down
4 changes: 2 additions & 2 deletions src/mapping/mapping.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module Mapping

using ..Domain
DO = Domain
const DO = Domain

using ..Utils
UT = Utils
const UT = Utils

include("mapping_continuous.jl")

Expand Down
2 changes: 1 addition & 1 deletion src/problem/problem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module Problem
using StaticArrays

using ..Utils
UT = Utils
const UT = Utils

include("problems.jl")

Expand Down
2 changes: 1 addition & 1 deletion src/symbolic/ellipsoidal_transitions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ using JuMP

using ..Domain
using ..Utils
UT = Utils
const UT = Utils

AffineSys = Union{
HybridSystems.NoisyConstrainedAffineControlDiscreteSystem,
Expand Down
6 changes: 3 additions & 3 deletions src/symbolic/symbolic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ using StaticArrays
using LinearAlgebra

using ..Utils
UT = Utils
const UT = Utils

using ..Domain
DO = Domain
const DO = Domain

using ..System
ST = System
const ST = System

include("automaton.jl")
include("symbolicmodel.jl")
Expand Down
4 changes: 2 additions & 2 deletions test/domain/test_griddomain.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ println("Started test")
domain3 = DO.DomainList(DO.GridFree(orig, SVector(0.1, 0.1)))
# First we compile
@allocated DO.add_set!(domain3, rect, DO.OUTER)
# It gives me 208 with Julia v1.10.2 but let's leave some margin
@test (@allocated DO.add_set!(domain3, rect, DO.OUTER)) < 256
# Test for the regression detected in https://github.com/dionysos-dev/Dionysos.jl/pull/346#issuecomment-2059069415
@test (@allocated DO.add_set!(domain3, rect, DO.OUTER)) == 0
end

sleep(0.1) # used for good printing
Expand Down

0 comments on commit 59dca38

Please sign in to comment.