Skip to content

Commit 8d75e26

Browse files
authored
Fix isinstance check in hm - allow 'bands' to be any integral type. (#92)
Replace the `isinstance(bands, int)` in hm.py with `isinstance(bands, numbers.Integral)` - this fixes an error where passing e.g. a numpy int would crash the calculation.
1 parent b3b3fad commit 8d75e26

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,6 @@ htmlcov
5555

5656
# editors
5757
.vscode
58+
59+
# Jupyter
60+
.ipynb_checkpoints

z2pack/hm.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
This module contains a class for creating Systems which are described by a Hamiltonian matrix (hm), such as k•p models.
55
"""
66

7+
import numbers
78
import itertools
89

910
import numpy as np
@@ -84,7 +85,7 @@ def __init__(
8485
self._pos = [np.array(p) for p in pos]
8586
if bands is None:
8687
bands = size // 2
87-
if isinstance(bands, int):
88+
if isinstance(bands, numbers.Integral):
8889
self._bands = list(range(bands))
8990
else:
9091
self._bands = bands

0 commit comments

Comments
 (0)