Skip to content

shading: use morphology.footprint_rectangle((1, 3)) for 1x3 structuring element#233

Open
Omesh37 wants to merge 2 commits into
pvlib:mainfrom
Omesh37:fix/skimage-rectangle-deprecated
Open

shading: use morphology.footprint_rectangle((1, 3)) for 1x3 structuring element#233
Omesh37 wants to merge 2 commits into
pvlib:mainfrom
Omesh37:fix/skimage-rectangle-deprecated

Conversation

@Omesh37

@Omesh37 Omesh37 commented Jul 2, 2026

Copy link
Copy Markdown

Fixes a TypeError / FutureWarning caused by differing scikit-image APIs. The structuring element creation in pvanalytics/features/shading.py now uses the modern morphology.footprint_rectangle((1,3)) call.

Testing
image
image

  • Closes Tests emit FutureWarning from skimage #226
  • Added tests to cover all new or modified code.
  • Clearly documented all new API functions with PEP257 and numpydoc compliant docstrings.
  • Added new API functions to docs/api.rst.
  • Non-API functions clearly documented with docstrings or comments as necessary.
  • Adds description and name entries in the appropriate "what's new" file
    in docs/whatsnew
    for all changes. Includes link to the GitHub Issue with :issue:`num`
    or this Pull Request with :pull:`num`. Includes contributor name
    and/or GitHub username (link with :ghuser:`user`).
  • Pull request is nearly complete and ready for detailed review.
  • Maintainer: Appropriate GitHub Labels and Milestone are assigned to the Pull Request and linked Issue.

@cwhanse cwhanse added the dependency Issues relating to dependencies or dependency management label Jul 3, 2026
@cwhanse cwhanse added this to the v0.2.3 milestone Jul 3, 2026
@cwhanse

cwhanse commented Jul 3, 2026

Copy link
Copy Markdown
Member

@Omesh37 did you test this locally? pvanalytics isn't getting much work and this fix has uncovered another unrelated problem.

@Omesh37

Omesh37 commented Jul 4, 2026

Copy link
Copy Markdown
Author

@cwhanse Yes, I have tested using command pytest --cov=pvanalytics --cov-config=.coveragerc --cov-report term-missing pvanalytics --runslow locally, which results 224 passed, 29 skipped (require ruptures, not installed locally), 0 failed.
After appending .copy() at the end of ghi_image[...] = np.nan

@cwhanse

cwhanse commented Jul 5, 2026

Copy link
Copy Markdown
Member

@Omesh37 there's also an error related to converting a timedelta. If you don't have time/patience to track that down, I'll see if I can push to your PR.

@Omesh37

Omesh37 commented Jul 5, 2026

Copy link
Copy Markdown
Author

@cwhanse I suggest a possible fix to this that is:

offset = frequencies.to_offset(freq)
try:
   return pd.to_timedelta(offset)
except ValueError:
   return pd.Timedelta(offset.nanos, unit='ns')

Storing pandas offset object and then returning the result. I have tested using:
pytest pvanalytics/tests/quality/test_gaps.py::test_completeness_score_no_data -v and it was successful locally.
But, by mistake i have pushed the code in wrong PR (#235)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependency Issues relating to dependencies or dependency management

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tests emit FutureWarning from skimage

2 participants