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

Do continuous integration and codecoverage as in reduceSPI / ioSPI #6

Merged
merged 41 commits into from
Oct 16, 2021

Conversation

geoffwoollard
Copy link
Contributor

@geoffwoollard geoffwoollard commented Oct 15, 2021

Like this PR for ioSPI, but with simSPI https://github.com/compSPI/ioSPI/pulls?q=is%3Apr+is%3Aclosed

…ing for because it is on the same level as tests. I checked with ioSPI and put src
… length in docstrings, while black ignores these
Copy link
Contributor

@ninamiolane ninamiolane left a comment

Choose a reason for hiding this comment

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

LGTM if tests pass!

$CONDA/bin/pytest --cov-report term --cov-report xml:coverage.xml --cov=ioSPI ${{matrix.test-folder}}
Copy link
Contributor

Choose a reason for hiding this comment

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

replace to simSPI

@codecov
Copy link

codecov bot commented Oct 16, 2021

Codecov Report

❗ No coverage uploaded for pull request base (master@0fcb819). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master       #6   +/-   ##
=========================================
  Coverage          ?   95.84%           
=========================================
  Files             ?        3           
  Lines             ?       72           
  Branches          ?        0           
=========================================
  Hits              ?       69           
  Misses            ?        3           
  Partials          ?        0           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0fcb819...57bef3b. Read the comment docs.

@geoffwoollard
Copy link
Contributor Author

The tests were failing because of low test coverage. For some reasons using a numba.jit decorator, and then testing this function, doesn't count for code coverage. Instead, I defined the function (to be jitted) without a decorator, then make a numba.jitted version of it and called it a different name. The slow plain vanilla function is used in the tests. The fast jitted function is used in other functions

https://github.com/geoffwoollard/simSPI/blob/ad591eff3bc32ab609673dee294977b01222b216/simSPI/transfer.py#L102

@geoffwoollard
Copy link
Contributor Author

I really don't understand how or why the tests passed in Python 3.7 and 3.8, but not 3.9.

There is a shape mis match, but the shapes should be even

=================================== FAILURES ===================================
________________________________ test_apply_ntf ________________________________

    def test_apply_ntf():
        """Test apply_ntf."""
        N_random = np.random.uniform(low=50, high=100)
        N = int(2 * (N_random // 2))
        ones = np.ones((N, N))
        freq_A_2d = transfer.ctf_freqs(N, dim=2)[0]
        ntf = np.sinc(freq_A_2d)
>       i = multislice.apply_ntf(shot_noise_sample=ones, ntf=ntf)

tests/test_multislice.py:96: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

shot_noise_sample = array([[1., 1., 1., ..., 1., 1., 1.],
       [1., 1., 1., ..., 1., 1., 1.],
       [1., 1., 1., ..., 1., 1., 1.],
       ...,
       [1., 1., 1., ..., 1., 1., 1.],
       [1., 1., 1., ..., 1., 1., 1.],
       [1., 1., 1., ..., 1., 1., 1.]])
ntf = array([[0.35818779, 0.36798049, 0.37768329, ..., 0.37768329, 0.36798049,
        0.35818779],
       [0.36798049, 0.37...76,
        0.36798049],
       [0.35818779, 0.36798049, 0.37768329, ..., 0.37768329, 0.36798049,
        0.35818779]])

    def apply_ntf(shot_noise_sample, ntf):
        """Convolution with detector's NTF.
    
        Convolution of (ctf and dqe applied) exit wave
        with the noise transfer function.
    
        Parameters
        ----------
        shot_noise_sample : numpy.ndarray, shape (N,N)
            Image with ctf applied.
        ntf : numpy.ndarray, shape (N,N)
            Noise transfer function (in 2D).
    
        Returns
        -------
        i : numpy.ndarray, shape (N,N)
            Exit wave with ntf applied (in real space).
        """
>       i = fourier.do_ifft(fourier.do_fft(shot_noise_sample, dim=2) * ntf, dim=2)
E       ValueError: operands could not be broadcast together with shapes (98,98) (99,99)

simSPI/multislice.py:93: ValueError

@geoffwoollard
Copy link
Contributor Author

well it passed the tests for 3.7,3.8,3.9. Maybe some issue with the way the integer is rounded to even??? https://github.com/geoffwoollard/simSPI/blob/ci/tests/test_multislice.py#L92

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.

2 participants