Skip to content

Commit 676c4a6

Browse files
Merge pull request #5 from dimitra-maoutsa/testing
Testing
2 parents a01508c + 1ac5afc commit 676c4a6

2 files changed

Lines changed: 18 additions & 10 deletions

File tree

DeterministicParticleFlowControl/reweighting/optimal_transport_reweighting.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from pyemd import emd_with_flow
1313
from scipy.spatial.distance import pdist, squareform
1414

15+
__all__ = ["reweight_optimal_transport_multidim"]
1516

1617
def reweight_optimal_transport_multidim(samples, weights):
1718

DeterministicParticleFlowControl/score_estimators/score_function_estimators.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,12 @@ def score_function_multid_seperate(X,Z,func_out=False, C=0.001,kern ='RBF',l=1,w
8484
employed for interpolation/estimation of
8585
the logarithmic gradient in the vicinity of the samples.
8686
87-
(For estimation across all dimensions simultaneously see score_function_multid_seperate_all_dims )
87+
For estimation across all dimensions simultaneously see also
88+
89+
See also
90+
----------
91+
score_function_multid_seperate_all_dims
92+
8893
8994
Parameters
9095
----------
@@ -112,7 +117,7 @@ def score_function_multid_seperate(X,Z,func_out=False, C=0.001,kern ='RBF',l=1,w
112117
"""
113118

114119
if kern=='RBF':
115-
120+
"""
116121
#@numba.njit(parallel=True,fastmath=True)
117122
def Knumba(x,y,l,res,multil=False): #version of kernel in the numba form when the call already includes the output matrix
118123
if multil:
@@ -127,8 +132,8 @@ def Knumba(x,y,l,res,multil=False): #version of kernel in the numba form when th
127132
tempi = np.zeros((x.shape[0], y.shape[0] ), dtype=np.float64)
128133
my_cdist(x, y,tempi,'sqeuclidean') #this sets into the array tempi the cdist result
129134
res = np.exp(-tempi/(2*l*l))
130-
return 0
131-
135+
#return 0
136+
"""
132137
def K(x,y,l,multil=False):
133138
if multil:
134139
res = np.ones((x.shape[0],y.shape[0]))
@@ -165,7 +170,7 @@ def grdx_K(x,y,l,which_dim=1,multil=False): #gradient with respect to the 1st ar
165170
redifs = np.multiply(diffs[:,:,ii],K(x,y,l))/(l*l)
166171
return redifs
167172

168-
173+
"""
169174
def grdy_K(x,y): # gradient with respect to the second argument
170175
_,dim = x.shape
171176
diffs = x[:,None]-y
@@ -184,6 +189,7 @@ def ggrdxy_K(x,y):
184189
for jj in range(which_dim-1,which_dim):
185190
redifs[ii, jj ] = np.multiply(np.multiply(diffs[:,:,ii],diffs[:,:,jj])+(l*l)*(ii==jj),K(x,y))/(l**4)
186191
return -redifs
192+
"""
187193

188194
#############################################################################
189195
elif kern=='periodic': ###############################################################################################
@@ -200,7 +206,7 @@ def K(x,y,l,multil=False):
200206

201207
res = np.ones((x.shape[0],y.shape[0]))
202208
for ii in range(len(l)):
203-
tempi = np.zeros((x[:,ii].size, y[:,ii].size ))
209+
#tempi = np.zeros((x[:,ii].size, y[:,ii].size ))
204210
##puts into tempi the cdist result
205211
#my_cdist(x[:,ii].reshape(-1,1), y[:,ii].reshape(-1,1),tempi, 'l1')
206212
#res = np.multiply(res, np.exp(- 2* (np.sin(tempi/ 2 )**2) /(l[ii]*l[ii])) )
@@ -215,7 +221,7 @@ def K(x,y,l,multil=False):
215221
return res
216222

217223
def grdx_K(x,y,l,which_dim=1,multil=False): #gradient with respect to the 1st argument - only which_dim
218-
N,dim = x.shape
224+
#N,dim = x.shape
219225
diffs = x[:,None]-y
220226
#print('diffs:',diffs)
221227
#redifs = np.zeros((1*N,N))
@@ -324,7 +330,7 @@ def score_function_multid_seperate_all_dims(X,Z,func_out=False, C=0.001,kern ='R
324330
"""
325331

326332
if kern=='RBF':
327-
333+
"""
328334
#@numba.njit(parallel=True,fastmath=True)
329335
def Knumba(x,y,l,res,multil=False): #version of kernel in the numba form when the call already includes the output matrix
330336
if multil:
@@ -340,6 +346,7 @@ def Knumba(x,y,l,res,multil=False): #version of kernel in the numba form when th
340346
my_cdist(x, y,tempi,'sqeuclidean') #this sets into the array tempi the cdist result
341347
res = np.exp(-tempi/(2*l*l))
342348
return 0
349+
"""
343350

344351
def K(x,y,l,multil=False):
345352
if multil:
@@ -558,7 +565,7 @@ def grdx_K(x,y,l,which_dim=1,multil=False): #gradient with respect to the 1st ar
558565
else:
559566
redifs = np.multiply(diffs[:,:,ii],K(x,y,l))/(l*l)
560567
return redifs
561-
568+
"""
562569
def grdy_K(x,y): # gradient with respect to the second argument
563570
#N,dim = x.shape
564571
diffs = x[:,None]-y
@@ -575,7 +582,7 @@ def ggrdxy_K(x,y):
575582
for jj in range(which_dim-1,which_dim):
576583
redifs[ii, jj ] = np.multiply(np.multiply(diffs[:,:,ii],diffs[:,:,jj])+(l*l)*(ii==jj),K(x,y))/(l**4)
577584
return -redifs
578-
585+
"""
579586
if isinstance(l, (list, tuple, np.ndarray)):
580587
### for different lengthscales for each dimension
581588
K_xz = K(X,Z,l,multil=True)

0 commit comments

Comments
 (0)