Skip to content

Typing for permuta/perm.py - #118

Merged
enadeau merged 15 commits into
PermutaTriangle:developfrom
JonSteinn:typing
Jul 2, 2020
Merged

enadeau merged 15 commits into
PermutaTriangle:developfrom
JonSteinn:typing

Conversation

@JonSteinn

@JonSteinn JonSteinn commented Jun 30, 2020 •

Copy link
Copy Markdown
Collaborator

Typing. Naming standardized for perm length and indices and elements in perms. Some refactoring. In permuta/perm.py.

@enadeau

enadeau commented Jun 30, 2020

Copy link
Copy Markdown
Member

This looks promising, I added mypy to the test suite so that the typing is checked.

@enadeau enadeau left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is mostly good to go I think. I left a few comments that you should look at

Comment thread permuta/interfaces/flippable.py Outdated
Comment thread permuta/interfaces/patt.py Outdated
Comment thread permuta/interfaces/rotatable.py Outdated
Comment thread permuta/interfaces/shiftable.py Outdated
Comment thread permuta/perm.py Outdated
Comment thread permuta/perm.py

@classmethod
def to_standard(cls, iterable):
def to_standard(cls, iterable: Iterable) -> "Perm":

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Iterable[int] ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is used from all sort of iterables. The example in the docstring even has one with a string.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable even if in practice we only ever use int

Comment thread permuta/perm.py
Comment thread permuta/perm.py Outdated
Comment thread permuta/perm.py Outdated
Comment thread permuta/perm.py
return self[value]

def __add__(self, other):
def __add__(self, other) -> "Perm":

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's more pythonic to check the type of other and return NotImplemented when the class of the object is not a Perm

@enadeau
enadeau merged commit 26bfeb4 into PermutaTriangle:develop Jul 2, 2020
@JonSteinn
JonSteinn deleted the typing branch July 2, 2020 16:56
christianbean added a commit that referenced this pull request Jul 20, 2020
* add insenc and lexmin options to permtools (#116)

* Typing for permuta/perm.py (#118)

* typing, refactoring and naming perm.py

* minor updates

* add mypy to test suite

* rem typechecking, prune comments, refactor perm.py

* mypy fix permutils

* mypy fix enum-strat

* mypy fix _perm_set

* mypy sympy

* permset mypy fix

* interfaces mypy fix

* flake8 fix in interfaces

* potential 36 fix

* 3.6 issues solved

* resolve issues

* fix issues 2.0

Co-authored-by: Émile Nadeau <nadeau.emile@gmail.com>

* Refactor (#120)

* add sympy as dependency

* more perm.py refactor + some tests

* tests + refactor + reimplementing block method

* more permpy tests and refactor, almost done

* sympy top

* .

* removed Rotatable, Shiftable, Flippable abc

* meshpatt refactor

* remove comment

* fix newl in docstr

* doctest fixes

* more fixes

* fix isort issue

* forgot -> type of inf iterator

* fix issues

* tmp solutions to sympy removal

* Bivincular (#122)

* rem cov badge

* dihedral group

* union find tests

* misc cleared

* tests updated

* pre-move push

* restructure

* testing for bivpatt

* added missing types

* doctest fix

* more_doctest_fixes

* fix flake issues

* Refactor permutils

* permutils finite+sym refactor

* poly refactor

* poly deque for performance

* utils refactoring done

* issues and p_utils to putils

* [requires.io] dependency update (#121)

Co-authored-by: requires.io <support@requires.io>

* SVG for patterns + HTML rendering (#125)

* perm2svg

* mesh svg

* svg open in tab

* openhtml cleanup

* removal of file

* Bisc perm properties refactor + tests (#127)

* include bisc jsons in pypi package

* .show in patts

* bisc perm prop refactoring

* forgot pylint in travis

* missing comma in pylintrc

* remove win from deployment

* enumeration_strategies typing + removing permuta/descriptors (#129)

* typing for enum_strat

* removed readme.d + docs

* forgot a few types in bisc-perm-prop

* basis to permsets

* basis

* mp gen moved to mp

* remove unused classvar

* bivpatt random made uniform

* doc fix

* forgot len in rand

* flake issue

* and more fixes...

* [requires.io] dependency update (#128)

Co-authored-by: requires.io <support@requires.io>

* permsets simplified (#130)

* cache clear function in perm

* minor cleanup in enumstrat

* remove .vscode

* .vscode to gitignore

* basis refactor

* perm_set simplified

* comments + enum test

* readme + comments + tests

* cache fix + cache test

* cache tests

* fix assertion in Av

* reduce memory of cache

* reduce loop of auto cache clearing

* issue fixing

* identical types fix

* cli typing (#132)

* cli typing

* typos + avoid iteration in cnt

* poly to cli

* , -> _

* version 2.0.0

* PEP 561 compatible

Co-authored-by: Jón Steinn Elíasson <jonsteinn@gmail.com>
Co-authored-by: Émile Nadeau <nadeau.emile@gmail.com>
Co-authored-by: requires.io <support@requires.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants