def test_zero_byte_string():
    # Tests hack to allow chars of non-zero length, but 0 bytes
    # make reader-like thing
    str_io = cStringIO()
    r = _make_readerlike(str_io, boc.native_code)
    c_reader = m5u.VarReader5(r)
    tag_dt = np.dtype([('mdtype', 'u4'), ('byte_count', 'u4')])
    tag = np.zeros((1,), dtype=tag_dt)
    tag['mdtype'] = mio5p.miINT8
    tag['byte_count'] = 1
    hdr = m5u.VarHeader5()
    # Try when string is 1 length
    hdr.set_dims([1,])
    _write_stream(str_io, tag.tostring() + b'        ')
    str_io.seek(0)
    val = c_reader.read_char(hdr)
    assert_equal(val, u(' '))
    # Now when string has 0 bytes 1 length
    tag['byte_count'] = 0
    _write_stream(str_io, tag.tostring())
    str_io.seek(0)
    val = c_reader.read_char(hdr)
    assert_equal(val, u(' '))
    # Now when string has 0 bytes 4 length
    str_io.seek(0)
    hdr.set_dims([4,])
    val = c_reader.read_char(hdr)
    assert_array_equal(val, [u(' ')] * 4)
Example #2
0
def test_zero_byte_string():
    # Tests hack to allow chars of non-zero length, but 0 bytes
    # make reader-like thing
    str_io = cStringIO()
    r = _make_readerlike(str_io, boc.native_code)
    c_reader = m5u.VarReader5(r)
    tag_dt = np.dtype([('mdtype', 'u4'), ('byte_count', 'u4')])
    tag = np.zeros((1, ), dtype=tag_dt)
    tag['mdtype'] = mio5p.miINT8
    tag['byte_count'] = 1
    hdr = m5u.VarHeader5()
    # Try when string is 1 length
    hdr.set_dims([
        1,
    ])
    _write_stream(str_io, tag.tostring() + b'        ')
    str_io.seek(0)
    val = c_reader.read_char(hdr)
    assert_equal(val, u(' '))
    # Now when string has 0 bytes 1 length
    tag['byte_count'] = 0
    _write_stream(str_io, tag.tostring())
    str_io.seek(0)
    val = c_reader.read_char(hdr)
    assert_equal(val, u(' '))
    # Now when string has 0 bytes 4 length
    str_io.seek(0)
    hdr.set_dims([
        4,
    ])
    val = c_reader.read_char(hdr)
    assert_array_equal(val, [u(' ')] * 4)
Example #3
0
    def analyze_line(line, names, disp=False):
        line = line.strip().decode('utf-8')

        # Check the commit author name
        m = re.match(u('^@@@([^@]*)@@@'), line)
        if m:
            name = m.group(1)
            line = line[m.end():]
            name = NAME_MAP.get(name, name)
            if disp:
                if name not in names:
                    stdout_b.write(("    - Author: %s\n" % name).encode('utf-8'))
            names.add(name)

        # Look for "thanks to" messages in the commit log
        m = re.search(u(r'([Tt]hanks to|[Cc]ourtesy of) ([A-Z][A-Za-z]*? [A-Z][A-Za-z]*? [A-Z][A-Za-z]*|[A-Z][A-Za-z]*? [A-Z]\. [A-Z][A-Za-z]*|[A-Z][A-Za-z ]*? [A-Z][A-Za-z]*|[a-z0-9]+)($|\.| )'), line)
        if m:
            name = m.group(2)
            if name not in (u('this'),):
                if disp:
                    stdout_b.write("    - Log   : %s\n" % line.strip().encode('utf-8'))
                name = NAME_MAP.get(name, name)
                names.add(name)

            line = line[m.end():].strip()
            line = re.sub(u(r'^(and|, and|, ) '), u('Thanks to '), line)
            analyze_line(line.encode('utf-8'), names)
