Skip to content

PyPlot interferes with LinearAlgebra in a weird way #477

Closed
@atbug

Description

@atbug

Let me start with how to reproduce:

julia> using LinearAlgebra, PyPlot

julia> xlim([-1, 1]) # a window will pop up, leave the window open.
(-1, 1)

julia> H = rand(46, 46)+im*rand(46, 46);

julia> values, vectors = eigen(Hermitian(H))
Eigen{Complex{Float64},Float64,Array{Complex{Float64},2},Array{Float64,1}}
values:
0-element Array{Float64,1} # should have been a 46 element array
vectors:
46×0 Array{Complex{Float64},2}

julia> versioninfo() # official binary
Julia Version 1.4.0
Commit b8e9a9ecc6 (2020-03-21 16:36 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i5-8265U CPU @ 1.60GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-8.0.1 (ORCJIT, skylake)

(@v1.4) pkg> st
Status `C:\Users\wangc\.julia\environments\v1.4\Project.toml`
  [c52e3926] Atom v0.12.10
  [6e4b80f9] BenchmarkTools v0.5.0
  [861a8166] Combinatorics v1.0.0
  [27194a60] Hop v0.1.0 [`D:/Workspace/Hop.jl`]
  [7073ff75] IJulia v1.21.1
  [6a3955dd] ImageFiltering v0.6.11
  [e5e0dc1b] Juno v0.8.1
  [5b5b96b6] MoireRelaxation v0.1.0 [`D:/Workspace/MoireRelaxation.jl`]
  [429524aa] Optim v0.20.6
  [438e738f] PyCall v1.91.4
  [d330b81b] PyPlot v2.9.0

Several observations:

  • Only the first run of values, vectors = eigen(Hermitian(H)) will give the wrong result. If the statement is run a second time, the eigenvalues and eigenvectors are correct.
  • I am not sure this is a Windows issue since I don't have linux machines with gui. To reproduce, the gui is essential: if PyPlot is started with Agg backend, the eigenvalues are correct.
  • The number 46 is not very special and 24, 12 would also reproduce this. However, if the number is 4. I cannot reproduce this on my machine.
  • If I collect all the statements in a file run.jl and do include(run.jl) in the REPL, I cannot reproduce this.
Python package list:
(base) C:\Users\wangc>conda list
# packages in environment at C:\Users\wangc\.julia\conda\3:
#
# Name                    Version                   Build  Channel
anaconda-client           1.7.2                    py37_0
anaconda-navigator        1.9.12                   py37_0
apscheduler               3.6.3                    py37_0
ase                       3.19.1                     py_0    conda-forge
asn1crypto                1.3.0                    py37_0
attrs                     19.3.0                     py_0
backcall                  0.1.0                    py37_0
blas                      1.0                         mkl
bleach                    3.1.0                    py37_0
bzip2                     1.0.8                he774522_0
ca-certificates           2020.1.1                      0
certifi                   2020.4.5.1               py37_0
cffi                      1.14.0           py37h7a1dbc1_0
cftime                    1.1.1.1          py37h2a96729_0
chardet                   3.0.4                 py37_1003
click                     7.1.1                      py_0
cloudpickle               1.3.0                      py_0
clyent                    1.2.2                    py37_1
colorama                  0.4.3                      py_0
conda                     4.8.3                    py37_0
conda-package-handling    1.6.0            py37h62dcd97_0
console_shortcut          0.1.1                         4
cryptography              2.8              py37h7a1dbc1_0
curl                      7.69.1               h2a8f88b_0
cycler                    0.10.0                   py37_0
cytoolz                   0.10.1           py37he774522_0
dask-core                 2.14.0                     py_0
decorator                 4.4.2                      py_0
defusedxml                0.6.0                      py_0
entrypoints               0.3                      py37_0
expat                     2.2.5                he025d50_0
fastcache                 1.1.0            py37he774522_0
flask                     1.1.1                      py_1
freetype                  2.9.1                ha9979f8_1
future                    0.18.2                   py37_0
geos                      3.8.0                h33f27b4_0
hdf4                      4.2.13               h712560f_2
hdf5                      1.10.4               h7ebc959_0
icc_rt                    2019.0.0             h0cc432a_1
icu                       58.2                 ha66f8fd_1
idna                      2.9                        py_1
imageio                   2.8.0                      py_0
importlib_metadata        1.5.0                    py37_0
intel-openmp              2020.0                      166
ipykernel                 5.1.4            py37h39e3cac_0
ipython                   7.13.0           py37h5ca1d4c_0
ipython_genutils          0.2.0                    py37_0
itsdangerous              1.1.0                    py37_0
jedi                      0.16.0                   py37_1
jinja2                    2.11.1                     py_0
jpeg                      9b                   hb83a4c4_2
json5                     0.9.4                      py_0
jsoncpp                   1.8.4                h74a9793_0
jsonschema                3.2.0                    py37_0
jupyter_client            6.1.2                      py_0
jupyter_core              4.6.3                    py37_0
jupyterlab                1.2.6              pyhf63ae98_0
jupyterlab_server         1.1.0                      py_0
kiwisolver                1.1.0            py37ha925a31_0
krb5                      1.17.1               hc04afaa_0
latexcodec                2.0.0                      py_0    conda-forge
libcurl                   7.69.1               h2a8f88b_0
libiconv                  1.15                 h1df5818_7
libnetcdf                 4.6.1                h411e497_2
libpng                    1.6.37               h2a8f88b_0
libsodium                 1.0.16               h9d3ae62_0
libssh2                   1.9.0                h7a1dbc1_1
libtiff                   4.1.0                h56a325e_0
libxml2                   2.9.9                h464c3ec_0
lz4-c                     1.8.1.2              h2fa13f4_0
m2w64-gcc-libgfortran     5.3.0                         6
m2w64-gcc-libs            5.3.0                         7
m2w64-gcc-libs-core       5.3.0                         7
m2w64-gmp                 6.1.0                         2
m2w64-libwinpthread-git   5.0.0.4634.697f757               2
markupsafe                1.1.1            py37he774522_0
matplotlib                3.1.3                    py37_0
matplotlib-base           3.1.3            py37h64f37c6_0
menuinst                  1.4.16           py37he774522_0
mistune                   0.8.4            py37he774522_0
mkl                       2020.0                      166
mkl-service               2.3.0            py37hb782905_0
mkl_fft                   1.0.15           py37h14836fe_0
mkl_random                1.1.0            py37h675688f_0
monty                     3.0.2                      py_0    conda-forge
mpmath                    1.1.0                    py37_0
msys2-conda-epoch         20160418                      1
nbconvert                 5.6.1                    py37_0
nbformat                  5.0.4                      py_0
netcdf4                   1.4.2            py37h812ae01_0
networkx                  2.4                        py_0
nodejs                    10.13.0                       0
notebook                  6.0.3                    py37_0
numpy                     1.18.1           py37h93ca92e_0
numpy-base                1.18.1           py37hc3f5095_1
olefile                   0.46                     py37_0
openssl                   1.1.1f               he774522_0
palettable                3.3.0                      py_0
pandas                    0.25.1           py37ha925a31_0
pandoc                    2.2.3.2                       0
pandocfilters             1.4.2                    py37_1
parso                     0.6.2                      py_0
pickleshare               0.7.5                    py37_0
pillow                    7.0.0            py37hcc1f983_0
pip                       20.0.2                   py37_1
plotly                    4.6.0                      py_0
powershell_shortcut       0.0.1                         3
prometheus_client         0.7.1                      py_0
prompt-toolkit            3.0.4                      py_0
prompt_toolkit            3.0.4                         0
psutil                    5.7.0            py37he774522_0
pybtex                    0.22.2           py37hc8dfbb8_1    conda-forge
pycosat                   0.6.3            py37he774522_0
pycparser                 2.20                       py_0
pydispatcher              2.0.5                    py37_1
pygments                  2.6.1                      py_0
pymatgen                  2020.4.2         py37heaa310e_0    conda-forge
pyopenssl                 19.1.0                   py37_0
pyparsing                 2.4.6                      py_0
pyqt                      5.9.2            py37h6538335_2
pyrsistent                0.16.0           py37he774522_0
pysocks                   1.7.1                    py37_0
python                    3.7.7           h60c2a47_0_cpython
python-dateutil           2.8.1                      py_0
python_abi                3.7                     1_cp37m    conda-forge
pytz                      2019.3                     py_0
pywavelets                1.1.1            py37he774522_0
pywin32                   227              py37he774522_1
pywinpty                  0.5.7                    py37_0
pyyaml                    5.3.1            py37he774522_0
pyzmq                     18.1.1           py37ha925a31_0
qt                        5.9.7            vc14h73c81de_0
qtpy                      1.9.0                      py_0
requests                  2.23.0                   py37_0
retrying                  1.3.3                    py37_2
ruamel.yaml               0.16.5           py37he774522_1
ruamel.yaml.clib          0.2.0            py37he774522_0
ruamel_yaml               0.15.87          py37he774522_0
scikit-image              0.16.2           py37h47e9c7a_0
scipy                     1.4.1            py37h9439919_0
send2trash                1.5.0                    py37_0
setuptools                46.1.3                   py37_0
shapely                   1.6.4            py37hd830579_0
sip                       4.19.8           py37h6538335_0
six                       1.14.0                   py37_0
spglib                    1.14.1           py37hbc2f12b_1    conda-forge
sqlite                    3.31.1               he774522_0
sympy                     1.5.1                    py37_0
tabulate                  0.8.3                    py37_0
tbb                       2020.0               h74a9793_0
terminado                 0.8.3                    py37_0
testpath                  0.4.4                      py_0
tk                        8.6.8                hfa6e2cd_0
toolz                     0.10.0                     py_0
tornado                   6.0.4            py37he774522_1
tqdm                      4.44.1                     py_0
traitlets                 4.3.3                    py37_0
tzlocal                   2.0.0                    py37_0
urllib3                   1.25.8                   py37_0
vc                        14.1                 h0510ff6_4
vs2015_runtime            14.16.27012          hf0eaf9b_1
vtk                       8.2.0           py37h1e53df8_200
wcwidth                   0.1.9                      py_0
webencodings              0.5.1                    py37_1
werkzeug                  1.0.0                      py_0
wheel                     0.34.2                   py37_0
win_inet_pton             1.1.0                    py37_0
wincertstore              0.2                      py37_0
winpty                    0.4.3                         4
xmltodict                 0.12.0                     py_0
xz                        5.2.4                h2fa13f4_4
yaml                      0.1.7                hc54c509_2
zeromq                    4.3.1                h33f27b4_3
zipp                      2.2.0                      py_0
zlib                      1.2.11               h62dcd97_3
zstd                      1.3.7                h508b16e_0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions