-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Fix core utils #1967
Fix core utils #1967
Conversation
Reviewer's Guide by SourceryThis pull request implements several improvements and bug fixes to the core utils of the Albumentations library, focusing on enhancing the LabelEncoder class and the to_tuple function. The changes aim to improve type handling, add support for numerical labels, and refactor code for better maintainability. Updated class diagram for LabelEncoderclassDiagram
class LabelEncoder {
- classes_: dict[str | int | float, int]
- inverse_classes_: dict[int, str | int | float]
- num_classes: int
- is_numerical: bool
+ fit(y: Sequence[Any] | np.ndarray) LabelEncoder
+ transform(y: Sequence[Any] | np.ndarray) np.ndarray
+ fit_transform(y: Sequence[Any] | np.ndarray) np.ndarray
+ inverse_transform(y: Sequence[Any] | np.ndarray) np.ndarray
}
Updated class diagram for DataProcessorclassDiagram
class DataProcessor {
- data_fields: list[str]
- label_encoders: dict[str, dict[str, LabelEncoder]]
- is_sequence_input: dict[str, bool]
- is_numerical_label: dict[str, dict[str, bool]]
+ add_label_fields_to_data(data: dict[str, Any]) dict[str, Any]
+ remove_label_fields_from_data(data: dict[str, Any]) dict[str, Any]
+ _process_label_fields(data: dict[str, Any], data_name: str) np.ndarray
+ _validate_label_field_length(data: dict[str, Any], data_name: str, label_field: str) void
+ _encode_label_field(data: dict[str, Any], data_name: str, label_field: str) np.ndarray
+ _handle_empty_data_array(data: dict[str, Any]) void
+ _remove_label_fields(data: dict[str, Any], data_name: str) void
+ _decode_label_field(data_name: str, label_field: str, encoded_labels: np.ndarray) np.ndarray
}
Updated class diagram for to_tuple functionclassDiagram
class to_tuple {
+ validate_args(low: ScaleType | None, bias: ScalarType | None) void
+ process_sequence(param: Sequence[ScalarType]) tuple[ScalarType, ScalarType]
+ process_scalar(param: ScalarType, low: ScalarType | None) tuple[ScalarType, ScalarType]
+ apply_bias(min_val: ScalarType, max_val: ScalarType, bias: ScalarType) tuple[ScalarType, ScalarType]
+ ensure_int_output(min_val: ScalarType, max_val: ScalarType, param: ScalarType) tuple[int, int] | tuple[float, float]
+ to_tuple(param: ScaleType, low: ScaleType | None = None, bias: ScalarType | None = None) tuple[int, int] | tuple[float, float]
}
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @ternaus - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟡 Testing: 4 issues found
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Fixes #1958
Summary by Sourcery
Fix numerical label handling in the LabelEncoder class, refactor label processing logic, enhance utility functions for better type handling, and update tests to cover new scenarios. Update pre-commit configuration to the latest Ruff version.
Bug Fixes:
Enhancements:
Tests:
Chores: