Ask Your Question

markus's profile - activity

2023-09-06 03:22:53 +0200 received badge  Famous Question (source)
2023-07-01 09:36:06 +0200 received badge  Popular Question (source)
2019-12-10 01:58:45 +0200 received badge  Notable Question (source)
2017-09-20 02:23:43 +0200 received badge  Popular Question (source)
2017-06-07 16:27:13 +0200 received badge  Nice Question (source)
2017-06-07 16:27:08 +0200 received badge  Nice Answer (source)
2017-06-03 03:22:29 +0200 asked a question urllib error in Sage running on a Mac

I have used urllib in Sage for a while now (on Mac OS Yosemite). However, recently I've been getting an error: [Errno url error] unknown url type: 'https'

The code I'm using is getting exchange rates from Yahoo.

import urllib
def getRate(sym):
    url = 'http://finance.yahoo.com/d/quotes.csv?s=%s&f=%s' % (sym, 'l1c1va2xj1b4j4dyekjm3m4rr5p5p6s7')
    values = urllib.urlopen(url).read().strip().strip('"').split(',')
    return float(str(values[0]))

sym="EUR=X"
getRate(sym)
2016-12-02 17:50:44 +0200 received badge  Self-Learner (source)
2016-12-02 04:44:19 +0200 answered a question TexShop sage.engine can't tell if running Sage is necessary

I've figured it out. Replacing the new_sum line sage.engine by

new_sum=$(egrep -v '^( _st_.goboom|print .SageT)' "$sagename" | egrep -v '(_st_.current_tex_line)' | md5)

does the trick.

2016-12-02 04:01:42 +0200 answered a question TexShop sage.engine can't tell if running Sage is necessary

I've figured it out. The expression for new_sum in sage.engine needs to be modified as follows

# do we need to run Sage?
if [ -f "$soutname" ]
then
    new_sum=$(egrep -v '^( _st_.goboom|print .SageT)' "$sagename" | egrep -v '^( _st_.current_tex_line = |print .SageT)' | md5)
    old_sum=$(egrep -o ^%[0-9a-f]{32}% "$soutname" | cut -b 2-33)
    if [ "$new_sum" != "$old_sum" ]
    then
        run_sage=yes
    fi
else
    # no .sout file, so run Sage
    run_sage=yes
fi
2016-12-01 22:25:00 +0200 commented question TexShop sage.engine can't tell if running Sage is necessary

Thanks for your response. I've added an example.

2016-12-01 06:06:03 +0200 asked a question TexShop sage.engine can't tell if running Sage is necessary

I have switched from sagetex.py version 2012/01/16 v2.3.3-69dcb0eb93de to version 2015/08/26 v3.0-92d9f7a. When I compile a tex file using sage.engine it can't determine whether sage needs to run or not. I've narrowed this down to the if statement in sage.engine

# do we need to run Sage?
if [ -f "$soutname" ]
then
    new_sum=$(egrep -v '^( _st_.goboom|print .SageT)' "$sagename" | md5)
    old_sum=$(egrep -o ^%[0-9a-f]{32}% "$soutname" | cut -b 2-33)
    if [ "$new_sum" != "$old_sum" ]
    then
        run_sage=yes
    fi
else
    # no .sout file, so run Sage
    run_sage=yes
fi

I think the first egrep call should also eliminate lines containing current_tex_line. I've tried

new_sum=$(egrep -v '^( _st_.goboom|print .SageT)' "$sagename" | egrep -v '^( _st_.current_tex_line)' | md5)

but to no avail.

Any ideas would be much appreciated. Thanks.

Here is an example: the test.tex file

% !TEX TS-program = sage
\documentclass[12pt]{article}
\usepackage{sagetex}
\begin{document}
$2+3=\sage{2+3}$
\end{document}

produces among other things a sagetex.sout file that contains

% This file was *autogenerated* from test.sagetex.sage with
 % sagetex.py version 2015/08/26 v3.0-92d9f7a
\newlabel{@sageinline0}{{%
5}{}{}{}{}}
%b22d43e1240df548df8cf6749b32284b% md5sum of corresponding .sage file (minus "goboom", "current_tex_line", and pause/unpause lines)

The sage.engine if statement should compare the md5 value of sagetex.sage minus a few lines to the md5sum in sagetex.sout.

2016-11-26 22:42:43 +0200 received badge  Nice Answer (source)
2016-11-26 05:11:35 +0200 received badge  Teacher (source)
2016-11-26 05:11:35 +0200 received badge  Self-Learner (source)
2016-11-26 04:12:42 +0200 answered a question using sage engine during compilation of tex file

I've figured it out. I needed to edit the file ~/Library/TeXShop/Engines/sage.engine. The line /Applications/Sage.app/Contents/Resources/sage/sage "$sagename" needed to be changed to /Applications/Sage-6.5.app/Contents/Resources/sage/sage "$sagename"

2016-11-25 23:25:01 +0200 received badge  Editor (source)
2016-11-25 23:21:45 +0200 asked a question using sage engine during compilation of tex file

I would like to automate calling sage after compiling a tex file in TeXShop. I have copied the sage.engine file from ~/Library/TeXShop/Engines/Inactive/Sage to ~/Library/TeXShop/Engines/ and followed the instructions in About Sage.pdf.

I've included the line % !TEX TS-program = sage in my tex file, but when I compile the file the sage expressions don't compute. I only get ?? for sage expressions. If I run sage on the sagetex.sage file and re-compile the tex file, then everything looks good.

I'm running TeXShop 3.75 on MacOS 10.10.5

2016-11-12 08:12:08 +0200 received badge  Scholar (source)
2016-11-12 08:12:03 +0200 commented answer How can I share a Sage Interaction on a website without giving away the code?

Thanks, Paul!

2016-11-12 05:42:04 +0200 received badge  Supporter (source)
2016-11-12 05:38:36 +0200 commented answer How can I share a Sage Interaction on a website without giving away the code?

Thank you, that works! I am still experiencing a problem with blank spaces. When I modify your example to run

import pandas
plot(sin)

then the permalink http://sagecell.sagemath.org/?z=eJzLz... works fine. But eval(decompress(decode('eJzLzC3ILypRKEjMS0ks5uUqyMkv0SjOzNMEAHDNCKQ=')))

returns the error: File "<string>", line 1 import pandas ^ SyntaxError: invalid syntax

2016-11-11 23:09:07 +0200 received badge  Good Question (source)
2016-11-11 21:37:52 +0200 commented answer How can I share a Sage Interaction on a website without giving away the code?

I agree with the idea of sharing code. But this is for a course that I teach. So I don't want to give away the solution for obvious reasons

2016-11-11 19:28:07 +0200 received badge  Nice Question (source)
2016-11-11 18:06:12 +0200 asked a question How can I share a Sage Interaction on a website without giving away the code?

I would like to add numerical examples coded in Sage (e.g. https://wiki.sagemath.org/interact/) to my website without making available the code in the html.

2012-05-05 07:48:57 +0200 received badge  Student (source)
2012-05-05 00:34:45 +0200 commented answer linear programming in cython

Thanks Volker! I think that is exactly what I need. I am new to Sage and Cython so it might take me a while but thanks for pointing me in the right direction. Also, do you have feeling for what time saving I can expect relative to MixedIntegerLinearProgam? Markus