Skip to content

[ENH] Initial type and named object validator code#122

Merged
RNKuhns merged 23 commits into
sktime:mainfrom
RNKuhns:validate
Feb 5, 2023
Merged

[ENH] Initial type and named object validator code#122
RNKuhns merged 23 commits into
sktime:mainfrom
RNKuhns:validate

Conversation

@RNKuhns
Copy link
Copy Markdown
Contributor

@RNKuhns RNKuhns commented Jan 26, 2023

Reference Issues/PRs

What does this implement/fix? Explain your changes.

Does your contribution introduce a new dependency? If yes, which one?

What should a reviewer concentrate their feedback on?

Any other comments?

PR checklist

For all contributions
  • I've reviewed the project documentation on contributing
  • I've added myself to the list of contributors.
  • The PR title starts with either [ENH], [CI/CD], [MNT], [DOC], or [BUG] indicating whether
    the PR topic is related to enhancement, CI/CD, maintenance, documentation, or a bug.
For code contributions
  • Unit tests have been added covering code functionality
  • Appropriate docstrings have been added (see documentation standards)
  • New public functionality has been added to the API Reference

Comment thread skbase/validate/_named_objects.py Fixed
Comment thread skbase/validate/_named_objects.py Fixed
Comment thread skbase/validate/_named_objects.py Fixed
Comment thread skbase/validate/_named_objects.py Fixed
@RNKuhns RNKuhns changed the title Initial type and named object validator code [ENH] Initial type and named object validator code Jan 26, 2023
require_unique_names=False,
sequence_name: Optional[str] = None,
) -> Union[Sequence[Tuple[str, BaseObject]], Dict[str, BaseObject]]:
... # pragma: no cover

Check notice

Code scanning / CodeQL

Statement has no effect

This statement has no effect.
require_unique_names=False,
sequence_name: Optional[str] = None,
) -> Sequence[Tuple[str, BaseObject]]:
... # pragma: no cover

Check notice

Code scanning / CodeQL

Statement has no effect

This statement has no effect.
require_unique_names=False,
sequence_name: Optional[str] = None,
) -> Union[Sequence[Tuple[str, BaseObject]], Dict[str, BaseObject]]:
... # pragma: no cover

Check notice

Code scanning / CodeQL

Statement has no effect

This statement has no effect.
Copy link
Copy Markdown
Contributor

@fkiraly fkiraly left a comment

Choose a reason for hiding this comment

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

This looks very useful!

One comment, based on a learning in sktime and a guess on what this will be for:

I recently changed the checking logic to allow lists of tuples of arbitrary length, where element 0 is name/str, element 1 is estimator, and the remaining elements can be anything (e.g., index specifiers in column estimators etc).

This is because there were a number of examples where heterogeneous estimators had more than two elements, and it turned out to be easiest to relax the typing constraint.

Comment thread skbase/validate/_types.py Fixed
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Jan 31, 2023

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.92%. Comparing base (acaefb3) to head (985bf5e).
⚠️ Report is 430 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #122      +/-   ##
==========================================
+ Coverage   78.07%   81.92%   +3.84%     
==========================================
  Files          23       30       +7     
  Lines        1884     2235     +351     
==========================================
+ Hits         1471     1831     +360     
+ Misses        413      404       -9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread skbase/validate/_types.py
Comment on lines +156 to +163
def check_sequence(
input_seq: Sequence[Any],
sequence_type: Optional[Union[type, Tuple[type, ...]]] = None,
element_type: Optional[Union[type, Tuple[type, ...]]] = None,
coerce_output_type_to: type = None,
coerce_scalar_input: bool = False,
sequence_name: str = None,
) -> Sequence[Any]:

Check notice

Code scanning / CodeQL

Returning tuples with varying lengths

check_sequence returns [tuple of size 1](1) and [tuple of size 2](2).
@RNKuhns RNKuhns requested a review from fkiraly February 5, 2023 04:02
@RNKuhns
Copy link
Copy Markdown
Contributor Author

RNKuhns commented Feb 5, 2023

@fkiraly I've got updates and additional testing taken care of.

I'm thinking we initially restrict the named object format to the current (str, BaseObject) or Dict[str, BaseObject], then relax it in a follow-on PR. The reason I want to take a bit more time to get familiar with different use cases of named objects and consider if there are any specific patterns we want to check. For example, (str, BaseObject, str). And whether we want to allow certain dictionary formats for these options (maybe Dict[str, (BaseObject, str)] but that is just off the top of my head).

Copy link
Copy Markdown
Contributor

@fkiraly fkiraly left a comment

Choose a reason for hiding this comment

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

ok, sure - happy to do this in a separate PR (and/or separate discussion stream on how/whether), I have opened an issue here: #124

Looks fine otherwise.

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.

4 participants