Ask Your Question

bolverk's profile - activity

2021-09-25 08:21:40 +0200 received badge  Famous Question (source)
2017-02-20 09:12:44 +0200 received badge  Notable Question (source)
2015-10-21 10:48:57 +0200 received badge  Notable Question (source)
2015-10-21 10:48:57 +0200 received badge  Popular Question (source)
2015-07-07 22:20:39 +0200 received badge  Popular Question (source)
2013-06-06 03:11:19 +0200 marked best answer Profiling and select.select

Maxima is being called to compute the answer. The select call is Sage waiting for Maxima to finish. If you want to profile this further you'd have to profile this within Maxima.

2013-06-04 04:01:53 +0200 received badge  Editor (source)
2013-06-04 03:49:39 +0200 asked a question Profiling and select.select

I'm trying to profile my code using prun, and what I'm getting is that the lion's share of the time is spent in something called "select.select", which, according to pytho documentation has something to do with I/O. Now, the thing is I'm not using I/O at all, so why does sage call this function? How can I which function was calling select.select?

Here's the original prun output:

138462 function calls (132753 primitive calls) in 11.954 second
Ordered by: internal time

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
      588    8.607    0.015    8.607    0.015 {select.select}
        1    1.166    1.166    1.168    1.168 maxima_lib.py:929(to_poly_solve)
      946    0.658    0.001    0.658    0.001 {method 'search' of '_sre.SRE_Pattern' objects}
    40001    0.560    0.000    0.560    0.000 calculus.py:1925(<lambda>)
       23    0.318    0.014    1.021    0.044 {method 'parse_sequence' of 'sage.misc.parser.Parser' objects}
      231    0.245    0.001    0.288    0.001 maxima_lib.py:380(_eval_line)
       46    0.042    0.001    0.043    0.001 maxima_lib.py:242(max_to_string)
2332/1166    0.032    0.000    0.042    0.000 lazy_attribute.py:506(__get__)
2013-05-26 14:05:22 +0200 received badge  Nice Question (source)
2013-05-18 02:48:32 +0200 asked a question Simplify shenanigans

I've noticed a strange (and annoying) behaviour in sage concerning symbolic substitution and simplification

def demonstrate_simplify_shenanigans():

    sym_func = function('func',nargs=1)

    my_expression = sym_func(0)+sym_func(1)+sym_func(2)

    print
    print 'without simplify'
    print my_expression.subs(func(0)==1)

    print
    print 'with simplify in expression'
    print my_expression.simplify().subs(func(0)==1)

    print
    print 'with simplify in both expression and substitution'
    print my_expression.simplify().subs(func(0).simplify()==1)

demonstrate_simplify_shenanigans()

The output is

without simplify
func(1) + func(2) + 1

with simplify in expression
func(0) + func(1) + func(2)

with simplify in both expression and substitution
func(1) + func(2) + 1

Why is there a different behaviour depending on whether simplify was called? Even though func(0) and func(0).simplify() seem identical.

2013-05-15 10:48:32 +0200 received badge  Nice Question (source)
2013-05-15 00:42:01 +0200 asked a question simplify and latex_name

In a notebook (with typesetting enabled), whenever I apply simplify to a simbolic function, the result is expressed in terms of the identifier of the function, rather than its latex name.

For example,

var('x')
my_func = function('df',x,latex_name='\Delta f')
my_func

returns ?f(x)

but

my_func.simplify()

returns df(x)

Is there any retain the latex name throughout simplification?

2013-03-01 06:19:14 +0200 asked a question Illegal kernel in adjoin pvar

I tried running a seemingly simple script involving a Fourier transform in a sage notebook

var('A, x, delta, k, dx, t, v, xi')
temp = A*exp(-(x/delta)^2)
temp = integral(temp*exp(-I*k*x),(x,-oo,oo)).simplify()
(delta>0).assume()
(k>0).assume()
(dx>0).assume()
(xi<1).assume()
temp = temp*exp(-I*k*t*v)*exp(-(k^2)*t*v*dx*(1-xi)/2)
temp = integral(temp*exp(I*k*x)/(2*pi),(k,-oo,oo))

and I got the following error message

Condition of type: SIMPLE-CONDITION
Illegal kernel in `adjoin-pvar'
Available restarts:

1. (CONTINUE) Return from BREAK.

Top level.
>

Any idea what's going on?

2013-02-22 04:17:29 +0200 received badge  Scholar (source)
2013-02-22 04:17:29 +0200 marked best answer Saving compiled expressions

I believe that fast_callable produces, and then compiles, C code under the hood; the object you get back from fast_callableis a wrapper around a foreign function call and hence can't be saved and restored by Python/Sage (see http://docs.python.org/2/library/pick...).

On the other hand, you can have Sage (via sympy) generate C code for a function that provides evaluation of your expression on C doubles. I gave a short example of this on this question:

http://ask.sagemath.org/question/366/...

It may also be possible to convert your expression into a python function and send that through the Cython compiler to produce compiled C code with a direct interface in Sage... I don't know if that's possible in your situation or not.

2013-02-22 01:42:15 +0200 received badge  Supporter (source)
2013-02-22 01:40:52 +0200 asked a question Saving compiled expressions

I have a large symbolic expression, such that converting it to fast callable takes more than a minute. After the conversion, evaluation is much faster than the symbolic evaluation. However, I don't know how to save the fast_callable so I could use it in other scripts. When I tried pickling it, I got the following error:

AttributeError: 'sage.ext.interpreters.wrapper_cdf.Wrapper_cdf' object has no attribute 'write'

Using sage's save and load methods, I was able to load it to another scipt, but when I tried to call it I got the ValueError.

Any help would be welcome.

2013-01-01 10:31:08 +0200 received badge  Student (source)
2013-01-01 04:15:48 +0200 asked a question sagenb upload

I'm using sagenb, and I would like to import data from one worksheet to another. Both are on the server. I'm guessing that I should use attach or load commands, but I don't know what path to give them, because the files are not on my computer but on the server.

Thanks in advance