Ask Your Question

Sammy Black's profile - activity

2022-02-07 13:46:05 +0200 received badge  Notable Question (source)
2019-08-02 14:20:07 +0200 received badge  Popular Question (source)
2019-06-25 22:17:59 +0200 received badge  Nice Question (source)
2018-09-19 04:51:00 +0200 received badge  Notable Question (source)
2018-09-19 04:51:00 +0200 received badge  Famous Question (source)
2017-08-04 17:40:40 +0200 received badge  Notable Question (source)
2017-08-04 17:40:40 +0200 received badge  Popular Question (source)
2014-06-29 03:14:24 +0200 marked best answer How do instantiate a new class properly?

Background

I have created a new class FeynmanGraph that is a subclass of Graph. It has some extra methods, and the module in which it lives also has some extra functions. The most important method for my purposes searches for possible colorings of the vertices that satisfy certain combinatorial criteria that have to do with spanning trees. (The details are not important here.)

The code works. I should mention that I'm editing feynman.sage in a text editor and attaching it to a sage session in a terminal. Once a I create an instance of the class via

G = FeynmanGraph(...)

everything seems to work.

Now, I created a module in which I would like to define specific graphs, with specific labeling of the vertices and edges, as well as plot positioning information. Shouldn't I be able to import the module feynman and make definitions such as the following?

from feynman import *
def FatY(): # a particular graph
    G = FeynmanGraph(...)
    ...
    return G

When I do this, the methods for FeynmanGraph raise all kinds of errors of the type where they don't recognize various functions, such as max or partitions_set.

Question

How do I structure the modules and classes so that I can instantiate the class properly?

2014-05-13 21:48:03 +0200 received badge  Good Question (source)
2013-08-05 14:44:09 +0200 received badge  Famous Question (source)
2013-05-12 19:42:56 +0200 marked best answer Why does graph minor not work with multiple edges?

I would say that if you split all edges of both graph by adding adding a new vertex b joined to a and c where there was an edge from a to c (this is a way to transform a graph with multiple edges into a normal graph), then checking that one is a minor of the other would give you the good definition.

I expect it to be slower, though.

And the explanation to your question "why aren't multiple edges considered by the minor function" is very easy and natural : why should it ? Things get implemented if somebody who cares about them takes the time to do it. Otherwise, they are not implemented.

Nathann

2013-05-12 19:42:50 +0200 commented answer Why does graph minor not work with multiple edges?

Yeah. I had already done that, but it was too slow. Thank you, though.

2013-05-11 21:30:09 +0200 asked a question Why does graph minor not work with multiple edges?

When $H$ has multiple edges, and we ask whether it is a minor of another graph $G$, using the method:

G.minor(H)

the multiple edges are ignored. As a result, it can return True, when $H$ is not actually a minor of $G$.

Here is a small example of this incorrect behavior.


Let $H$ be a triangle with a double edge, and let $G$ be a square. Clearly, $H$ is not a minor of $G$.

H = Graph()
H.allow_multiple_edges(True)
H.add_edges([(0,1), (0,1), (0,2), (1,2)])

G = Graph()
G.allow_multiple_edges(True)
G.add_edges([(0,1), (0,3), (1,2), (2,3)])

G.minor(H)

The output is:

{0: [0], 1: [1], 2: [2, 3]}

Is there a work-around?

2013-04-08 03:42:41 +0200 received badge  Popular Question (source)
2012-12-04 12:55:31 +0200 received badge  Nice Question (source)
2012-09-13 18:31:22 +0200 received badge  Notable Question (source)
2012-05-16 18:20:50 +0200 received badge  Nice Question (source)
2012-01-28 04:10:02 +0200 received badge  Popular Question (source)
2011-07-14 19:51:46 +0200 marked best answer How do I display the full output that includes graphics?

Try writing your output to an html file. Do something like:

f=open('myoutput.html','w')
f.write(some output)
f.write(some more output)
f.close()

That file should appear as a link in the output of the cell. If you click on the link, you should see your output as an html file.

2011-07-14 19:49:51 +0200 marked best answer Upgrade sage: build from sources?

I have never build sage from source. It is useful only if you plan on working on the development of sage or modify the source code. Your notebooks are not stored in sage directory but home. So you can just delete the present version, download sage 4.7 and install the binaries. That should work for most users.

2011-07-13 18:16:37 +0200 asked a question Upgrade sage: build from sources?

I'm using an older version of Sage (4.5.3) in Ubuntu 10.04. I like it, but I'd like to upgrade to a more recent version. From the command prompt, calling

$ sage -upgrade

throws a scary warning at me:

 ** WARNING: This is a source-based upgrade, which could take hours,
 ** fail, and render your Sage install useless!! This is a binary
 ** install, so upgrading in place is *not* recommended unless you are
 ** an expert.  Please consider installing a new binary from
 ** http://sagemath.org instead.

Question: Is there really a significant advantage to building the binaries from source?

I am running a Sony Vaio laptop on 4 2.13 GHz Intel cores. (I can specify more stats if it helps somebody to give me good advice.)

2011-03-30 21:36:28 +0200 commented question subsets with condition

You can create a set out of a list L with S = set(L). It will eliminate duplicates, and ignore the order. (You see the set elements sorted.) The set S has methods that impliment various set-theoretic operations. Type S.<tab> to see possibilities, such as S.intersect(T) which returns a the intersection of sets S and T.

2011-03-30 20:59:24 +0200 asked a question How do I display the full output that includes graphics?

Background

I am working in the notebook GUI.

I have code that produces graphics (.png files) to display arrays with colors satisfying certain combinatorial criteria. When the output gets too long, Sage returns the message

WARNING: Output truncated!
full_output.txt

The .txt file contains some html code, but doesn't display in a web browser.

Question

How do I see my graphical arrays?

2011-03-21 20:27:54 +0200 received badge  Nice Question (source)
2011-03-21 16:59:31 +0200 commented answer Why does graph plotting crop so aggressively, and what is a work-around?

Thanks. I wasn't using the keyword `axes_pad` explicitly, but rather trying to hack the `graph_plot.py` module. This works.

2011-03-21 16:57:57 +0200 marked best answer Why does graph plotting crop so aggressively, and what is a work-around?

Try this:

sage: g1 = Graph({0:{1:'a'}, 1:{2:'b'}, 2:{0:'c'}})
sage: g2 = Graph({0:{1:'a'}, 1:{2:'b'}, 2:{3:'c'}, 3:{0:'d'}})
sage: G = graphics_array([g1.plot(), g2.plot()])
sage: G.show(axes_pad=0.1)
2011-03-21 16:57:42 +0200 commented question Why does graph plotting crop so aggressively, and what is a work-around?

@benjaminfjones: I am using 4.5.3. Perhaps it's time for an upgrade. :)

2011-03-21 14:00:06 +0200 asked a question Why does graph plotting crop so aggressively, and what is a work-around?

Surely, the Sage community is aware of this bug. For example, there is this ticket, in which the problem is supposed to be fixed. But it's not!

A patch is described: in sage/graphs/graph_plot.py we can add the line(?)

G._extra_kwds['axes_pad']=.05

Am I to change this value in order to fix this over-zealous cropping behavior? No matter what I do, in this regard, I still end up with graph vertices partially cut off.

What's the easy work-around? I would like to be able to plot graphics_array objects with several graphs (with their vertices clearly shown!).

(http://trac.sagemath.org/sage_trac/ti...)

2011-03-21 03:32:25 +0200 commented answer How do instantiate a new class properly?

Thanks, Felix. I should have mentioned that I was still having problems even when I renamed it `feynman.py`. I was just trying to mimic the style built into the various Sage (python) modules.

2011-03-21 03:30:20 +0200 marked best answer How do instantiate a new class properly?

Instead of "from feynman import *", try "attach feynman.sage" - my guess is that if you use the from ... import syntax then the .sage file is treated like a .py file rather than sage code.

2011-03-21 03:30:20 +0200 received badge  Scholar (source)
2011-03-21 03:30:19 +0200 received badge  Supporter (source)
2011-03-19 04:11:10 +0200 received badge  Student (source)