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

masked_array ** 2 operation differs from array ** 2 operation on cluster architecture #6395

Open
andsor opened this issue Sep 30, 2015 · 2 comments

Comments

@andsor
Copy link

andsor commented Sep 30, 2015

Hi @juliantaylor, it's me again. I encounter a similar issue as before (#6251) with the following code using now Python 3.4.3 (GCC 4.7.2) with numpy 1.9.3:

from __future__ import division, print_function, absolute_import

import numpy as np
import numpy.ma as ma

from pprint import pprint


a = ma.array(
    np.array(
        [0.25375743, 0.49557181, -0.32551902, -0.37675809, -0.04705212999999997]
#        [0.67696689, 0.91878127, 0.09769044, 0.04645137, 0.37615733]
    ),
    mask=np.array([False, False, False, False, False], dtype=np.bool)
)

pprint(a)

ma_squared = a**2
a = np.asarray(a)
a_squared = a**2

pprint(a_squared - ma_squared)
pprint(a_squared[0])
pprint(ma_squared[0])

The output is

masked_array(data = [0.25375743 0.49557181 -0.32551902 -0.37675809 -0.04705212999999997],
             mask = [False False False False False],
       fill_value = 1e+20)

masked_array(data = [ -1.38777878e-17   0.00000000e+00  -1.38777878e-17   0.00000000e+00
   0.00000000e+00],
             mask = False,
       fill_value = 1e+20)

0.064392833280204897
0.064392833280204911

numpy.show_config():

blas_opt_info:
    libraries = ['f77blas', 'cblas', 'atlas']
    language = c
    library_dirs = ['/usr/nld/atlas-3.8.4-skadi-seq/lib']
    include_dirs = ['/usr/nld/atlas-3.8.4-skadi-seq/include']
    define_macros = [('ATLAS_INFO', '"\\"3.8.4\\""')]
openblas_info:
  NOT AVAILABLE
lapack_opt_info:
    libraries = ['lapack', 'f77blas', 'cblas', 'atlas']
    language = f77
    library_dirs = ['/usr/nld/atlas-3.8.4-skadi-seq/lib']
    include_dirs = ['/usr/nld/atlas-3.8.4-skadi-seq/include']
    define_macros = [('ATLAS_INFO', '"\\"3.8.4\\""')]
atlas_3_10_blas_threads_info:
  NOT AVAILABLE
mkl_info:
  NOT AVAILABLE
atlas_blas_threads_info:
  NOT AVAILABLE
atlas_3_10_threads_info:
  NOT AVAILABLE
atlas_threads_info:
  NOT AVAILABLE
openblas_lapack_info:
  NOT AVAILABLE
lapack_mkl_info:
  NOT AVAILABLE
atlas_3_10_blas_info:
  NOT AVAILABLE
atlas_blas_info:
    libraries = ['f77blas', 'cblas', 'atlas']
    language = c
    library_dirs = ['/usr/nld/atlas-3.8.4-skadi-seq/lib']
    include_dirs = ['/usr/nld/atlas-3.8.4-skadi-seq/include']
    define_macros = [('ATLAS_INFO', '"\\"3.8.4\\""')]
atlas_info:
    libraries = ['lapack', 'f77blas', 'cblas', 'atlas']
    language = f77
    library_dirs = ['/usr/nld/atlas-3.8.4-skadi-seq/lib']
    include_dirs = ['/usr/nld/atlas-3.8.4-skadi-seq/include']
    define_macros = [('ATLAS_INFO', '"\\"3.8.4\\""')]
atlas_3_10_info:
  NOT AVAILABLE
blas_mkl_info:
  NOT AVAILABLE

The numpy tests pass, but this lets one scipy test fail, scipy/scipy#5197 .

Do you think it is related. This time I used the newer C compiler, though.

@juliantaylor
Copy link
Contributor

I guess you are also using a really old libc?
the difference is likely due to masked array using pow(a, 2) while the non-masked rewrite this to a*a

@andsor
Copy link
Author

andsor commented Nov 7, 2015

Running the libc library:

 $ /lib64/libc.so.6
GNU C Library stable release version 2.11.1 (20100118), by Roland McGrath et al.
Copyright (C) 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Configured for x86_64-suse-linux.
Compiled by GNU CC version 4.3.4 [gcc-4_3-branch revision 152973].
Compiled on a Linux 2.6.32 system on 2010-05-06.
Available extensions:
        crypt add-on version 2.1 by Michael Glad and others
        GNU Libidn by Simon Josefsson
        Native POSIX Threads Library by Ulrich Drepper et al
        BIND-8.2.3-T5B
For bug reporting instructions, please see:
<http://www.gnu.org/software/libc/bugs.html>.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants