Skip to content

Suggestion for https://github.com/scikit-learn/scikit-learn/pull/16084#8

Merged
jnothman merged 4 commits intojnothman:recodefrom
thomasjpfan:pr/16084
Feb 22, 2020
Merged

Suggestion for https://github.com/scikit-learn/scikit-learn/pull/16084#8
jnothman merged 4 commits intojnothman:recodefrom
thomasjpfan:pr/16084

Conversation

@thomasjpfan
Copy link
Copy Markdown

I was thinking of this.

CC: @jnothman

@thomasjpfan thomasjpfan changed the title Suggestion for #16084 Suggestion for https://github.com/scikit-learn/scikit-learn/pull/16084 Feb 14, 2020
@jnothman
Copy link
Copy Markdown
Owner

jnothman commented Feb 14, 2020 via email

Copy link
Copy Markdown
Owner

@jnothman jnothman left a comment

Choose a reason for hiding this comment

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

I like this, but the control flow becomes quite hard to read, and it may be hard for the reader to understand why the postprocessing should be outside of parse_arff (so that could deserve a comment).

Do you think we can tweak it so that it looks like:

if as_frame:
    def parse_arff(...):
        ....
        return frame,
    def postprocess(frame):
        ....
        return X, y, nominal_attributes
else:
    def parse_arff(...):
        ....
        return X, y, nominal_attributes
    def postrprocess(X, y, nominal_attributes):
        ....
        return X, y, nominal_attributes

    out = _retry_with_clean_cache(url, data_home)(
        _load_arff_response)(url, data_home,
                return_type=return_type,
                encode_nominal=not as_frame,
                parse_arff=parse_arff)
    X, y, nominal_attributes = postprocess(*out)
    return Bunch(...)

?

@thomasjpfan
Copy link
Copy Markdown
Author

Updated PR with the approach you suggested

@jnothman
Copy link
Copy Markdown
Owner

Thank you

@jnothman jnothman merged commit 0d51b73 into jnothman:recode Feb 22, 2020
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