Skip to content

Conversation

@ChrisRackauckas-Claude
Copy link

Summary

  • Remove unnecessary isinplace check from OptimizationFunction{iip} constructor when iip is explicitly provided
  • Add tests to verify the fix works correctly
  • Align behavior with ODEFunction{iip} which already handles this correctly

Problem

OptimizationFunction{false} was still calling isinplace(f, 2) even when the user explicitly provided the iip=false type parameter. This prevented users from creating OptimizationFunction objects with functions that fail the isinplace check (such as compiled Reactant functions), even when they know the function signature and want to bypass the automatic detection.

Solution

  • Remove the isinplace call from line 4282 in the OptimizationFunction{iip} constructor
  • Keep the isinplace call in the non-parameterized OptimizationFunction constructor where it's needed to infer the iip value
  • Add tests to ensure both OptimizationFunction{false} and OptimizationFunction{true} work without triggering isinplace checks

Test plan

  • All existing tests pass
  • New test verifies that OptimizationFunction{iip} can be created with functions that would fail isinplace checks
  • Behavior now matches ODEFunction{iip} patterns

Fixes #1103

🤖 Generated with Claude Code

ChrisRackauckas and others added 2 commits September 3, 2025 09:10
Remove isinplace call from OptimizationFunction{iip} constructor when
iip is explicitly provided. This matches the behavior of ODEFunction
and fixes issue SciML#1103 where functions that fail isinplace checks
(like compiled Reactant functions) cannot be used even when the user
explicitly specifies the iip parameter.

The isinplace check is kept for the non-parameterized
OptimizationFunction constructor where it's needed to infer the iip value.

Fixes SciML#1103

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@ChrisRackauckas ChrisRackauckas merged commit 898f9ac into SciML:master Sep 3, 2025
49 of 63 checks passed
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.

OptimizationFunction{false} still does isinplace check

2 participants