Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix a bug : when sklearn has string characters in its version, sklear… #68

Open
wants to merge 1 commit into
base: stable
Choose a base branch
from

Conversation

earlsuke
Copy link

…n-porter raises a value error
#67


## Suffix lists for minor, patch version in sklearn
MINOR_VERSION_SUFFIX_LIST = ["rc3", "rc2", "rc1", "b1", "a1"]
PATCH_VERSION_SUFFIX_LIST = ["post1", "0b1", "0b2"]
Copy link

@SoftwareApe SoftwareApe Apr 22, 2020

Choose a reason for hiding this comment

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

At least post1 is not part of the patch version, but after the patch version:

grafik

Comment on lines +60 to +93

## Suffix lists for minor, patch version in sklearn
MINOR_VERSION_SUFFIX_LIST = ["rc3", "rc2", "rc1", "b1", "a1"]
PATCH_VERSION_SUFFIX_LIST = ["post1", "0b1", "0b2"]

sklearn_ver = str(sklearn_ver).split('.')
sklearn_ver = [int(v) for v in sklearn_ver]
major, minor = sklearn_ver[0], sklearn_ver[1]
patch = sklearn_ver[2] if len(sklearn_ver) >= 3 else 0

major_cand_str = sklearn_ver[0]
minor_cand_str = sklearn_ver[1]
patch_cand_str = sklearn_ver[2] if len(sklearn_ver) >= 3 else '0'

## Convert version str to integer
major = int(major_cand_str)

try:
minor = int(minor_cand_str)

except ValueError as ve:
for check_key in MINOR_VERSION_SUFFIX_LIST:
if check_key in minor_cand_str:
minor_cand_str.replace(check_key, '')
break
minor = int(minor_cand_str)

try:
patch = int(patch_cand_str)

except ValueError as ve:
for check_key in PATCH_VERSION_SUFFIX_LIST:
if check_key in patch_cand_str:
patch_cand_str.replace(check_key, '0')
break
patch = int(patch_cand_str)

Choose a reason for hiding this comment

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

This seems like a perfect application for regex.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants