Ask Your Question

SLOtoSF's profile - activity

2021-03-09 11:08:46 +0200 received badge  Famous Question (source)
2020-09-24 17:36:28 +0200 received badge  Notable Question (source)
2019-03-08 02:12:24 +0200 received badge  Notable Question (source)
2019-03-02 20:21:34 +0200 received badge  Famous Question (source)
2018-11-02 14:41:56 +0200 received badge  Notable Question (source)
2018-05-30 11:20:04 +0200 received badge  Popular Question (source)
2018-03-30 17:15:54 +0200 received badge  Notable Question (source)
2018-01-16 15:17:06 +0200 received badge  Popular Question (source)
2017-05-31 15:48:42 +0200 received badge  Notable Question (source)
2016-09-02 00:08:27 +0200 received badge  Popular Question (source)
2016-05-23 20:42:20 +0200 received badge  Notable Question (source)
2016-05-23 20:42:20 +0200 received badge  Popular Question (source)
2016-02-26 07:29:45 +0200 received badge  Taxonomist
2015-03-27 04:12:17 +0200 marked best answer Comparing objects in Python
sage: R = ZZ
sage: S = ZZ
sage: R == S

No really this comes up as "True", but for my class which I derived from the Ring Class, something like this comes up as False. How can I avoid this?

2015-03-27 04:12:17 +0200 marked best answer Object Persistence

Is Object Persistence faster than just recreating the object? Why? And how do I do it, what are the steps? I read this:, but am unclear about the parameters and how it works. Does this object only get associated with me as a user of the notebook, or can I share this object with other users (like if want to explore the properties of a clique graph on 20 nodes, which took 20 minutes to construct, how can I make that available to others?)

Sorry for all the questions, primarily I'm interested in how I can user Object Persistence to make my life easier.

2015-03-27 04:12:17 +0200 marked best answer is a parent like a set?

Does a parent function like a set? I would like to create a ring with elements which are sets and then place those elements into a matrix so that I can perform certain assigned operations on those elements.

2015-03-27 04:12:16 +0200 marked best answer strings and other objects in matrices


Rather than me starting by creating a thin wrapper around a list of lists and calling it a SpecialMatrix, does anyone have any ideas creating SpecialMatrix class deriving from some base matrix class such that I can load up the matrix with objects in the entries?

Ultimately I would not like to recreate matrix addition and matrix multiplication and instead leverage what's currently in existence.

In the documentation, it specifically says it can pull callable objects. Any tips?


2015-03-27 04:12:15 +0200 marked best answer Creating Element Classes

Hi! I want to be able to create elements, and want their parents to be elements, so I've been reading this page:

The example shows Cython commands it seems (cdef v def).... Why? Couldn't I just do this in Python?

Excerpt from page cited above.

Elements typically define a method _new_c, e.g.,

cdef _new_c(self, defining data): cdef FreeModuleElement_generic_dense x x = PY_NEW(FreeModuleElement_generic_dense) x._parent = self._parent x._entries = v

2015-03-27 04:12:15 +0200 marked best answer Is there a general place for education materials on Sage Development?

Worksheets are fantastic. Is there a central repository for such a thing?

2015-03-27 04:11:54 +0200 marked best answer Getting Started With First Project

Hi! I am trying to get started using Sage. I've read through python tutorials and feel comfortable with the command line. I want to create functions, classes, etc for a particular project I'm starting with. Unfortunately I am completely stuck when it comes to the basics of starting a project: This means that I want to have a folder in SAGE_ROOT which is the title of my project. I want to have a set of .sage files and ultimately want to load them in memory so that I can use them in the sage: command line.

Any tips? Any links? I have read through the documentation but found nothing that would help me with the step-by-step.

2015-03-27 04:11:41 +0200 marked best answer make class iterable

How do I make a class iterable?

I want to create a class, which is a set of objects that I created, that has attributes of its own.

The user experience I am thinking of is the following:

(let's say A, B, and C are Objects in memory)

sage: D = Box((A,B,C))

I want to be able to say for i in D: ....

But I can't.

Any tips?

2015-03-27 04:08:52 +0200 marked best answer _zero_element()

I have a Ring R which I made and a method to return the zero element of that ring.

I want to be able to type R(0) and have it return the zero element.

I have tried, and it works if I call the method directly, but not if I use R(0). Any tips?

class MyRing(Ring): .... def _zero_element(self): return ......

2015-03-27 04:08:51 +0200 marked best answer Implementing a new Ring and its elements.


Say I have a class which I defined as class MyRing(Ring): ...

And another class which I defined as: class MyRingElements(SageObject): ...

I've read the material on Coercion so that I can create the operations of + and * on my ring, but what do I have to do to MyRingElements or MyRing to let them know who their parents and elements are?


2015-03-27 04:08:48 +0200 marked best answer What is the difference between dense and sparse matrices?

And when would I use which?

2015-03-27 04:08:47 +0200 marked best answer Fixed Column Width

Say I have two lists a and b: a = [1,'boy','tree'] and b = ['mathematics','is','fun'].

How can I display this evenly spaced like below? (can someone please edit the below so that there is actually evenly spaced columns, as the editor is deleting the spacing)

1           boy     tree
mathematics is      fun
2015-03-27 04:08:47 +0200 marked best answer Matrix Multiplication

Where would I look in the source code (the specific file) to see where matrix multiplication is defined? I want to create my own matrix class so that I can override this definition with something of my own.

2015-03-27 04:08:47 +0200 marked best answer Unique Representation

Please explain why the following output is as so. How is it possible for id's not to match but the names to be equal?

sage: SP = SetPartitions(5)
sage: a = SetPartitions(5).random_element()
sage: a
{{2, 3, 4, 5}, {1}}
sage: id(a)
sage: a in SetPartitions(5)
sage: a in SP
sage: print id(SP); print id(SetPartitions(5))
sage: SP == SetPartitions(5)
2015-03-27 04:08:45 +0200 marked best answer python file in package not working, not recognizing "integrate" method, why?

Hi! I have spent more than 40 hours figuring out how to install linux, then sage (from source), and even got a github account going for a new project.

I have a python file which only has the text:

def testThis(): var('x') return integrate(x,x)

But I am getting an error about the var command. If i remove it then it doesn't even recognize the integrate command.

What do I need to do in order for sage to recognize these commands? They work in sage, but why won't they work in python?

Many Thanks! I can't wait to actually start programming!

2015-03-27 04:08:38 +0200 marked best answer Why would someone use .sage vs .py?

Why would someone use .sage vs .py? What's recommended? What are the pros and cons? There are questions people ask like: "This can be done in Sage but I can't do it in my python file?" Why would they do anything in python if they could just do it in Sage?

2015-03-27 04:07:16 +0200 marked best answer comparing in Python

I have the following function defined on a class:

def __eq__(self,other):
        return self.get_object() == other.get_object() and str(self.get_genfunc()) ==


When I use __cmp__ I get something weird.... What is the difference between cmp and eq?

2014-11-28 20:27:17 +0200 received badge  Popular Question (source)
2014-08-19 19:23:55 +0200 received badge  Popular Question (source)
2014-06-29 21:16:53 +0200 received badge  Famous Question (source)
2014-06-29 21:16:53 +0200 received badge  Notable Question (source)
2014-06-29 21:16:53 +0200 received badge  Popular Question (source)
2014-06-29 21:08:10 +0200 received badge  Famous Question (source)
2014-06-29 21:08:10 +0200 received badge  Notable Question (source)
2014-06-29 21:08:10 +0200 received badge  Popular Question (source)
2014-06-29 03:15:29 +0200 marked best answer Does Sage have GUI capabilities?

I would like to be able to construct two sets of objects, and use the Sage Notebook display a list of the objects in each set (representing them with the __repr__ special method).

Let d = dict().

Then I would like to click on an object in one of the sets (say object a, click on an object in the other set, b), and those two clicks and a button click signifies d[a] = b.

I guess I am asking for a user-friendly way to do this.

2014-06-29 03:15:28 +0200 marked best answer Constructing a Ring of sets?

How can I create a class which derives from RingElement and Set?

It seems I get the standard:

TypeError: Error when calling the metaclass bases
    multiple bases have instance lay-out conflict
2014-06-29 03:15:28 +0200 marked best answer Set vs set

I am trying to create a class deriving from set or Set because I would like to tack on various attributes to this set based on its elements.

What is the best way to do this? What is the difference between Set and set?

I've posted another question asking how to make a ring of sets.

I understand how to make a ring, but when I try to make a Ring Element I get a base class issue.

Any help in this area is appreciated.

2014-06-29 03:15:27 +0200 marked best answer Do I have to restart the notebook everytime I build Sage?

What I mean is, when I am developing changes that do not affect the notebook, and then I build sage, and I quit and restart a worksheet, the built changes seem to register. I wanted to know whether I could count on this.

Also, is it 'okay' to run sage in command line in another ssh session and keep the notebook running?

2014-06-29 03:15:27 +0200 marked best answer Where is the Inverse feature in FiniteSetMaps??

Say I have defined a map f within the set of maps FiniteSetMaps....

It's great that I can do things like: f.domain(), f.codomain(), f.image_set(), f.getimage().

But how do I take the inverse? Is that feature not present? Is it in the roadmap?


2014-06-29 03:15:27 +0200 marked best answer comparing Expressions in python


I have an Expression I want to compare:

x+y == x+y

But this does not return True. Why?