Skip to content

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

Merged
merged 1 commit into from
Sep 20, 2019
Merged

Conversation

ChrisRackauckas
Copy link
Member

No description provided.

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

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

::Type doesn't specialize.

Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member Author

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.

Copy link
Member

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

Copy link
Member

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?

Copy link
Member Author

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

@ChrisRackauckas ChrisRackauckas merged commit a584988 into master Sep 20, 2019
@ChrisRackauckas ChrisRackauckas deleted the callback branch September 20, 2019 01:35
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.

2 participants