blob: 185e6d3cc4505d6c851a843afbf475d8cb0ab1e6 [file] [log] [blame]
Wenzel Jakob57082212015-09-04 23:42:12 +02001#!/usr/bin/env python
2from __future__ import print_function
Wenzel Jakob38bd7112015-07-05 20:05:44 +02003import sys
4sys.path.append('.')
5
6from example import Matrix
Wenzel Jakobfab881c2015-10-18 17:04:24 +02007
8try:
9 import numpy as np
10except ImportError:
Jason Rhinelander7de9f6c2016-07-08 17:44:12 -040011 # NumPy missing: skip test
12 exit(99)
Wenzel Jakob38bd7112015-07-05 20:05:44 +020013
14m = Matrix(5, 5)
15
16print(m[2, 3])
17m[2, 3] = 4
18print(m[2, 3])
19
20m2 = np.array(m, copy=False)
21print(m2)
22print(m2[2, 3])
23m2[2, 3] = 5
24print(m[2, 3])
25
26m3 = np.array([[1,2,3],[4,5,6]]).astype(np.float32)
27print(m3)
28m4 = Matrix(m3)
29for i in range(m4.rows()):
30 for j in range(m4.cols()):
31 print(m4[i, j], end = ' ')
32 print()
Jason Rhinelander3f589372016-08-07 13:05:26 -040033
34from example import ConstructorStats
35cstats = ConstructorStats.get(Matrix)
36print("Instances not destroyed:", cstats.alive())
37m = m4 = None
38print("Instances not destroyed:", cstats.alive())
39m2 = None # m2 holds an m reference
40print("Instances not destroyed:", cstats.alive())
41print("Constructor values:", cstats.values())
42print("Copy constructions:", cstats.copy_constructions)
43#print("Move constructions:", cstats.move_constructions >= 0) # Don't invoke any
44print("Copy assignments:", cstats.copy_assignments)
45print("Move assignments:", cstats.move_assignments)