Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing some doctests. #4118

Merged
merged 10 commits into from
Apr 11, 2023
30 changes: 22 additions & 8 deletions package/MDAnalysis/core/universe.py
Original file line number Diff line number Diff line change
Expand Up @@ -806,9 +806,12 @@ def add_TopologyAttr(self, topologyattr, values=None):
-------
For example to add bfactors to a Universe:

>>> u.add_TopologyAttr('bfactors')
>>> u.atoms.bfactors
array([ 0., 0., 0., ..., 0., 0., 0.])
>>> import MDAnalysis as mda
>>> from MDAnalysis.tests.datafiles import PSF, DCD
>>> u = mda.Universe(PSF, DCD)
>>> u.add_TopologyAttr('tempfactors')
>>> u.atoms.tempfactors
array([0., 0., 0., ..., 0., 0., 0.])

.. versionchanged:: 0.17.0
Can now also add TopologyAttrs with a string of the name of the
Expand Down Expand Up @@ -863,8 +866,15 @@ def del_TopologyAttr(self, topologyattr):
-------
For example to remove bfactors to a Universe:

>>> u.del_TopologyAttr('bfactors')
>>> hasattr(u.atoms[:3], 'bfactors')
>>> import MDAnalysis as mda
>>> from MDAnalysis.tests.datafiles import PSF, DCD
>>> u = mda.Universe(PSF, DCD)
>>> u.add_TopologyAttr('tempfactors')
>>> hasattr(u.atoms[:3], 'tempfactors')
True
>>>
>>> u.del_TopologyAttr('tempfactors')
>>> hasattr(u.atoms[:3], 'tempfactors')
False


Expand Down Expand Up @@ -987,9 +997,12 @@ def add_Residue(self, segment=None, **attrs):

Adding a new GLY residue, then placing atoms within it:

>>> newres = u.add_Residue(segment=u.segments[0], resid=42, resname='GLY')
>>> import MDAnalysis as mda
>>> from MDAnalysis.tests.datafiles import PSF, DCD
>>> u = mda.Universe(PSF, DCD)
>>> newres = u.add_Residue(segment=u.segments[0], resid=42, resname='GLY', resnum=0)
>>> u.atoms[[1, 2, 3]].residues = newres
>>> u.select_atoms('resname GLY and resid 42')
>>> u.select_atoms('resname GLY and resid 42 and resnum 0')
<AtomGroup with 3 atoms>

"""
Expand Down Expand Up @@ -1407,6 +1420,7 @@ def from_smiles(cls, smiles, sanitize=True, addHs=True,
--------
To create a Universe with 10 conformers of ethanol:

>>> from rdkit.Chem import AllChem
>>> u = mda.Universe.from_smiles('CCO', numConfs=10)
>>> u
<Universe with 9 atoms>
Expand All @@ -1416,7 +1430,7 @@ def from_smiles(cls, smiles, sanitize=True, addHs=True,
To use a different conformer generation algorithm, like ETKDGv3:

>>> u = mda.Universe.from_smiles('CCO', rdkit_kwargs=dict(
params=AllChem.ETKDGv3()))
... params=AllChem.ETKDGv3()))
>>> u.trajectory
<RDKitReader with 1 frames of 9 atoms>

Expand Down
Loading