all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Nicolas Goaziou <mail@nicolasgoaziou.fr>
To: Seb <spluque@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: indentation error in python source block
Date: Sat, 10 Nov 2018 08:30:50 +0100	[thread overview]
Message-ID: <875zx5crth.fsf@nicolasgoaziou.fr> (raw)
In-Reply-To: <87muqilxgy.fsf@otaria.sebmel.org> (Seb's message of "Thu, 08 Nov 2018 21:51:41 -0600")

Hello,

Seb <spluque@gmail.com> writes:

> 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")
>     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 "<stdin>", line 1
>     axs[0].annotate(row["pos"], (row["mid"], 1), ha="center",
>     ^
> IndentationError: unexpected indent
> ---<--------------------cut here---------------end--------------------->---

I cannot reproduce your error. You may want to upgrade Org.

Regards,

-- 
Nicolas Goaziou

  reply	other threads:[~2018-11-10  7:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-09  3:51 indentation error in python source block Seb
2018-11-10  7:30 ` Nicolas Goaziou [this message]
2018-11-10 15:58   ` Sebastian P. Luque
2018-12-14 14:12 ` iemacs

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=875zx5crth.fsf@nicolasgoaziou.fr \
    --to=mail@nicolasgoaziou.fr \
    --cc=emacs-orgmode@gnu.org \
    --cc=spluque@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.