scikit-beam / scikit-beam

@@ -450,16 +450,18 @@
Loading
450 450
451 451
def test_get_four_time_from_two_time():
452 452
    np.random.seed(0)
453 -
    l = 5
454 -
    g12 = np.random.rand(2, l, l)
453 +
    ll = 5
454 +
    g12 = np.random.rand(2, ll, ll)
455 455
    for k in range(g12.shape[0]):
456 456
        q = g12[k]
457 -
        g12[k] = np.tril(q) + np.tril(q).T - 2*np.diag(np.diag(q)) + np.diag(np.ones(len(q)))    
458 -
    g2 = np.random.rand(2,l)+10*np.exp(-0.05*np.array(range(l)))        
459 -
    res = get_four_time_from_two_time(g12, g2, (1,l))    
460 -
    
457 +
        g12[k] = np.tril(q) + np.tril(q).T - 2 * np.diag(np.diag(q)) + \
458 +
            np.diag(np.ones(len(q)))
459 +
    g2 = np.random.rand(2, ll) + 10 * np.exp(-0.05 * np.array(range(ll)))
460 +
    res = get_four_time_from_two_time(g12, g2, (1, ll))
461 +
461 462
    assert_array_almost_equal(res, [[0., 0.00019202, 0.00053148, 0.],
462 -
                                    [0., 0.00031959, 0.00028276, 0.]] , decimal = 8)
463 +
                                    [0., 0.00031959, 0.00028276, 0.]],
464 +
                              decimal=8)
463 465
464 466
465 467
def test_CrossCorrelator_badinputs():

@@ -1265,70 +1265,54 @@
Loading
1265 1265
1266 1266
    return imgc
1267 1267
1268 -
def get_four_time_from_two_time( g12, g2 , frames = None ):
1269 -
    ''' 
1268 +
1269 +
def get_four_time_from_two_time(g12, g2, frames=None):
1270 +
    """
1270 1271
    Get four-time correlation function from two correlation function
1271 1272
    namely, calculate the deviation of each diag line of g12 to get four-time correlation fucntion
1272 1273
    TOBEDONE: deal with bad frames
1273 -
    
1274 +
1274 1275
    Parameters
1275 1276
    ----------
1276 1277
    g12: 3-D array
1277 -
        two correlation function, shape as ( num_rois, imgs_length, imgs_length)  
1278 +
        two correlation function, shape as ( num_rois, imgs_length, imgs_length)
1278 1279
    g2: a 2-D array, shape as ( num_rois, imgs_length), or (num_rois, tau)
1279 1280
        one-time correlation fucntion, for normalization of the four-time
1280 1281
    frames: if not None, a tulpe (start, finish)
1281 -
   
1282 +
1282 1283
    Returns
1283 1284
    -------
1284 -
    g4f12: 2-D array, shape as (num_rois, imgs_length), 
1285 -
        a four-time correlation function  
1286 -
     
1285 +
    g4f12: 2-D array, shape as (num_rois, imgs_length),
1286 +
        a four-time correlation function
1287 +
1287 1288
    Examples
1288 -
    --------        
1289 +
    --------
1289 1290
    >>> s1, s2 = 0, 2000
1290 1291
    >>> g4 = get_four_time_from_two_time( g12bm, g2b, roi=[s1,s2,s1,s2] )
1291 -
         
1292 -
    '''      
1292 +
1293 +
    """
1293 1294
    # preallocate the array
1294 -
    if frames == None:
1295 +
    if frames is None:
1295 1296
        g4f12 = np.empty([g12.shape[0], g12.shape[1]])
1296 1297
    else:
1297 1298
        g4f12 = np.empty([g12.shape[0], frames[1]-frames[0]])
1298 -
       
1299 +
1299 1300
    for ind, q in enumerate(g12):
1300 1301
        temp = []
1301 -
        
1302 -
        #consider only time-slice of frames
1303 -
        if frames != None: 
1302 +
1303 +
        # consider only time-slice of frames
1304 +
        if frames is not None:
1304 1305
            start, end = frames
1305 -
            q = q[start:end,start:end]
1306 -
        
1307 -
        norm = (g2[ind,:][0] -1)**2
1308 -
        
1306 +
            q = q[start:end, start:end]
1307 +
1308 +
        norm = (g2[ind, :][0] - 1)**2
1309 +
1309 1310
        for tau in range(q.shape[0]):
1310 -
            d = np.diag(q, k = tau)
1311 +
            d = np.diag(q, k=tau)
1311 1312
            g4 = (d.std())**2 / norm
1312 1313
            temp.append(g4)
1313 -
            
1314 -
        temp = np.array(temp)       
1315 -
        g4f12[ind, :] = temp[:]
1316 -
        
1317 -
    return g4f12
1318 -
        
1319 -
    
1320 -
1321 -
1322 -
1323 -
1324 -
1325 -
1326 -
1327 -
1328 -
1329 -
1330 -
1331 -
1332 -
1333 1314
1315 +
        temp = np.array(temp)
1316 +
        g4f12[ind, :] = temp[:]
1334 1317
1318 +
    return g4f12
Files Coverage
skbeam 90.95%
Project Totals (68 files) 90.95%
2137.7
TRAVIS_PYTHON_VERSION=3.7
TRAVIS_OS_NAME=linux

No yaml found.

Create your codecov.yml to customize your Codecov experience

Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading