Ask Your Question

candide's profile - activity

2020-08-15 22:59:04 -0600 received badge  Notable Question (source)
2020-06-15 16:42:12 -0600 received badge  Popular Question (source)
2019-08-02 12:18:43 -0600 received badge  Popular Question (source)
2018-10-08 13:43:15 -0600 received badge  Notable Question (source)
2017-11-23 09:29:15 -0600 received badge  Popular Question (source)
2017-11-22 05:47:36 -0600 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 03:12:39 -0600 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 08:26:18 -0600 commented answer Alternative to piecewise functions?

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

2016-11-15 18:38:59 -0600 received badge  Commentator
2016-11-15 18:38:59 -0600 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 16:08:57 -0600 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 15:43:55 -0600 received badge  Popular Question (source)
2016-11-10 12:36:09 -0600 received badge  Notable Question (source)
2016-11-10 12:36:09 -0600 received badge  Popular Question (source)
2016-11-02 15:11:07 -0600 received badge  Notable Question (source)
2016-11-02 15:11:07 -0600 received badge  Popular Question (source)
2016-09-29 10:14:46 -0600 received badge  Notable Question (source)
2016-03-27 12:09:01 -0600 received badge  Popular Question (source)
2016-03-27 05:57:40 -0600 commented answer range and division : unexpected behavior

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

2016-03-27 04:28:01 -0600 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-21 19:21:14 -0600 commented answer sagews and sws file format specification

Excellent suggestion, thanks!

2016-02-20 09:04:22 -0600 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 08:35:45 -0600 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-11 17:05:06 -0600 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 02:14:25 -0600 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 14:28:46 -0600 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 14:16:36 -0600 commented question Change name of worksheet in sagemath cloud

I met the same problem.

2015-06-23 03:02:11 -0600 received badge  Self-Learner (source)
2015-06-23 03:02:11 -0600 received badge  Teacher (source)
2015-06-20 02:50:23 -0600 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-19 18:28:37 -0600 received badge  Supporter (source)
2015-06-19 18:19:49 -0600 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-19 17:44:57 -0600 commented answer get the coefficients from the Polynomial

Useful option. Doesn't exist in Sage 5.8.

2015-06-19 16:05:55 -0600 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-19 16:05:09 -0600 commented answer Is the R interface identical to R in a R.<x> assignment?

Thanks, I didn't realize that the R.<x> assignment rebinds R to a polynomial ring. But, as you can check, the docs misleadingly build polynomial ring generator with the syntax R.<some_id>, (nearly) always with the R name in such a way I thought that the letter R was mandatory. This is not true since S.<x> is valid and create a new binding from S to a polynomial ring. In fact, what your response just explains is the non-negligible difference between Python syntax and Sage syntax (I imagine, due to the Sage preprocessor). In Python, R.<x> raises a syntax error. And worse, in Python R.attr always refers to an R attribute (not the case here with Sage) and doesn't bind or rebind R. I consider the R.<x> as an unfortunate choice (the is no attribute setting) and R<x> would have been clearer.