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

Update BalancedBinningReference quick method #1034

Merged
merged 10 commits into from
Feb 9, 2020

Conversation

Kautumn06
Copy link
Contributor

As part of Issue #960

  • Added show parameter to the balanced_binning_reference quick method
  • Added a quick method test and baseline image
  • Updated the docs to include an example using the quick method

@wagner2010 wagner2010 self-assigned this Feb 8, 2020
Comment on lines 65 to 75
def test_quick_method(self):
"""
Test the quick method with producing a valid visualization
"""
data = load_occupancy(return_dataset=True)
_, y = data.to_pandas()

visualizer = balanced_binning_reference(y, show=False)

assert isinstance(visualizer, BalancedBinningReference)
self.assert_images_similar(visualizer, tol=0.5)
Copy link
Member

Choose a reason for hiding this comment

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

@Kautumn06 @wagner2010 I notice that the Appveyor Miniconda test is hanging indefinitely on this test. One thing that you could try is either

  1. changing line 70 to _, y = data.to_numpy()
    OR
  2. adding the @pytest.mark.skipif(pd is None, reason="pandas is required") decorator to the test_quick_method function (since if you have the line _, y = data.to_pandas(), then the test requires Pandas, which not all testing environments will have)

Copy link
Contributor

Choose a reason for hiding this comment

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

GM @rebeccabilbro @Kautumn06 I'll go for option 2 using the in-line editor. Thank you both!

updated test_binning to accomodate non-pandas environments.
updated balanced_binning_reference hyperlink
Copy link
Contributor

@wagner2010 wagner2010 left a comment

Choose a reason for hiding this comment

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

@Kautumn06 Nice work on the balanced_binning_reference QM! Thank you!

updating line 70 to "_, y = data.to_numpy()" to try to pass tests.
Comment on lines 65 to 75
def test_quick_method(self):
"""
Test the quick method with producing a valid visualization
"""
data = load_occupancy(return_dataset=True)
_, y = data.to_numpy()

visualizer = balanced_binning_reference(y, show=False)

assert isinstance(visualizer, BalancedBinningReference)
self.assert_images_similar(visualizer, tol=0.5)
Copy link
Member

Choose a reason for hiding this comment

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

@wagner2010 @Kautumn06 my apologies if my previous comment caused confusion; I should have been more clear!

When you skip a test, the skip-if decorator needs to go right on top of the function definition in order to work, e.g.:

    @pytest.mark.skipif(pd is None, reason="pandas is required")
    def test_quick_method(self):
        """
        Test the quick method with producing a valid visualization
        """     
        data = load_occupancy(return_dataset=True)
        _, y = data.to_pandas()
        
        visualizer = balanced_binning_reference(y, show=False)

        assert isinstance(visualizer, BalancedBinningReference)
        self.assert_images_similar(visualizer, tol=0.5)

I like to think of decorators as sparkly tiaras that you put on top of the function or method's head so that they can say "do you even know who I am?" 👑 Then Python sees the tiara first and changes how it treats the function/method (in this case knowing to skip the whole test if there's no Pandas installed on that machine)

Maybe @bbengfort and I can do a clinic on testing sometime... In the meantime though, you can read more about Python decorators here). Thanks again for pushing ahead with this PR & review!

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for sharing the resource! It helps us improve!

@rebeccabilbro
Copy link
Member

@wagner2010 @Kautumn06 I just figured out what's making the tests hang; hold tight, about to push the fix

Comment on lines +189 to +193

if show:
visualizer.show()
else:
visualizer.finalize()
Copy link
Member

Choose a reason for hiding this comment

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

I think this is what was missing! We have the show=False parameter set on @Kautumn06's quick method test (as it should be!), but because we hadn't yet added the show/finalize logic to the actual quick method yet, when we got to the Appeyor/Miniconda test, it was trying to finalize instead of show, causing the test to hang indefinitely. This should fix it 🤞 🙏 😅

@rebeccabilbro rebeccabilbro merged commit b986232 into DistrictDataLabs:develop Feb 9, 2020
@Kautumn06 Kautumn06 deleted the balanced-binning-qm branch March 20, 2022 14:03
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

3 participants