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

Emcee reader support #550

Merged
merged 20 commits into from
Jan 21, 2019
Merged

Emcee reader support #550

merged 20 commits into from
Jan 21, 2019

Conversation

OriolAbril
Copy link
Member

To this date, there are 3 possible cases to be taken into account in from_emcee:

  • emcee2
  • emcee3
  • emcee3 "reader", which is using emcee.backend to store the posterior in file and reading it afterwards. It is different from the "regular" emcee3 sampler because the observed data is not stored.

The first two cases already work, this adds support to the 3rd case. I have run some tests manually in my computer to check they work, but I don't know how to update the tests to include different emcee versions.

@canyon289
Copy link
Member

@OriolAbril Can you write the test suite in pytest for the new emcee "reader" and check it works in your local environment?

After that I can make the changes in TravisCI to test the emcee reader as well

@OriolAbril
Copy link
Member Author

OriolAbril commented Jan 19, 2019

I added a test for the emcee reader in its own file inside the tests folder. However I am not sure about how to implement it directly in test_data.py, because it should only executed when emcee version is >=3 but without stopping to test the regular emcee3 sampler.

Here, all tests will probably fail because I think actually none of them uses emcee3, but in my local environment pytest test_emceereader.py is passed.

@ColCarroll
Copy link
Member

ColCarroll commented Jan 19, 2019

This would be a great use for a pytest.skipif fixture:

needs_emcee3 = pytest.mark.skipif(emcee.__version__ < '3', reason="emcee3 required")

...

@needs_emcee3
def test_emcee3_stuff(...):
    ...

https://docs.pytest.org/en/latest/skipping.html

@ahartikainen
Copy link
Contributor

I think having individual test files for each library a good idea. Let's still use skip fixture to handle different versions.

Good work!

@canyon289
Copy link
Member

What @ColCarroll and @ahartikainen said about skipif :)

@OriolAbril Let us know if you need help with any of this.

And thank you for adding tests

@OriolAbril
Copy link
Member Author

I used skipif to implement an extra test inside the class for emcee. Now the test should pass, but it may not mean I have implemented them properly because they will be skipped. What sould be changed to include emcee3 in the tests?

I did not run them locally because I do not have all libraries installed (i.e. stan). Splitting them as @ahartikainen proposed would ease running them locally, at least for me.

@canyon289
Copy link
Member

canyon289 commented Jan 19, 2019

@OriolAbril
Youre able to select tests to run using the -k parameter in pytest. I can provide an example if needed

https://docs.pytest.org/en/latest/usage.html#specifying-tests-selecting-tests

I forgot in the previous commit
arviz/tests/helpers.py Outdated Show resolved Hide resolved
@OriolAbril
Copy link
Member Author

Will the -k flag avoid importing the libraries at the start of helpers.py? It is my first time using pytest, I hope I don't take too much of your time.

@canyon289
Copy link
Member

canyon289 commented Jan 19, 2019

@OriolAbril You're definitely not taking up too much of my time! I'll speak for everyone and say we really appreciate YOUR time :)

If you'd like we can chat on gitter as well for faster collaboration.

https://gitter.im/arviz-devs/community

You are correct though. -k won't help here. I'll make a note of this, that we should make it easier to test if not all libraries are installed

@canyon289
Copy link
Member

canyon289 commented Jan 19, 2019

@OriolAbril Two more things I can mention
We have a docker image for testing if you'd like to check that tests work locally without messing with your host operating system.

Also annoying, youre welcome to push tests to TravisCI and see if they pass there.

@OriolAbril
Copy link
Member Author

OriolAbril commented Jan 19, 2019

For now I'd rather push the changes here, but I will start looking into docker. Can you recommend me some tutorials?

Now only the lint check is failing, I disabled all no-member and invalid-arguments in the emcee3 code. Also an invalid-name for needs_emcee3, but I wasn't really sure about disabling it or using uppercase

@ahartikainen
Copy link
Contributor

Is it for tests? Disable is fine.

@ahartikainen
Copy link
Contributor

For now I'd rather push the changes here

TBH this is mostly how I do stuff. I just run black arviz and pylint arviz (or usually specific file I have changed) (I ignore all import errors) and then push to travis.

This is because I do dev work on different machines / phone, so I only need git tools and vim.

Forgot again
Errors are not detected locally because there pylint uses emcee3
@canyon289
Copy link
Member

ThIs LGTM. The rest of the work is on us to add emcee3 reader testing to TravisCI

If no one has any problems I'll open an issue for emcee3 reader testing and will merge in 24 hours.

@ahartikainen
Copy link
Contributor

Sounds fine.

LGTM

@canyon289
Copy link
Member

Thanks @OriolAbril

@canyon289 canyon289 merged commit f154757 into arviz-devs:master Jan 21, 2019
@ColCarroll ColCarroll mentioned this pull request Feb 22, 2019
@OriolAbril OriolAbril deleted the emcee_reader branch March 15, 2019 12:51
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