From: Torsten Wagner <torsten.wagner@gmail.com>
To: Org Mode Mailing List <emacs-orgmode@gnu.org>
Subject: execute sbe macro fails
Date: Sat, 13 Jul 2013 22:57:44 +0200 [thread overview]
Message-ID: <CAPaq-gM1WWCxfWMj3JSGJb2Y1nJvzM3sGZ=yuHuABb0-igjt9g@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1570 bytes --]
Hi,
I wrote a python code block which should translate scores into marks.
The python code seems to work. It takes two arguments. The reached score
(out of 100) as well as how many scores where needed to pass. Starting from
that, higher grades are calculated on a even base.
I want to call the python block for each row using the sbe macro
However, this results in an error and I can't see why
| Name | ID | 1.1 | 1.2 | 1.3 | 1.4 | 2.1 | 2.2 | 2.3 | 2.4 | 2.5 | Extra
| Sum | Mark |
|---------------------+------------+-----+-----+-----+-----+-----+-----+-----+-----+-----+-------+-------+--------|
| Name1 | 111111 | 10 | 10 | 10 | 12 | 12 | 3 | 4 | 12 | 3
| 2 | 78 | #ERROR |
| Name2 | 22222 | | | | | | | | |
| | 0 | #ERROR |
| Name3 | 33333 | | | | | | | | |
| | 0 | #ERROR |
#+TBLFM: $14='(sbe score2mark (score $13) (passscore 50))
#+name: score2mark(score, passscore)
#+begin_src python
def score2mark(score, passscore):
marklist = [5, 4.3, 4, 3.7, 3.3, 3, 2.7 ,2.3, 2, 1.7, 1.3, 1]
step=(100-passscore)/(len(marklist)-1)
if score < passscore:
return marklist[0]
for mark in marklist[1:]:
if round(passscore) <= score <= round(passscore+step):
return mark
else:
passscore += step
return -1
#+end_src
Any idea what I am doing wrong? I tried different versions with
"score2mark" some additional brackets etc. However, no luck yet.
Thanks for help
Torsten
[-- Attachment #2: Type: text/html, Size: 1830 bytes --]
next reply other threads:[~2013-07-13 20:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-13 20:57 Torsten Wagner [this message]
2013-07-14 22:24 ` execute sbe macro fails Eric Schulte
2013-07-15 9:35 ` Torsten Wagner
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='CAPaq-gM1WWCxfWMj3JSGJb2Y1nJvzM3sGZ=yuHuABb0-igjt9g@mail.gmail.com' \
--to=torsten.wagner@gmail.com \
--cc=emacs-orgmode@gnu.org \
/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.