~ubuntu-branches/ubuntu/trusty/python-numpy/trusty-updates

« back to all changes in this revision

Viewing changes to numpy/core/tests/test_unicode.py

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2013-01-28 19:03:02 UTC
  • mfrom: (7.1.13 experimental)
  • Revision ID: package-import@ubuntu.com-20130128190302-1kyak9j26902djjg
Tags: 1:1.7.0~rc1-1ubuntu1
Merge with Debian; remaining changes:

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
from numpy.compat import asbytes
6
6
 
7
7
# Guess the UCS length for this python interpreter
8
 
if sys.version_info[0] >= 3:
 
8
if sys.version_info[:2] >= (3, 3):
 
9
    # Python 3.3 uses a flexible string representation
 
10
    ucs4 = False
 
11
    def buffer_length(arr):
 
12
        if isinstance(arr, unicode):
 
13
            arr = str(arr)
 
14
            return (sys.getsizeof(arr+"a") - sys.getsizeof(arr)) * len(arr)
 
15
        v = memoryview(arr)
 
16
        if v.shape is None:
 
17
            return len(v) * v.itemsize
 
18
        else:
 
19
            return prod(v.shape) * v.itemsize
 
20
elif sys.version_info[0] >= 3:
9
21
    import array as _array
10
22
    ucs4 = (_array.array('u').itemsize == 4)
11
23
    def buffer_length(arr):