Skip to content

Fix invalid parameter default - #15281

Merged
cclauss merged 4 commits into
TheAlgorithms:masterfrom
kadubhumika:fix-invalid-parameter-default
Sep 11, 2026
Merged

Fix invalid parameter default#15281
cclauss merged 4 commits into
TheAlgorithms:masterfrom
kadubhumika:fix-invalid-parameter-default

Conversation

@kadubhumika

Copy link
Copy Markdown
Contributor

Describe your change

  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Add or change doctests? -- Note: Please avoid changing both code and tests in a single pull request.
  • Documentation change?

Checklist

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • All new Python files are placed inside an existing directory.
  • All filenames are in all lowercase characters with no spaces or dashes.
  • All functions and variable names follow Python naming conventions.
  • All function parameters and return values are annotated with Python type hints.
  • All functions have doctests that pass the automated testing.
  • All new algorithms include at least one URL that points to Wikipedia or another similar explanation.
  • If this pull request resolves one or more open issues, then the description above includes the issue number(s) with a closing keyword: "Fixes #ISSUE-NUMBER".

Summary

Fixed the invalid-parameter-default type-checking errors.

  • Updated data_type to use npt.DTypeLike in computer_vision/haralick_descriptors.py.
  • Updated alpha to allow None in machine_learning/loss_functions.py.
  • Removed the invalid-parameter-default ignore rule from pyproject.toml.

The invalid-parameter-default diagnostics are now clean.

@algorithms-keeper algorithms-keeper Bot added awaiting reviews This PR is ready to be reviewed merge conflicts Open a new PR or rebase on the latest commit enhancement This PR modified some existing files and removed merge conflicts Open a new PR or rebase on the latest commit labels Sep 11, 2026
@kadubhumika

Copy link
Copy Markdown
Contributor Author

@cclauss @priya-sundaram-dev I’ve fixed the invalid-parameter-default issues and removed the rule from the ignore list. All checks are passing. Could you please review when you get a chance? Thank you!

@priya-sundaram-dev priya-sundaram-dev 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.

Thanks @kadubhumika — nice work, and the code fixes look correct to me:

  • computer_vision/haralick_descriptors.py: data_type: npt.DTypeLike = np.uint8 is the right annotation (np.uint8 is a dtype-like class, not a np.dtype instance), so the default no longer violates the rule. 👍
  • machine_learning/loss_functions.py: alpha: np.ndarray | None = None is exactly the intended fix. 👍

One thing to fix in pyproject.toml before this merges. The diff there is:

-rules.invalid-parameter-default = "ignore"
+rules.invalid-assignment = "ignore"

Removing invalid-parameter-default is correct — that's the rule you cleared. But this also re-adds invalid-assignment = "ignore", which isn't on master anymore (it was already cleaned up and removed in an earlier PR). Re-suppressing it silently disables a rule that's currently green.

Could you just delete the invalid-parameter-default line rather than renaming it, so invalid-assignment stays enabled? i.e. the block should read:

rules.invalid-argument-type = "ignore"
rules.invalid-return-type = "ignore"

with no invalid-assignment line between them. Checks stay green either way (an added ignore won't fail CI), which is exactly why it's worth catching by eye. Everything else is good to go once that's tidied. 🙌

Comment thread pyproject.toml Outdated
rules.deprecated = "ignore"
rules.invalid-argument-type = "ignore"
rules.invalid-parameter-default = "ignore"
rules.invalid-assignment = "ignore"

@cclauss cclauss Sep 11, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This line needs to be removed.

Always start new pull requests from an up-to-date master branch.

@algorithms-keeper algorithms-keeper Bot added awaiting changes A maintainer has requested changes to this PR and removed awaiting reviews This PR is ready to be reviewed labels Sep 11, 2026
@kadubhumika
kadubhumika force-pushed the fix-invalid-parameter-default branch from 37c5b18 to 52198c6 Compare September 11, 2026 16:35
@algorithms-keeper algorithms-keeper Bot added merge conflicts Open a new PR or rebase on the latest commit awaiting reviews This PR is ready to be reviewed and removed awaiting changes A maintainer has requested changes to this PR labels Sep 11, 2026
@algorithms-keeper algorithms-keeper Bot removed the merge conflicts Open a new PR or rebase on the latest commit label Sep 11, 2026

@priya-sundaram-dev priya-sundaram-dev 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.

Thanks @kadubhumika — this is exactly right now. The invalid-parameter-default line is cleanly removed from the ignore list (no other rule silently re-suppressed), and the two fixes are correct:

  • haralick_descriptors.py: data_type: npt.DTypeLike = np.uint8np.uint8 is a dtype-like class rather than a np.dtype instance, so npt.DTypeLike is the accurate annotation. 👍
  • loss_functions.py: alpha: np.ndarray | None = NoneNone default now matches the type.

ty passes with the rule fully enforced, and ruff/pre-commit are green. Nicely done. LGTM 🎉

@cclauss cclauss left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sweet!!

@algorithms-keeper algorithms-keeper Bot removed the awaiting reviews This PR is ready to be reviewed label Sep 11, 2026
@cclauss
cclauss merged commit 1eb3c71 into TheAlgorithms:master Sep 11, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement This PR modified some existing files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants