コード例 #1
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)
コード例 #2
0
ファイル: authors.py プロジェクト: jamesBaker361/pynary
    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)
コード例 #3
0
ファイル: authors.py プロジェクト: jamesBaker361/pynary
 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())
コード例 #4
0
ファイル: test_mio.py プロジェクト: dyao-vu/meta-core
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'])
コード例 #5
0
ファイル: test_mio.py プロジェクト: Juanlu001/scipy
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"])
コード例 #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'])
コード例 #7
0
ファイル: test_binned_statistic.py プロジェクト: Arasz/scipy
 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)
コード例 #8
0
 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_allclose(stat1, stat2)
     assert_allclose(binx1, binx2)
     assert_allclose(biny1, biny2)
コード例 #9
0
 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_allclose(stat1, stat2)
     assert_allclose(binx1, binx2)
     assert_allclose(biny1, biny2)
コード例 #10
0
ファイル: authors.py プロジェクト: apetcho/pywt
import optparse
import re
import sys
import os
import subprocess


from scipy._lib.six import u, PY3

if PY3:
    stdout_b = sys.stdout.buffer
else:
    stdout_b = sys.stdout


NAME_MAP = {u("Helder"): u("Helder Oliveira")}


def main():
    p = optparse.OptionParser(__doc__.strip())
    p.add_option("-d", "--debug", action="store_true", help="print debug output")
    options, args = p.parse_args()

    if len(args) != 1:
        p.error("invalid number of arguments")

    try:
        rev1, rev2 = args[0].split("..")
    except ValueError:
        p.error("argument is not a revision range")
コード例 #11
0
ファイル: authors.py プロジェクト: jamesBaker361/pynary
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('aman-thakral'): u('Aman Thakral'),
    u('andbo'): u('Anders Bech Borchersen'),
    u('Andreea_G'): u('Andreea Georgescu'),
    u('Andreas H'): u('Andreas Hilboll'),
    u('argriffing'): u('Alex Griffing'),
    u('arichar6'): u('Steve Richardson'),
    u('ArmstrongJ'): u('Jeff Armstrong'),
    u('axiru'): u('@axiru'),
    u('Benny'): u('Benny Malengier'),
    u('bewithaman'): u('Aman Singh'),
    u('brettrmurphy'): u('Brett R. Murphy'),
    u('cgholke'): u('Christoph Gohlke'),
    u('cgohlke'): u('Christoph Gohlke'),
コード例 #12
0
ファイル: authors.py プロジェクト: Pybonacci/scipy
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('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('Dapid'): u('David Menendez Hurtado'),
コード例 #13
0
ファイル: authors.py プロジェクト: wolever/scipy
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('aman-thakral'): u('Aman Thakral'),
    u('andbo'): u('Anders Bech Borchersen'),
    u('andrew'): u('Andrew Fowlie'),
    u('Andreea_G'): u('Andreea Georgescu'),
    u('Andreas H'): u('Andreas Hilboll'),
    u('argriffing'): u('Alex Griffing'),
    u('arichar6'): u('Steve Richardson'),
    u('ArmstrongJ'): u('Jeff Armstrong'),
    u('aw'): u('@chemelnucfin'),
    u('axiru'): u('@axiru'),
    u('bdvd'): u('Dávid Bodnár'),
    u('bhavikat'): u('Bhavika Tekwani'),
    u('Benny'): u('Benny Malengier'),
コード例 #14
0
from __future__ import division, print_function, absolute_import

import optparse
import re
import sys
import os
import subprocess

from scipy._lib.six import u, PY3
if PY3:
    stdout_b = sys.stdout.buffer
else:
    stdout_b = sys.stdout

NAME_MAP = {
    u('Helder'): u('Helder Oliveira'),
}


def main():
    p = optparse.OptionParser(__doc__.strip())
    p.add_option("-d",
                 "--debug",
                 action="store_true",
                 help="print debug output")
    options, args = p.parse_args()

    if len(args) != 1:
        p.error("invalid number of arguments")

    try:
コード例 #15
0
ファイル: authors.py プロジェクト: holgern/pydespiking
import optparse
import re
import sys
import os
import subprocess


from scipy._lib.six import u, PY3
if PY3:
    stdout_b = sys.stdout.buffer
else:
    stdout_b = sys.stdout


NAME_MAP = {
    u('Nahrstaedt'): u('Nahrstaedt Holger'),
}


def main():
    p = optparse.OptionParser(__doc__.strip())
    p.add_option("-d", "--debug", action="store_true",
                 help="print debug output")
    options, args = p.parse_args()

    if len(args) != 1:
        p.error("invalid number of arguments")

    try:
        rev1, rev2 = args[0].split('..')
    except ValueError:
コード例 #16
0
ファイル: test_mio.py プロジェクト: dyao-vu/meta-core
    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(
コード例 #17
0
ファイル: authors.py プロジェクト: Kitchi/scipy
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("aman-thakral"): u("Aman Thakral"),
    u("andbo"): u("Anders Bech Borchersen"),
    u("Andreea_G"): u("Andreea Georgescu"),
    u("Andreas H"): u("Andreas Hilboll"),
    u("argriffing"): u("Alex Griffing"),
    u("arichar6"): u("Steve Richardson"),
    u("ArmstrongJ"): u("Jeff Armstrong"),
    u("aw"): u("@chemelnucfin"),
    u("axiru"): u("@axiru"),
    u("Benny"): u("Benny Malengier"),
    u("behzad nouri"): u("Behzad Nouri"),
    u("bewithaman"): u("Aman Singh"),
    u("brettrmurphy"): u("Brett R. Murphy"),
コード例 #18
0
ファイル: test_hierarchy.py プロジェクト: Kitchi/scipy
 def test_linkage_tdist(self):
     for method in ["single", "complete", "average", "weighted", u("single")]:
         yield self.check_linkage_tdist, method
コード例 #19
0
ファイル: test_mio.py プロジェクト: Juanlu001/scipy
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)}}
コード例 #20
0
ファイル: authors.py プロジェクト: HenryZhou1002/pywt
import optparse
import re
import sys
import os
import subprocess


from scipy._lib.six import u, PY3
if PY3:
    stdout_b = sys.stdout.buffer
else:
    stdout_b = sys.stdout


NAME_MAP = {
    u('Gregory Lee'): u('Gregory R. Lee'),
    u('Daniel M Pelt'): u('Daniel M. Pelt'),
    u('Helder'): u('Helder Oliveira'),
    u('Kai'): u('Kai Wohlfahrt'),
    u('asnt'): u('Alexandre Saint'),
}


def main():
    p = optparse.OptionParser(__doc__.strip())
    p.add_option("-d", "--debug", action="store_true",
                 help="print debug output")
    options, args = p.parse_args()

    if len(args) != 1:
        p.error("invalid number of arguments")
コード例 #21
0
ファイル: authors.py プロジェクト: saraghav/pywt
import optparse
import re
import sys
import os
import subprocess


from scipy._lib.six import u, PY3
if PY3:
    stdout_b = sys.stdout.buffer
else:
    stdout_b = sys.stdout


NAME_MAP = {
    u('Helder'): u('Helder Oliveira'),
    u('Kai'): u('Kai Wohlfahrt'),
}


def main():
    p = optparse.OptionParser(__doc__.strip())
    p.add_option("-d", "--debug", action="store_true",
                 help="print debug output")
    options, args = p.parse_args()

    if len(args) != 1:
        p.error("invalid number of arguments")

    try:
        rev1, rev2 = args[0].split('..')
コード例 #22
0
ファイル: authors.py プロジェクト: LiuFang816/SALSTM_py_data
from __future__ import division, print_function, absolute_import

import optparse
import re
import sys
import os
import subprocess

from scipy._lib.six import u, PY3
if PY3:
    stdout_b = sys.stdout.buffer
else:
    stdout_b = sys.stdout

NAME_MAP = {
    u('Gregory Lee'): u('Gregory R. Lee'),
    u('Daniel M Pelt'): u('Daniel M. Pelt'),
    u('Helder'): u('Helder Oliveira'),
    u('Kai'): u('Kai Wohlfahrt'),
    u('asnt'): u('Alexandre Saint'),
}


def main():
    p = optparse.OptionParser(__doc__.strip())
    p.add_option("-d",
                 "--debug",
                 action="store_true",
                 help="print debug output")
    options, args = p.parse_args()
コード例 #23
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({
コード例 #24
0
ファイル: test_hierarchy.py プロジェクト: alchemyst/scipy
 def test_linkage_tdist(self):
     for method in ['single', 'complete', 'average', 'weighted', u('single')]:
         yield self.check_linkage_tdist, method
コード例 #25
0
ファイル: test_hierarchy.py プロジェクト: quintusdias/scipy
 def test_linkage_tdist(self):
     for method in [
             'single', 'complete', 'average', 'weighted',
             u('single')
     ]:
         yield self.check_linkage_tdist, method
コード例 #26
0
ファイル: authors.py プロジェクト: witcxc/scipy
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('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('Dapid'): u('David Menendez Hurtado'),