Skip to content

confusing results, the same usage memory in loops besides negative values #353

@alisheikholeslam

Description

@alisheikholeslam

@fabianp How could I get true results or interpret them? memory-profiler shows same usage values for lines in the loop.

import numpy as np
from scipy.spatial import cKDTree, distance
import os
from memory_profiler import profile

radii = np.loadtxt(os.path.join(os.path.join(os.environ['USERPROFILE']), 'Desktop', "data", 'radii.csv'))
poss = np.loadtxt(os.path.join(os.path.join(os.environ['USERPROFILE']), 'Desktop', "data", 'coordinates.csv'), delimiter=",")
print(len(radii))
rad_max = np.amax(np.hstack(radii))
dia_max = 2 * rad_max

@profile
def ends_gap_opt(poss, dia_max):
    particle_corsp_overlaps = []
    ends_ind = [np.empty([1, 2], dtype=np.int64)]

    kdtree = cKDTree(poss)

    for particle_idx in range(len(poss)):
        cur_point = poss[particle_idx]
        nears_i_ind = np.array(kdtree.query_ball_point(cur_point, r=dia_max), dtype=np.int64)
        assert len(nears_i_ind) > 0

        if len(nears_i_ind) <= 1:
            continue

        nears_i_ind = nears_i_ind[nears_i_ind != particle_idx]
        dist_i = distance.cdist(poss[nears_i_ind], cur_point[None, :]).squeeze()

        contact_check = dist_i - (radii[nears_i_ind] + radii[particle_idx])
        connected = contact_check[contact_check <= 0]

        particle_corsp_overlaps.append(connected)

11
radii.csv
coordinates.csv

I have modified the memory_profiler.py as pull requests Fix: Large negative increments #350 and also, in another test using large negative increment values in line profiler #195, . Both solutions remove previous negative values from increments. Which of them is the true one?
The same mem usages are doubtful and seem to be wrong:

111

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions