-
-
Notifications
You must be signed in to change notification settings - Fork 119
allow for arbitrary array types in CallbackCache #341
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
Conversation
@@ -637,7 +637,15 @@ mutable struct CallbackCache{conditionType,signType} | |||
prev_sign::signType | |||
end | |||
|
|||
function CallbackCache(max_len,conditionType::Type,signType::Type) | |||
function CallbackCache(u,max_len,::Type{conditionType},::Type{signType}) where {conditionType,signType} |
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.
What's the purpose of the where
clauses? IMO all type annotations could/should be removed.
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.
::Type
doesn't specialize.
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.
But isn't it sufficient to remove the type annotation completely?
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.
IIRC no, you need to specialize it so it transforms it from DataType
.
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.
IIRC, this and how ::Function
works are the two exceptions to the auto-specialization rule.
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.
Oh interesting, I didn't know that
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.
But wait, isn't it slightly different for Function
in that if the type annotation is removed, it is actually specialized? E.g., f(g) = g(0)
should specialize whereas f(g::Function) = g(0)
doesn'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.
Yes, it's the opposite way with Function
, with the caveat that Function
will also specialize there if it's called... two oddly specific and weird heuristics.
CallbackCache{typeof(tmp_condition),typeof(next_sign)}(tmp_condition,previous_condition,next_sign,prev_sign) | ||
end | ||
|
||
function CallbackCache(max_len,::Type{conditionType},::Type{signType}) where {conditionType,signType} |
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.
Same here
No description provided.