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

Test consistent #37

Merged
merged 4 commits into from
May 26, 2020
Merged

Test consistent #37

merged 4 commits into from
May 26, 2020

Conversation

amoodie
Copy link
Member

@amoodie amoodie commented May 23, 2020

add a test to check a small slice of the eta matrix, so we can be sure the model is not changed by any of our steps (or at least we can tell when things are changed...).

Fix a small warning about literal checking.

@ericbarefoot can you verify the test passes on your local?

@amoodie amoodie requested a review from ericbarefoot May 23, 2020 20:44
This was referenced May 23, 2020
@ericbarefoot
Copy link
Collaborator

I'm not sure why this would be, but the test fails for me if I specifically do pytest tests/test_consistency.py but passes if I do just pytest see below.

(base) 15:16:15 ericfoot pyDeltaRCM_WMT $ (amoodie/test_consistent) pytest tests/test_consistent.py 
================================== test session starts ===================================
platform darwin -- Python 3.7.7, pytest-5.4.2, py-1.8.1, pluggy-0.13.1
rootdir: /Users/ericfoot/Dropbox/programs/git_repos/pyDeltaRCM_WMT
plugins: arraydiff-0.3, remotedata-0.3.2, hypothesis-5.11.0, openfiles-0.5.0, doctestplus-0.5.0, astropy-header-0.1.2
collected 1 item                                                                         

tests/test_consistent.py F                                                         [100%]

======================================== FAILURES ========================================
_______________________________ test_bed_after_one_update ________________________________

    def test_bed_after_one_update():
        """
        """
        delta.update()
        # slice is: delta.eta[:5, 4]
        print(delta.eta[:5, 4])
    
        _exp = np.array([-1., -0.82951754, -0.9981775 , -1., -1.])
>       assert np.all(delta.eta[:5, 4] == pytest.approx(_exp))
E       assert False
E        +  where False = <function all at 0x102778830>(array([-1.       , -0.840265 , -0.9976036, -1.       , -1.       ],\n      dtype=float32) == approx([-1.0 ± 1.0e-06, -0.82951754 ± 8.3e-07, -0.9981775 ± 1.0e-06, -1.0 ± 1.0e-06, -1.0 ± 1.0e-06]))
E        +    where <function all at 0x102778830> = np.all
E        +    and   approx([-1.0 ± 1.0e-06, -0.82951754 ± 8.3e-07, -0.9981775 ± 1.0e-06, -1.0 ± 1.0e-06, -1.0 ± 1.0e-06]) = <function approx at 0x1014f38c0>(array([-1.        , -0.82951754, -0.9981775 , -1.        , -1.        ]))
E        +      where <function approx at 0x1014f38c0> = pytest.approx

tests/test_consistent.py:23: AssertionError
---------------------------------- Captured stdout call ----------------------------------
[-1.        -0.840265  -0.9976036 -1.        -1.       ]
================================ short test summary info =================================
FAILED tests/test_consistent.py::test_bed_after_one_update - assert False
=================================== 1 failed in 0.83s ====================================

versus

(base) 15:18:33 ericfoot pyDeltaRCM_WMT $ (amoodie/test_consistent) pytest
================================== test session starts ===================================
platform darwin -- Python 3.7.7, pytest-5.4.2, py-1.8.1, pluggy-0.13.1
rootdir: /Users/ericfoot/Dropbox/programs/git_repos/pyDeltaRCM_WMT
plugins: arraydiff-0.3, remotedata-0.3.2, hypothesis-5.11.0, openfiles-0.5.0, doctestplus-0.5.0, astropy-header-0.1.2
collected 102 items                                                                      

tests/test_bmi_delta.py ...                                                        [  2%]
tests/test_command_line_tool.py ...                                                [  5%]
tests/test_consistent.py .                                                         [  6%]
tests/test_deltaRCM_driver.py ..                                                   [  8%]
tests/test_deltaRCM_tools.py ..                                                    [ 10%]
tests/test_init_tools.py ......................................................... [ 66%]
.............                                                                      [ 79%]
tests/test_sed_tools.py .                                                          [ 80%]
tests/test_shared_tools.py ..                                                      [ 82%]
tests/test_water_tools.py .......                                                  [ 89%]
tests/test_yaml_parsing.py ..x..xx....                                             [100%]

============================= 99 passed, 3 xfailed in 7.76s ==============================

@amoodie
Copy link
Member Author

amoodie commented May 25, 2020

@ericbarefoot nice catch, I think this had something to do with the fact that the delta object was instantiated outside of the test. I have updated the test (and another few tests which check model "state") to instantiate inside of the tests. For simple "exists" checks like in tests_init_tools the single instantiation at the top of the file should be fine, but I guess anything state dependent should happen inside of the test itself.

@amoodie
Copy link
Member Author

amoodie commented May 25, 2020

well this lowered coverage for some weird reason, but maybe you can check it out again and test locally, @ericbarefoot, if things pass, I think it can be merged.

Copy link
Collaborator

@ericbarefoot ericbarefoot left a comment

Choose a reason for hiding this comment

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

This looks fantastic to me. I am not so worried about small decreases in coverage. We are going to increase coverage by a bunch eventually when we make a consistent effort to provide unit tests for everything.

I'll go ahead and merge this, then rebase my branch off of this. That way we can see if the jitting is affecting the consistency. To eye it looks fine, but you never know...

@ericbarefoot ericbarefoot merged commit b5e3bcf into DeltaRCM:develop May 26, 2020
@amoodie amoodie deleted the test_consistent branch February 25, 2021 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants