Bugfix/fix ruff errors#12
Merged
Merged
Conversation
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…uses Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
RootSIFT() and vgg16(weights=...) were evaluated once at import time; vgg16 in particular triggered a model download on import. They are now instantiated per-call inside __init__ when the argument is omitted. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
All zipped sequences are required to have equal lengths, so strict=True turns silent truncation on a length mismatch into an immediate ValueError. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Replaces 'from pyvisim._utils import *' with explicit imports in the five example notebooks. This required restoring plot_image, cluster_and_return_labels, cluster_images_and_generate_statistics, plot_and_save_heatmap and plot_and_save_barplot to pyvisim/_utils.py: they were deleted as dead code in b2832a7, but the notebooks still call them (the dead-code scan did not cover notebooks). Restored versions are modernized to pass the current lint config, and the bogus check_is_image decorator was not restored. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR resolves Ruff lint issues across the library and updates developer tooling by adding ruff-check to the pre-commit configuration, aiming to keep formatting/linting consistent before commits.
Changes:
- Fixes Ruff-related Python issues (e.g., avoiding instantiated objects as default args, improving exception chaining, adding
stacklevelto warnings). - Tightens iterable pairing via
zip(..., strict=True)in several evaluation/encoding utilities. - Updates examples/notebooks and adds a
ruff-check --fixhook to pre-commit.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
pyvisim/features/_features.py |
Avoids constructing VGG16 as a default arg; improves exception chaining. |
pyvisim/eval.py |
Uses zip(..., strict=True) for query/label iteration. |
pyvisim/encoders/vlad.py |
Avoids RootSIFT() as a default arg by deferring construction. |
pyvisim/encoders/pipeline.py |
Uses strict zip in encoding iteration and encoding-map creation. |
pyvisim/encoders/fisher_vector.py |
Avoids RootSIFT() default arg; adds warning stacklevel. |
pyvisim/encoders/_base_encoder.py |
Adds warning stacklevel, strict zip, and exception chaining improvements. |
pyvisim/datasets/__init__.py |
Adds __all__ export list. |
pyvisim/_utils.py |
Adds plotting + clustering helper utilities (and additional imports). |
pyvisim/_base_classes.py |
Removes redundant empty lines / no-op __init__. |
examples/vlad_and_fisher_with_vgg16_deep_features.ipynb |
Cleans imports and notebook execution state. |
examples/pipeline.ipynb |
Cleans imports and notebook execution state. |
examples/m_ap_and_top_k_accuracy.ipynb |
Cleans notebook execution state; uses zip(..., strict=True). |
examples/clustering_images_using_vlad.ipynb |
Cleans imports and notebook execution state. |
examples/clustering_images_using_pipeline.ipynb |
Cleans imports and notebook execution state. |
examples/clustering_images_using_fv.ipynb |
Cleans imports/outputs and notebook execution state. |
.pre-commit-config.yaml |
Adds ruff-check --fix hook (but currently has invalid indentation). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
fixed indentation in pre commit config file Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
in plot_image, detach if it's a torch tensor Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
in plot_and_save_heatmap, turn everything to numpy before plotting Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixed all errors that ruff throws, and then adds ruff check into pre commit hook