本文整理汇总了Python中scipy._lib.six.u函数的典型用法代码示例。如果您正苦于以下问题:Python u函数的具体用法?Python u怎么用?Python u使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了u函数的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: analyze_line
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)
开发者ID:7924102,项目名称:scipy,代码行数:27,代码来源:authors.py
示例2: test_zero_byte_string
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)
开发者ID:1641731459,项目名称:scipy,代码行数:28,代码来源:test_mio5_utils.py
示例3: name_key
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())
开发者ID:7924102,项目名称:scipy,代码行数:15,代码来源:authors.py
示例4: test_unicode_mat4
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'])
开发者ID:dyao-vu,项目名称:meta-core,代码行数:7,代码来源:test_mio.py
示例5: test_2d_mean_unicode
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)
开发者ID:metamorph-inc,项目名称:meta-core,代码行数:9,代码来源:test_binned_statistic.py
示例6: test_2d_mean_unicode
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)
开发者ID:Arasz,项目名称:scipy,代码行数:9,代码来源:test_binned_statistic.py
示例7: matdims
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(
开发者ID:dyao-vu,项目名称:meta-core,代码行数:31,代码来源:test_mio.py
示例8: u
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'),
开发者ID:7924102,项目名称:scipy,代码行数:31,代码来源:authors.py
示例9: test_linkage_tdist
def test_linkage_tdist(self):
for method in ['single', 'complete', 'average', 'weighted', u('single')]:
yield self.check_linkage_tdist, method
开发者ID:alchemyst,项目名称:scipy,代码行数:3,代码来源:test_hierarchy.py
示例10: u
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")
开发者ID:apetcho,项目名称:pywt,代码行数:30,代码来源:authors.py
示例11: u
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"),
开发者ID:Kitchi,项目名称:scipy,代码行数:31,代码来源:authors.py
示例12: mlarr
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)}}
开发者ID:Juanlu001,项目名称:scipy,代码行数:30,代码来源:test_mio.py
示例13: u
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")
开发者ID:HenryZhou1002,项目名称:pywt,代码行数:31,代码来源:authors.py
示例14: u
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'),
开发者ID:Pybonacci,项目名称:scipy,代码行数:31,代码来源:authors.py
示例15: u
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('..')
开发者ID:FrankYu,项目名称:pywt,代码行数:31,代码来源:authors.py
示例16: u
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:
开发者ID:holgern,项目名称:pydespiking,代码行数:31,代码来源:authors.py
注:本文中的scipy._lib.six.u函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论