@@ -29,7 +29,7 @@ cdef DTYPE_t INF = np.inf
29
29
30
30
from ..utils._typedefs cimport DTYPE_t, ITYPE_t, DITYPE_t, DTYPECODE
31
31
from ..utils._typedefs import DTYPE, ITYPE
32
-
32
+ from ..utils._readonly_array_wrapper import ReadonlyArrayWrapper
33
33
34
34
# #####################################################################
35
35
# newObj function
@@ -191,8 +191,8 @@ cdef class DistanceMetric:
191
191
"""
192
192
def __cinit__ (self ):
193
193
self .p = 2
194
- self .vec = np.zeros(1 , dtype = DTYPE, order = ' c' )
195
- self .mat = np.zeros((1 , 1 ), dtype = DTYPE, order = ' c' )
194
+ self .vec = ReadonlyArrayWrapper( np.zeros(1 , dtype = DTYPE, order = ' c' ) )
195
+ self .mat = ReadonlyArrayWrapper( np.zeros((1 , 1 ), dtype = DTYPE, order = ' c' ) )
196
196
self .size = 1
197
197
198
198
def __reduce__ (self ):
@@ -214,8 +214,8 @@ cdef class DistanceMetric:
214
214
set state for pickling
215
215
"""
216
216
self .p = state[0 ]
217
- self .vec = state[1 ]
218
- self .mat = state[2 ]
217
+ self .vec = ReadonlyArrayWrapper( state[1 ])
218
+ self .mat = ReadonlyArrayWrapper( state[2 ])
219
219
if self .__class__.__name__ == " PyFuncDistance" :
220
220
self .func = state[3 ]
221
221
self .kwargs = state[4 ]
@@ -444,7 +444,7 @@ cdef class SEuclideanDistance(DistanceMetric):
444
444
D( x, y) = \s qrt{ \s um_i \f rac{ ( x_i - y_i) ^ 2}{V_i} }
445
445
"""
446
446
def __init__ (self , V ):
447
- self .vec = np.asarray(V, dtype = DTYPE)
447
+ self .vec = ReadonlyArrayWrapper( np.asarray(V, dtype = DTYPE) )
448
448
self .size = self .vec.shape[0 ]
449
449
self .p = 2
450
450
0 commit comments