Comments (1)
with ] add FixArgs#nested
(see Manifest.toml
for full details)
using LazySets: LazySets, Interval, VPolytope
using LazySets: intersection, cartesian_product
using LazySets: concretize
using LazySets: CartesianProduct, Intersection, CartesianProductArray, AbstractPolyhedron
using FixArgs: FixArgs, @fix, Fix, @FixT
using Polyhedra: Polyhedra # LazySets: package 'Polyhedra' not loaded (it is required for executing `default_polyhedra_backend`)
a = Interval(0.1, 0.9)
b = Interval(0.2, 0.8)
c = VPolytope([[0.0, 0.0], [1.0, 0.0], [0.0, 1.0]])
cap_now = Intersection(CartesianProductArray([a, b]), c)
cap_fix = @fix intersection((@fix reduce(cartesian_product, [a, b])), c)
# Note, this definition is not needed to create `cap_fix` above!
function LazySets.cartesian_product(a::Interval, b::Interval)
cartesian_product(
convert(VPolytope, a),
convert(VPolytope, b)
)
end
cap_now_concrete = concretize(cap_now)
cap_fix_concrete = cap_fix(())
println("\nconcretization evalautes to the same value:")
@show cap_now_concrete == cap_fix_concrete
println("\n")
@show typeof(cap_now)
println("\n")
@show typeof(cap_fix)
# type annotation on `cap` argument:
# https://github.com/JuliaReach/LazySets.jl/blob/53f21cb9c26355e7f218578e5b4036c3ff0091fe/src/Approximations/overapproximate.jl#L1202
T_now{N} = Intersection{
N,
<:CartesianProductArray,
<:AbstractPolyhedron
}
println("\nvalue type and annotation type now:")
@show typeof(cap_now) <: T_now
CartesianProductArray_fix{T} = FixArgs.@FixT reduce(::typeof(cartesian_product), ::Vector{T})
# @FixT wraps with `Some` unless `nothing`, and @fix leaves `Fix` unwrapped.
# TODO allow the following to work
# Intersection_fix{#=N, =#A, B} = FixArgs.@FixT intersection(::A, ::B)
# TODO allow extra type parameters in `Fix` type (maybe in a `Tuple`)
Intersection_fix{#=N, =#A, B} = Fix{typeof(intersection),Tuple{A, B}, NamedTuple{(), Tuple{}}} where B where A
T_fix#={N}=# = Intersection_fix{#=N, =#CartesianProductArray_fix{T}, Some{B}} where {T, B <: AbstractPolyhedron}
println("\nvalue type and annotation type using FixArgs.jl:")
@show typeof(cap_fix) <: T_fix
/Users/goretkin/projects/LazySetsFixArgs/Manifest.toml
println("\npieces of the types:")
@show typeof(cap_fix.args[1]) <: CartesianProductArray_fix
@show typeof(something(cap_fix.args[2])) <: AbstractPolyhedron
output
concretization evalautes to the same value:
cap_now_concrete == cap_fix_concrete = true
typeof(cap_now) = Intersection{Float64,CartesianProductArray{Float64,Interval{Float64,IntervalArithmetic.Interval{Float64}}},VPolytope{Float64,Array{Float64,1}}}
typeof(cap_fix) = Fix{typeof(intersection),Tuple{Fix{typeof(reduce),Tuple{Some{typeof(cartesian_product)},Some{Array{Interval{Float64,IntervalArithmetic.Interval{Float64}},1}}},NamedTuple{(),Tuple{}}},Some{VPolytope{Float64,Array{Float64,1}}}},NamedTuple{(),Tuple{}}}
value type and annotation type now:
typeof(cap_now) <: T_now = true
value type and annotation type using FixArgs.jl:
typeof(cap_fix) <: T_fix = true
pieces of the types:
typeof(cap_fix.args[1]) <: CartesianProductArray_fix = true
typeof(something(cap_fix.args[2])) <: AbstractPolyhedron = true
true
from fixargs.jl.
Related Issues (19)
- simplify type parameter corresponding to keyword arguments HOT 1
- positional placeholder ("holes") HOT 1
- reify function arguments on their own, e.g. `FrankenTuples` HOT 1
- TagBot trigger issue HOT 3
- nesting HOT 10
- Error message to suggest rewriting some syntax as a function call
- Do not use nothing for holes? HOT 29
- Mention related packages in README HOT 5
- Connection to structural typing?
- Support or not for closures
- Related patterns HOT 4
- Broadcasting considerations HOT 2
- inference with nested lambdas
- Rename+export bind? HOT 4
- Version released to Pkg is old HOT 4
- Broadcast Functions not working
- Rename and register? HOT 4
- Macros to facilitate expressing types in methods HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fixargs.jl.