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

Allowing functions containing parameters for Contractor #142

Closed
wants to merge 1 commit into from
Closed

Allowing functions containing parameters for Contractor #142

wants to merge 1 commit into from

Conversation

yashvardhan747
Copy link
Contributor

@yashvardhan747 yashvardhan747 commented May 19, 2019

Fixes #140

@yashvardhan747
Copy link
Contributor Author

@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.

@yashvardhan747
Copy link
Contributor Author

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
Copy link
Member

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)
Copy link
Member

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])
Copy link
Member

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.

@dpsanders
Copy link
Member

No longer relevant.

@dpsanders dpsanders closed this Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow parameters in Contractor
2 participants