Skip to content

Conversation

@shinaoka
Copy link
Member

Summary

Add backward compatibility support for sparse-ir 1.x API to help users migrate from older versions.

Changes

Backward Compatibility Features

  • work_dtype parameter in sve.compute(): Accepts but ignores this parameter for backward compatibility with sparse-ir 1.x
  • kernel parameter in FiniteTempBasis.__init__(): Accepts kernel parameter (deprecated) to maintain compatibility with legacy code
  • max_size parameter: Made optional with keyword-only argument

Bug Fixes

  • Fixed MatsubaraSampling.fit() bug

Merged Changes from mainline

API Changes

Before (sparse-ir 1.x)

# Old API with work_dtype
sve_result = sparse_ir.sve.compute(kernel, eps=1e-5, work_dtype=numpy.float64)

# Old API with kernel parameter
basis = sparse_ir.FiniteTempBasis('F', beta, wmax, eps=1e-5, kernel=kernel)

After (sparse-ir 2.x with compatibility)

# Still works! work_dtype is accepted but ignored
sve_result = sparse_ir.sve.compute(kernel, eps=1e-5, work_dtype=numpy.float64)

# Still works! kernel is accepted but deprecated
basis = sparse_ir.FiniteTempBasis('F', beta, wmax, eps=1e-5, kernel=kernel)

# Recommended new API
sve_result = sparse_ir.sve.compute(kernel, eps=1e-5)
basis = sparse_ir.FiniteTempBasis('F', beta, wmax, eps=1e-5)

Testing

  • All 95 tests pass
  • No breaking changes to existing code

Motivation

This allows packages like dcorelib that depend on sparse-ir 1.x API to work with sparse-ir 2.1.0 without requiring immediate code changes.

- Add work_dtype parameter to sve.compute() and SVEResult to control
  working precision during SVE/SVD computation
- Add backward-compatible API to FiniteTempBasis.__init__() to support
  kernel= and max_size= keyword arguments
- Fix bug in MatsubaraSampling.fit() that only returned real part,
  causing loss of imaginary components in fitted coefficients
@shinaoka shinaoka merged commit d956bc7 into mainline Dec 30, 2025
9 checks passed
@shinaoka shinaoka mentioned this pull request Dec 30, 2025
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