Improving Computational Topology in Sage (Knots or Persistent Homology)

539 views
Skip to first unread message

aesil...@gmail.com

unread,
Feb 26, 2014, 9:44:41 PM2/26/14
to sage...@googlegroups.com
Just saw the GSOC announcement - awesome stuff!

My name is Andrew Silver, I'm an undergraduate mathematics major at the University of Florida (Gainseville, FL).
I currently do numerical/statistical work in computer vision: I'm comfortable in C++, familiar with Java, HTML5, Javascript, and recently Sage/Python.

This semester I was lucky enough to get into a graduate course in Computational Topology (Topological Data Analysis), and I'm hooked.

Why Sage? I compiled Sage as soon as my prof gave us a long hw assignment that involved computing homology of a torus, klein bottle, and the Real Projective Plane...
..based on triangulations that had 27x18 boundary matrices we had to get in smith form... (I actually found a bug in matrices mod 2 that I have a ticket open for, just got to write up some doctests and it should be fixed). I used Sage instead of Matlab because I couldn't figure out how to get Matlab to save the u,v matrices - open source is the way to go.

What do I want to do? I'd love to work on implementing knots/links as per ( https://docs.google.com/document/d/15v7lXZR1U4H2pT21d2fyPduYGb74JAFjkXJ6CWYmYfw/pub#h.6l9ekqoc9br7 ), writing classes, functions, invariants, etc. A potential caveat is how much we want to "reinvent the wheel" because there are already existing implementations in other packages for some of these things.

If there isn't enough work there, I'd also be interested in integrating Stanford's computational topology tools into Sage (http://comptop.stanford.edu/programs/) for persistent homology calculations. Dr. Carlsson (Stanford) gave a talk at UF this week and told me that the tools are still under development, so it would probably be a matter of getting permission if the community wants to go this route. Or we could start from scratch. I'm thinking Persistence Diagrams, Barcodes, witness complexes, etc.

Other math exposure:
Linear Algebra
Introductory Probability
Calc I - III
Discrete Mathematics

Why do I want to do this?
If I don't contribute to Sage, I'd be implementing algorithms for my research anyway. Might as well share them with other people!

github that I contribute to when I have time: https://github.com. You can reach me by email at aesil...@gmail.com


Miguel Angel Marco

unread,
Feb 27, 2014, 5:07:07 AM2/27/14
to sage...@googlegroups.com
Welcome,

i am very happy that you have interest in participating in this project. From what i know, persistent homology does not fit really in the knot theory work (even though it would also be a nice addition). I agree with you that one of the first things we should do is to clarify which external software can be used, to wrap it instead of rewriting. Although, it might be tricky, some of this software is not maintained anymore, or has some limitations. So it could be the case that, even if there exists some external software to do the job, rewriting it in sage/cython would be a better option. That's why a part of the work should be to go through this available software and check how well it would fit for our purposes.

If you feel that writing the knot/link class is not enough work, i would also suggest to write an interactive knot editor (following the idea of the graph editor, although, if possible, i would really like something like the knotplot editor) for the notebook. I really don't know much about javascript, so i cannot tell how much work it would take. Anyways, it could perfectly be a separate project.

If you have any further questions, please ask.

Dima Pasechnik

unread,
Feb 27, 2014, 9:44:38 AM2/27/14
to sage...@googlegroups.com
On 2014-02-27, Miguel Angel Marco <miguel....@gmail.com> wrote:
> Welcome,
>
> i am very happy that you have interest in participating in this project.
> From what i know, persistent homology does not fit really in the knot
> theory work (even though it would also be a nice addition). I agree with
> you that one of the first things we should do is to clarify which external
> software can be used, to wrap it instead of rewriting. Although, it might
> be tricky, some of this software is not maintained anymore, or has some
> limitations. So it could be the case that, even if there exists some
> external software to do the job, rewriting it in sage/cython would be a
> better option. That's why a part of the work should be to go through this
> available software and check how well it would fit for our purposes.
>
> If you feel that writing the knot/link class is not enough work, i would
> also suggest to write an interactive knot editor (following the idea of the
> graph editor, although, if possible, i would really like something like the
> knotplot editor) for the notebook. I really don't know much about
> javascript, so i cannot tell how much work it would take. Anyways, it could
> perfectly be a separate project.

IMHO a good and timely project would be knot recognition, a la
knotscape. It seems that the only present alternatives to knotscape
are Mathematica packages. Knotscape also computes polynomial invariants, so this
would be a nice feature to get them properly as polynomials rather
than as lists of coefficients...

Incorporating parts of knotscape into Sage looks doable, as this is
plain C code. True that it is old, but this does not make it less
viable.

Dima




>
> If you have any further questions, please ask.
>
> El jueves, 27 de febrero de 2014 03:44:41 UTC+1, aesil...@gmail.com
> escribió:
>>
>> Just saw the GSOC announcement - awesome stuff!
>>
>> My name is Andrew Silver, I'm an undergraduate mathematics major at the
>> University of Florida (Gainseville, FL).
>> I currently do numerical/statistical work in computer vision: I'm
>> comfortable in C++, familiar with Java, HTML5, Javascript, and recently
>> Sage/Python.
>>
>> This semester I was lucky enough to get into a graduate course in
>> Computational Topology (Topological Data Analysis), and I'm hooked.
>>
>> Why Sage? I compiled Sage as soon as my prof gave us a long hw assignment
>> that involved computing homology of a torus, klein bottle, and the Real
>> Projective Plane...
>> ..based on triangulations that had 27x18 boundary matrices we had to get
>> in smith form... (I actually found a bug in matrices mod 2 that I have a
>> ticket open for, just got to write up some doctests and it should be
>> fixed). I used Sage instead of Matlab because I couldn't figure out how to
>> get Matlab to save the u,v matrices - open source is the way to go.
>>
>> What do I want to do? I'd love to work on implementing knots/links as per
>> (
>> https://docs.google.com/document/d/15v7lXZR1U4H2pT21d2fyPduYGb74JAFjkXJ6CWYmYfw/pub#h.6l9ekqoc9br7), writing classes, functions, invariants, etc. A potential caveat is how
>> much we want to "reinvent the wheel" because there are already existing
>> implementations in other packages for some of these things.
>>
>> If there isn't enough work there, I'd also be interested in integrating
>> Stanford's computational topology tools into Sage (
>> http://comptop.stanford.edu/programs/) for persistent homology
>> calculations. Dr. Carlsson (Stanford) gave a talk at UF this week and told
>> me that the tools are still under development, so it would probably be a
>> matter of getting permission if the community wants to go this route. Or we
>> could start from scratch. I'm thinking Persistence Diagrams, Barcodes,
>> witness complexes, etc.
>>
>> Other math exposure:
>> Linear Algebra
>> Introductory Probability
>> Calc I - III
>> Discrete Mathematics
>>
>> Why do I want to do this?
>> If I don't contribute to Sage, I'd be implementing algorithms for my
>> research anyway. Might as well share them with other people!
>>
>> github that I contribute to when I have time: https://github.com. You can
>> reach me by email at aesil...@gmail.com <javascript:>
>>
>>
>>
>

Amit Jamadagni

unread,
Feb 27, 2014, 10:05:18 AM2/27/14
to sage...@googlegroups.com
Hello,
        I have been going through the documentation and have following the discussion on sage-devel. I have this doubt of how the input for a specific calculation will be given. For example we have a  trefoil knot, then if the user inputs this we can return back the various invariants or various other properties. But that is being identified by name, how can we make it more general. One idea I have in mind is the braid word implementation or can we use tables as they have used. But I still am unclear on how an user would input a specific knot. Any help on this would be really great. Thanks.

Amit.


>>
>>
>>
>

--
You received this message because you are subscribed to the Google Groups "sage-gsoc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sage-gsoc+...@googlegroups.com.
To post to this group, send email to sage...@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-gsoc.
For more options, visit https://groups.google.com/groups/opt_out.

Dima Pasechnik

unread,
Feb 27, 2014, 10:12:55 AM2/27/14
to sage...@googlegroups.com
On 2014-02-27, Amit Jamadagni <bitsja...@gmail.com> wrote:
> Hello,
> I have been going through the documentation and have following the
> discussion on sage-devel. I have this doubt of how the input for a specific
> calculation will be given. For example we have a trefoil knot, then if the
> user inputs this we can return back the various invariants or various other
> properties. But that is being identified by name, how can we make it more
> general. One idea I have in mind is the braid word implementation or can we
> use tables as they have used. But I still am unclear on how an user would
> input a specific knot. Any help on this would be really great. Thanks.

try out knotscape: here it is patched so that it builds on modern
Linux/OSX:

https://github.com/dimpase/knotscap

(I only tested on OSX 10.6.8, do not forget to modify the knotscape
script to spacify the location)

There are examples how to enter knots...

Dima

Miguel Angel Marco

unread,
Feb 27, 2014, 12:57:52 PM2/27/14
to sage...@googlegroups.com
There are several options for the user to enter a knot/link:

1) As a braid closure, as you mentioned.
2) By means of a Gauss code,  Dowker-Thistlethwaite Notation or some other similar codification of its planar diagram. For example, there is a way to codify a link diagram as a planar representation of a graph.
3) By a list of three dimensional vertices that determine a piecewise linear curve (or several of them, if we are talking about links). In principle it could also be done by better aproximations of the curve (splines or bezier curves), but i think for this purpose just piecewise linear is fine. This kind of input would be important if we want it to be usable over real world problems, since it is sometimes the case that the knot is obtained from experimental data. There is a R package that works with this kind of input [1]. 
4) If an interactive editor is integrated in the notebook (like the graph editor for example), by drawing it.


One of the goals of the project would be to translate between this different possible representations.

Miguel Angel Marco

unread,
Feb 27, 2014, 1:01:56 PM2/27/14
to sage...@googlegroups.com
Maybe making a c library out of knotscape, interfacing it and wrap it in a class would be a good way to approach this project. But then again, there are more software available for similar tasks. Comparing and choosing the best option could also be interesting.

Amit Jamadagni

unread,
Feb 27, 2014, 1:12:39 PM2/27/14
to sage...@googlegroups.com
Yes, I was thinking of converting the braid words to DT codes and then once this is achieved we can get the Alexander's polynomial (this was achieved in knotaltas) and I guess if one of the invariants is obtained converting them into others might not be a heavy task(I am not completely sure of the algorithms though but I guess this can be achieved). I have gone through knotscape (not completely though) and have started working on converting given braid word representation into DT codes for a start. 


Miguel Angel Marco

unread,
Feb 27, 2014, 3:34:39 PM2/27/14
to sage...@googlegroups.com
Alexander polynomial can be computed directly from the braid expression. It would also be good to have different methods to compute the invariants from dofferent representations.

aesil...@gmail.com

unread,
Mar 2, 2014, 12:17:25 AM3/2/14
to sage...@googlegroups.com
Yeah, persistent homology would be a separate issue. I can understand if you don't want to take on a second project! It looks like Amit here is already pretty deep into the implementation for knots, so maybe the editor is better. Unless you don't mind collaborating on both, Amit?  

We should start figuring out the schedule/tasks part of the proposal.

Amit Jamadagni

unread,
Mar 2, 2014, 2:56:35 AM3/2/14
to sage...@googlegroups.com
Hello,
I had started with a sample implementation of braid word to DTcode and I had to take a break from it as my semester terminal exams started and would be working on after I am done with it which would be 2 days from now. Coming to the proposal I still have to figure out with more accuracy the things that could be implemented, even though I guess I have the main idea I need to structure it with the right algorithms and implementation details. So if once that is done then it would be give me a more clear idea of what could compliment each others work to bring the editor to life (In sense we start working on the constructing the base of two different things and at the end use each others work to complete the project) . Hoping to discuss this as soon as I am done with the terminal exams. Thanks.  


Miguel Angel Marco

unread,
Mar 2, 2014, 5:00:29 AM3/2/14
to sage...@googlegroups.com
Just a comment, i don't have the abilities to be a mentor of a javascript editor. But i guess we could find someone that can.

Amit Jamadagni

unread,
Mar 4, 2014, 3:35:41 PM3/4/14
to sage...@googlegroups.com
Hello,
       As I mentioned I have started with the implementation but stuck mid way, Knotscape is using tables if I am not wrong and so is KnotAtlas but there has been no reference to any algorithms. And coming to the implementation of fox derivatives we cant expect the user to give me a large word if its a huge knot. It would be of great help if some reference to the algorithmic implementation is provided. I have searched through web to the best of my efforts for implementation through gauss codes, vogel's algorithm but there seems to be no computer algebraic to it. Thanks. 

Amit Jamadagni

unread,
Mar 7, 2014, 4:50:02 PM3/7/14
to sage...@googlegroups.com
Hello,
        I have gone through [1] and [2] for the implementation of Seifert Matrix. [1] is the pdf containing the algorithm and [2] is the website which has the same kind of implementation. I have created a gist [3] and would be sending in a pull request sooner when I am done with refinements.  [3] calculates only the Seifert Matrix but this could be extended to get the genus and Alexander's polynomial (If I am not wrong this can be done from burau representation but from my understanding there are some issues with generalizing)the braid word which is the input to the program [ [1] has the explanation for the implementation of the above mentioned topics]. I would also like to mention that I would start working on the Vogel's algorithm sooner after everything with [3] is done. Recently I  came across [4] which gives an alternate way of producing the knot diagrams (I still have not tried it out on sage but I guess the material there would work out). I would like to start working on my proposal for SoC and would require help from the community on commenting and refining the ideas. I would also like to know if 2 projects on the same topic would be accepted as there seems to lot of work going onto preparing a graphical version of knots. I request the mentors to look through the attached files. 

[1] http://www.maths.ed.ac.uk/~s0681349/SeifertMatrix/SeifertMatrix.pdf
[2] http://www.maths.ed.ac.uk/~s0681349/SeifertMatrix/#braidnotation
[3] https://gist.github.com/amitjamadagni/9420632 [This is in very initial stage, lots of work has to be done on it]

Miguel Angel Marco

unread,
Mar 8, 2014, 5:14:49 AM3/8/14
to sage...@googlegroups.com
I guess it would be possible to have two different students, one working in the backend and another one in the javascript editor. Bat that would deppend on several things: the number of students that google decides to fund for the sage organization, the quality of the proposals, tha availability of mentors...

I would be happy to answer your questions about your proposal. Just ask.

Amit Jamadagni

unread,
Mar 8, 2014, 5:24:05 AM3/8/14
to sage...@googlegroups.com
Hello,
       Thanks for the reply. It would be helpful if you could post your thoughts on the implementation [3] (I know its in the rudimentary level but I would like to start off there, is there a better way of getting around or it is fine to go on enhancing the current implementation. And it would be valuable if some thoughts were posted on [4]. I have started to draft the proposal, once it gets into a presentable stage I would like your comments on it. 

Amit.


For more options, visit https://groups.google.com/d/optout.

Miguel Angel Marco

unread,
Mar 8, 2014, 10:46:45 AM3/8/14
to sage...@googlegroups.com
I dont think the approach in [4] would be very helpful in our case. It is not clear to me weather every knot can be representad that way, and even if it can, determine the actual parametrization from the combinatorial data contained in a diagram sounds like a really difficult problem. It would be nice to have 3d representations of knots, but that is definitely not the way to go.

About your code in 3, is hard for me to follow exactly what you are doing. What is the matrix b supposed to be? There are also some things that could be done simpler. For instance

new = []
for i in range(len(x)):
    a = abs(x[i])
    new.append(a)

Can be accomplished with

new=map(abs,x)

or 

new=[i.abs() for i in x]

which are both simpler and easyer to read and maintain.


Or also, missing can be computed just as the difference of the set of range(1,sorted[-1]+1) and sorted.

Amit Jamadagni

unread,
Mar 8, 2014, 11:42:22 AM3/8/14
to sage...@googlegroups.com
Thanks for the reply. The matrix b is Seifert Matrix but there has to be lot of simplification as the the answer does not match for all the cases. I am still to get acquainted with Sage matrix methods, so instead I got the rows and initialized every element to zero and then started to manipulate the matrix as per the homology generators algorithm given in the pdf that I attached. I would refine this further and post it back . Thanks for the review.  

Amit Jamadagni

unread,
Mar 10, 2014, 4:26:43 AM3/10/14
to sage...@googlegroups.com
Hello, 
       I have started working on my proposal and I would like to present my ideas of implementation. With my understanding I see two phases to the project one which plays around with various representations and conversion between them and then a separate class of invariants which would form the second phase(But both would be worked on simultaneously, the phase split is only to make two as independent as possible). I would like to start of with the representation part as there seems to be work done with respect to braid groups. We start with the  braid word as the input for the knot and then calculate the Seifert Matrix and then Alexander's polynomial from this matrix. So once an invariant is calculated we can move to the others from this (For reference we can use http://mathworld.wolfram.com/AlexanderPolynomial.html. A list of total implementation of presentation as well as invariants is given in http://www.indiana.edu/~knotinfo/ out of which we can try to achieve as much as possible taking into consideration the feasibility. Then once we are done with the  braid word representation I would like to implement the Vogel's algorithm which takes in the Gauss Code and generates the braid word. So this would be a layer above the initial layer as the user can input either the Gauss Code or Briad word and similarly this would linked to the Invariants class. Gauss code being closely related to DT code we can use the above implementation to generate the DT Code. The presentations which remain are the Planar Diagram presentation, Arc presentations, Conway notation (This is in comparison to http://katlas.org/wiki/The_Mathematica_Package_KnotTheory%60) for which I have to find a way in order to convert between.Finally there is the fox algorithm from which we can move to the Alexander's polynomial. I am yet to see the partial differential implementation in Sage which might be useful for this implementation. This would come under the presentation part. So to summarize it,

                                                  class   Various presentations ==============  class of invariants 
                                                                    |
                                                                    |
                                                       inter conversion between
                                                       one presentation to other ---------------------------- >same here
                                                                    |
                                                                    | 
                                                         More generally this would 
                                                         help in taking the input for ========> This could be extended to present the various diagrams.
                                                         various computations

* I feel taking in the input would be the most difficult part  even though we would provide with a lot of options, I guess user would be more interested in giving in a input which is as compact as possible.

I understand the need to focus more on the invariants and I will try to add (mainly the algorithms) as much as possible in the coming days.

Finally to test the above implementation we can use the already present software which I would like to list in order to what goes for what.

1. For the Siefert Matrix we have the site http://www.maths.ed.ac.uk/~s0681349/SeifertMatrix/#alphabetical
2. For Vogel's algorithm we have the GAP implementation ( I still have to go through this).
3. For braid to DT code we can use knotscape to test the code.

I hope the above outline would take around 4 - 5 weeks with everything in place (Considering the documentation, test cases, code including a part of the invariants). The rest of the remaining weeks if everything goes according to plan would be implementing the other invariants.

I have seen through Spherogram which has a very good implementation of links. I am still in the process of reading the entire material and would integrate parts of it once I am thoroughly done with it.

This is an outline on which I would like to build my proposal. Any comments or further inputs would be of great help in making this project successful.

Amit.  

Miguel Angel Marco

unread,
Mar 10, 2014, 5:46:34 AM3/10/14
to sage...@googlegroups.com
I don't really see why having a separate class for the invariants is better than just having methods in the Link class that produce those invariants. I mean, i think that the user would expect something like:

sage: L=Link("some entry")
sage: type(L)
<class of links>
sage: L.alexander_polynomial()
t^(-1) + 1 + t

No need to have something like:

sage: L=Link("some entry")
sage: type(L)
<class of links>
sage: LI=L.invariants()
sage: type(LI)
<class of link invariants>
sage: LI.alexander_polynomial()
t^(-1) + 1 + t

In spherogram (which is a part of snappy) there is already something similar to that. It can be taken as a basis to start with.

By the way, i do consider that besides gauss/DT codes or braids, another way to enter a knot could be a list of points in space (such that the knot is the piecewise linear curve defined by them). This kind of input can appear in real life applications, so it would be good to give support to it.

Amit Jamadagni

unread,
Mar 10, 2014, 2:58:06 PM3/10/14
to sage...@googlegroups.com
Hello,
     Thanks for the review of the outline. I meant a separate class in the sense we could avoid code duplication to the extent possible. We define a method in the link class for the invariant, when called would refer to the class of invariants rather than defining each invariant for every representation. I guess we can define the invariants for the one kind of representation and any when an invariant is called from the other representation we could convert this into the one where we have the invariant defined and then return the answer.

For example :

We define for the braid word representation and it is easy to get the Alexander polynomial from this. So given any other representation we could convert it to braid word and then get the Alexanders polynomial (So for instance if the user inputs the DT code we can convert it to braid word and then get the invariant from it rather than writing an algorithm to calculate from the given representation, I do not say it is not possible but in some cases, anyways your views on it would be really  helpful) . Similarly if from other presentations we can get some other invariants quickly we can convert the given input to the present one and then get the invariant. 

Amit.

        


--

Miguel Angel Marco

unread,
Mar 11, 2014, 5:16:20 AM3/11/14
to sage...@googlegroups.com
Well we should check in which cases it is faster to convert from one representation to another and then compute the invariant, or directly use another method to compute the invariant from a different representation. My intuition tells me that the traduction between different representations will be very fast compared to the computation of the invariant... but it wouldn't hurt to run some benchmarks.

I don't think that having two different methods to compute, say, the knot group, from the braid representation and from the DT code would really mean a duplication problem: they would be two different methods that do different things. 

Amit Jamadagni

unread,
Mar 12, 2014, 11:04:48 AM3/12/14
to sage...@googlegroups.com
Hello,
      I have drafted a proposal which still has a lot to add, this is in between the totally finished and a rough outline. I would need some reviews and comments on it. Thanks.

https://github.com/amitjamadagni/Knots/wiki/Knot-theory-implementation 

Miguel Angel Marco

unread,
Mar 12, 2014, 4:07:31 PM3/12/14
to sage...@googlegroups.com
At a very first glance, i would like to mention that sage already has a class for braids, so i think it woul be better to have something like this:

sage: B=BraidGroup(2)
sage: b=B([1,1,1])
sage L=Link(b)
...

That way we could also accept gauss/DT codes to create the Link.

Also, i strongly recommend you to take a look at spherogram, since it already implements a class for links. 

Amit Jamadagni

unread,
Mar 12, 2014, 4:15:23 PM3/12/14
to sage...@googlegroups.com
Hello,
         Thanks for the review.  I have seen the braid.py in groups in Sage and would like to make that as a starting point. I will have a look at it and try to bring it in the prototypes. I have also mentioned that it would be my start point. I have started going through Spherogram and would add the inputs from it as well. Any other comments would be really helpful in making it more perfect. Thanks.

Amit Jamadagni

unread,
Mar 12, 2014, 5:03:45 PM3/12/14
to sage...@googlegroups.com
Hello,
        I feel that taking making the inputs discrete class would allow the user to choose over the input rather than always asking him to use the already present braid implementation. Here in this case we can directly call it as braidwords rather than calling the Braid group first and then the braid word presentation and then passing it onto as a input for link. As I have mentioned in the proposal we could have separate classes for Gauss code and DT codes directly allowing the user to work on this. I have just had a view at implementation of Spherogram links, they have taken PD as input and have methods defined for properties of various crossings such as rotation ...(I may be completely wrong here so please correct me). I feel having classes for each representation would give freedom to the user and also calculate more properties relating to the input.  I do not intend to say we must keep it as a separate entity, I would like to mention that we can construct it in such a way that we can have both these approaches working rather than just the approach mentioned, so that the user has the freedom to compute things in a more direct manner. These are my thoughts, but please correct me if I am going wrong. Thanks.

Miguel Angel Marco

unread,
Mar 13, 2014, 5:20:31 AM3/13/14
to sage...@googlegroups.com
I think that, for the user, it makes much more sense to have just one class (Link), that can be created from a braid, a DT code, a Gauss Code, or a list of 3d points. Then it is up to the class init method to initialize the object in different ways deppending on the type of the input. That is, if the input is a braid, then use the procedure to initialize the object from a braid word. If the input has the format of a DT code, then proceed accordingly, and so on. If it is not possible to distinguish from the format of the input, then maybe a keyword could be used, as 

sage:  Link(gauss_code=[-1, 3, -2, 1, -3, 2])

or

sage: Link(dt_code = [4, 8, 10, -14, 2, -16, -18, -6, -12])

and so on. But i definitely not like the idea of the user needing to use different functions to create the same class of objects. Think of what happens with plot, for instance. You can call it on a symbollic expression, a string, a polynomial, a function... and the user doesn't have to care about it. Something similar happens with permutations and many other classes.

For instance, if say, the link is created from a gauss code, then the constructor initializes the atribute _gauss_code and leaves the rest as None. Then, the method to compute the DT code would first check which atributes are already defined, and, if _dt_code is None, compute it from the available atributes, and then initialize _dt_code to its value.

I hope what i wrote makes sense to you.

Amit Jamadagni

unread,
Mar 13, 2014, 4:35:22 PM3/13/14
to sage...@googlegroups.com
Hello,
        Yes I got the idea of what you have mentioned. For an update I have started working on editing my prototype which would make link as the main class. I would update it once I am done with it concretely. Any other comments on the implementation details would be of great help. Thanks. 

Amit Jamadagni

unread,
Mar 14, 2014, 5:43:21 AM3/14/14
to sage...@googlegroups.com
Can we have something like this :

class Link:
        def __init__(self, value, input):
                self.value = value
                self.input = input
                if(self.value == "braidword"):
                        self.a = Braidword()
                if(self.value == "DTCode"):
                        self.b = DTCode

        def braid2dt(self):
                return self.a.braid2dt

class Braidword():
    def braid2dt(self):

    <Other Methods>

class DTCode():
   <Methods>

        Similarly other methods from braidword and dtcode would be get defined under link class and would be called from their respective classes. This would allow the user to have Link as input and as well others (even though others might not be of help, they would act as base classes for link).This would allow particular method from a class and not any method from any class. Everything again here will be discrete, the classes would be retained but Link would be having all the methods from the other representations and in addition some special ones which can be taken from Spherogram. Any comments on this would be helpful. Thanks.


Miguel Angel Marco

unread,
Mar 14, 2014, 9:05:22 AM3/14/14
to sage...@googlegroups.com
I like more something like:

class Link:
    def __init__(self, input=None, gauss_code=None, dt_code=None,...):
        if type(input) == sage.groups.braid.Braid:
            self._braid = braid
            self._gauss_code = None
            self.dt_code = None
        elif gauss_code!=None:
            self._braid = None
            self._gauss_code = gauss_code
            self.dt_code = None 
...          

    def gauss_code(self):
        if self._gauss_code == None:
            self._gauss_code= (code to compute the gauss code from the available data)
       return self._gauss_code


And so on. No need to create classes that the user will not use.

Even, if we decide to use different formats for DT codes and gauss codes, we wouldn't even need to use special parameters, we could see if the input is one or the other by looking into its format.

The main idea is that we will be implementing a few possible representations for a link... but there might be others that could be implemented in the future (polygonal curves in the space, tangles, some kind of codification in a planar graph...). I do not think that creating a class for each representation is a good idea. That would force to touch all the code in the future. 

Maybe it is a matter of personal taste, but i really prefear to have only one class. But if somebody has some other insights, i would like to hear about it. 

Amit Jamadagni

unread,
Mar 15, 2014, 6:11:31 AM3/15/14
to sage...@googlegroups.com
Hello,
        Thanks for the insight and help. I have been working on my prototypes and have tried to add methods for other representations as well. I would like to post it once I am all done with it. Any other comments on the previously posted outline of the proposal would be helpful. It would be great if you could comment on whether I am in the right direction or if not mention the changes so that it would help me in making a good proposal. Thanks.

Miguel Angel Marco

unread,
Mar 15, 2014, 6:59:46 AM3/15/14
to sage...@googlegroups.com
Do you already have a draft of your proposal? I would suggest you to write it in the google melange site. That way we could make comments based on the proposal itself.

Amit Jamadagni

unread,
Mar 15, 2014, 8:13:55 AM3/15/14
to sage...@googlegroups.com
Hello,
I drafted the initial proposal on Github Wiki page (the link which I shared previously and then we had the prototype discussion, sorry as I am unable to provide the link again as I am currently editing the same page) and I would like to mention that I did not post it on melange. I will post it on melange as soon as possible with all the edits. Thanks.

Amit Jamadagni

unread,
Mar 15, 2014, 4:08:12 PM3/15/14
to sage...@googlegroups.com
Hello,
         This is the draft of the proposal https://github.com/amitjamadagni/Knots/wiki/Knot-theory-implementation. Any comments on this would be really helpful. Thanks.

Miguel Angel Marco

unread,
Mar 17, 2014, 8:24:16 AM3/17/14
to sage...@googlegroups.com
I think we shouldn't have methods like GausstoBraid(), but simply a braid() method, that returns the braid representation of the link. It is the duty of the method to check if the braid has been already stored, or to compute it from the available info if not. The user shouldn't need to know how the object was created to determine which methods to call.

Amit Jamadagni

unread,
Mar 17, 2014, 8:38:56 AM3/17/14
to sage...@googlegroups.com
Hello, 
      Thanks for the review. Yeah I agree with what you have mentioned as we are checking in on the input. I would like to know whether everything is going in the right direction with respect to the proposal. I would like to mention that I have already posted my proposal on melange and would edit the necessary. Thanks again for the review.

Miguel Angel Marco

unread,
Mar 17, 2014, 9:15:33 AM3/17/14
to sage...@googlegroups.com
Your proposal seems quite fine to me, except for those details about the design of the prototype. I would suggest you to include also references to spherogram, and stating that its link class could be used as a basis, improving sage integration and documentatio, which would be positive both for sage and spherogram projects. Also, it would be nice if you put in contact with the students proposing to work in the front-end (i.e. the javascript editor) about possible ways to implement the interface between both projects, and include something about it in the proposal.

Amit Jamadagni

unread,
Mar 17, 2014, 1:26:44 PM3/17/14
to sage...@googlegroups.com
Hello,
I would like to thank you for reviewing the proposal. I have edited the prototypes on melange. I need to add the part which uses the link class from Spherogram as the base class. I am working on this and would add as soon as I am done with it.  I have posted on the other google group thread which has the discussion on the implementation of front end, about my proposal so that we could discuss about what can be done from my side to make the total project more complete. Once I get an idea of this then I could include it in my proposal. Thanks. 

Amit Jamadagni

unread,
Mar 18, 2014, 9:47:52 AM3/18/14
to sage...@googlegroups.com
Hello,
      I have worked on my proposal and have done the best I could excluding the extension to javascript editor which still remains as I am yet to discuss it with the fellow students working on it. It would be really great if you comment on the melange page about any improvements that can be done. Thanks.

Amit Jamadagni

unread,
Mar 20, 2014, 11:34:07 AM3/20/14
to sage...@googlegroups.com
Hello,
      Thanks for replying on the proposal posted on melange. Coming to the 3d point presentation, I have this idea, the user inputting the vertices in an ordered way, from this data we can decide whether it is an under crossing or over crossing of the knot and I would like to send this data structure back along with the crossing knowledge for the editor to work upon. I would like to know your thoughts on this. Thanks.

Miguel Angel Marco

unread,
Mar 20, 2014, 4:20:16 PM3/20/14
to sage...@googlegroups.com
I don't understand what you mean. Can you be more explicit?

Amit Jamadagni

unread,
Mar 20, 2014, 4:29:29 PM3/20/14
to sage...@googlegroups.com
Hello,
      There was a reference by you on the 3D input cases to RKnots. I have been going through that. The idea that I would like to propose is the 3d co ordinates would be given in as input, by projecting this into the 2d space and calculating the crossings, we have complete data of how the knot should look and this data would be sent to the front-end. I would like to hear your thoughts on this.
 Referring to the previous thread, the idea was vague and it went something like this, if the user inputs co ordinates in an ordered fashion then by constructing line segments from the ordered data and then predicting which segment is over the other, I thought we could comment on the crossing but that would be tough to implement.  
These are the things I am thinking about right now and also referring to RKnots. 

Miguel Angel Marco

unread,
Mar 21, 2014, 6:01:09 AM3/21/14
to sage...@googlegroups.com
Yes, that is pretty much the idea: use the 3d data as one of the possible representations, writing the appropriate methods to translate from 3d data to gauss code (or DT code, or Braid...) and vice-versa. Of course, all these data can be updated by the editor, but that is another story. Just keep in mind that, among the possible presentations (Gauss, DT, braid...) there should be the 3d curve.

Amit Jamadagni

unread,
Mar 22, 2014, 12:53:55 PM3/22/14
to sage...@googlegroups.com
Hello Miguel,
      Thank you for the review on the proposal. I have included the above mentioned conversion in the proposal and am reading through the necessary contents to get a greater understanding of the implementation details (Mainly the RKnots package, as the initial idea was referred from that).

Amit Jamadagni

unread,
Apr 12, 2014, 3:29:37 PM4/12/14
to sage...@googlegroups.com
Hello Miguel,
      Sorry for not posting back on the progress. I have been a bit busy with the exams at the university and have managed to go through the various implementations in Sage whenever I could find time. I just came across this ticket http://trac.sagemath.org/ticket/15914 which has some related work. I would like to work on this whenever I find time. I would also like to inform that I have been going through Rknots simultaneously and I would be able to discuss the implementation details at a greater depth, in addition to the specifications on the proposal, once I get a comfortable hold on the same.  

Miguel Angel Marco

unread,
Apr 14, 2014, 2:43:21 PM4/14/14
to sage...@googlegroups.com
Ok, i think that what we need from Rknots is mainly the method to compute a combinatorial description (be it a DT code, Gauss code, planar diagram, or braid expression) of the knot from the list of 3d points. 

BTW, have you been able to install rknots inside sage?

Amit Jamadagni

unread,
Apr 15, 2014, 8:56:58 AM4/15/14
to sage...@googlegroups.com
Hello Miguel,
Yes, I was able to install rknots inside Sage. Initially there was a problem with rgl but then I resolved it. I will work around on the options available to strengthen the present ideas i.e., which is more feasible to convert to, among the presentations.

Miguel Angel Marco

unread,
Apr 15, 2014, 5:31:42 PM4/15/14
to sage...@googlegroups.com
Maybe you should take a look at how rknots computes the combinatorial description from the space curves. But if you are not comfortable with the R code, i guess writing the method from scratch would not be that difficult.
...

Amit Jamadagni

unread,
Apr 22, 2014, 12:12:27 AM4/22/14
to sage...@googlegroups.com
Hello Miguel,
             I would like to thank you and the Sage community for having selected me as a student for Google Summer of Code 2014. I am really excited and looking forward to learn and at the same time contribute back to the community by working on this project. :-)

Miguel Angel Marco

unread,
Apr 22, 2014, 6:33:47 AM4/22/14
to sage...@googlegroups.com
Good.

Acording to the schedule, now starts the phase of getting to know each other, read documentation, and get ready for the project. But i think we have already done part of that, so i propose to go deeper into the preparations.

Here are some tasks that you should do:

1)  Create a blog (or a section on an existing blog, or some other way of keeping the community informed of your work) about the project. You should write periodical entries about the project: discuss possible dessign options, ideas that you get from other pieces of software, parts that you code, problems you encounter.... This is not a minor issue. One of the important objectives of the program is to get used develop software as part of a community, and that includes the communication with that community. It will also help in your evaluations. This is not a substitute for technical discussions on the usual  forums (i.e. sage-devel google group).

2) Create a repository for your code on this project. Since sage uses git and guthub, i recommed you to use github. But if you prefear something else, like bitbucket, it is ok.

3) At some point we should start to discuss about how to structure the new code.
...

Miguel Angel Marco

unread,
Apr 22, 2014, 6:38:44 AM4/22/14
to sage...@googlegroups.com
I forgot to say that, instead of am new repository, you can open a trac ticket and use the corresponding branch

Amit Jamadagni

unread,
Apr 22, 2014, 4:38:10 PM4/22/14
to sage...@googlegroups.com
Hello Miguel,
                  Thank you for guiding me on the immediate steps to be taken.
1. I have started setting up the blog on wordpress and will publish my post as soon as possible. I hope to reach the expected standards on this as it forms an important part.
2. I think I am more comfortable with the idea of creating a repo on github rather than going for a trac ticket.(I see some advantages like the commit history more appealing and in line comments on github helpful, I am still not clear whether track has such option of inline comments). It would be really great to hear your views on this.
3. I guess once I am done with the above we will be ready to move forward.
I hope to achieve the above in the coming 1 to 2 days. 


On Tue, Apr 22, 2014 at 4:08 PM, Miguel Angel Marco <miguel....@gmail.com> wrote:
I forgot to say that, instead of am new repository, you can open a trac ticket and use the corresponding branch

Miguel Angel Marco

unread,
Apr 23, 2014, 10:55:48 AM4/23/14
to sage...@googlegroups.com
You have commit history on the track server too. At some point you would have to go through that (since it is the way to get your code merged in sage), so you can either do it now, or work on a separate repo and at the end create the ticket and include the branch there.

Besides, the track ticket allows also a discussion there about it with the rest of the community. But it is up to you, if you feel more comfortable working on a separate repo, and only merging at the end of the project, it is also ok.

About the blog, the most important is too keep the communication in it. That is, to post often about your project. Think of it as if it were a diary of the project.

Harald Schilly

unread,
Apr 23, 2014, 11:57:28 AM4/23/14
to sage...@googlegroups.com
Hello everyone, and yes, thank you for posting this. You almost read my mind ;-)

On Tue, Apr 22, 2014 at 12:33 PM, Miguel Angel Marco
<miguel....@gmail.com> wrote:
> Here are some tasks that you should do:
>
> 1) Create a blog ...

Yes, everyone has to do this. Post a short or longer status update
once a week ... and you can start right now with a nice introduction.
What's also important is to "tag" the postings. For example, in
blogger, wordpress and so on you can add a label like "sage" to your
postings. Then, there is a view of your post where only those postings
associated with that tag "sage" are visible.
Why? I'll add this feed of postings to Sage's community blog:
http://planet.sagemath.org ... where your postings will appear right
next to all the other ones. So, once you have done this, please send
me the blog url and an info about this tag.

>
> 2) Create a repository for your code on this project. Since sage uses git
> and guthub, i recommed you to use github. But if you prefear something else,
> like bitbucket, it is ok.

Yes, Github or a branch on Sage's trac. In case you are working on the
Android app, forking that project is of course the preferred way.

Harald

Amit Jamadagni

unread,
Apr 23, 2014, 1:01:53 PM4/23/14
to sage...@googlegroups.com
Hello Harald, Miguel,
                   I would like to work on a repo and then create a ticket on the trac server once there is sufficient amount of code in there. I guess we can have few intermediate tickets with decent amount of code in it rather than creating a single ticket with bulk code as it would be easy to review. I have tried to setup the blog and here is the link 
https://knotsknotted.wordpress.com/


Amit Jamadagni

unread,
Apr 25, 2014, 3:51:36 AM4/25/14
to sage...@googlegroups.com
Hello Miguel,

Initially I used the following procedure to set the patch 
1. Downloaded the lzma file and untarred it,
2. Then I did a git pull so I get the latest master
3. Then edit the necessary changes, then built it using ./sage -b and tested using ./sage -t, if everything was okay I used to commit onto the trac server.

I had this doubt on setting the repo up.For a start I forked the repo on github and have cloned the sage repo from github onto my local system, I had to run the make file, here are my doubts on this subject:
1. Is running make once enough, in sense after once I have run make can I use ./sage -b after editing the code.  
2. Can I push the binary that I have untarred from the lzma onto github, work on this code and then push intermediate tickets onto the trac server. 

It would be great if you could comment if I am going in the right direction. Thanks.

Miguel Angel Marco

unread,
Apr 25, 2014, 10:07:26 AM4/25/14
to sage...@googlegroups.com
To question 1, yes, you can.
To question 2, i don't see why you would want to do that. Why would you want to push any binary to github?

William Stein

unread,
Apr 25, 2014, 10:16:06 AM4/25/14
to sage...@googlegroups.com
On Fri, Apr 25, 2014 at 7:07 AM, Miguel Angel Marco
<miguel....@gmail.com> wrote:
> To question 1, yes, you can.
> To question 2, i don't see why you would want to do that. Why would you want
> to push any binary to github?

I'm guessing Amit is just confused and really means "can I push the
source code that I got as part of the *binary* [...] to github".
The answer is yes -- it's an unusual core design decision in Sage that
even our "binaries" ship with the git repo, so users can immediately
contribute back changes they make to a "binary".

william
--
William Stein
Professor of Mathematics
University of Washington
http://wstein.org

Amit Jamadagni

unread,
Apr 25, 2014, 5:00:06 PM4/25/14
to sage...@googlegroups.com
Hello William,
          Thanks for the input. That was exactly what I was thinking. I have cloned the git repo, I could not run ./sage directly without running the make file. Where as in the lzma pack I could just extract and get on with the development (after I did a pull). So am I missing something here from the git repo as I could not run. I have cloned this repo https://github.com/sagemath/sage. Thanks for all the help and input.

Dima Pasechnik

unread,
Apr 26, 2014, 10:00:19 AM4/26/14
to sage...@googlegroups.com
On 2014-04-25, Amit Jamadagni <bitsja...@gmail.com> wrote:
> Hello William,
> Thanks for the input. That was exactly what I was thinking. I
> have cloned the git repo, I could not run ./sage directly without running
> the make file. Where as in the lzma pack I could just extract and get on
> with the development (after I did a pull). So am I missing something here
> from the git repo as I could not run. I have cloned this repo
> https://github.com/sagemath/sage. Thanks for all the help and input.
no, you are not missing anything from the repo - but getting Sage from
github (or trac.sagemath) will only give you the source code of
everything, which you need to compile. After this is done (by doing
make) you should have a working copy of Sage.

I suppose by 'the lzma pack' you mean the binary distribution of Sage
for your platform. While you may use it for development, it is perhaps
less suited for this - it is really meant for end users, not for
developers, and various things there might be missing.

HTH,
Dima
Reply all
Reply to author
Forward
0 new messages