HEXRD / hexrd

A cross-platform, open-source library for the analysis of X-ray diffraction data.
Other
54 stars 26 forks source link

fix error in fractional occupancy cases while reading cif file. #650

Open saransh13 opened 3 weeks ago

saransh13 commented 3 weeks ago

Same as description.

pep8speaks commented 3 weeks ago

Hello @saransh13! Thanks for opening this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 724:13: E722 do not use bare 'except'

saransh13 commented 3 weeks ago

@psavery it seems like PEP8 is not happy with the bare except. Do you know of a better way to handle this part of the code?

psavery commented 3 weeks ago

It wants you to specify the type of exception. In this case, it should only ever raise a ValueError, so you could do except ValueError:.

If you want to catch every possible exception, you can still do except Exception:, which catches them all.

ZackAttack614 commented 2 weeks ago

This may be a bit cleaner, if I am understanding the use case well enough:

            occ = []
            for p in cifdata[occ_U[0]]:
                v = p.split('(')[0]

                occ.append(np.float64(v) if v.isnumeric() else 1.0)

            atompos.append(np.asarray(occ))