lmhale99 / atomman

Atomistic Manipulation Toolkit
Other
34 stars 40 forks source link

Impr: Error message when data not found by am.load('atom_data') #8

Closed arn-all closed 4 years ago

arn-all commented 5 years ago

Another improvement to the behaviour of am.load() that I'd like to work on :

Problem

When using am.load() with an incorrectly formatted file, or when providing it a filename that doesn't exist, the error message :

UnboundLocalError: local variable 'xlo' referenced before assignment

is not the one we'd expect for a missing file.

Steps to reproduce

import atomman as am
am.load("atom_data", "hello look at this error message")

---------------------------------------------------------------------------
UnboundLocalError                         Traceback (most recent call last)
<ipython-input-3-6c5913967289> in <module>
----> 1 am.load('atom_data',"hello, look at this error message")

~/.local/lib/python3.7/site-packages/atomman/load/__init__.py in load(style, input, **kwargs)
     44 
     45     elif style == 'atom_data':
---> 46         return load_atom_data(input, **kwargs)
     47 
     48     elif style == 'atom_dump':

~/.local/lib/python3.7/site-packages/atomman/load/atom_data/load.py in load(data, pbc, symbols, atom_style, units)
    106 
    107     # Create system
--> 108     box = Box(xlo=xlo, xhi=xhi,
    109               ylo=ylo, yhi=yhi,
    110               zlo=zlo, zhi=zhi,

UnboundLocalError: local variable 'xlo' referenced before assignment

Comments

lmhale99 commented 5 years ago

I'm for all of those suggestions.

Response to comments

lmhale99 commented 4 years ago

I made changes to the atom_data load/dump style in preparation of an upcoming atomman 1.3.0 release.

If you have the time, can you test the new atom_data behavior with your files to see that it is correct or if you have any other improvement suggestions?

arn-all commented 4 years ago

Hi,

I did different tests with my files, it all worked fine :

I just have two comments :

Anyway, THANKS for your work on that !

lmhale99 commented 4 years ago

That's good!

I'll close this one now.