Conversation
assumes a standard-conforming XYZ file
| # Guessing time | ||
| atomtypes = guessers.guess_types(names) | ||
| masses = guessers.guess_masses(atomtypes) | ||
| masses = guessers.guess_masses(names) |
There was a problem hiding this comment.
Here I assume that names contain element symbols (XYZ file format). As discusses in #2420 this might not always be the case. Should I make this more flexible?
There was a problem hiding this comment.
I think (hope) guess_masses is smart enough to skip a bad value and print a warning?
|
@richardjgowers tests for the writer are still missing... Any suggestions on how to best write them? |
|
@RMeli something like... import io
import MDAnalysis as mda
u = mda.Universe.empty(n_atoms=5)
u.add_TopologyAttr('elements', values=['Te', 'S', 'Ti', 'N', 'Ga'])
ns = mda.lib.util.NamedStream(io.StringIO(), 'file.xyz')
with mda.Writer(ns) as w:
w.write(u)
names = ''.join(l.split()[0] for l in ns.readlines())
assert names[:-1].lower() == 'testing' |
|
@richardjgowers Thanks for the funny suggestion. I meant to ask how to best incorporate them in the existing suite... I put the tests in |
Codecov Report
@@ Coverage Diff @@
## develop #2456 +/- ##
===========================================
+ Coverage 89.99% 90.01% +0.01%
===========================================
Files 177 177
Lines 22439 22233 -206
Branches 2914 2908 -6
===========================================
- Hits 20193 20012 -181
+ Misses 1637 1619 -18
+ Partials 609 602 -7
Continue to review full report at Codecov.
|
|
Given that @richardjgowers approved and I checked the codecov is nothing to worry about (the low diff coverage comes from changes in indentations that don't even show up in these files – weird) so I am merging, |
Fixes #2420 and #2421
Changes made in this Pull Request:
XYZParseradds elements attributeXYZWritertries to use theatoms.elementsattribute (fallback toatoms.names)PR Checklist