Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling geometry.close with ret_isc=True and a single radius fails. #605

Closed
nils-wittemeier opened this issue Aug 3, 2023 · 2 comments
Closed

Comments

@nils-wittemeier
Copy link
Contributor

Describe the bug
Calling geometry.close with ret_isc=True and a single radius fails. Possibly related to #604

Reproducable code

import sisl
g = sisl.Geometry([0.,0.,0.], lattice=sisl.Lattice([[1.,0.,0.],[0.,1.,0.],[0.,0.,1.]], nsc=[3,3,3]))
print('No extra return', geometry.close(0, R=0.5))                # Works fine
print('Return isc', geometry.close(0, R=0.5, ret_isc=True))    # Failes with TypeError

Output

No extra return [ 0  2  4  5  6  8 10 11 12 13 14 15 16 17 19 21 22 23 25]
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[7], line 4
      2 g = sisl.Geometry([0.,0.,0.], lattice=sisl.Lattice([[1.,0.,0.],[0.,1.,0.],[0.,0.,1.]], nsc=[3,3,3]))
      3 print('No extra return', geometry.close(0, R=1.5))
----> 4 print('Return isc', geometry.close(0, R=1.5, ret_isc=True))
      5 print('Return xyz', geometry.close(0, R=1.5, ret_xyz=True))
      6 print('Return xyz', geometry.close(0, R=1.5, ret_rij=True))

File [~/codes/sisl/src/sisl/geometry.py:3823](https://vscode-remote+ssh-002dremote-002bpc-002eicn2.vscode-resource.vscode-cdn.net/home/ICN2/nwittemeier/Projects/2023/tb-bdg-model/~/codes/sisl/src/sisl/geometry.py:3823), in Geometry.close(self, xyz_ia, R, atoms, atoms_xyz, ret_xyz, ret_rij, ret_isc)
   3821         if ret_isc:
   3822             ret[iisc][i] = concatenate((ret[iisc][i], isc_tile(isc, len(x))), axis=0)
-> 3823 elif len(sret[0]) > 0:
   3824     # We can add it to the list (len(R) == 1)
   3825     # We add the atomic offset for the supercell index
   3826     ret[0][0] = concatenate((ret[0][0], sret[0] + na), axis=0)
   3827     if ret_xyz:

TypeError: object of type 'numpy.int32' has no len()

Version details
Run the below code and add to bug-report:

>>> print(sys.version)
3.11.4 | packaged by conda-forge | (main, Jun 10 2023, 18:08:17) [GCC 12.2.0]
>>> print(sisl.__version__)
0.13.1.dev266+g9b1cc673
zerothi added a commit that referenced this issue Aug 5, 2023
It was a result of a leftover check since close_sc did
not return isc, and hence the check.

It should now work.

Signed-off-by: Nick Papior <[email protected]>
@zerothi
Copy link
Owner

zerothi commented Aug 5, 2023

Please check if it is fixed now, I believe so, thanks for the bug-report!

@zerothi zerothi closed this as completed Aug 6, 2023
@nils-wittemeier
Copy link
Contributor Author

Yes, works fine now. Thanks, Nick.

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

No branches or pull requests

2 participants