Skip to content

fix: return numpy arrays from CrystVector/CrystMatrix bindings - #128

Open
clemisch wants to merge 2 commits into
diffpy:nanobind_migration_testfrom
clemisch:127_getlatticepar-converter
Open

clemisch wants to merge 2 commits into
diffpy:nanobind_migration_testfrom
clemisch:127_getlatticepar-converter

Conversation

@clemisch

Copy link
Copy Markdown
Contributor

nanobind has no global converter for CrystVector_REAL/CrystMatrix_REAL, so bindings that returned them directly raised when called.

Wrap them in crystvec_to_array/crystmat_to_array:

  • UnitCell.GetLatticePar(), UnitCell.GetOrthonormalCoords()
  • Crystal.GetMinDistanceTable()
  • ScatteringPower.GetScatteringFactor(), GetTemperatureFactor(), GetResonantScattFactReal(), GetResonantScattFactImag(), (both in the base binding and in the forwarding for ScatteringPowerAtom and GlobalScatteringPower)

Add tests that call each method, plus a check that no binding's signature still returns a raw CrystVector/CrystMatrix.

fixes #127

nanobind has no global converter for CrystVector_REAL/CrystMatrix_REAL,
so bindings that returned them directly raised when called.

Wrap them in crystvec_to_array/crystmat_to_array:

- UnitCell.GetLatticePar(), UnitCell.GetOrthonormalCoords()
- Crystal.GetMinDistanceTable()
- ScatteringPower.GetScatteringFactor(), GetTemperatureFactor(),
  GetResonantScattFactReal(), GetResonantScattFactImag(),
  (both in the base binding and in the forwarding for ScatteringPowerAtom
  and GlobalScatteringPower)

Add tests that call each method, plus a check that no binding's
signature still returns a raw CrystVector/CrystMatrix.

fixes diffpy#127

This branch has not been deployed

No deployments
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.

1 participant