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

feat: add BatchedInterface #65

Merged
merged 5 commits into from
Apr 11, 2024
Merged

feat: add BatchedInterface #65

merged 5 commits into from
Apr 11, 2024

Conversation

AayushSabharwal
Copy link
Member

Checklist

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

Additional context

Add any other context about the problem here.

Copy link

codecov bot commented Apr 2, 2024

Codecov Report

Attention: Patch coverage is 0% with 124 lines in your changes are missing coverage. Please review.

Project coverage is 26.68%. Comparing base (f43b850) to head (6dba9ff).

Files Patch % Lines
src/batched_interface.jl 0.00% 124 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master      #65       +/-   ##
===========================================
+ Coverage    0.00%   26.68%   +26.68%     
===========================================
  Files           8       10        +2     
  Lines         372      476      +104     
===========================================
+ Hits            0      127      +127     
+ Misses        372      349       -23     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@test associated_systems(bi) == [1, 1, 1, 1, 2, 2, 3, 3]

getter = getu(bi)
@test (@inferred getter(probs...)) == [1.0, 3.0, 0.2, 0.3, 5.0, 0.6, 0.7, 0.8]
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't seem quite right, you'd want an array for each to make remaking easy?

if !is_variable(sys, sym) && !is_parameter(sys, sym)
error("Only variables and parameters allowed in BatchedInterface.")
end
if !in(sym, symbol_order)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if !in(sym, symbol_order)
if isnothing(findfirst(isequal(sym), symbol_order))

I think this should be changed as in least to using symbolic variables in a Boolean context.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed in db5038a

Copy link
Contributor

@SebastianM-C SebastianM-C left a comment

Choose a reason for hiding this comment

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

Thanks!

error("Only symbolic variables allowed in BatchedInterface.")
end
if symbolic_type(sym) === ArraySymbolic()
append!(allsyms, collect(sym))
Copy link
Contributor

Choose a reason for hiding this comment

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

This removes the need for ArrayPartitions?

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

@variables x[1:2] y z

syss = [
SymbolCache([x..., y]),
Copy link
Contributor

Choose a reason for hiding this comment

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

Is splatting required? Would [x, y] work?

Copy link
Member Author

Choose a reason for hiding this comment

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

Splatting is required. SymbolCache treats the variables as-is, so it would think x is at index 1 and y at 2

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, I see. But for array parameters in MTK, that would be different?

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. This is specifically only needed for SymbolCache, MTK handles it completely differently. I didn't want to pull in MTK for this one test so I used Symbolics and the rest of the SII infrastructure

@AayushSabharwal
Copy link
Member Author

SciMLBase downstream failing here is my fault in MTK 😅 It's fixed in SciML/ModelingToolkit.jl#2630

@ChrisRackauckas
Copy link
Member

Can we get a follow up tutorial on the batched interface? That's one that takes a bit more depth than the other pieces.

@ChrisRackauckas ChrisRackauckas merged commit 063783b into master Apr 11, 2024
12 of 13 checks passed
@ChrisRackauckas ChrisRackauckas deleted the as/batched-getu branch April 11, 2024 14:09
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.

3 participants