Skip to content

Bio.PDB sorting not tested and Python 2 only #1189

Closed

Description

@peterjc

The cmp function is Python 2 only, sorting using a key function is the preferred idiom for Python 2 and 3.

Bio/PDB/Chain.py class Chain uses cmp in never used private method ``._sort```, could remove this?

Bio/PDB/Structure.py class Structure, same.

Bio/PDB/Model.py class Model, same.

Bio/PDB/Residue.py class Residue defines ._sort and uses in public .sort but not tested.

Spotted via flake8 tests (installed and running under Python 3),

$ flake8 --config=/dev/null --select F821 Bio/PDB/
Bio/PDB/Chain.py:34:20: F821 undefined name 'cmp'
Bio/PDB/Chain.py:36:20: F821 undefined name 'cmp'
Bio/PDB/Chain.py:37:16: F821 undefined name 'cmp'
Bio/PDB/Model.py:52:16: F821 undefined name 'cmp'
Bio/PDB/Residue.py:52:20: F821 undefined name 'cmp'
Bio/PDB/Residue.py:62:20: F821 undefined name 'cmp'
Bio/PDB/Residue.py:67:16: F821 undefined name 'cmp'
Bio/PDB/Structure.py:36:16: F821 undefined name 'cmp'

Activity

  1. peterjc commented on Apr 24, 2017

    @peterjc
    MemberAuthor

    @etal @lennax @JoaoRodrigues etc - comments welcome on how best to solve this, thanks.

  2. JoaoRodrigues commented on Apr 24, 2017

    @JoaoRodrigues
    Member
  3. peterjc commented on Apr 24, 2017

    @peterjc
    MemberAuthor

    I would guess we can delete/deprecate the ._sort methods, and add .sort using key=... rather than the legacy cmp style sorting?

  4. JoaoRodrigues commented on Apr 24, 2017

    @JoaoRodrigues
    Member
  5. peterjc commented on Jun 19, 2017

    @peterjc
    MemberAuthor

    @JoaoRodrigues are you likely to be able to look at this this week? If not do you mind if I try?

  6. JoaoRodrigues commented on Jun 20, 2017

    @JoaoRodrigues
    Member
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions