Skip to content

Clarify interface requirements for supports_inplace and similar#103

Merged
goerz merged 4 commits into
masterfrom
clarify-supports-inplace
Feb 24, 2026
Merged

Clarify interface requirements for supports_inplace and similar#103
goerz merged 4 commits into
masterfrom
clarify-supports-inplace

Conversation

@goerz
Copy link
Copy Markdown
Member

@goerz goerz commented Feb 24, 2026

Delegate to ArrayInterface.

Closes #102

The `similar` function must return a "mutable" array, but not
necessarily one that returns `true` for `supports_inplace`. Instead,
`ArrayInterface.ismutable` seems like a more sensible check.
The expectation is that we can use in-place operators for abstract
arrays that are both mutable and can for which write access is
efficient. The `ArrayInterface` package provides traits for this.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes an incorrect fallback for the supports_inplace interface function by delegating to ArrayInterface.ismutable and ArrayInterface.fast_scalar_indexing instead of using Base.ismutabletype, which incorrectly returns false for wrapper types like Hermitian{ComplexF64, Matrix{ComplexF64}} that do support in-place operations.

Changes:

  • Updated supports_inplace fallback to use ArrayInterface.ismutable(T) && ArrayInterface.fast_scalar_indexing(T) for AbstractArray types
  • Changed validation in check_state and check_operator to use ArrayInterface.ismutable instead of supports_inplace when checking similar() results
  • Added comprehensive test for Hermitian matrices to verify the fix
  • Updated documentation to clarify interface requirements and added ArrayInterface references

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
Project.toml Added ArrayInterface 7.0 as a dependency
docs/Project.toml Added ArrayInterface for documentation
docs/make.jl Added ArrayInterface documentation link
test/Project.toml Added ArrayInterface for tests
src/interfaces/supports_inplace.jl Updated fallback to use ArrayInterface functions and improved documentation
src/interfaces/supports_matrix_interface.jl Clarified that setindex! is not required for matrix interface
src/interfaces/state.jl Changed validation to use ArrayInterface.ismutable and fixed typo in documentation
src/interfaces/operator.jl Changed validation to use ArrayInterface.ismutable and clarified documentation
test/test_operator_linalg.jl Added test for Hermitian matrix in-place support
test/test_invalid_interfaces.jl Updated error message expectations to match new validation approach

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/interfaces/supports_inplace.jl
Comment thread src/interfaces/supports_inplace.jl Outdated
As pointed out by GitHub Copilot in code review
@goerz goerz force-pushed the clarify-supports-inplace branch from ac88cc4 to 356d684 Compare February 24, 2026 22:58
@goerz goerz merged commit d6dfe6f into master Feb 24, 2026
5 checks passed
@goerz goerz deleted the clarify-supports-inplace branch February 24, 2026 23:04
@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 24, 2026

Codecov Report

❌ Patch coverage is 90.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 90.2%. Comparing base (e6ead20) to head (356d684).
⚠️ Report is 5 commits behind head on master.

Files with missing lines Patch % Lines
src/interfaces/supports_inplace.jl 50.0% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           master    #103     +/-   ##
========================================
+ Coverage    90.2%   90.2%   +0.1%     
========================================
  Files          35      35             
  Lines        2551    2550      -1     
========================================
  Hits         2299    2299             
+ Misses        252     251      -1     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

Incorrect fallback for supports_inplace

2 participants