Skip to content

Commit

Permalink
comments and input validation in simplesupercell
Browse files Browse the repository at this point in the history
  • Loading branch information
bonfus committed May 27, 2016
1 parent b5aafa0 commit e3b7b85
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
20 changes: 20 additions & 0 deletions muesr/core/cells.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,26 @@ def get_simple_supercell(sample, multi):

unitcell = sample.cell

if type(multi) is np.ndarray:
multi = multi.tolist()

if type(multi) is list:
if len(multi) == 3:
try:
multi = [int(x) for x in multi]
except:
raise TypeError('Cannot convert multi to int')
if multi[0] <= 0 or multi[1] <= 0 or multi[2] <= 0:
raise ValueError('Supercell values must be strictly positive.')
else:
# everything is fine!
pass
else:
raise ValueError('multi must be a 3D vector!')
else:
raise TypeError('multi must me list or numpy array of integers' +
' (automatically converted)')

have_mag_structure = True

FC=None
Expand Down
2 changes: 2 additions & 0 deletions muesr/io/xsf/xsfio.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@


def write_xsf(fileobj, images, data=None):

# this won't work with unicode!!
if isinstance(fileobj, str):
fileobj = open(fileobj, 'w')

Expand Down

0 comments on commit e3b7b85

Please sign in to comment.