Ask Your Question

candide's profile - activity

2022-09-20 09:57:48 +0200 received badge  Famous Question (source)
2020-12-04 18:04:44 +0200 received badge  Notable Question (source)
2020-08-16 05:59:04 +0200 received badge  Notable Question (source)
2020-06-15 23:42:12 +0200 received badge  Popular Question (source)
2019-08-02 19:18:43 +0200 received badge  Popular Question (source)
2018-10-08 20:43:15 +0200 received badge  Notable Question (source)
2017-11-23 16:29:15 +0200 received badge  Popular Question (source)
2017-11-22 12:47:36 +0200 commented answer Python's Fraction Incompatibility ?

Thanks for your answer. The problem with f=Fraction(int(2), int(3)) is that now some operations are broken, for instance 1*f or f*f. On the other hand, referring to the traceback, I can't figure out why f=Fraction(2,3) causes isinstance(numerator, Rational) to be True since Rational represents an internal Python classe and numerator a Sage int.

2017-11-22 10:12:39 +0200 asked a question Python's Fraction Incompatibility ?

Hi

Sagemath doesn't seem to recognize Fraction from the standard module fractions :

$ sage
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 8.0, Release Date: 2017-07-21                     │
│ Type "notebook()" for the browser-based notebook interface.        │
│ Type "help()" for help.                                            │
└────────────────────────────────────────────────────────────────────┘
sage: from fractions import Fraction 
sage: Fraction
<class 'fractions.Fraction'>
sage: Fraction(2,3)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-3-9755b3988eff> in <module>()
----> 1 Fraction(Integer(2),Integer(3))

 /sage8.0/SageMath/local/lib/python2.7/fractions.pyc in __new__(cls, numerator, denominator)
    152             isinstance(denominator, Rational)):
    153             numerator, denominator = (
--> 154                 numerator.numerator * denominator.denominator,
    155                 denominator.numerator * numerator.denominator
    156                 )

TypeError: unsupported operand type(s) for *: 'builtin_function_or_method' and 'builtin_function_or_method'

Any workaround ?

2016-11-16 15:26:18 +0200 commented answer Alternative to piecewise functions?

f(x,a,b) and a<x<b have same value.

2016-11-16 01:38:59 +0200 received badge  Commentator
2016-11-16 01:38:59 +0200 commented answer Unable to modify cell contents

Thanks, I got it but it's counterintuitive, you have to click on the upper cell, line 1 on the screenshot above.

2016-11-15 23:08:57 +0200 asked a question Unable to modify cell contents

Hi

Inside a cell within a sagews on SageMathCloud :

%md(hide=True)

# My Title
 blah blah ...

Now the cell outputs nicely w/o Markdown code visible, good. But the code is so well hidden that I cannot modify it ;) What's the tricks please ?

screenshot :image description

2016-11-15 22:43:55 +0200 received badge  Popular Question (source)
2016-11-10 19:36:09 +0200 received badge  Popular Question (source)
2016-11-10 19:36:09 +0200 received badge  Notable Question (source)
2016-11-02 21:11:07 +0200 received badge  Popular Question (source)
2016-11-02 21:11:07 +0200 received badge  Notable Question (source)
2016-09-29 17:14:46 +0200 received badge  Notable Question (source)
2016-03-27 19:09:01 +0200 received badge  Popular Question (source)
2016-03-27 12:57:40 +0200 commented answer range and division : unexpected behavior

Thanks, now the benefits of using srange is more apparent.

2016-03-27 11:28:01 +0200 asked a question range and division : unexpected behavior

Consider the following snippet :

N=5

# code 1
for n in range(N,N+1):
    for k in range(0,n):
        print k/n

print '-'*10

# code 2
n=N
for k in range(0,n):
    print k/n

I was expecting code 1 and code 2 to print the same output. This is not the case :

0
0
0
0
0
----------
0
1/5
2/5
3/5
4/5

In the first case, k/n is Python-evaluated as an integer division, in the second case, k/n is Sage-evaluated as a fraction. Can someone elaborate please ?

I only notice that substituting srange(N,N+1) to range(N,N+1) fixes the problem.

2016-02-22 02:21:14 +0200 commented answer sagews and sws file format specification

Excellent suggestion, thanks!

2016-02-20 16:04:22 +0200 asked a question sagews and sws file format specification

Hi

In order to generate programmaticaly sage worksheet files (using a script) I need to check the sagews/sws formats grammar. Is the specification available somewhere? I need a kind of description similar to the IPython notebook format as described here.

2016-02-20 15:35:45 +0200 commented answer Sagemath cloud user interface

Thanks for your response. OK for (tool|menu)bar removing. On the other hand, what do you mean by command + A (i'm not on mac), what "command" is referring to ? How does mouse cell selection work? Can we select any group of cells not even consecutive?

2016-02-12 00:05:06 +0200 asked a question Sagemath cloud user interface

Hi

I have a lot a trouble with Sagemath Cloud user interface (respect to Sagenote book interface).

Some questions to have a better online experience.

How do you remove toolbar ?

How do you remove menu bar ?

How do you delete all output ?

How do you execute all the code cells ?

How to remove many consecutive cells whatever type they are ? [the later is easily done within the Sage Notebook interface for providing access to the source code in text format by means of a very handy Edit button allowing cutting, pasting or exchanging chunks of a worksheet]

Thanks

2015-11-26 09:14:25 +0200 asked a question Documentation within a single file

Sage documentation is segmented in multiple pdf files. Does the docs provide a single big file we can search in as it was the case some years ago? If not, is it possible to get all the doc files by downloading a single zip file in order to merge the various files with ad hoc pdf tools?

2015-07-06 21:28:46 +0200 commented answer Change name of worksheet in sagemath cloud

The above answer solves the question, thanks. But, in this case Sage ergonomics is poor. The (i) popup explains "Edit to rename" but this message stucked me. And one cannot imagine that the name on the left upper corner can be changed by clicking on it because the name has not a html form appearance.

2015-07-06 21:16:36 +0200 commented question Change name of worksheet in sagemath cloud

I met the same problem.

2015-06-23 10:02:11 +0200 received badge  Self-Learner (source)
2015-06-23 10:02:11 +0200 received badge  Teacher (source)
2015-06-20 15:36:35 +0200 marked best answer Is the R interface identical to R in a R.<x> assignment?

R is a builtin identifier in Sage and refers to the r interface :

sage: R
sage.interfaces.r.R
sage: r
R Interpreter

Now I was wondering if the later R is related to the R letter used in a left hand side assignment for instance :

R.<x> = ZZ[]
2015-06-20 09:50:23 +0200 answered a question Recovering an overwritten Sage built-in name

This previous response gives a clue : the reset function. Passing the variables as a string argument, the reset function allows to selectively restore some Sage global variables in their initial state. Example :

sage: max(2000,2038)
2038
sage: max=42
sage: max(2000,2038)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-3-1c36721a9cff> in <module>()
----> 1 max(Integer(2000),Integer(2038))

TypeError: 'sage.rings.integer.Integer' object is not callable
sage: I=42
sage: reset("max I")
sage: I*I
-1
sage: max(2000,2038)
2038
2015-06-20 01:28:37 +0200 received badge  Supporter (source)
2015-06-20 01:19:49 +0200 asked a question Recovering an overwritten Sage built-in name

In Python 2.7, if you accidentally overwrite a builtin name (eg max, str, int, ...), you can recover it by calling the __builtins__ module :

>>> max(2020, 42)
2020
>>> max=2038
>>> max(2020, 42)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'int' object is not callable
>>> max=__builtins__.max
>>> max(2020, 42)
2020
>>>

What is the equivalent for Sage built-in names (there are about 2000 so accident can occur) ? For instance, imagine I overwrite the complex number I :

sage: I=42

How can I recover it ?

2015-06-20 00:44:57 +0200 commented answer get the coefficients from the Polynomial

Useful option. Doesn't exist in Sage 5.8.