File: test_byteordercodes.py

package info (click to toggle)
python-scipy 0.7.2%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 28,500 kB
  • ctags: 36,081
  • sloc: cpp: 216,880; fortran: 76,016; python: 71,576; ansic: 62,118; makefile: 243; sh: 17
file content (28 lines) | stat: -rw-r--r-- 900 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
''' Tests for byteorder module '''

import sys

import numpy as np

from numpy.testing import assert_raises

import scipy.io.matlab.byteordercodes as sibc

def test_native():
    native_is_le = sys.byteorder == 'little'
    assert sibc.sys_is_le == native_is_le

def test_to_numpy():
    if sys.byteorder == 'little':
        assert sibc.to_numpy_code('native') == '<'
        assert sibc.to_numpy_code('swapped') == '>'
    else:
        assert sibc.to_numpy_code('native') == '>'
        assert sibc.to_numpy_code('swapped') == '<'
    assert sibc.to_numpy_code('native') == sibc.to_numpy_code('=')
    assert sibc.to_numpy_code('big') == '>'
    for code in ('little', '<', 'l', 'L', 'le'):
        assert sibc.to_numpy_code(code) == '<'
    for code in ('big', '>', 'b', 'B', 'be'):
        assert sibc.to_numpy_code(code) == '>'
    assert_raises(ValueError, sibc.to_numpy_code, 'silly string')