Example #4
0
 def name_key(fullname):
     m = re.search(u(' [a-z ]*[A-Za-z-]+$'), fullname)
     if m:
         forename = fullname[:m.start()].strip()
         surname = fullname[m.start():].strip()
     else:
         forename = ""
         surname = fullname.strip()
     if surname.startswith(u('van der ')):
         surname = surname[8:]
     if surname.startswith(u('de ')):
         surname = surname[3:]
     if surname.startswith(u('von ')):
         surname = surname[4:]
     return (surname.lower(), forename.lower())
Example #5
0
def test_unicode_mat4():
    # Mat4 should save unicode as latin1
    bio = BytesIO()
    var = {"second_cat": u("Schrödinger")}
    savemat(bio, var, format="4")
    var_back = loadmat(bio)
    assert_equal(var_back["second_cat"], var["second_cat"])
Example #6
0
def test_unicode_mat4():
    # Mat4 should save unicode as latin1
    bio = BytesIO()
    var = {'second_cat': u('Schrödinger')}
    savemat(bio, var, format='4')
    var_back = loadmat(bio)
    assert_equal(var_back['second_cat'], var['second_cat'])
Example #7
0
def test_unicode_mat4():
    # Mat4 should save unicode as latin1
    bio = BytesIO()
    var = {'second_cat': u('Schrödinger')}
    savemat(bio, var, format='4')
    var_back = loadmat(bio)
    assert_equal(var_back['second_cat'], var['second_cat'])
 def test_2d_mean_unicode(self):
     x = self.x
     y = self.y
     v = self.v
     stat1, binx1, biny1, bc = binned_statistic_2d(x, y, v, u('mean'), bins=5)
     stat2, binx2, biny2, bc = binned_statistic_2d(x, y, v, np.mean, bins=5)
     assert_array_almost_equal(stat1, stat2)
     assert_array_almost_equal(binx1, binx2)
     assert_array_almost_equal(biny1, biny2)
 def test_2d_mean_unicode(self):
     x = self.x
     y = self.y
     v = self.v
     stat1, binx1, biny1, bc = binned_statistic_2d(x,
                                                   y,
                                                   v,
                                                   u('mean'),
                                                   bins=5)
     stat2, binx2, biny2, bc = binned_statistic_2d(x, y, v, np.mean, bins=5)
     assert_array_almost_equal(stat1, stat2)
     assert_array_almost_equal(binx1, binx2)
     assert_array_almost_equal(biny1, biny2)
