-
Notifications
You must be signed in to change notification settings - Fork 17
New BasicContractor type is made #137
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
New BasicContractor type is made #137
Conversation
src/contractor.jl
Outdated
| end | ||
|
|
||
| struct BasicContractor{F1<:Function, F2<:Function} <:AbstractContractor | ||
| forward::GeneratedFunction{F1} |
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.
We don't need the code that's stored in a GeneratedFunction; this should just be the function itself.
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.
The goal is to have an object that satisfies isbitstype(C) == true.
src/contractor.jl
Outdated
|
|
||
| function (C::Contractor{N,Nout,F1,F2,ex})( | ||
| A::IntervalBox{Nout,T}, X::IntervalBox{N,T}) where {N,Nout,F1,F2,ex,T} | ||
| function (C::Contractor{N,1,F1,F2,ex})( |
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.
You can remove all the type parameters in this function, since we don't need them
src/contractor.jl
Outdated
| (C::Contractor{N,1,F1,F2,ex})(A::Interval{T}, X::IntervalBox{N,T}) where {N,F1,F2,ex,T} = C(IntervalBox(A), X) | ||
|
|
||
|
|
||
| function (C::BasicContractor{F1,F2})( |
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.
Ah, I forgot that you can't define this for abstract types :/ You can use metaprogramming instead to avoid this code duplication.
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.
Actually the easier thing would just be to factor out the contents of the function into a new function.
src/contractor.jl
Outdated
| (C::Contractor)(A::Interval{T}, X::IntervalBox{N,T}) where {N,T} = C(IntervalBox(A), X) | ||
|
|
||
|
|
||
| function Forward(C::AbstractContractor) |
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.
forward
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.
You can write this in one line.
src/contractor.jl
Outdated
| return C.forward | ||
| end | ||
|
|
||
| function Backward(C::AbstractContractor) |
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.
backward
src/contractor.jl
Outdated
|
|
||
| function (C::Contractor{N,Nout,F1,F2,ex})( | ||
| A::IntervalBox{Nout,T}, X::IntervalBox{N,T}) where {N,Nout,F1,F2,ex,T} | ||
| function (C::BasicContractor)( |
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 is a duplication of the code at line 52. This is what needs to be factored out.
src/contractor.jl
Outdated
|
|
||
| function (C::Contractor{N,Nout,F1,F2,ex})( | ||
| A::IntervalBox{Nout,T}, X::IntervalBox{N,T}) where {N,Nout,F1,F2,ex,T} | ||
| function Contract(C::AbstractContractor, A::IntervalBox{Nout,T}, X::IntervalBox{N,T})where {N,Nout,T} |
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.
contract
Capitals for types, lower case for functions.
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.
cool..
|
LGTM, thanks! |
Solves#136