Skip to content
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

[ENH] fill_direction improve #778

Merged
merged 16 commits into from
Dec 9, 2020
Merged

[ENH] fill_direction improve #778

merged 16 commits into from
Dec 9, 2020

Conversation

samukweku
Copy link
Collaborator

@samukweku samukweku commented Nov 25, 2020

PR Description

Please describe the changes proposed in the pull request:

  • use existing functions to check type and presence of columns

This PR improves #704 .

PR Checklist

Please ensure that you have done the following:

  1. PR in from a fork off your branch. Do not PR from <your_username>:dev, but rather from <your_username>:<feature-branch_name>.
  1. If you're not on the contributors list, add yourself to AUTHORS.rst.
  1. Add a line to CHANGELOG.rst under the latest version header (i.e. the one that is "on deck") describing the contribution.
    • Do use some discretion here; if there are multiple PRs that are related, keep them in a single line.

Quick Check

To do a very quick check that everything is correct, follow these steps below:

  • Run the command make check from pyjanitor's top-level directory. This will automatically run:
    • black formatting
    • flake8 checking
    • running the test suite
    • docs build

Once done, please check off the check-box above.

If make check does not work for you, you can execute the commands listed in the Makefile individually.

Code Changes

If you are adding code changes, please ensure the following:

  • Ensure that you have added tests.
  • Run all tests ($ pytest .) locally on your machine.
    • Check to ensure that test coverage covers the lines of code that you have added.
    • Ensure that all tests pass.

Documentation Changes

If you are adding documentation changes, please ensure the following:

  • Build the docs locally.
  • View the docs to check that it renders correctly.

Relevant Reviewers

Please tag maintainers to review.

@samukweku samukweku self-assigned this Nov 25, 2020
@codecov
Copy link

codecov bot commented Nov 25, 2020

Codecov Report

Merging #778 (22dc841) into dev (9e96d67) will increase coverage by 0.70%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##              dev     #778      +/-   ##
==========================================
+ Coverage   94.49%   95.20%   +0.70%     
==========================================
  Files          17       17              
  Lines         745      875     +130     
==========================================
+ Hits          704      833     +129     
- Misses         41       42       +1     

@samukweku samukweku requested review from hectormz and loganthomas and removed request for hectormz November 25, 2020 22:23
@samukweku
Copy link
Collaborator Author

@ericmjl @hectormz @sallyhong and others. Need your advice on the API. Currently different values for different columns cannot be applied for the limit parameter; if there are multiple columns, the same limit will be applied to all the columns. I am of the opinion that the API should be changed to allow different limit for different columns. It looks likely to break current API. Or should I just leave as is; probably users don’t care much for limit?

Copy link
Member

@ericmjl ericmjl left a comment

Choose a reason for hiding this comment

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

The only change I'm requesting, @samukweku, is about docstring triple quotes, nothing else!

@@ -13,6 +13,7 @@ new version (on deck)
- [ENH] Add ``pivot_wider`` function, which is the inverse of the `pivot_longer`
function. @samukweku
- [INF] Add `openpyxl` to `environment-dev.yml`. @samukweku
- [ENH] Reduce code by reusing existing functions for fill_direction. @samukweku
Copy link
Member

Choose a reason for hiding this comment

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

🎉

Comment on lines +4395 to +4397
# TODO: option to specify limit per column; current implementation
# is one `limit` for all the columns. Might need refactoring, or an
# API change.
Copy link
Member

Choose a reason for hiding this comment

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

This is a classic "do we apply this function to one column, or multiple columns" situation!

As the library matures, I've grown to realize that having singular and plural functions is not necessarily the best, so allowing a function to be applied to multiple columns simultaneously is probably the better way. There must be some way we can "compose" them together, I think, such that we get the desired behaviour. I'm kind of inspired by what I see in JAX, where we have vmap to map a function over an array axis. This makes composing functions together more natural.

Maybe a better solution to this problem is to provide a .map_columns() function, which allows us to map any pyjanitor function across columns. Let's talk about this in another setting. For now, I like what you've done here, @samukweku, in that you've left this API piece as a TODO to think about later on.

tests/functions/test_fill_direction.py Outdated Show resolved Hide resolved
Copy link
Member

@ericmjl ericmjl left a comment

Choose a reason for hiding this comment

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

I approve, @samukweku! Let's get this one merged in. You've done a massive job with recent PRs, please take the honour of merging this one!

@samukweku samukweku merged commit b5dca48 into pyjanitor-devs:dev Dec 9, 2020
@samukweku samukweku deleted the fill_direction_improve branch December 9, 2020 18:42
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.

None yet

2 participants