Ask Your Question

ppurka's profile - activity

2019-05-20 07:11:07 -0600 received badge  Nice Answer (source)
2019-03-16 14:36:54 -0600 received badge  Nice Answer (source)
2018-05-02 17:11:47 -0600 received badge  Nice Answer (source)
2018-04-12 09:07:03 -0600 received badge  Nice Answer (source)
2017-09-17 18:49:49 -0600 received badge  Nice Answer (source)
2016-10-14 20:25:02 -0600 received badge  Nice Answer (source)
2016-06-15 07:24:39 -0600 answered a question Using SageMath in a Unix pipe without creating files

As far as I know sage is not aware of piped inputs. It does have the -c switch by which it can run commands "on-the-fly". You can use a while loop and collect all the code into a string and pass it on to sage. For this, you need to tell the while loop to stop collecting the code when some special string is present. Let us say the string is EOD. Then the following is the basic syntax of the sage part of the pipelines:

# IFS='' is needed to preserve leading spaces
# -r is needed to read in raw mode, for example to preserve \ line continuation
while IFS='' read -r line; do
if [[ "${line}" = "EOD" ]]; then
    sage -c "${thecode}"; thecode=""

Can not seem to answer this question in full! It seems my shell code is creating issues with this website!! Anyway, here is the example in pastebin:


  1. the three parts of the pipelines will not run in parallel in general. If you have myprogram1 | shell code | myprogram2 then when any of the three parts are running, the other parts might be idle. If the sage part is the slowest, which it could be because it is launching a new sage process every time, then this will remain the bottleneck.
  2. the shell code is really just a shell code, so you can create a bash shell script, called "sage_shell_code" for example, and then just run it as myprogram1 | sage_shell_code | myprogram2.
2014-06-16 16:29:37 -0600 received badge  Good Answer (source)
2014-04-12 05:08:21 -0600 commented answer plot directed bipartite graph

Updated the first and last line of @fidbc's code. Nice idea there, fidbc.

2014-04-12 05:07:47 -0600 edited answer plot directed bipartite graph

Just a slight modification of your code. Not sure if this is what you are looking for.

G = DiGraph() # G=Graph(); Use DiGraph instead. (-ppurka)
for (i,v) in enumerate(left+rt):
for l in left:
    for r in rt:
G.plot(pos=pos) # G.to_directed().plot(pos=pos); Graph is already directed (-ppurka)

Sample output (new sample output -ppurka): image description

2014-03-22 04:54:06 -0600 received badge  Good Answer (source)
2014-03-22 04:54:06 -0600 received badge  Enlightened (source)
2014-02-20 23:09:18 -0600 commented answer How to unpack .spkg files

The question was about unarchiving on Windows. :)

2014-02-15 20:07:57 -0600 answered a question Interactive 3D!top...

Also check and, both of which can use webgl based 3D plots.

2014-02-15 03:03:01 -0600 commented answer Why does my browser not ask me to save my cloud password ?

@William Stein Good that chrome has started to address this issue. Though it is quite limited for now (only Macs) and quite hidden.

2014-02-13 10:29:55 -0600 commented answer Why does my browser not ask me to save my cloud password ?

What are you referring to when you say "I don't think you can do that in Chrome"?

2014-02-12 04:27:20 -0600 answered a question Why does my browser not ask me to save my cloud password ?

No idea why smc does not trigger a 'store password' response from the browser.

Also, this holds for most browsers (opera is an exception): if some other user has access to your machine, they can simply open the browser settings and read off your stored passwords in plain text. So, storing passwords in browsers may not be that good of an idea! :)

That said, every time you are about to log in to a server, you should check that the site has https connection and the certificate is valid. Most modern browsers make this very prominent in the urlbar when the site is a legit site (usually a part of the urlbar is highlighted as green).

2014-02-10 14:05:21 -0600 edited question Error in mathjax_sage.js. What's wrong with my configuration?

I have installed Sage 6.1 on a brand new laptop running Ubuntu 12.04 LTS. When I fired up Sage and tried opening a worksheet in the notebook (Chrome/Firefox), the inline latex equations did not compile (they just appear as $...$) and the display equations appeared correctly, but in the color green. In the JS console I get the error:

Failed to load resource: the server responded with a status of 500 (Internal Server Error) http://localhost:8080/javascript/dynamic/mathjax_sage.js

And here's the stack trace in Terminal:

Executing twistd  --pidfile="sage_notebook.sagenb/" -ny "sage_notebook.sagenb/twistedconf.tac"
/home/corleymj/Programs/sage-6.1-x86_64-Linux/local/lib/python2.7/site-packages/Crypto/Util/ PowmInsecureWarning: Not using mpz_powm_sec.  You should rebuild using libgmp >= 5 to avoid timing attack vulnerability.
  _warn("Not using mpz_powm_sec.  You should rebuild using libgmp >= 5 to avoid timing attack vulnerability.", PowmInsecureWarning)
2014-02-10 19:07:46-0500 [-] Log opened.
2014-02-10 19:07:46-0500 [-] twistd 13.1.0 (/home/corleymj/Programs/sage-6.1-x86_64-Linux/local/bin/python 2.7.5) starting up.
2014-02-10 19:07:46-0500 [-] reactor class: twisted.internet.epollreactor.EPollReactor.
2014-02-10 19:07:46-0500 [-] QuietSite starting on 8080
2014-02-10 19:07:46-0500 [-] Starting factory <__builtin__.QuietSite instance at 0x5ba97a0>
2014-02-10 19:07:50-0500 [-] WSGI application error
    Traceback (most recent call last):
      File "/home/corleymj/Programs/sage-6.1-x86_64-Linux/local/lib/python2.7/site-packages/Twisted-13.1.0-py2.7-linux-x86_64.egg/twisted/python/", line 212, in _worker
        o = self.q.get()
      File "/home/corleymj/Programs/sage-6.1-x86_64-Linux/local/lib/python2.7/site-packages/Twisted-13.1.0-py2.7-linux-x86_64.egg/twisted/python/", line 118, in callWithContext
        return self.currentContext().callWithContext(ctx, func, *args, **kw)
      File "/home/corleymj/Programs/sage-6.1-x86_64-Linux/local/lib/python2.7/site-packages/Twisted-13.1.0-py2.7-linux-x86_64.egg/twisted/python/", line 83, in callWithContext
      File "/home/corleymj/Programs/sage-6.1-x86_64-Linux/local/lib/python2.7/site-packages/Twisted-13.1.0-py2.7-linux-x86_64.egg/twisted/web/", line 340, in run
        self.started = True
    --- <exception caught here> ---
      File "/home/corleymj/Programs/sage-6.1-x86_64-Linux/local/lib/python2.7/site-packages/Twisted-13.1.0-py2.7-linux-x86_64.egg/twisted/web/", line 315, in run
        appIterator = self.application(self.environ, self.startResponse)
      File "/home/corleymj/Programs/sage-6.1-x86_64-Linux/local/lib/python2.7/site-packages/Flask-0.10.1-py2.7.egg/flask/", line 1836, in __call__
        return self.wsgi_app(environ, start_response)
      File "/home/corleymj/Programs/sage-6.1-x86_64-Linux/local/lib/python2.7/site-packages/Flask-0.10.1-py2.7.egg/flask/", line 1820, in wsgi_app
        response = self.make_response(self.handle_exception(e))
      File "/home/corleymj/Programs/sage-6.1-x86_64-Linux/local/lib/python2.7/site-packages/Flask-0.10.1-py2.7.egg/flask/", line 1403, in handle_exception
        reraise(exc_type, exc_value, tb)
      File "/home/corleymj/Programs/sage-6.1-x86_64-Linux/local/lib/python2.7/site-packages/Flask-0.10.1-py2.7.egg/flask/", line 1817, in wsgi_app
        response = self.full_dispatch_request()
      File "/home/corleymj/Programs/sage-6.1-x86_64-Linux/local/lib/python2.7/site-packages/Flask-0.10.1-py2.7.egg/flask/", line 1477, in full_dispatch_request
        rv = self ...
2014-02-10 14:04:49 -0600 answered a question Error in mathjax_sage.js. What's wrong with my configuration?

This bug is fixed in sage-6.1.1. Please upgrade.

2014-02-08 03:57:03 -0600 answered a question interactive graphics in html

I can not see your web page properly, probably because I am not on Windows and don't have the CDF player.

For sage, look at the sage cell server (, and the interact wiki which makes use of the cell server:

2014-02-07 19:21:18 -0600 commented answer can sagecell show more than one line codes results?

Yes. Probably by design for sagenb. In cloud.s.c one doesn't need the print statements.

2014-02-07 19:18:26 -0600 edited question Will you shop shoes how high the [spam]

remove spam

2014-02-07 14:39:30 -0600 edited question Website selling shoes that relatively good?

remove spam

2014-02-06 01:57:37 -0600 received badge  Nice Answer (source)
2014-02-05 23:13:40 -0600 answered a question Get a 3d plot with points (no surface) from a parametric_plot3d?

You can use the points function to do so. The only difference is that you will have to sample the function yourself. Here I am sampling it at [40, 40] points which is the default for parametric plot.

sage: pointlist = [(x(u,v), y(u,v), z(u,v)) for u in xrange(0, 200, 5) for v in xrange(40)]
sage: points(pointlist)
2014-02-04 20:54:45 -0600 received badge  Nice Answer (source)
2014-02-04 13:49:44 -0600 commented answer Strings with given frequency

You can input strings directly :) sage: P = Permutations(['0']*2+['1']) sage: map(join, P) ['0 0 1', '0 1 0', '1 0 0'] sage: map(lambda x: ''.join(x), P) ['001', '010', '100']

2014-02-04 12:53:54 -0600 answered a question Strings with given frequency

What you want is probably Permutations

sage: P = Permutations([0]*2+[1])
sage: P.list()
[[0, 0, 1], [0, 1, 0], [1, 0, 0]]
2014-02-04 12:51:41 -0600 commented answer In-line graphics for Sage in ipython notebook?

You can post this in sage-support. I don't know of any trivial way to do this.

2014-02-04 05:13:49 -0600 answered a question In-line graphics for Sage in ipython notebook?

I don't have ipython notebook installed either system wide or in sage. Perhaps the instructions in the following website helps?

2014-02-03 04:01:47 -0600 edited question pseudoprime numbers solve in sage

Help me solve my exam: Determine how many numbers pseudoprime the base 7 is in the interval [4.10 ^ 10 ^ 60] (calculate the length of the list). Define the appropriate list and check after determining that its elements satisfy the relevant conditions.

Check how many in the interval [10 ^ 3.10 ^ 5] is the number of bases that are pseudopierwszych consecutive numbers

the first 2,3, ..., n the base p_n= 3 NOTE: In the second part of the task, do not write out explicitly n conditions and use the forall. Do not write out explicitly primes.

2014-02-02 18:24:19 -0600 commented answer Controlling tick marks in plots

It's already mentioned in the documentation to look up mpl's ticker documentation.

2014-02-01 14:05:19 -0600 received badge  Necromancer (source)
2014-02-01 10:55:03 -0600 answered a question Controlling tick marks in plots

You can use the FormatStrFormatter of matplotlib.

sage: from matplotlib import ticker
sage: TT = ticker.FormatStrFormatter('%.7f')
sage: plot(1-2*x^2,x,.707106,.707107, tick_formatter=TT)
2014-01-30 23:39:52 -0600 edited question Want some guidance on cab in Birmingham?

It is one of the first moment for me personally to attend Birmingham. How do I discover a cab in Birmingham? Produce a phone? Is there any cab waiting outside seven sisiter subterranean stop? Just how much does a cab bill in Birmingham? May I take advantage of my charge card to fund cab?

2014-01-26 04:50:20 -0600 commented question Growth of Business Formula

This forum is about Sage, the mathematical software system - it is not for generic math questions. You will find better help at mathstackexchange:

2014-01-24 04:39:41 -0600 answered a question How to change linestyle of 2d vector field plots

Look at the output below. You can see that it is possible to change the arrow style but not the linewidths.

sage: p = plot_vector_field((x, y), (x, -2, 2), (y, -2, 2), headlength=10, headwidth=10)
sage: p._objects
[PlotField defined by a 20 x 20 vector grid]
sage: P = p._objects[0]
sage: P._allowed_options()
{'color': 'The color of the arrows',
 'headaxislength': 'head length at shaft intersection, default is 4.5',
 'headlength': 'head length as multiple of shaft width, default is 5',
 'headwidth': 'Head width as multiple of shaft width, default is 3',
 'pivot': 'Where the arrow should be placed in relation to the point (tail, middle, tip)',
 'plot_points': 'How many points to use for plotting precision',
 'zorder': 'The layer level in which to draw'}

I must agree that the documentation of vector field is pretty poor. And the function definitely needs to add the functionality for linewidth, and possible other things. The plot_vector_field calls matplotlib's quiver function which has support for linewidth.

I just opened ticket 15724 and ticket 15725 to address these issues.

2014-01-24 04:22:40 -0600 answered a question Export notebook cell output as LaTeX?

Right click on the rendered math and Click on "Show math as" -> "tex commands", and then you will get the latex.

2014-01-20 00:45:18 -0600 answered a question how to plot poset and subposet in a graph?
sage: PP = Posets(6)[18]
sage: Q = PP.subposet([2,4])
sage: PP.plot(vertex_size=100,vertex_colors='yellow') + Q.plot(vertex_size=100,vertex_colors='green')
2014-01-18 06:33:05 -0600 answered a question is notebook(interface='', secure=False) a loophole?

interface='' implies that the server is open to any computer that can connect to the computer on which it is running. secure=False means that all the communication between the browser and the server happen in plain text. So, if you want encrypted connection, then enable secure=True.

2014-01-18 06:30:17 -0600 commented answer Mysterious behavior for quotient rings and cover()

@tmonteil maybe open a ticket for this.

2014-01-12 22:14:25 -0600 commented question What are these TRAC Tickets useful for

just close it as spam

2014-01-12 22:14:11 -0600 edited question What are these TRAC Tickets useful for

I get paid for creating TICKETS but my boss never revealed what they are for.. I'm curious and anybody tell how they are useful for online Marketing... and how they work

2014-01-08 03:48:43 -0600 received badge  Good Answer (source)
2014-01-08 02:22:14 -0600 received badge  Nice Answer (source)
2014-01-08 01:48:25 -0600 answered a question How to get the same environment in "sage -ipython notebook" as in "sage"?

Well yes, of course. The sage environment uses a preparser. That is why the sage command line is not the same as the ipython command line. You can see what the preparser does by running it manually, like this:

sage: preparse('integrate(x^2,x)')

As you can see ** is the actual python command for taking powers. Whereas ^ does only xor operation. Similarly, the number 2 is not of type 'int' anymore. It is actually of type 'Integer', which is a sage object. The difference is quite stark - in particular, fractions are automatically changed to type QQ in sage, but not in ipython:

sage: preparser(False) # Turn off preparser
sage: 1/2
sage: preparser(True)  # This is the default when you start sage
sage: 1/2

If you want to use sage commands inside ipython then you have to stick to python commands. You can use sage commands, but not everything will automatically work unless coerced/typecast into the correct type. You can get more examples and information here.