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)
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)
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())
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_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_allclose(stat1, stat2) assert_allclose(binx1, binx2) assert_allclose(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_allclose(stat1, stat2) assert_allclose(binx1, binx2) assert_allclose(biny1, biny2)
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")
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'),
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'),
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'),
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:
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:
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("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"),
def test_linkage_tdist(self): for method in ["single", "complete", "average", "weighted", u("single")]: yield self.check_linkage_tdist, method
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)}}
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")
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('..')
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()
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({
def test_linkage_tdist(self): for method in ['single', 'complete', 'average', 'weighted', u('single')]: yield self.check_linkage_tdist, method
def test_linkage_tdist(self): for method in [ 'single', 'complete', 'average', 'weighted', u('single') ]: yield self.check_linkage_tdist, method
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'),