Skip to content

universe.segment and universe.residues triger a deprecation warning #1476

@jbarnoud

Description

@jbarnoud

Likeky following #1403, calling the segments property of a universe issues the following deprecation warning:

/home/jon/dev/mdanalysis/package/MDAnalysis/core/topologyattrs.py:1268: DeprecationWarning: `_get_named_segment` is deprecated!
Instant selector SegmentGroup.<name> is deprecated and will be removed in 1.0. Use SegmentGroup[SegmentGroup.segids == '<name>'] instead.
  return segmentgroup._get_named_segment(segid)

The residues property issues the following one:

/home/jon/dev/mdanalysis/package/MDAnalysis/core/topologyattrs.py:1064: DeprecationWarning: `_get_named_residue` is deprecated!
Instant selector ResidueGroup.<name> or Segment.<name> is deprecated and will be removed in 1.0. Use ResidueGroup[ResidueGroup.resnames == '<name>'] or Segment.residues[Segment.residues == '<name>'] instead.
  return residuegroup._get_named_residue(resname)

No warning should be emitted.

The atoms property does not emit warning as expected.

Resnames._get_named_residue and Segments._get_named_segment should handle the deprecation warning the same way as Atoms._get_named_atom; issue the warning only if the methods return something. See #1403 (comment) and a9f9655.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions