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

Add strip_cache for DECache #766

Closed
wants to merge 4 commits into from

Conversation

jClugstor
Copy link
Contributor

Checklist

  • [ x] Appropriate tests were added
  • [ x] Any code changes were done in a way that does not break public API
  • [ x] All documentation related to code changes were updated
  • [ x] The new code follows the
    contributor guidelines, in particular the SciML Style Guide and
    COLPRAC.
  • [ x] Any new documentation only uses public API

Additional context

Add any other context about the problem here.

@ChrisRackauckas
Copy link
Member

Create a test that catches this.

@jClugstor jClugstor changed the title Fix typo in strip_interpolation Add strip_cache for DECache Aug 19, 2024
@ChrisRackauckas
Copy link
Member

why is this needed here? Isn't it just internal to OrdinaryDiffEq?

@jClugstor
Copy link
Contributor Author

I wasn't sure if there were other interpolation types in SciMLBase that would have caches.
Is it better to just put

function strip_cache(cache::OrdinaryDiffEqCache)
    # most caches don't have jac_config or grad_config
    cache
end

in to OrdinaryDiffEq?

@ChrisRackauckas
Copy link
Member

You define a special strip_interpolation in OrdianryDiffEq, and that will have a function in there to strip caches, and then that is defined as just a helper which uses knowledge of how caches in OrdinaryDiffEq work. I don't see that as generic at all though.

@jClugstor
Copy link
Contributor Author

I was thinking something like this:

function SciMLBase.strip_interpolation(id::InterpolationData)
    cache = id.cache
    
    cache = strip_cache(cache)

    InterpolationData(nothing, id.timeseries,
        id.ts,
        id.ks,
        id.alg_choice,
        id.dense,
        cache,
        id.differential_vars,
        id.sensitivitymode)
end

function strip_cache(cache::OrdinaryDiffEqCache)
    # most caches don't have jac_config or grad_config
    cache
end

and then I can define strip_cache specifically for the cache types that need jac_config and grad_config to be taken out.

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