forked from MDAnalysis/mdanalysis
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add AtomGroup stub Any class used from this module will raise a warning. The classes work without needed to be specially imported. * fix Universe Warning Message * update changelog * add test for deprecation warning * Added compatibility for old AtomGroup init methods * Added tests for deprecated Group init methods
- Loading branch information
1 parent
9d5d7bf
commit 2b85baa
Showing
5 changed files
with
137 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import warnings | ||
|
||
from .groups import (Atom, AtomGroup, Residue, ResidueGroup, Segment, | ||
SegmentGroup) | ||
from . import universe | ||
|
||
|
||
def deprecate_class(class_new, message): | ||
"""utility to deprecate a class""" | ||
|
||
class new_class(class_new): | ||
def __init__(self, *args, **kwargs): | ||
super(new_class, self).__init__(*args, **kwargs) | ||
warnings.warn(message, DeprecationWarning) | ||
|
||
return new_class | ||
|
||
|
||
Universe = deprecate_class( | ||
universe.Universe, | ||
"MDAnalysis.core.AtomGroup.Universe has been removed." | ||
"Please use MDAnalaysis.Universe." | ||
"This stub will be removed in 1.0") | ||
|
||
_group_message = ("MDAnalysis.core.AtomGroup.{0} has been removed." | ||
"Please use MDAnalaysis.groups.{0}" | ||
"This stub will be removed in 1.0") | ||
|
||
Atom = deprecate_class(Atom, message=_group_message.format('Atom')) | ||
AtomGroup = deprecate_class( | ||
AtomGroup, message=_group_message.format('AtomGroup')) | ||
|
||
Residue = deprecate_class(Residue, message=_group_message.format('Residue')) | ||
ResidueGroup = deprecate_class( | ||
ResidueGroup, message=_group_message.format('ResidueGroup')) | ||
|
||
Segment = deprecate_class(Segment, message=_group_message.format('Segment')) | ||
SegmentGroup = deprecate_class( | ||
SegmentGroup, message=_group_message.format('SegmentGroup')) | ||
|
||
__all__ = [ | ||
'Universe', 'Atom', 'AtomGroup', 'Residue', 'ResidueGroup', 'Segment', | ||
'SegmentGroup' | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters