Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump upper version of NumPy #1347

Merged
merged 11 commits into from
Aug 25, 2023
Merged

Bump upper version of NumPy #1347

merged 11 commits into from
Aug 25, 2023

Conversation

nfahlgren
Copy link
Member

Describe your changes
Removes upper limit restriction on NumPy by fixing issues with deprecated methods, more stringent types, etc.

Type of update
Is this a: Work in progress

Associated issues
#1343

For the reviewer
See this page for instructions on how to review the pull request.

  • PR functionality reviewed in a Jupyter Notebook
  • All tests pass
  • Test coverage remains 100%
  • Documentation tested
  • New documentation pages added to plantcv/mkdocs.yml
  • Changes to function input/output signatures added to updating.md
  • Code reviewed
  • PR approved

@nfahlgren nfahlgren added work in progress Mark work in progress update Updates an existing feature/method labels Aug 23, 2023
@nfahlgren nfahlgren added this to Pull Requests in PlantCV4 via automation Aug 23, 2023
@codecov
Copy link

codecov bot commented Aug 23, 2023

Codecov Report

Merging #1347 (a92ae7b) into main (7912b18) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##              main     #1347   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          155       155           
  Lines         6840      6841    +1     
=========================================
+ Hits          6840      6841    +1     
Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
plantcv/plantcv/analyze/npq.py 100.00% <100.00%> (ø)
...ntcv/plantcv/visualize/chlorophyll_fluorescence.py 100.00% <100.00%> (ø)

@nfahlgren
Copy link
Member Author

With NumPy 1.25.2 the tests for pcv.analyze.npq fail with the following errors:

test_data = <tests.conftest.TestData object at 0x292409f30>

    def test_npq_cropreporter(test_data):
        """Test for PlantCV."""
        # Clear results
        outputs.clear()
        da_dark = test_data.psii_cropreporter('ojip_dark')
        da_light = test_data.psii_cropreporter('ojip_light')
>       _ = analyze_npq(ps_da_light=da_light, ps_da_dark=da_dark, labeled_mask=test_data.create_ps_mask(),
                        auto_fm=False,
                        measurement_labels=["Fq/Fm"], label="prefix", min_bin="auto", max_bin="auto")

tests/plantcv/analyze/test_npq.py:14:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
plantcv/plantcv/analyze/npq.py:87: in npq
    npq_lbl = ps_da_light.sel(frame_label='Fmp').groupby('measurement', squeeze=False).map(_calc_npq, fm=fm)
../../miniconda3/envs/plantcv-test/lib/python3.10/site-packages/xarray/core/groupby.py:1396: in map
    return self._combine(applied, shortcut=shortcut)
../../miniconda3/envs/plantcv-test/lib/python3.10/site-packages/xarray/core/groupby.py:1415: in _combine
    applied_example, applied = peek_at(applied)
../../miniconda3/envs/plantcv-test/lib/python3.10/site-packages/xarray/core/utils.py:188: in peek_at
    peek = next(gen)
../../miniconda3/envs/plantcv-test/lib/python3.10/site-packages/xarray/core/groupby.py:1395: in <genexpr>
    applied = (maybe_wrap_array(arr, func(arr, *args, **kwargs)) for arr in grouped)
