-
-
Notifications
You must be signed in to change notification settings - Fork 487
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Metaticket - SageManifolds Code Improvement Discussion #30139
Comments
comment:1
Allow me to start the discussion. In my opinion, the highest priority has the removal of code duplication. The new feature of vector bundles, for example, came with a cost: code duplication and redundancies. This is certainly unwanted (see ticket #29234). Take sections and tensor fields. They share a lot of common code snippets and methods. For example the method Of course, this issue is not only restricted to vector bundles. As I modified tensor fields, I had to make changes in three different files simultaneously which had a very similar setup with similar code snippets: Another thing I am bothering with is the invocation of private variables via |
This comment has been minimized.
This comment has been minimized.
comment:4
Let me preface my comments: I have only very recently started to look into sage-manifolds and my understanding of this code is very shallow. Replying to @mjungmath:
If you are concerned about removing doctests (rather than documentation) as a byproduct of removing code duplications: There is a solution by moving many tests from doctests to I did this in the In |
comment:5
Replying to @mkoeppe:
Thank you. This is good to know and definitely an important point. My concern, however, is also the documentation itself. Tensor fields and sections are declared slighly differently. For example, sections are constructed by using an instance of the vector bundle. Tensor fields, on the other hand, are declared by using an instance of the manifold. Therefore, it would be good to have separate closed minimal examples and hence distinct documentations. What about something like this: class MyClass(ParentClass)
r"""
Blabla
"""
my_method(self, a, b, c='c'):
r"""
Overwritten docstring
"""
return ParentClass.my_method(self, a, b, c=c) Or is that too nasty? |
comment:6
Nothing wrong with that, I would say. (Of course, one would use |
comment:7
Just one caveat: it makes it more complicated to look at the code of the method by introspection. I don't have a good solution though. The best approximation I can come it is to include both the examples/doc of vector bundles and tensor fields in the documentation of the method. It makes it a bit long for the reader. But points out the similarity, which is not bad per se. Matthias: glad to see _test methods being adopted at a large scale, with additional tooling :-) |
comment:8
In a different direction: The (multi)linear algebra in It would be nice to be able to use it for computational (exact and inexact) (multi)linear algebra. In #30061, Eric already did some improvements that makes better use of sparsity. In addition to such speedups, it would be good to be able to use different backends for storing tensors instead of the current dictionary backend. On the one hand, for special cases such as vectors and matrices by existing special implementations; for the special case of fully symmetric tensors, using fast implementations of multivariate polynomials. On the other hand, for general numerical tensors using mainstream accelerated frameworks like PyTorch (see #30096). |
comment:9
Replying to @mkoeppe:
I would have thought that referring to the parent class by name is more robust against changes and increases readability. Is there a particular reason to prefer
That's good. Replying to @nthiery:
What exactly do you mean by that?
I'd guess this would contradict the well-documented philosophy of Sage, wouldn't it? |
comment:10
Replying to @mjungmath:
For classes with single inheritance, it is merely a matter of style. But as soon as multiple inheritance enters, using |
This comment has been minimized.
This comment has been minimized.
comment:12
As someone who's new to sage, but would like to get involved in SageManifolds: how can I help? |
comment:13
Replying to @bollu:
Welcome to the project! If you take a look at the metaticket #18528, you'll see that various tickets are in stalled state (mostly the blue ones), are therefore are open for development. For instance, #18786 about complex structures. You could pick one of those or create a brand new ticket about a topic that you like. |
This comment has been minimized.
This comment has been minimized.
comment:15
Replying to @mjungmath:
This is code duplication and should be avoided IMHO, cf. comment:6 in #29234 for the case of sections vs. tensor fields. |
comment:16
Replying to @nthiery:
+1 |
comment:17
Tobias had a very nice idea how to deal with some code duplication, in particular the restriction process: introduce sheafs (cf. comment:7 in #29234). I like that idea and I think this is something we definitely should aim for. However, this task is not as easy as one might think on the first glimpse. My first attempt would be utilizing the morphism framework of Sage. Unfortunately, my experience with morphisms in Sage is very limited. What do you think? Any further ideas? |
comment:18
Replying to @mjungmath:
I guess Nicolas means that if the user would like to take a look at the source code via |
comment:20
I thought a bit about optimizations and the first thing that came to my mind: Cythonize code. Of course, one has to check with prun etc. whether it's worth it. However, Cythonizing One thing that could definitely be Cythonized is the way of how names, i.e. strings, are concatenated, for example in Eric, what do you think? |
comment:21
Replying to @mjungmath:
Cythonizing the algebraic part of tensor calculus will unfortunately not help much to improve the computational speed on manifolds. The reason is that the main bottleneck is symbolic calculus on the tensor field components and more specifically the simplification process, which is performed via Maxima (default backend, Lisp based) or by SymPy (optional backend, Python based). To really gain in performance, one shall rely on parallelization rather than cythonization. A real limitation in this respect is #27492, which forbids parallelization with symbolic functions (side note: certainly Sage's symbolic functions require some major rewritting, see #31047) |
comment:22
Perhaps I am missing something. SymPy has a new C++ backend called SymEngine https://github.com/symengine/symengine. Would that improve performance by some degree? |
comment:23
Replying to @bollu:
Thanks for pointing this! This is certainly worth to investigate. Especially SymEngine's README says: Python wrappers allow easy usage from Python and integration with SymPy and Sage (the symengine.py repository). |
comment:24
If one were to attempt to integrate/use SymEngine for the purpose of making the algebra faster, what should one do? I'd imagine
|
comment:25
Replying to @bollu:
That looks extremely promising. It's definitely worth investigating. And who knows, perhaps it could even replace the entire symbolic backend in Sage. Perhaps we should post this in the sage-devel group and initiate a discussion. |
comment:26
Replying to @mjungmath:
Indeed, this is all the more relevant, given that the main developer of Pynac (Sage's symbolic backend) has resigned:
Yes this is certainly the right place to initiate the discussion. |
comment:27
I've created a thread on sage-devel about moving to SymEngine https://groups.google.com/g/sage-devel/c/sY3zh-pq8T4 |
comment:28
Sage development has entered the release candidate phase for 9.3. Setting a new milestone for this ticket based on a cursory review of ticket status, priority, and last modification date. |
comment:29
Indeed, it would be nice to (co)homology of manifolds. There are two approaches I see right now:
As for Morse homology I'd like to refer to https://www.sciencedirect.com/science/article/pii/S0723086905000642. With the orientation implementation we already have, this could be doable, even though there are some immediate problems that I can think of:
Is there perhaps a nice class of Morse functions we can easily deal with? Opinions, comments, hints, references and ideas are welcome! :) |
comment:30
I would probably start with Čech cohomology since it is more straightforward. For finding the critical points in Morse homology, I think you can compute them on each chart individually since they are suppose to be isolated IIRC and then remove redundancies. From there, you can check the degeneracy condition. |
comment:31
Replying to @tscrim:
For that, we need "good covers" consisting of contractible sets, and all its intersections being contractible. Thus we need a way to check contractibility for open subsets. Is that worth a post in sage-devel? |
comment:32
The manifolds code is growing steadily and more files are added. Do you think it is time that we consider refactoring the folder structure of the manifolds module? |
comment:33
Replying to @mjungmath:
Some of the things added as part of #31740 (Meta-ticket: Families, posets, complexes of manifold subsets) could certainly be moved into a subpackage
|
comment:34
Opened #32274 for the structuring issue. |
The main purpose of this ticket is a discussion and coordination platform regarding general code improvements of the preexisting SageManifolds code apart from bugfixes and new features. That is, for instance, the removal of existing code duplication, and strategies to improve readability, debugging and compatibility.
I for myself do not have much experience in this field. However, I am eager to improve this nice piece of package as much as I can, so that anyone can benefit from it. In any case, this is not a one man task and I appreciate any support in this matter.
I am looking forward to the discussion! :)
Tasks:
Section
andTensorField
CC: @egourgoulhon @tscrim @tobiasdiez @fchapoton @mkoeppe @nthiery
Component: manifolds
Keywords: sagemanifolds
Issue created by migration from https://trac.sagemath.org/ticket/30139
The text was updated successfully, but these errors were encountered: