From mboxrd@z Thu Jan 1 00:00:00 1970 From: iemacs@gmail.com Subject: Re: indentation error in python source block Date: Fri, 14 Dec 2018 22:12:35 +0800 Message-ID: References: <87muqilxgy.fsf@otaria.sebmel.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:55598) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXoCw-0000Nz-48 for emacs-orgmode@gnu.org; Fri, 14 Dec 2018 09:12:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gXoCv-0005qt-4o for emacs-orgmode@gnu.org; Fri, 14 Dec 2018 09:12:50 -0500 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]:40534) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gXoCu-0005qP-Tt for emacs-orgmode@gnu.org; Fri, 14 Dec 2018 09:12:49 -0500 Received: by mail-wr1-x436.google.com with SMTP id p4so5567063wrt.7 for ; Fri, 14 Dec 2018 06:12:48 -0800 (PST) In-Reply-To: <87muqilxgy.fsf@otaria.sebmel.org> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Seb Cc: org-mode mailing list On Fri, Nov 9, 2018 at 11:52 AM Seb wrote: > > Hello, > > I believe I've hit a strange bug. Given this file: > > ---<--------------------cut here---------------start------------------->--- > #+STARTUP: content indent hideblocks > #+PROPERTY: header-args :tangle yes > #+PROPERTY: header-args:python :session *Python* > > #+NAME: python_init > #+BEGIN_SRC python :results silent :exports none > import matplotlib as mpl > mpl.use("Agg") > import matplotlib.pyplot as plt > import numpy as np > import pandas as pd > #+END_SRC > > #+NAME: test > #+BEGIN_SRC python :results file :exports results > beg = ["2017-07-13 15:27:31", "2017-07-13 15:28:24"] > beg = pd.to_datetime(beg) > end = ["2017-07-13 15:28:03", "2017-07-13 15:28:57"] > end = pd.to_datetime(end) > pos = np.arange(1, 3).tolist() > experiment = pd.DataFrame(dict(index=np.arange(1, 3), > beg=beg, end=end, pos=pos)) > # Mid points > experiment["mid"] = (experiment["beg"] + > (experiment["end"] - experiment["beg"]) / 2) > fig, axs = plt.subplots(3, 1, sharex=True) > # Shade experiment periods > for idx, row in experiment.iterrows(): > for ax in axs: > ax.axvspan(row["beg"], row["end"], facecolor="0.5") How about adding an empty line here? > axs[0].annotate(row["pos"], (row["mid"], 1), ha="center", > xycoords=("data", "axes fraction")) > # TEMPORARY: limit to experiment periods > axs[0].set_xlim(experiment["beg"].iloc[0], > experiment["end"].iloc[-1]) > fig.tight_layout() > fig.savefig("junk.png", bbox_inches="tight") > plt.close() > "junk.png" > #+END_SRC > ---<--------------------cut here---------------end--------------------->--- > > Problem is in the second source block. With point on the #+BEGIN line, > hitting C-c to execute the block yields indentation errors in the > Python process (first one): > > ---<--------------------cut here---------------start------------------->--- > >>> experiment["end"].iloc[-1]) > File "", line 1 > axs[0].annotate(row["pos"], (row["mid"], 1), ha="center", > ^ > IndentationError: unexpected indent > ---<--------------------cut here---------------end--------------------->--- > > Tangling the file and running the Python script shows no error at all. > Executing the source block from the dedicated buffer via C-c ' > (`org-edit-special') also runs without errors. What is going on? > > Thanks, > -- > Seb > > -- Yours faithfully, Tian Qiu