Skip to content

Commit

Permalink
Merge pull request #13 from e-koch/numpy_1.10_fix
Browse files Browse the repository at this point in the history
Numpy 1.10 fix
  • Loading branch information
e-koch committed Oct 30, 2015
2 parents 793f313 + 1139099 commit a145c85
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ install:

# Now install dependencies
- conda install --yes h5py
- conda install --yes numpy==1.9
- conda install --yes numpy
- conda install --yes scipy
- conda install --yes matplotlib
- conda install --yes scikit-image
Expand Down
34 changes: 20 additions & 14 deletions fil_finder/width.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,20 +449,26 @@ def radial_profile(img, dist_transform_all, dist_transform_sep, offsets,

whichbins = np.digitize(width_distance, bins)
bin_centers = (bins[1:] + bins[:-1]) / 2.0
radial_prof = np.array(
[np.median(width_value[(whichbins == bin)]) for bin in
range(1, int(nbins) + 1)])

if weighting == "number":
weights = np.array([whichbins[whichbins == bin].sum()
for bin in range(1, int(nbins) + 1)])
elif weighting == "var":
weights = np.array(
[np.nanvar(width_value[whichbins == bin]) for bin in
range(1, int(nbins) + 1)])
weights[np.isnan(weights)] = 0.0 # Empty bins

# Ignore empty bins

radial_prof = np.zeros_like(bin_centers)
weights = np.zeros_like(bin_centers)

for nbin in xrange(1, int(nbins) + 1):

bin_posns = whichbins == nbin

# Skip any empty bins
if bin_posns.sum() == 0:
continue

radial_prof[nbin-1] = np.median(width_value[bin_posns])

if weighting == "number":
weights[nbin-1] = whichbins[bin_posns].sum()
elif weighting == "var":
weights[nbin-1] = np.nanvar(width_value[bin_posns])

# Remove all empty bins
radial_prof = radial_prof[weights > 0]
bin_centers = bin_centers[weights > 0]
weights = weights[weights > 0]
Expand Down

0 comments on commit a145c85

Please sign in to comment.