# Buggy code
def __init__(self, vstring):
    self.vstring = vstring
    ver_main = re.match(r"\d[.]\d+[.]\d+", vstring)
    if not ver_main:
        raise ValueError("Not a valid numpy version string")

    self.version = ver_main.group()
    self.major, self.minor, self.bugfix = [int(x) for x in self.version.split(".")]
    if len(vstring) == ver_main.end():
        self.pre_release = "final"
    else:
        alpha = re.match(r"a\d", vstring[ver_main.end() :])
        beta = re.match(r"b\d", vstring[ver_main.end() :])
        rc = re.match(r"rc\d", vstring[ver_main.end() :])
        pre_rel = [m for m in [alpha, beta, rc] if m is not None]
        if pre_rel:
            self.pre_release = pre_rel[0].group()
        else:
            self.pre_release = ""

    self.is_devversion = bool(re.search(r".dev-", vstring))


# Traceback (AssertionError)
======================================================================
FAIL: test_lsmr.TestLSMR.testBidiagonalA
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/nose/case.py", line 197, in runTest
self.test(*self.arg)
File "/usr/local/lib/python2.7/dist-packages/scipy/sparse/linalg/isolve/tests/test_lsmr.py", line 60, in testBidiagonalA
self.assertCompatibleSystem(A,xtrue)
File "/usr/local/lib/python2.7/dist-packages/scipy/sparse/linalg/isolve/tests/test_lsmr.py", line 40, in assertCompatibleSystem
assert_almost_equal(norm(x - xtrue), 0, 6)
File "/usr/local/lib/python2.7/dist-packages/numpy/testing/utils.py", line 486, in assert_almost_equal
raise AssertionError(_build_err_msg())
AssertionError:
Arrays are not almost equal to 6 decimals
ACTUAL: 5.1808311642882019e-07
DESIRED: 0

======================================================================
FAIL: test_tmean (test_mstats_basic.TestCompareWithStats)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/scipy/stats/tests/test_mstats_basic.py", line 901, in test_tmean
assert_equal(stats.tmean(x),stats.mstats.tmean(xm))
File "/usr/local/lib/python2.7/dist-packages/numpy/ma/testutils.py", line 100, in assert_equal
raise AssertionError(msg)
AssertionError:
Items are not equal:
ACTUAL: 0.040175456835823721
DESIRED: 0.040175456835823714

======================================================================
FAIL: test_trim (test_mstats_basic.TestTrimming)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/scipy/stats/tests/test_mstats_basic.py", line 274, in test_trim
assert_equal(trimx._mask.ravel(),[1]*20+[0]*70+[1]*20)
File "/usr/local/lib/python2.7/dist-packages/numpy/ma/testutils.py", line 123, in assert_equal
return assert_array_equal(actual, desired, err_msg)
File "/usr/local/lib/python2.7/dist-packages/numpy/ma/testutils.py", line 196, in assert_array_equal
header='Arrays are not equal')
File "/usr/local/lib/python2.7/dist-packages/numpy/ma/testutils.py", line 189, in assert_array_compare
verbose=verbose, header=header)
File "/usr/local/lib/python2.7/dist-packages/numpy/testing/utils.py", line 660, in assert_array_compare
raise AssertionError(msg)
AssertionError:
Arrays are not equal

(mismatch 9.09090909091%)
x: array([ True,  True,  True,  True,  True,  True,  True,  True,  True,
True,  True,  True,  True,  True,  True,  True,  True,  True,
True,  True, False, False, False, False, False, False, False,...
y: array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,...

----------------------------------------------------------------------
Ran 16571 tests in 96.936s

FAILED (KNOWNFAIL=277, SKIP=871, errors=81, failures=3)
<nose.result.TextTestResult run=16571 errors=81 failures=3>

# Fixed code
def __init__(self, vstring):
    self.vstring = vstring
    ver_main = re.match(r"\d[.]\d+[.]\d+", vstring)
    if not ver_main:
        raise ValueError("Not a valid numpy version string")

    self.version = ver_main.group()
    self.major, self.minor, self.bugfix = [int(x) for x in self.version.split(".")]
    if len(vstring) == ver_main.end():
        self.pre_release = "final"
    else:
        alpha = re.match(r"a\d", vstring[ver_main.end() :])
        beta = re.match(r"b\d", vstring[ver_main.end() :])
        rc = re.match(r"rc\d", vstring[ver_main.end() :])
        pre_rel = [m for m in [alpha, beta, rc] if m is not None]
        if pre_rel:
            self.pre_release = pre_rel[0].group()
        else:
            self.pre_release = ""

    self.is_devversion = bool(re.search(r".dev", vstring))