Skip to content

Commit

Permalink
Merge d1b88f3 into 4286761
Browse files Browse the repository at this point in the history
  • Loading branch information
tkoyama010 committed Nov 1, 2020
2 parents 4286761 + d1b88f3 commit 019296b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
13 changes: 10 additions & 3 deletions dask_image/ndmeasure/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"minimum_position",
"standard_deviation",
"sum",
"sum_labels",
"variance",
]

Expand Down Expand Up @@ -678,9 +679,9 @@ def standard_deviation(image, label_image=None, index=None):
return std_lbl


def sum(image, label_image=None, index=None):
def sum_labels(image, label_image=None, index=None):
"""
Find the sum over an image at specified subregions.
Find the sum of all pixels over specified subregions of an image.

Parameters
----------
Expand All @@ -696,7 +697,7 @@ def sum(image, label_image=None, index=None):

Returns
-------
sum : ndarray
sum_lbl : ndarray
Sum of ``image`` over the ``index`` selected regions from
``label_image``.
"""
Expand All @@ -712,6 +713,12 @@ def sum(image, label_image=None, index=None):
return sum_lbl


def sum(image, label_image=None, index=None):
"""DEPRECATED FUNCTION. Use `sum_labels` instead."""
warnings.warn("DEPRECATED FUNCTION. Use `sum_labels` instead.", DeprecationWarning)
return sum_labels(image, label_image=label_image, index=index)


def variance(image, label_image=None, index=None):
"""
Find the variance over an image at specified subregions.
Expand Down
2 changes: 1 addition & 1 deletion docs/coverage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ This table shows which SciPy ndimage functions are supported by dask-image.
* - ``standard_deviation``
- ✓
- ✓
* - ``sum``
* - ``sum_labels``
- ✓
- ✓
* - ``uniform_filter``
Expand Down
16 changes: 12 additions & 4 deletions tests/test_dask_image/test_ndmeasure/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
# -*- coding: utf-8 -*-

from __future__ import absolute_import

from distutils.version import LooseVersion
import scipy
import itertools as it
import warnings as wrn

import pytest

import numpy as np

import scipy
import scipy.ndimage as spnd

import dask.array as da
Expand All @@ -28,7 +30,7 @@
"minimum",
"minimum_position",
"standard_deviation",
"sum",
"sum_labels",
"variance",
]
)
Expand Down Expand Up @@ -88,7 +90,7 @@ def test_center_of_mass(datatype):
"minimum",
"minimum_position",
"standard_deviation",
"sum",
"sum_labels",
"variance",
]
)
Expand All @@ -110,7 +112,13 @@ def test_center_of_mass(datatype):
]
)
def test_measure_props(funcname, shape, chunks, has_lbls, ind):
sp_func = getattr(spnd, funcname)
# early scipy version uses a different name sum insted of sum_labels.
if funcname == 'sum_labels' and scipy.__version__ < LooseVersion('1.5.0'):
scipy_funcname = 'sum'
else:
scipy_funcname = funcname

sp_func = getattr(spnd, scipy_funcname)
da_func = getattr(dask_image.ndmeasure, funcname)

a = np.random.random(shape)
Expand Down

0 comments on commit 019296b

Please sign in to comment.