-
Notifications
You must be signed in to change notification settings - Fork 16
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
Allowing functions containing parameters for Contractor #142
Allowing functions containing parameters for Contractor #142
Conversation
@dpsanders as you suggested, I allowed to input parameters in function argument to avoid the problem of slowing down the process due to global variables. And also made the test cases as you needed. |
I think you can merge this PR now. |
@@ -148,7 +157,7 @@ BasicContractor(vars, f::Function) = BasicContractor([Variable(Symbol(i))() for | |||
|
|||
Contractor(expr::Operation) = Contractor([], expr::Operation) | |||
|
|||
Contractor(vars::Union{Vector{Operation}, Tuple{Vararg{Operation,N}}}, g::Function) where N = Contractor(vars, g(vars...)) #Contractor can be constructed by function name only | |||
Contractor(vars::Union{Vector{Operation}, Tuple{Vararg{Operation,N}}}, para::Union{Vector{Operation}, Tuple{Vararg{Operation,N}}}, g::Function) where N = Contractor(vars, g(vars..., para...)) #Contractor can be constructed by function name onlyContractor(vars::Union{Vector{Operation}, Tuple{Vararg{Operation,N}}}, g::Function) where N = Contractor(vars, g(vars...)) #Contractor can be constructed by function name only |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should not be necessary to use so many type annotations.
Also there is some duplication at the end of the line.
Please always add a space after #
in comments.
|
||
for p in parameters | ||
X = ×(X, p..p) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be very slow.
Also the parameters might conceivably be intervals.
@@ -69,25 +74,29 @@ function contract(C::AbstractContractor, A::IntervalBox{Nout,T}, X::IntervalBox{ | |||
# @show constrained | |||
# @show intermediate | |||
# @show C.backward(X, constrained, intermediate) | |||
return IntervalBox{N,T}(C.backward(X, constrained, intermediate) ) | |||
return IntervalBox{N,T}(C.backward(X, constrained, intermediate)[1:N]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why there's [1:N]
here suddenly.
No longer relevant. |
Fixes #140