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

feat: Add multiple otsu as threshold method with selection range of components (Sourcery refactored) #713

Merged

Conversation

sourcery-ai[bot]
Copy link
Contributor

@sourcery-ai sourcery-ai bot commented Sep 13, 2022

Pull Request #710 refactored by Sourcery.

If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.

NOTE: As code is pushed to the original Pull Request, Sourcery will
re-run and update (force-push) this Pull Request with new refactorings as
necessary. If Sourcery finds no refactorings at any point, this Pull Request
will be closed automatically.

See our documentation here.

Run Sourcery locally

Reduce the feedback loop during development by using the Sourcery editor plugin:

Review changes via command line

To manually merge these changes, make sure you're on the feature/multipe_otsu_components branch, then run:

git fetch origin sourcery/feature/multipe_otsu_components
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from Czaki September 13, 2022 21:23
def calculate_property(area_array: np.ndarray, channel: np.ndarray, **_): # pylint: disable=W0221
def calculate_property(area_array: np.ndarray, channel: np.ndarray, **_): # pylint: disable=W0221
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function PixelBrightnessSum.calculate_property refactored with the following changes:

This removes the following comments ( why? ):

# pragma: no cover

Comment on lines -916 to +914
if np.any(area_array):
return np.max(channel[area_array > 0])
return 0
return np.max(channel[area_array > 0]) if np.any(area_array) else 0
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function MaximumPixelBrightness.calculate_property refactored with the following changes:

Comment on lines -936 to +932
if np.any(area_array):
return np.min(channel[area_array > 0])
return 0
return np.min(channel[area_array > 0]) if np.any(area_array) else 0
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function MinimumPixelBrightness.calculate_property refactored with the following changes:

Comment on lines -956 to +950
if np.any(area_array):
return np.mean(channel[area_array > 0])
return 0
return np.mean(channel[area_array > 0]) if np.any(area_array) else 0
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function MeanPixelBrightness.calculate_property refactored with the following changes:

Comment on lines -976 to +968
if np.any(area_array):
return np.median(channel[area_array > 0])
return 0
return np.median(channel[area_array > 0]) if np.any(area_array) else 0
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function MedianPixelBrightness.calculate_property refactored with the following changes:

Comment on lines -999 to +989
if np.any(area_array):
return np.std(channel[area_array > 0])
return 0
return np.std(channel[area_array > 0]) if np.any(area_array) else 0
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function StandardDeviationOfPixelBrightness.calculate_property refactored with the following changes:

Comment on lines -1216 to +1204
if np.any(final_mask):
return np.sum(channel[final_mask])
return 0
return np.sum(channel[final_mask]) if np.any(final_mask) else 0
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function RimPixelBrightnessSum.calculate_property refactored with the following changes:

@sourcery-ai
Copy link
Contributor Author

sourcery-ai bot commented Sep 13, 2022

Sourcery Code Quality Report

❌  Merging this PR will decrease code quality in the affected files by 0.16%.

Quality metrics Before After Change
Complexity 4.26 ⭐ 4.28 ⭐ 0.02 👎
Method Length 50.59 ⭐ 50.55 ⭐ -0.04 👍
Working memory 7.49 🙂 7.51 🙂 0.02 👎
Quality 71.06% 🙂 70.90% 🙂 -0.16% 👎
Other metrics Before After Change
Lines 1377 1363 -14
Changed files Quality Before Quality After Quality Change
package/PartSegCore/analysis/measurement_calculation.py 71.06% 🙂 70.90% 🙂 -0.16% 👎

Here are some functions in these files that still need a tune-up:

File Function Complexity Length Working Memory Quality Recommendation
package/PartSegCore/analysis/measurement_calculation.py MeasurementProfile.calculate_yield 14 🙂 326 ⛔ 34.22% 😞 Try splitting into smaller methods
package/PartSegCore/analysis/measurement_calculation.py MeasurementResult.get_separated 15 🙂 196 😞 14 😞 38.04% 😞 Try splitting into smaller methods. Extract out complex expressions
package/PartSegCore/analysis/measurement_calculation.py MeasurementProfile._clip_arrays 9 🙂 230 ⛔ 15 😞 39.72% 😞 Try splitting into smaller methods. Extract out complex expressions
package/PartSegCore/analysis/measurement_calculation.py MeasurementProfile._calculate_node 13 🙂 225 ⛔ 12 😞 40.68% 😞 Try splitting into smaller methods. Extract out complex expressions
package/PartSegCore/analysis/measurement_calculation.py DistanceROIROI.calculate_property 7 ⭐ 148 😞 15 😞 48.36% 😞 Try splitting into smaller methods. Extract out complex expressions

Legend and Explanation

The emojis denote the absolute quality of the code:

  • ⭐ excellent
  • 🙂 good
  • 😞 poor
  • ⛔ very poor

The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request.


Please see our documentation here for details on how these metrics are calculated.

We are actively working on this report - lots more documentation and extra metrics to come!

Help us improve this quality report!

@deprecated-napari-hub-preview-bot
Copy link

deprecated-napari-hub-preview-bot bot commented Sep 13, 2022

Preview page for your plugin is ready here:
https://preview.napari-hub.org/4DNucleome/PartSeg/713
Updated: 2022-09-13T21:37:37.165465

@codecov
Copy link

codecov bot commented Sep 13, 2022

Codecov Report

Base: 88.76% // Head: 88.75% // Decreases project coverage by -0.00% ⚠️

Coverage data is based on head (6bf9a65) compared to base (8642146).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@                         Coverage Diff                         @@
##           feature/multipe_otsu_components     #713      +/-   ##
===================================================================
- Coverage                            88.76%   88.75%   -0.01%     
===================================================================
  Files                                  190      190              
  Lines                                29349    29335      -14     
===================================================================
- Hits                                 26051    26037      -14     
  Misses                                3298     3298              
Impacted Files Coverage Δ
...ge/PartSegCore/analysis/measurement_calculation.py 97.07% <100.00%> (-0.04%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@Czaki Czaki merged commit fdbca4a into feature/multipe_otsu_components Sep 13, 2022
@Czaki Czaki deleted the sourcery/feature/multipe_otsu_components branch September 13, 2022 22:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant