codecov-io: # [Codecov](https://codecov.io/gh/spacetx/starfish/pull/1718?src=pr&el=h1) Report
> Merging [#1718](https://codecov.io/gh/spacetx/starfish/pull/1718?src=pr&el=desc) into [master](https://codecov.io/gh/spacetx/starfish/commit/0f1420e521e7fae0561af6dff8b7894961641332?src=pr&el=desc) will **increase** coverage by `<.01%`.
> The diff coverage is `90.9%`.

[![Impacted file tree graph](https://codecov.io/gh/spacetx/starfish/pull/1718/graphs/tree.svg?width=650&token=kliQHejt6T&height=150&src=pr)](https://codecov.io/gh/spacetx/starfish/pull/1718?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master    #1718      +/-   ##
==========================================
+ Coverage   89.96%   89.97%   +<.01%     
==========================================
  Files         246      246              
  Lines        9170     9176       +6     
==========================================
+ Hits         8250     8256       +6     
  Misses        920      920
```


| [Impacted Files](https://codecov.io/gh/spacetx/starfish/pull/1718?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [starfish/core/test/test\_display.py](https://codecov.io/gh/spacetx/starfish/pull/1718/diff?src=pr&el=tree#diff-c3RhcmZpc2gvY29yZS90ZXN0L3Rlc3RfZGlzcGxheS5weQ==) | `60.86% <0%> (ø)` | :arrow_up: |
| [starfish/core/morphology/Filter/areafilter.py](https://codecov.io/gh/spacetx/starfish/pull/1718/diff?src=pr&el=tree#diff-c3RhcmZpc2gvY29yZS9tb3JwaG9sb2d5L0ZpbHRlci9hcmVhZmlsdGVyLnB5) | `100% <100%> (ø)` | :arrow_up: |
| [...ish/core/morphology/Filter/test/test\_areafilter.py](https://codecov.io/gh/spacetx/starfish/pull/1718/diff?src=pr&el=tree#diff-c3RhcmZpc2gvY29yZS9tb3JwaG9sb2d5L0ZpbHRlci90ZXN0L3Rlc3RfYXJlYWZpbHRlci5weQ==) | `100% <100%> (ø)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/spacetx/starfish/pull/1718?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/spacetx/starfish/pull/1718?src=pr&el=footer). Last update [0f1420e...f9f1dd0](https://codecov.io/gh/spacetx/starfish/pull/1718?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

diff --git a/starfish/core/morphology/Filter/areafilter.py b/starfish/core/morphology/Filter/areafilter.py
index 963f18f5..f3f9c399 100644
--- a/starfish/core/morphology/Filter/areafilter.py
+++ b/starfish/core/morphology/Filter/areafilter.py
@@ -19,10 +19,15 @@ class AreaFilter(FilterAlgorithm):
         collection.
     """
 
-    def __init__(self, min_area: Optional[int], max_area: Optional[int]):
+    def __init__(self, *, min_area: Optional[int] = None, max_area: Optional[int] = None):
         self._min_area = min_area
         self._max_area = max_area
 
+        if (self._min_area is not None
+                and self._max_area is not None
+                and self._min_area > self._max_area):
+            raise ValueError(f"min_area ({min_area}) should be smaller than max_area ({max_area})")
+
     def run(
             self,
             binary_mask_collection: BinaryMaskCollection,

MinDistanceLabel needs kwargs and sanity checking
#### Description
<!-- Example: Joblib Error thrown when calling fit on LatentDirichletAllocation with evaluate_every > 0-->

#### Steps/Code to Reproduce
<!--
If the code is too long, feel free to put it in a public gist and link
it in the issue: https://gist.github.com
-->

#### Expected Results
<!-- Example: No error is thrown. Please paste or describe the expected results.-->

#### Actual Results
<!-- Please paste or specifically describe the actual output or traceback. -->

#### Versions
<!--
import platform; print(platform.platform())
import sys; print("Python", sys.version)
import numpy; print("NumPy", numpy.__version__)
import scipy; print("SciPy", scipy.__version__)
import skimage; print("scikit-image", skimage.__version__)
import pandas; print("pandas", pandas.__version__)
import sklearn; print("sklearn", sklearn.__version__)
import xarray; print("xarray", xarray.__version__)
import sympy; print("sympy", sympy.__version__)
import starfish; print("starfish", starfish.__version__)
-->


<!-- Thanks for contributing! -->

diff --git a/starfish/core/morphology/Filter/test/test_areafilter.py b/starfish/core/morphology/Filter/test/test_areafilter.py
index 32d85b1d..1a52c0e1 100644
--- a/starfish/core/morphology/Filter/test/test_areafilter.py
+++ b/starfish/core/morphology/Filter/test/test_areafilter.py
@@ -1,10 +1,12 @@
+import pytest
+
 from starfish.core.morphology.binary_mask.test.factories import binary_mask_collection_2d
 from ..areafilter import AreaFilter
 
 
 def test_empty_filter():
     input_mask_collection = binary_mask_collection_2d()
-    output_mask_collection = AreaFilter(None, None).run(input_mask_collection)
+    output_mask_collection = AreaFilter().run(input_mask_collection)
     assert len(output_mask_collection) == len(input_mask_collection)
 
     for mask_num in range(len(input_mask_collection)):
@@ -15,11 +17,16 @@ def test_empty_filter():
 
 def test_min_area():
     input_mask_collection = binary_mask_collection_2d()
-    output_mask_collection = AreaFilter(6, None).run(input_mask_collection)
+    output_mask_collection = AreaFilter(min_area=6).run(input_mask_collection)
     assert len(output_mask_collection) == 1
 
 
 def test_max_area():
     input_mask_collection = binary_mask_collection_2d()
-    output_mask_collection = AreaFilter(None, 5).run(input_mask_collection)
+    output_mask_collection = AreaFilter(max_area=5).run(input_mask_collection)
     assert len(output_mask_collection) == 1
+
+
+def test_illegal_areas():
+    with pytest.raises(ValueError):
+        AreaFilter(min_area=7, max_area=1)

pip install -e .[dev]
parse_log_pytest
requirements.txt
pytest pytest-cov pytest-xdist
3.6
REQUIREMENTS.txt REQUIREMENTS-CI.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
argon2-cffi==21.3.0
argon2-cffi-bindings==21.2.0
async-generator==1.10
attrs==22.2.0
backcall==0.2.0
bleach==4.1.0
boto3==1.23.10
botocore==1.26.10
certifi==2021.5.30
cffi==1.15.1
charset-normalizer==2.0.12
click==8.0.4
comm==0.1.4
coverage==6.2
cycler==0.11.0
dataclasses==0.6
decorator==4.4.2
defusedxml==0.7.1
diskcache==5.6.3
entrypoints==0.4
execnet==1.9.0
idna==3.10
imageio==2.15.0
importlib-metadata==4.8.3
importlib-resources==5.4.0
iniconfig==1.1.1
ipykernel==5.5.6
ipython==7.16.3
ipython-genutils==0.2.0
ipywidgets==7.8.5
jedi==0.17.2
Jinja2==3.0.3
jmespath==0.10.0
joblib==1.1.1
jsonschema==3.2.0
jupyter-client==7.1.2
jupyter-core==4.9.2
jupyterlab-pygments==0.1.2
jupyterlab_widgets==1.1.11
kiwisolver==1.3.1
MarkupSafe==2.0.1
matplotlib==3.3.4
mistune==0.8.4
mpmath==1.3.0
nbclient==0.5.9
nbconvert==6.0.7
nbformat==5.1.3
nest-asyncio==1.6.0
networkx==2.5.1
notebook==6.4.10
numpy==1.19.5
packaging==21.3
pandas==1.1.5
pandocfilters==1.5.1
parso==0.7.1
pexpect==4.9.0
pickleshare==0.7.5
Pillow==8.4.0
pluggy==1.0.0
prometheus-client==0.17.1
prompt-toolkit==3.0.36
ptyprocess==0.7.0
py==1.11.0
pycparser==2.21
Pygments==2.14.0
pyparsing==3.1.4
pyrsistent==0.18.0
pytest==7.0.1
pytest-cov==4.0.0
pytest-xdist==3.0.2
python-dateutil==2.8.0
pytz==2025.2
PyWavelets==1.1.1
PyYAML==6.0.1
pyzmq==25.1.2
regional==1.1.2
requests==2.27.1
s3transfer==0.5.2
scikit-image==0.17.2
scikit-learn==0.24.2
scipy==1.5.4
semantic-version==2.10.0
Send2Trash==1.8.3
showit==1.1.4
six==1.17.0
slicedimage==4.1.1
-e git+https://github.com/spacetx/starfish.git@38fb2d7e2eb7810300e4dbf9a469b84c701b1ffe#egg=starfish
sympy==1.9
terminado==0.12.1
testpath==0.6.0
threadpoolctl==3.1.0
tifffile==2020.9.3
tomli==1.2.3
tornado==6.1
tqdm==4.64.1
trackpy==0.5.0
traitlets==4.3.3
typing_extensions==4.1.1
urllib3==1.26.20
validators==0.20.0
wcwidth==0.2.13
webencodings==0.5.1
widgetsnbextension==3.6.10
xarray==0.16.2
zipp==3.6.0

name: starfish
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2021.5.30=py36h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.3=he6710b0_2
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=21.2.2=py36h06a4308_0
  - python=3.6.13=h12debd9_1
  - readline=8.2=h5eee18b_0
  - setuptools=58.0.4=py36h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - argon2-cffi==21.3.0
      - argon2-cffi-bindings==21.2.0
      - async-generator==1.10
      - attrs==22.2.0
      - backcall==0.2.0
      - bleach==4.1.0
      - boto3==1.23.10
      - botocore==1.26.10
      - cffi==1.15.1
      - charset-normalizer==2.0.12
      - click==8.0.4
      - comm==0.1.4
      - coverage==6.2
      - cycler==0.11.0
      - dataclasses==0.6
      - decorator==4.4.2
      - defusedxml==0.7.1
      - diskcache==5.6.3
      - entrypoints==0.4
      - execnet==1.9.0
      - idna==3.10
      - imageio==2.15.0
      - importlib-metadata==4.8.3
      - importlib-resources==5.4.0
      - iniconfig==1.1.1
      - ipykernel==5.5.6
      - ipython==7.16.3
      - ipython-genutils==0.2.0
      - ipywidgets==7.8.5
      - jedi==0.17.2
      - jinja2==3.0.3
      - jmespath==0.10.0
      - joblib==1.1.1
      - jsonschema==3.2.0
      - jupyter-client==7.1.2
      - jupyter-core==4.9.2
      - jupyterlab-pygments==0.1.2
      - jupyterlab-widgets==1.1.11
      - kiwisolver==1.3.1
      - markupsafe==2.0.1
      - matplotlib==3.3.4
      - mistune==0.8.4
      - mpmath==1.3.0
      - nbclient==0.5.9
      - nbconvert==6.0.7
      - nbformat==5.1.3
      - nest-asyncio==1.6.0
      - networkx==2.5.1
      - notebook==6.4.10
      - numpy==1.19.5
      - packaging==21.3
      - pandas==1.1.5
      - pandocfilters==1.5.1
      - parso==0.7.1
      - pexpect==4.9.0
      - pickleshare==0.7.5
      - pillow==8.4.0
      - pluggy==1.0.0
      - prometheus-client==0.17.1
      - prompt-toolkit==3.0.36
      - ptyprocess==0.7.0
      - py==1.11.0
      - pycparser==2.21
      - pygments==2.14.0
      - pyparsing==3.1.4
      - pyrsistent==0.18.0
      - pytest==7.0.1
      - pytest-cov==4.0.0
      - pytest-xdist==3.0.2
      - python-dateutil==2.8.0
      - pytz==2025.2
      - pywavelets==1.1.1
      - pyyaml==6.0.1
      - pyzmq==25.1.2
      - regional==1.1.2
      - requests==2.27.1
      - s3transfer==0.5.2
      - scikit-image==0.17.2
      - scikit-learn==0.24.2
      - scipy==1.5.4
      - semantic-version==2.10.0
      - send2trash==1.8.3
      - showit==1.1.4
      - six==1.17.0
      - slicedimage==4.1.1
      - sympy==1.9
      - terminado==0.12.1
      - testpath==0.6.0
      - threadpoolctl==3.1.0
      - tifffile==2020.9.3
      - tomli==1.2.3
      - tornado==6.1
      - tqdm==4.64.1
      - trackpy==0.5.0
      - traitlets==4.3.3
      - typing-extensions==4.1.1
      - urllib3==1.26.20
      - validators==0.20.0
      - wcwidth==0.2.13
      - webencodings==0.5.1
      - widgetsnbextension==3.6.10
      - xarray==0.16.2
      - zipp==3.6.0
prefix: /opt/conda/envs/starfish

starfish/core/morphology/Filter/test/test_areafilter.py::test_empty_filter starfish/core/morphology/Filter/test/test_areafilter.py::test_min_area starfish/core/morphology/Filter/test/test_areafilter.py::test_max_area starfish/core/morphology/Filter/test/test_areafilter.py::test_illegal_areas
starfish/core/morphology/Filter/areafilter.py
starfish/core/morphology/Filter/areafilter.py