{"action":"created","issue":{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/7980","repository_url":"https://api.github.com/repos/scikit-learn/scikit-learn","labels_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/7980/labels{/name}","comments_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/7980/comments","events_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/7980/events","html_url":"https://github.com/scikit-learn/scikit-learn/issues/7980","id":193451436,"number":7980,"title":"Improve version comparison for non released versions","user":{"login":"lesteve","id":1680079,"avatar_url":"https://avatars.githubusercontent.com/u/1680079?v=3","gravatar_id":"","url":"https://api.github.com/users/lesteve","html_url":"https://github.com/lesteve","followers_url":"https://api.github.com/users/lesteve/followers","following_url":"https://api.github.com/users/lesteve/following{/other_user}","gists_url":"https://api.github.com/users/lesteve/gists{/gist_id}","starred_url":"https://api.github.com/users/lesteve/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lesteve/subscriptions","organizations_url":"https://api.github.com/users/lesteve/orgs","repos_url":"https://api.github.com/users/lesteve/repos","events_url":"https://api.github.com/users/lesteve/events{/privacy}","received_events_url":"https://api.github.com/users/lesteve/received_events","type":"User","site_admin":false},"labels":[{"id":12995801,"url":"https://api.github.com/repos/scikit-learn/scikit-learn/labels/Enhancement","name":"Enhancement","color":"d7e102","default":false},{"id":218978315,"url":"https://api.github.com/repos/scikit-learn/scikit-learn/labels/Need%20Contributor","name":"Need Contributor","color":"009800","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-12-05T09:45:49Z","updated_at":"2016-12-06T00:14:48Z","closed_at":null,"body":"Moved from https://github.com/scikit-learn/scikit-learn/pull/7902.\r\n\r\nOur code comparing versions (for example in `sklearn.utils.fixes` which implement backports of older numpy, scipy, etc... functionalities) doesn't deal very well with non-released versions:\r\n\r\n#### `sklearn.utils.fixes._parse_version`\r\nparses a version string into a tuple and comparing the tuple afterwards. This will either give the wrong answer or raise an exception:\r\n```py\r\nfrom sklearn.utils.fixes import _parse_version\r\n\r\n_parse_version('1.12.0b1') < (1, 12)  # False although 1.12.0b1 is before 1.12\r\n\r\n_parse_version('1.12b1') < (1, 12, 0)  # Exception trying to compare str and int in Python 3\r\n```\r\n\r\n#### `distutils.version.LooseVersion`\r\ndoesn't deal correctly with beta version either:\r\n\r\n``` py\r\nfrom distutils.version import LooseVersion\r\nLooseVersion('1.12b1') < LooseVersion('1.12')  # False\r\n```\r\n\r\n#### `pkg_resources.parse_version`\r\ndoes deal with beta versions:\r\n\r\n``` py\r\nfrom pkg_resources import parse_version\r\n\r\nparse_version('1.12b1') < parse_version('1.12')  # True\r\n```\r\n\r\nMaking scikit-learn depend on setuptools is controversial so porting a reasonable implementation in sklearn.utils was deemed the best option in https://github.com/scikit-learn/scikit-learn/pull/7902#issuecomment-261281587."},"comment":{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/comments/265020924","html_url":"https://github.com/scikit-learn/scikit-learn/issues/7980#issuecomment-265020924","issue_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/7980","id":265020924,"user":{"login":"amueller","id":449558,"avatar_url":"https://avatars.githubusercontent.com/u/449558?v=3","gravatar_id":"","url":"https://api.github.com/users/amueller","html_url":"https://github.com/amueller","followers_url":"https://api.github.com/users/amueller/followers","following_url":"https://api.github.com/users/amueller/following{/other_user}","gists_url":"https://api.github.com/users/amueller/gists{/gist_id}","starred_url":"https://api.github.com/users/amueller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amueller/subscriptions","organizations_url":"https://api.github.com/users/amueller/orgs","repos_url":"https://api.github.com/users/amueller/repos","events_url":"https://api.github.com/users/amueller/events{/privacy}","received_events_url":"https://api.github.com/users/amueller/received_events","type":"User","site_admin":false},"created_at":"2016-12-06T00:14:48Z","updated_at":"2016-12-06T00:14:48Z","body":"see https://github.com/pypa/setuptools/blob/master/pkg_resources/__init__.py#L146 ?"}}
{"actor":{"display_login":"amueller"}}