plantcv/plantcv/analyze/npq.py:133: in _calc_npq
    div = np.divide(fm, fmp, out=out_flt,
../../miniconda3/envs/plantcv-test/lib/python3.10/site-packages/xarray/core/arithmetic.py:86: in __array_ufunc__
    return apply_ufunc(
../../miniconda3/envs/plantcv-test/lib/python3.10/site-packages/xarray/core/computation.py:1197: in apply_ufunc
    return apply_dataarray_vfunc(
../../miniconda3/envs/plantcv-test/lib/python3.10/site-packages/xarray/core/computation.py:304: in apply_dataarray_vfunc
    result_var = func(*data_vars)
../../miniconda3/envs/plantcv-test/lib/python3.10/site-packages/xarray/core/computation.py:833: in apply_array_ufunc
    return func(*args)
../../miniconda3/envs/plantcv-test/lib/python3.10/site-packages/xarray/core/arithmetic.py:86: in __array_ufunc__
    return apply_ufunc(
../../miniconda3/envs/plantcv-test/lib/python3.10/site-packages/xarray/core/computation.py:1210: in apply_ufunc
    return apply_array_ufunc(func, *args, dask=dask)
../../miniconda3/envs/plantcv-test/lib/python3.10/site-packages/xarray/core/computation.py:815: in apply_array_ufunc
    if any(is_chunked_array(arg) for arg in args):
../../miniconda3/envs/plantcv-test/lib/python3.10/site-packages/xarray/core/computation.py:815: in <genexpr>
    if any(is_chunked_array(arg) for arg in args):
../../miniconda3/envs/plantcv-test/lib/python3.10/site-packages/xarray/core/pycompat.py:99: in is_chunked_array
    return is_duck_dask_array(x) or (is_duck_array(x) and hasattr(x, "chunks"))
../../miniconda3/envs/plantcv-test/lib/python3.10/site-packages/xarray/core/pycompat.py:95: in is_duck_dask_array
    return is_duck_array(x) and is_dask_collection(x)
../../miniconda3/envs/plantcv-test/lib/python3.10/site-packages/xarray/core/pycompat.py:87: in is_dask_collection
    if module_available("dask"):
../../miniconda3/envs/plantcv-test/lib/python3.10/site-packages/xarray/core/utils.py:1160: in module_available
    return importlib.util.find_spec(module) is not None
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

name = 'dask', package = None

    def find_spec(name, package=None):
        """Return the spec for the specified module.

        First, sys.modules is checked to see if the module was already imported. If
        so, then sys.modules[name].__spec__ is returned. If that happens to be
        set to None, then ValueError is raised. If the module is not in
        sys.modules, then sys.meta_path is searched for a suitable spec with the
        value of 'path' given to the finders. None is returned if no spec could
        be found.

        If the name is for submodule (contains a dot), the parent module is
        automatically imported.

        The name and package arguments work the same as importlib.import_module().
        In other words, relative module names (with leading dots) work.

        """
>       fullname = resolve_name(name, package) if name.startswith('.') else name
E       RecursionError: maximum recursion depth exceeded while calling a Python object

../../miniconda3/envs/plantcv-test/lib/python3.10/importlib/util.py:90: RecursionError
!!! Recursion error detected, but an error occurred locating the origin of recursion.
  The following exception happened when comparing locals in the stack frame:
    ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
  Displaying first and last 10 stack frames out of 2225.
_________________________________________________________________________________________________ test_npq_waltz __________________________________________________________________________________________________

test_data = <tests.conftest.TestData object at 0x292409f30>

    def test_npq_waltz(test_data):
        """Test for PlantCV."""
        # Clear results
        outputs.clear()
        da_dark = test_data.psii_walz('ojip_dark')
        da_light = test_data.psii_walz('ojip_light')
>       _ = analyze_npq(ps_da_light=da_light, ps_da_dark=da_dark, labeled_mask=test_data.create_ps_mask(), auto_fm=True,
                        measurement_labels=None, label="prefix", min_bin="auto", max_bin="auto")

tests/plantcv/analyze/test_npq.py:26:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
plantcv/plantcv/analyze/npq.py:87: in npq
    npq_lbl = ps_da_light.sel(frame_label='Fmp').groupby('measurement', squeeze=False).map(_calc_npq, fm=fm)
../../miniconda3/envs/plantcv-test/lib/python3.10/site-packages/xarray/core/groupby.py:1396: in map
    return self._combine(applied, shortcut=shortcut)
../../miniconda3/envs/plantcv-test/lib/python3.10/site-packages/xarray/core/groupby.py:1415: in _combine
    applied_example, applied = peek_at(applied)
../../miniconda3/envs/plantcv-test/lib/python3.10/site-packages/xarray/core/utils.py:188: in peek_at
    peek = next(gen)
../../miniconda3/envs/plantcv-test/lib/python3.10/site-packages/xarray/core/groupby.py:1395: in <genexpr>
    applied = (maybe_wrap_array(arr, func(arr, *args, **kwargs)) for arr in grouped)
plantcv/plantcv/analyze/npq.py:133: in _calc_npq
    div = np.divide(fm, fmp, out=out_flt,
../../miniconda3/envs/plantcv-test/lib/python3.10/site-packages/xarray/core/arithmetic.py:86: in __array_ufunc__
    return apply_ufunc(
../../miniconda3/envs/plantcv-test/lib/python3.10/site-packages/xarray/core/computation.py:1197: in apply_ufunc
    return apply_dataarray_vfunc(
../../miniconda3/envs/plantcv-test/lib/python3.10/site-packages/xarray/core/computation.py:304: in apply_dataarray_vfunc
    result_var = func(*data_vars)
../../miniconda3/envs/plantcv-test/lib/python3.10/site-packages/xarray/core/computation.py:833: in apply_array_ufunc
    return func(*args)
../../miniconda3/envs/plantcv-test/lib/python3.10/site-packages/xarray/core/arithmetic.py:86: in __array_ufunc__
    return apply_ufunc(
../../miniconda3/envs/plantcv-test/lib/python3.10/site-packages/xarray/core/computation.py:1210: in apply_ufunc
    return apply_array_ufunc(func, *args, dask=dask)
../../miniconda3/envs/plantcv-test/lib/python3.10/site-packages/xarray/core/computation.py:815: in apply_array_ufunc
    if any(is_chunked_array(arg) for arg in args):
../../miniconda3/envs/plantcv-test/lib/python3.10/site-packages/xarray/core/computation.py:815: in <genexpr>
    if any(is_chunked_array(arg) for arg in args):
../../miniconda3/envs/plantcv-test/lib/python3.10/site-packages/xarray/core/pycompat.py:99: in is_chunked_array
    return is_duck_dask_array(x) or (is_duck_array(x) and hasattr(x, "chunks"))
../../miniconda3/envs/plantcv-test/lib/python3.10/site-packages/xarray/core/pycompat.py:95: in is_duck_dask_array
    return is_duck_array(x) and is_dask_collection(x)
../../miniconda3/envs/plantcv-test/lib/python3.10/site-packages/xarray/core/pycompat.py:87: in is_dask_collection
    if module_available("dask"):
../../miniconda3/envs/plantcv-test/lib/python3.10/site-packages/xarray/core/utils.py:1160: in module_available
    return importlib.util.find_spec(module) is not None
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

name = 'dask', package = None

    def find_spec(name, package=None):
        """Return the spec for the specified module.

        First, sys.modules is checked to see if the module was already imported. If
        so, then sys.modules[name].__spec__ is returned. If that happens to be
        set to None, then ValueError is raised. If the module is not in
        sys.modules, then sys.meta_path is searched for a suitable spec with the
        value of 'path' given to the finders. None is returned if no spec could
        be found.

        If the name is for submodule (contains a dot), the parent module is
        automatically imported.

        The name and package arguments work the same as importlib.import_module().
        In other words, relative module names (with leading dots) work.

        """
>       fullname = resolve_name(name, package) if name.startswith('.') else name
E       RecursionError: maximum recursion depth exceeded while calling a Python object

../../miniconda3/envs/plantcv-test/lib/python3.10/importlib/util.py:90: RecursionError
!!! Recursion error detected, but an error occurred locating the origin of recursion.
  The following exception happened when comparing locals in the stack frame:
    ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
  Displaying first and last 10 stack frames out of 2225.

@nfahlgren
Copy link
Member Author

I have confirmed that with these updates, tests pass with NumPy versions 1.22 - 1.25

@nfahlgren nfahlgren added ready to review and removed work in progress Mark work in progress labels Aug 24, 2023
@nfahlgren nfahlgren added this to the PlantCV v4.0.1 milestone Aug 25, 2023
@HaleySchuhl
Copy link
Contributor

Nothing changed and the start output changed back to the old values somehow? Re-run tests and now pass... shrug, So now planning to make different test assertion

@nfahlgren nfahlgren merged commit ebd9b96 into main Aug 25, 2023
6 checks passed
PlantCV4 automation moved this from Pull Requests to Done Aug 25, 2023
@nfahlgren nfahlgren deleted the upgrade-numpy branch August 25, 2023 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready to review update Updates an existing feature/method
Projects
PlantCV4
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants