@@ -2,31 +2,31 @@ import XCTest
22import PythonKit
33
44class NumpyConversionTests : XCTestCase {
5- static var numpyModule = try? Python . attemptImport ( " numpy " )
6-
7- func testArrayConversion ( ) {
8- guard let np = NumpyConversionTests . numpyModule else { return }
9-
10- let numpyArrayEmpty = np . array ( [ ] as [ Float ] , dtype : np . float32 )
11- XCTAssertEqual ( [ ] , Array < Float > ( numpy : numpyArrayEmpty ) )
12-
13- let numpyArrayBool = np . array ( [ true , false , false , true ] )
14- XCTAssertEqual ( [ true , false , false , true ] , Array < Bool > ( numpy : numpyArrayBool ) )
15-
16- let numpyArrayFloat = np . ones ( [ 6 ] , dtype : np . float32 )
17- XCTAssertEqual ( Array ( repeating : 1 , count : 6 ) , Array < Float > ( numpy : numpyArrayFloat ) )
18-
19- let numpyArrayInt32 = np . array ( [ - 1 , 4 , 25 , 2018 ] , dtype : np . int32 )
20- XCTAssertEqual ( [ - 1 , 4 , 25 , 2018 ] , Array < Int32 > ( numpy : numpyArrayInt32 ) )
21-
22- let numpyArray2D = np . ones ( [ 2 , 3 ] )
23- XCTAssertNil ( Array < Float > ( numpy : numpyArray2D ) )
24-
25- let numpyArrayStrided = np . array ( [ [ 1 , 2 ] , [ 1 , 2 ] ] , dtype : np . int32 ) [
26- Python . slice ( Python . None ) , 1 ]
27- // Assert that the array has a stride, so that we're certainly testing a
28- // strided array.
29- XCTAssertNotEqual ( numpyArrayStrided . __array_interface__ [ " strides " ] , Python . None )
30- XCTAssertEqual ( [ 2 , 2 ] , Array < Int32 > ( numpy : numpyArrayStrided ) )
31- }
5+ static var numpyModule = try? Python . attemptImport ( " numpy " )
6+
7+ func testArrayConversion ( ) {
8+ guard let np = NumpyConversionTests . numpyModule else { return }
9+
10+ let numpyArrayEmpty = np . array ( [ ] as [ Float ] , dtype : np . float32 )
11+ XCTAssertEqual ( [ ] , Array < Float > ( numpy : numpyArrayEmpty ) )
12+
13+ let numpyArrayBool = np . array ( [ true , false , false , true ] )
14+ XCTAssertEqual ( [ true , false , false , true ] , Array < Bool > ( numpy : numpyArrayBool ) )
15+
16+ let numpyArrayFloat = np . ones ( [ 6 ] , dtype : np . float32 )
17+ XCTAssertEqual ( Array ( repeating : 1 , count : 6 ) , Array < Float > ( numpy : numpyArrayFloat ) )
18+
19+ let numpyArrayInt32 = np . array ( [ - 1 , 4 , 25 , 2018 ] , dtype : np . int32 )
20+ XCTAssertEqual ( [ - 1 , 4 , 25 , 2018 ] , Array < Int32 > ( numpy : numpyArrayInt32 ) )
21+
22+ let numpyArray2D = np . ones ( [ 2 , 3 ] )
23+ XCTAssertNil ( Array < Float > ( numpy : numpyArray2D ) )
24+
25+ let numpyArrayStrided = np . array ( [ [ 1 , 2 ] , [ 1 , 2 ] ] , dtype : np . int32 ) [
26+ Python . slice ( Python . None ) , 1 ]
27+ // Assert that the array has a stride, so that we're certainly testing a
28+ // strided array.
29+ XCTAssertNotEqual ( numpyArrayStrided . __array_interface__ [ " strides " ] , Python . None )
30+ XCTAssertEqual ( [ 2 , 2 ] , Array < Int32 > ( numpy : numpyArrayStrided ) )
31+ }
3232}
0 commit comments