This file is indexed.

/usr/share/psi4/samples/numpy-array-interface/input.dat is in psi4-data 1:1.1-5.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
118
119
120
121
122
123
124
125
126
127
#! Numpy interface testing

import numpy as np

# Matrix from array
arr_matrix = np.random.rand(2, 2)
arr_matrix_value = arr_matrix[0, 0]

mat1 = psi4.Matrix.from_array(arr_matrix)
mat2 = psi4.Matrix.from_array([arr_matrix, arr_matrix+3])



# Array from matrix
np_mat1 = mat1.to_array()
np_mat2 = mat2.to_array()
np_mat1_ex = np.array(mat1)

for h in range(mat2.nirrep()):
# Explicit should fail

np_mat1_view = mat1.to_array(copy=False)
np_mat2_view = mat2.to_array(copy=False)
mat1.set(0, 0, 13)
mat2.set(0, 0, 0, 13)




# Vector from array
arr_vector = np.random.rand(4)
arr_vec_value = arr_vector[0]

vec1 = psi4.Vector.from_array(arr_vector)
vec2 = psi4.Vector.from_array([arr_vector, arr_vector])



# Array from Vector
np_vec1 = vec1.to_array()
np_vec2 = vec2.to_array()

np_vec1_view = vec1.to_array(copy=False)
np_vec2_view = vec2.to_array(copy=False)
vec1.set(0, 13)
vec2.set(0, 0, 13)



# Test blank irreps





dim1_match = list(dim1) == list(dim1.to_tuple())
dim2_match = list(dim2) == list(dim2.to_tuple())





irrep_mat = Matrix("Matrix with two zero irreps", dim1, dim2)
irrep_mat.set(0, 0, 0, 4)
irrep_mat.set(0, 0, 1, 3)
irrep_mat.set(0, 1, 0, -5)

arr = irrep_mat.to_array()

new_mat = Matrix.from_array(arr)


irrep_vec = Vector("Vector with two zero irreps", dim2)

arr = irrep_vec.to_array()

new_vec = Vector.from_array(arr)

# Test dense conversion
dense_vec = irrep_vec.to_array(dense=True)

dense_mat = irrep_mat.to_array(dense=True)


irreped_mat = Matrix.from_array([np.random.rand(1,4), np.empty(shape=(0,3)), np.random.rand(2,1)])
dense_arr = irreped_mat.to_array(dense=True)
irreped_mat2 = Matrix.from_array(dense_arr, dim1=(1, 0, 2), dim2=(4, 3, 1))

irreped_arr = irreped_mat2.to_array()

irreped_vec = Vector.from_array([np.random.rand(1), np.empty(shape=(0)), np.random.rand(2)])
dense_arr = irreped_vec.to_array(dense=True)
irreped_vec2 = Vector.from_array(dense_arr, dim1=(1, 0, 2))

irreped_arr = irreped_vec2.to_array()

# Test save
irreped_mat.np_write("irreped_mat")
read_irreped_mat = psi4.Matrix.np_read("irreped_mat")

irreped_vec.np_write("irreped_vec")
read_irreped_vec = psi4.Vector.np_read("irreped_vec")


fkeys = irreped_mat.np_write(prefix='mat ')
fkeys.update(irreped_vec.np_write(prefix='vec '))
np.savez("compound", **fkeys)

read_irreped_mat = psi4.Matrix.np_read("compound", prefix='mat ')

read_irreped_vec = psi4.Vector.np_read("compound", prefix='vec ')


# Make sure our pointers are being tracked correctly
tmp = []
for n in range(1000):
    tmp.append(np.asarray(Matrix(3, 3)))
residual = sum(np.sum(x) for x in tmp)



# Try out JSON serialization
json_data = irreped_vec.to_serial()
json_vec = psi4.Vector.from_serial(json_data)

json_data = irreped_mat.to_serial()
json_vec = psi4.Matrix.from_serial(json_data)