Skip to content

Tests: Simple sense test for linear regression #39

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

Merged
merged 12 commits into from
Feb 27, 2019
Merged

Tests: Simple sense test for linear regression #39

merged 12 commits into from
Feb 27, 2019

Conversation

springcoil
Copy link
Contributor

@springcoil springcoil commented Jan 11, 2019

I couldn't get the eight schools model to work - PyMC4 didn't have half normal.

However I did get this to work, and the test passes. Do we want to add a tests file to the travis CI? Or is that too soon?

@springcoil springcoil added the enhancement New feature or request label Jan 11, 2019
@springcoil
Copy link
Contributor Author

@twiecki @fonnesbeck

@eigenfoo
Copy link
Member

Not relevant to this PR, but once #41 gets merged we'll have all the distributions 😄

@springcoil
Copy link
Contributor Author

springcoil commented Jan 12, 2019 via email

Copy link
Member

@eigenfoo eigenfoo left a comment

Choose a reason for hiding this comment

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

Great work @springcoil! I know this looks like a boatload of comments, but most of them are just to do with readability and unnecessary code. I added suggestions where I could.

Just a few more comments though:

  • We can't call this file test_eight_schools! 😅 Maybe test_example_linear_regression?
  • Can you run black on this file, with the --py36 -l 100 flags? Alternatively you could rebase onto master.
  • Currently we test that the logp of the samples are equal to some pre-computed value. Shouldn't we also test that the samples themselves are equal to their pre-computed values?

import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt
import pytest
Copy link
Member

Choose a reason for hiding this comment

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

Unused import

Suggested change
import pytest

Copy link
Member

Choose a reason for hiding this comment

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

We don't need to import pytest in our test files, do we? We don't do that in the PyMC3 test suite.


forward_sample = sess.run(model.forward_sample())

forward_sample
Copy link
Member

Choose a reason for hiding this comment

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

Unneeded

Suggested change
forward_sample

Copy link
Member

Choose a reason for hiding this comment

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

Looks like it's still there :)

@springcoil
Copy link
Contributor Author

I called this test_eight schools? I'm clearly not the brightest, I even left my coffee in a cafe this morning :)

@springcoil
Copy link
Contributor Author

I'll fix these this evening Eigenfoo. Thanks for the constructive and thorough feedback :)

@springcoil
Copy link
Contributor Author

springcoil commented Jan 14, 2019 via email

@ericmjl
Copy link
Member

ericmjl commented Jan 14, 2019

Currently we test that the logp of the samples are equal to some pre-computed value.

I learned something today, @eigenfoo! This is a great idea for testing.

@springcoil springcoil force-pushed the tests branch 2 times, most recently from e96bbb9 to d1d9650 Compare January 15, 2019 10:37
@springcoil springcoil dismissed eigenfoo’s stale review January 15, 2019 10:37

I've done the changes as he asked :)

@eigenfoo
Copy link
Member

Travis tests failed. You just need to format it with black! black -l 100 --py36 tests/ should do the trick.

@springcoil
Copy link
Contributor Author

springcoil commented Jan 16, 2019 via email

@springcoil springcoil force-pushed the tests branch 2 times, most recently from 0eb4aa0 to 7fc5dba Compare January 16, 2019 23:52
@springcoil
Copy link
Contributor Author

@eigenfoo I took your advice and added in a sample test :)


model = linreg.configure()

forward_sample = sess.run(model.forward_sample())
Copy link
Member

Choose a reason for hiding this comment

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

Once #49 is merged should use that fixture.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree wholeheartedly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this ready to merge?

@twiecki
Copy link
Member

twiecki commented Jan 19, 2019

we should port this to the new testing framework m

@springcoil
Copy link
Contributor Author

springcoil commented Jan 19, 2019 via email

@springcoil
Copy link
Contributor Author

@canyon289 I might not have a lot of time over the next few weeks. So if you wanted to just copy and paste the test into your stuff - you can :)

@canyon289
Copy link
Member

I can work on deconflicting this branch to prep for a merge in the next ~36 hours. Any naysayers for proposal?

@springcoil
Copy link
Contributor Author

springcoil commented Feb 16, 2019 via email

@canyon289
Copy link
Member

@springcoil Can you review and let me know if this still meets your intent?

Copy link
Contributor Author

@springcoil springcoil left a comment

Choose a reason for hiding this comment

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

Lgtm

@canyon289
Copy link
Member

Seems like there's just enough floating point error to cause the tests to fail. I'll make adjustments in the next couple of days.

@canyon289
Copy link
Member

This is ready for review again

@@ -0,0 +1,172 @@
import pymc4 as pm
Copy link
Member

Choose a reason for hiding this comment

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

should probably be called test_linear_regression_model.py

forward_sample = sess.run(model.forward_sample())


func = model.make_log_prob_function()
Copy link
Member

Choose a reason for hiding this comment

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

should these all hang out in the module namespace?

@springcoil
Copy link
Contributor Author

springcoil commented Feb 26, 2019 via email

@twiecki twiecki merged commit 8c4d6ad into master Feb 27, 2019
@twiecki twiecki deleted the tests branch February 27, 2019 13:42
@twiecki
Copy link
Member

twiecki commented Feb 27, 2019

Thanks @canyon289!

@canyon289
Copy link
Member

And @springcoil

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants