millejoh / emacs-ipython-notebook

Jupyter notebook client in Emacs
http://millejoh.github.io/emacs-ipython-notebook/
GNU General Public License v3.0
1.47k stars 122 forks source link

Plots do not appear when there is a list comprehension in the same cell #716

Closed jmcarcell closed 4 years ago

jmcarcell commented 4 years ago

I noticed that when there is a list comprehension in the same cell the image will not appear (I have output-area-inlined-images set to t in my config) This shows a plot:

import matplotlib.pyplot as plt
fig, ax = plt.subplots(1, 1)
aux = np.arange(100)
ax.plot(aux)

but if we add one line (place doesn't matter) with a list comprehension it doesn't show an image anymore

import matplotlib.pyplot as plt
fig, ax = plt.subplots(1, 1)
aux = np.arange(100)
ax.plot(aux)
x = [3 for i in range(100)]

One can use plt.show() to show the image but it is mildly inconvenient having to type this at every cell. I have tried disabling other packages that I use at the same time, but so far I have always gotten the same result. I'm using Arch Linux, with emacs 26.3 and ein 20200514.2040, everything up to date.

dickmao commented 4 years ago

Following the README instructions on reporting bugs might lead to insights into what is currently an unreproducible bug.

Peek 2020-05-20 07-06

jmcarcell commented 4 years ago

After some testing I found that the bug is reproducible. I picked a laptop that I don't use a lot with Arch Linux and the bug wasn't happening, updated system packages and emacs packages and it happens. So it must be something that changed in the last month or so, the time since I last updated my laptop.

I tried following the README but it still happens. Steps to reproduce on my machine:

I reduced my init.el to this (only ein installed):

(require 'package)
(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/"))
(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/"))

(package-initialize)
(unless (package-installed-p 'use-package)
  (package-refresh-contents)
  (package-install 'use-package))
(setq use-package-always-ensure t)
(use-package use-package-ensure-system-package :ensure t) ;; Enable ensure-system-package extension

;;; -*- lexical-binding: t -*-

(defun tangle-init ()
  "If the current buffer is 'init.org' the code-blocks are
tangled, and the tangled file is compiled."
  (when (equal (buffer-file-name)
               (expand-file-name "~/.dotfiles/emacs/.emacs.d/init.org"))
    ;; Avoid running hooks when tangling.
    (let ((prog-mode-hook nil))
      (org-babel-tangle))))

(add-hook 'after-save-hook 'tangle-init)

(use-package ein
  :config
  (setq ein:output-area-inlined-images t)
)
jmcarcell commented 4 years ago

It appears to be something related to emacs rather than ein. I checked out commits from +3 months ago and the same bug happens.

I'm not sure if I loaded ein correctly (I loaded all the *.el files, and one file was giving an error about not calling it, I guess it was not intended to be loaded like this) but ein was working so I think this is fine.

dickmao commented 4 years ago

I tried following the README but it still happens. Steps to reproduce on my machine:

That's not quite following the README, which suggests really getting down to brass tacks via emacs -Q -f package-initialize --eval "(setq debug-on-error t)". Nothing in your pared down init.el stands out as suspect, but I can't be sure unless you really follow the README. Also, this invocation of use-package is preferred: (use-package ein :custom (ein:output-area-inlined-images t))

I'm not sure if I loaded ein correctly (I loaded all the *.el files, and one file was giving an error about not calling it, I

It's not clear what you mean by "I loaded all the .el files". If you've installed EIN via the melpa method as laid out in the README, any manual loading of .el files can only impair, not ensure.

Optional: Seeing is believing, so if you have the wherewithal to construct an animated gif via gif-screencastor peek, that would motivate me to take this more seriously.

jmcarcell commented 4 years ago

That's not quite following the README I remember following the README (somehow, only the -Q part to check whether it was a problem with my config) and it still happened. I enumerated the steps that I had to do to reproduce it, regardless of starting emacs with -Q or not.

Anyways, since some weeks ago I have not been able to reproduce it. I update regularly so some update must have changed something. The version of emacs has not changed, it still is 26.3.

Quite strange, but I'm 100% sure that happened as if in your gif nothing appeared under the cell when the list comprehension was in it. Too bad I didn't record it!