Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
executable file
·
117 lines (91 loc) · 4.22 KB

File metadata and controls

executable file
·
117 lines (91 loc) · 4.22 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# -*- python -*-
#
# Copyright (c) 2010-2012, Jim Bosch
# All rights reserved.
#
# ndarray is distributed under a simple BSD-like license;
# see the LICENSE file that should be present in the root
# of the source distribution, or alternately available at:
# https://github.com/ndarray/ndarray
#
import numpy
import python_test_mod
import unittest
class TestNDArray(unittest.TestCase):
def testIntArrayConversion(self):
a1 = numpy.zeros((5,3,4),dtype=numpy.int32)
a2 = a1[:,:,:2]
self.assertTrue(a1.flags["WRITEABLE"])
self.assertTrue(a2.flags["WRITEABLE"])
ua1 = numpy.zeros((5,3,4),dtype=numpy.uint32)
self.assertTrue(ua1.flags["WRITEABLE"])
b1 = python_test_mod.passIntArray33(a1)
self.assertTrue(b1.flags["WRITEABLE"])
self.assertEqual(a1.shape,b1.shape)
self.assertEqual(a1.strides,b1.strides)
ub1 = python_test_mod.passUIntArray33(ua1)
self.assertTrue(ub1.flags["WRITEABLE"])
self.assertEqual(a1.shape,ub1.shape)
self.assertEqual(a1.strides,ub1.strides)
c1 = python_test_mod.passIntArray30(a1)
self.assertTrue(c1.flags["WRITEABLE"])
self.assertEqual(a1.shape,c1.shape)
self.assertEqual(a1.strides,c1.strides)
d1 = python_test_mod.passConstIntArray33(a1)
self.assertEqual(a1.shape,d1.shape)
self.assertEqual(a1.strides,d1.strides)
self.assertTrue(not d1.flags.writeable)
self.assertRaises(ValueError, python_test_mod.passIntArray33, a2)
c2 = python_test_mod.passIntArray30(a2)
self.assertTrue(c2.flags["WRITEABLE"])
self.assertEqual(a2.shape,c2.shape)
self.assertEqual(a2.strides,c2.strides)
# test to be sure a tuple of tuples does not work
self.assertRaises(TypeError, python_test_mod.passIntArray30, ((1,1,1),(2,2,2),(3,3,3)))
# test to be sure an array of the wrong type does not work
self.assertRaises(ValueError, python_test_mod.passIntArray30,
numpy.zeros((4,3,4),dtype=numpy.float))
def testVectorConversion(self):
a = (3.5,6.7,1.2)
b = python_test_mod.passFloatVector3(a)
self.assertEqual(a,b)
def testArrayConversion(self):
a1 = numpy.zeros((5,3,4),dtype=float)
a2 = a1[:,:,:2]
self.assertTrue(a1.flags["WRITEABLE"])
self.assertTrue(a2.flags["WRITEABLE"])
b1 = python_test_mod.passFloatArray33(a1)
self.assertTrue(b1.flags["WRITEABLE"])
self.assertEqual(a1.shape,b1.shape)
self.assertEqual(a1.strides,b1.strides)
c1 = python_test_mod.passFloatArray30(a1)
self.assertTrue(c1.flags["WRITEABLE"])
self.assertEqual(a1.shape,c1.shape)
self.assertEqual(a1.strides,c1.strides)
d1 = python_test_mod.passConstFloatArray33(a1)
self.assertEqual(a1.shape,d1.shape)
self.assertEqual(a1.strides,d1.strides)
self.assertTrue(not d1.flags.writeable)
self.assertRaises(ValueError, python_test_mod.passFloatArray33, a2)
c2 = python_test_mod.passFloatArray30(a2)
self.assertTrue(c2.flags["WRITEABLE"])
self.assertEqual(a2.shape,c2.shape)
self.assertEqual(a2.strides,c2.strides)
# test to be sure a tuple of tuples does not work
self.assertRaises(TypeError, python_test_mod.passFloatArray30,
((1.0,1.0,1.0),(2.0,2.0,2.0),(3.0,3.0,3.0)))
# test to be sure an array of the wrong type does not work
self.assertRaises(ValueError, python_test_mod.passFloatArray30,
numpy.zeros((4,3,4),dtype=numpy.int32))
# test to be sure a tuple of tuples does not work
self.assertRaises(TypeError, python_test_mod.passFloatArray30,
((1.0,1.0,1.0),(2.0,2.0,2.0),(3.0,3.0,3.0)))
# test to be sure an array of the wrong type does not work
self.assertRaises(ValueError, python_test_mod.passFloatArray30,
numpy.zeros((4,3,4),dtype=numpy.int32))
def testFloatArrayCreation(self):
a = python_test_mod.makeFloatArray3((3,4,5))
def testIntArrayCreation(self):
a = python_test_mod.makeIntArray3((3,4,5))
if __name__ == "__main__":
unittest.main()
Morty Proxy This is a proxified and sanitized view of the page, visit original site.