Skip to content

ENH: Add complex number support for fromfile - #14730

Merged
mattip merged 2 commits into
numpy:masterfrom
zjpoh:fromfile_complex
Oct 31, 2019
Merged

mattip merged 2 commits into
numpy:masterfrom
zjpoh:fromfile_complex

Conversation

@zjpoh

@zjpoh zjpoh commented Oct 17, 2019

Copy link
Copy Markdown
Member

As discussed in #14227, we want to support complex numbers for fromfile too.

@zjpoh
zjpoh requested a review from seberg October 17, 2019 05:05
@zjpoh

zjpoh commented Oct 18, 2019

Copy link
Copy Markdown
Member Author

I got this error on Azure Windows Python 3.7 32 bit build but I don't understand the failure.

self = <numpy.core.tests.test_multiarray.TestMethods object at 0x1256D090>
func = <ufunc 'matmul'>, dtype = 'F'

    @pytest.mark.parametrize('func', (np.dot, np.matmul))
    @pytest.mark.parametrize('dtype', 'ifdFD')
    def test_no_dgemv(self, func, dtype):
        # check vector arg for contiguous before gemv
        # gh-12156
        a = np.arange(8.0, dtype=dtype).reshape(2, 4)
        b = np.broadcast_to(1., (4, 1))
        ret1 = func(a, b)
        ret2 = func(a, b.copy())
        assert_equal(ret1, ret2)
    
        ret1 = func(b.T, a.T)
        ret2 = func(b.T.copy(), a.T)
        assert_equal(ret1, ret2)
    
        # check for unaligned data
        dt = np.dtype(dtype)
        a = np.zeros(8 * dt.itemsize // 2 + 1, dtype='int16')[1:].view(dtype)
        a = a.reshape(2, 4)
        b = a[0]
        # make sure it is not aligned
        assert_(a.__array_interface__['data'][0] % dt.itemsize != 0)
        ret1 = func(a, b)
>       ret2 = func(a.copy(), b.copy())
E       RuntimeWarning: invalid value encountered in matmul

a          = array([[0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j],
       [0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j]], dtype=complex64)
b          = array([0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j], dtype=complex64)
dt         = dtype('complex64')
dtype      = 'F'
func       = <ufunc 'matmul'>
ret1       = array([0.+0.j, 0.+0.j], dtype=complex64)
ret2       = array([[ 6.+0.j, 22.+0.j]])
self       = <numpy.core.tests.test_multiarray.TestMethods object at 0x1256D090>

C:\hostedtoolcache\windows\Python\3.7.4\x86\lib\site-packages\numpy\core\tests\test_multiarray.py:2899: RuntimeWarning

However, I found #12494 (comment), which is referring to the same error

@seberg

seberg commented Oct 18, 2019

Copy link
Copy Markdown
Member

Do not worry about it, it is unrelated and random (and additionally very certainly an issue with the linear algebra backend and not numpy itself)

@mattip
mattip merged commit c1d9eec into numpy:master Oct 31, 2019
@mattip

mattip commented Oct 31, 2019

Copy link
Copy Markdown
Member

Thanks @zjpoh

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.

3 participants