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

fix python script generated by kslice #154

Merged
merged 4 commits into from Dec 21, 2017

Conversation

qiaojunfeng
Copy link
Collaborator

Hi, when I run examples17 in the tutorial, I came up with a python error:

Traceback (most recent call last):
  File "Fe-kslice-fermi_lines.py", line 36, in <module>
    bbands=bands.reshape((dimy,dimx,numbands))
TypeError: 'float' object cannot be interpreted as an integer

The python script was generated by kslice calculation of postw90.x.
I'm using Anaconda 4.3.30 on openSUSE Tumbleweed.

I found simply add an int() conversion could fix the bug.
Thanks for the wannier90, it's wonderful!

@greschd
Copy link
Contributor

greschd commented Dec 20, 2017

Hi @qiaojunfeng,

This issue is due to division changing from integer division to "true" division from Python 2 to 3. While casting the result to int also works, the correct way of doing this would be to use the integer division operator //. For Python 2 compatibility, you need to add from __future__ import division to the top of the file.

So it would be

from __future__ import division

...

num_bands = bands_up.size // num_pt

EDIT: The future import is not needed to make integer division work in Python 2, only if you want the "regular" division to work the same in Py2 / 3.

@qiaojunfeng
Copy link
Collaborator Author

Hi @greschd ,

You are right, it's better to use floor division // than int casting. I have changed it to //. Forgive my dirty hack.

Moreover, I found another two minor bugs,

  1. in example18/Fe.win line 37, kslice_kmesh should be kslice_2dkmesh
  2. in Tutorial.pdf of example18, page 33, gnuplot> plot ‘Fe-kubo-A_xy.dat’ u 1:2 w l should be gnuplot> plot ‘Fe-kubo_A_xy.dat’ u 1:2 w l, the filename should be kubo_A instead of kubo-A

Copy link
Member

@jryates jryates left a comment

Choose a reason for hiding this comment

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

All looks good to me

@jryates
Copy link
Member

jryates commented Dec 21, 2017

Thanks for fixing this!

@jryates jryates merged commit 59c19ea into wannier-developers:develop Dec 21, 2017
@qiaojunfeng qiaojunfeng deleted the fix_kslice branch January 23, 2020 10:43
manxkim pushed a commit to manxkim/wannier90 that referenced this pull request Jan 10, 2021
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.

None yet

3 participants