Skip to content

UnitCell.GetLatticePar() without index fails on nanobind_migration_test #127

Open

Description

@clemisch
from pyobjcryst.crystal import Crystal

c = Crystal(4.76, 4.76, 12.99, "R-3c")

print(c.GetLatticePar(0))  # 4.76
print(c.GetLatticePar())   # main: array of 6 values; nanobind branch: TypeError
# TypeError: Unable to convert function return value to a Python type!
#     GetLatticePar(self) -> CrystVector<double>

On main, GetLatticePar() returns numpy array of 6 lattice params through the globally used CrystVector_REAL_to_ndarray converter.

On the nanobind branch, nb_unitcell.cpp:95 binds the overload directly, and since there's no converter for CrystVector<double>, the conversion fails. Claude suggests wrapping it in crystvec_to_array to fix it.

All existing tests call GetLatticePar(index) so didn't catch this regression. Other methods returning CrystVector might have the same problem.

(tested on 3452813)

Activity

  1. sbillinge commented on Nov 12, 2026

    @sbillinge
    Contributor

    thanks @clemisch

  2. vincefn commented on Nov 13, 2026

    @vincefn
    Collaborator

    @clemisch can you propose a PR for this ?

  3. clemisch commented on Nov 13, 2026

    @clemisch
    ContributorAuthor

    I'm happy to, but I didn't so far because tbh my knowledge of nanobind is limited to what Claude tells me, so I was waiting for your opinion on it 😬 I'll propose a PR and we can discuss there

    *see #128

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions