Skip to content

Bugfix/fix ruff errors#12

Merged
MechaCritter merged 13 commits into
mainfrom
bugfix/fix_ruff_errors
Jun 10, 2026
Merged

Bugfix/fix ruff errors#12
MechaCritter merged 13 commits into
mainfrom
bugfix/fix_ruff_errors

Conversation

@MechaCritter

Copy link
Copy Markdown
Owner

Fixed all errors that ruff throws, and then adds ruff check into pre commit hook

MechaCritter and others added 9 commits June 10, 2026 21:06
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>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 stacklevel to warnings).
  • Tightens iterable pairing via zip(..., strict=True) in several evaluation/encoding utilities.
  • Updates examples/notebooks and adds a ruff-check --fix hook 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.

Comment thread .pre-commit-config.yaml Outdated
Comment thread pyvisim/_utils.py
Comment thread pyvisim/_utils.py Outdated
Comment thread pyvisim/encoders/pipeline.py
MechaCritter and others added 4 commits June 10, 2026 23:19
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>
@MechaCritter MechaCritter merged commit 43736ad into main Jun 10, 2026
2 of 3 checks passed
@MechaCritter MechaCritter deleted the bugfix/fix_ruff_errors branch June 10, 2026 21:45
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.

2 participants