Example #10
0
case_table4 = [{
    'name': 'double',
    'classes': {
        'testdouble': 'double'
    },
    'expected': {
        'testdouble': theta
    }
}]
case_table4.append({
    'name': 'string',
    'classes': {
        'teststring': 'char'
    },
    'expected': {
        'teststring': array([u('"Do nine men interpret?" "Nine men," I nod.')])
    }
})
case_table4.append({
    'name': 'complex',
    'classes': {
        'testcomplex': 'double'
    },
    'expected': {
        'testcomplex': np.cos(theta) + 1j * np.sin(theta)
    }
})
A = np.zeros((3, 5))
A[0] = list(range(1, 6))
A[:, 0] = list(range(1, 4))
case_table4.append({
Example #11
0
def mlarr(*args, **kwargs):
    """ Convenience function to return matlab-compatible 2D array
    """
    arr = np.array(*args, **kwargs)
    arr.shape = matdims(arr)
    return arr


# Define cases to test
theta = np.pi / 4 * np.arange(9, dtype=float).reshape(1, 9)
case_table4 = [{"name": "double", "classes": {"testdouble": "double"}, "expected": {"testdouble": theta}}]
case_table4.append(
    {
        "name": "string",
        "classes": {"teststring": "char"},
        "expected": {"teststring": array([u('"Do nine men interpret?" "Nine men," I nod.')])},
    }
)
case_table4.append(
    {
        "name": "complex",
        "classes": {"testcomplex": "double"},
        "expected": {"testcomplex": np.cos(theta) + 1j * np.sin(theta)},
    }
)
A = np.zeros((3, 5))
A[0] = list(range(1, 6))
A[:, 0] = list(range(1, 4))
case_table4.append({"name": "matrix", "classes": {"testmatrix": "double"}, "expected": {"testmatrix": A}})
case_table4.append(
    {"name": "sparse", "classes": {"testsparse": "sparse"}, "expected": {"testsparse": SP.coo_matrix(A)}}
Example #12
0
import os
import subprocess

try:
    from scipy.lib.six import u, PY3
except ImportError:
    sys.path.insert(
        0, os.path.join(os.path.dirname(__file__), os.pardir, 'scipy', 'lib'))
    from six import u, PY3
if PY3:
    stdout_b = sys.stdout.buffer
else:
    stdout_b = sys.stdout

NAME_MAP = {
    u('87'): u('Han Genuit'),
    u('aarchiba'): u('Anne Archibald'),
    u('alex'): u('Alex Griffing'),
    u('andbo'): u('Anders Bech Borchersen'),
    u('argriffing'): u('Alex Griffing'),
    u('arichar6'): u('Steve Richardson'),
    u('ArmstrongJ'): u('Jeff Armstrong'),
    u('Benny'): u('Benny Malengier'),
    u('brettrmurphy'): u('Brett R. Murphy'),
    u('cgholke'): u('Christoph Gohlke'),
    u('cgohlke'): u('Christoph Gohlke'),
    u('chris.burns'): u('Chris Burns'),
    u('Christolph Gohlke'): u('Christoph Gohlke'),
    u('ckuster'): u('Christopher Kuster'),
    u('Collin Stocks'): u('Collin RM Stocks'),
    u('cnovak'): u('Clemens Novak'),
Example #13
0
 def test_linkage_tdist(self):
     for method in ['single', 'complete', 'average', 'weighted', u('single')]:
         yield self.check_linkage_tdist, method
Example #14
0
import sys
import os
import subprocess

try:
    from scipy.lib.six import u, PY3
except ImportError:
    sys.path.insert(0, os.path.join(os.path.dirname(__file__), os.pardir, "scipy", "lib"))
    from six import u, PY3
if PY3:
    stdout_b = sys.stdout.buffer
else:
    stdout_b = sys.stdout

NAME_MAP = {
    u("87"): u("Han Genuit"),
    u("aarchiba"): u("Anne Archibald"),
    u("alex"): u("Alex Griffing"),
    u("argriffing"): u("Alex Griffing"),
    u("arichar6"): u("Steve Richardson"),
    u("ArmstrongJ"): u("Jeff Armstrong"),
    u("cgholke"): u("Christoph Gohlke"),
    u("cgohlke"): u("Christoph Gohlke"),
    u("chris.burns"): u("Chris Burns"),
    u("Christolph Gohlke"): u("Christoph Gohlke"),
    u("ckuster"): u("Christopher Kuster"),
    u("Collin Stocks"): u("Collin RM Stocks"),
    u("Daniel Smith"): u("Daniel B. Smith"),
    u("dellsystem"): u("Wendy Liu"),
    u("Derek Homeir"): u("Derek Homeier"),
    u("Derek Homier"): u("Derek Homeier"),
Example #15
0
    arr = np.array(*args, **kwargs)
    arr.shape = matdims(arr)
    return arr

# Define cases to test
theta = np.pi/4*np.arange(9,dtype=float).reshape(1,9)
case_table4 = [
    {'name': 'double',
     'classes': {'testdouble': 'double'},
     'expected': {'testdouble': theta}
     }]
case_table4.append(
    {'name': 'string',
     'classes': {'teststring': 'char'},
     'expected': {'teststring':
                  array([u('"Do nine men interpret?" "Nine men," I nod.')])}
     })
case_table4.append(
    {'name': 'complex',
     'classes': {'testcomplex': 'double'},
     'expected': {'testcomplex': np.cos(theta) + 1j*np.sin(theta)}
     })
A = np.zeros((3,5))
A[0] = list(range(1,6))
A[:,0] = list(range(1,4))
case_table4.append(
    {'name': 'matrix',
     'classes': {'testmatrix': 'double'},
     'expected': {'testmatrix': A},
     })
case_table4.append(
import os
import subprocess

try:
    from scipy.lib.six import u, PY3
except ImportError:
    sys.path.insert(0, os.path.join(os.path.dirname(__file__),
                                    os.pardir, 'scipy', 'lib'))
    from six import u, PY3
if PY3:
    stdout_b = sys.stdout.buffer
else:
    stdout_b = sys.stdout

NAME_MAP = {
    u('87'): u('Han Genuit'),
    u('aarchiba'): u('Anne Archibald'),
    u('alex'): u('Alex Griffing'),
    u('argriffing'): u('Alex Griffing'),
    u('arichar6'): u('Steve Richardson'),
    u('ArmstrongJ'): u('Jeff Armstrong'),
    u('cgholke'): u('Christoph Gohlke'),
    u('cgohlke'): u('Christoph Gohlke'),
    u('chris.burns'): u('Chris Burns'),
    u('Christolph Gohlke'): u('Christoph Gohlke'),
    u('ckuster'): u('Christopher Kuster'),
    u('Collin Stocks'): u('Collin RM Stocks'),
    u('cnovak'): u('Clemens Novak'),
    u('Daniel Smith'): u('Daniel B. Smith'),
    u('dellsystem'): u('Wendy Liu'),
    u('Derek Homeir'): u('Derek Homeier'),
Example #17
0
import os
import subprocess

try:
    from scipy.lib.six import u, PY3
except ImportError:
    sys.path.insert(0, os.path.join(os.path.dirname(__file__),
                                    os.pardir, 'scipy', 'lib'))
    from six import u, PY3
if PY3:
    stdout_b = sys.stdout.buffer
else:
    stdout_b = sys.stdout

NAME_MAP = {
    u('87'): u('Han Genuit'),
    u('aarchiba'): u('Anne Archibald'),
    u('ArmstrongJ'): u('Jeff Armstrong'),
    u('cgholke'): u('Christoph Gohlke'),
    u('cgohlke'): u('Christoph Gohlke'),
    u('chris.burns'): u('Chris Burns'),
    u('Christolph Gohlke'): u('Christoph Gohlke'),
    u('ckuster'): u('Christopher Kuster'),
    u('Collin Stocks'): u('Collin RM Stocks'),
    u('Derek Homeir'): u('Derek Homeier'),
    u('Derek Homier'): u('Derek Homeier'),
    u('dhuard'): u('David Huard'),
    u('dsimcha'): u('David Simcha'),
    u('edschofield'): u('Ed Schofield'),
    u('Gael varoquaux'): u('Gaël Varoquaux'),
    u('gotgenes'): u('Chris Lasher'),
Example #18
0
 def test_linkage_tdist(self):
     for method in [
             'single', 'complete', 'average', 'weighted',
             u('single')
     ]:
         yield self.check_linkage_tdist, method
Example #19
0
import subprocess

try:
    from scipy.lib.six import u, PY3
except ImportError:
    sys.path.insert(0, os.path.join(os.path.dirname(__file__),
                                    os.pardir, 'scipy', 'lib'))
    from six import u, PY3
if PY3:
    stdout_b = sys.stdout.buffer
else:
    stdout_b = sys.stdout


NAME_MAP = {
    u('87'): u('Han Genuit'),
    u('aarchiba'): u('Anne Archibald'),
    u('alex'): u('Alex Griffing'),
    u('andbo'): u('Anders Bech Borchersen'),
    u('argriffing'): u('Alex Griffing'),
    u('arichar6'): u('Steve Richardson'),
    u('ArmstrongJ'): u('Jeff Armstrong'),
    u('Benny'): u('Benny Malengier'),
    u('brettrmurphy'): u('Brett R. Murphy'),
    u('cgholke'): u('Christoph Gohlke'),
    u('cgohlke'): u('Christoph Gohlke'),
    u('chris.burns'): u('Chris Burns'),
    u('Christolph Gohlke'): u('Christoph Gohlke'),
    u('ckuster'): u('Christopher Kuster'),
    u('Collin Stocks'): u('Collin RM Stocks'),
    u('cnovak'): u('Clemens Novak'),