Re: [sage-devel] 2+2 in python3
> On 10/09/2017, at 18:16, Frédéric Chapoton wrote: > > Hello everybody, > > I just want to share the little pleasure that sage managed to add 2+2 in > python3. > > Here is a sample session in ipython3 > > In [1]: import sage.all > In [2]: from sage.combinat.q_bernoulli import * > In [3]: a=ZZ(2) > In [4]: b=ZZ(691) > In [5]: a+b > Out[5]: 693 > In [6]: a-b > Out[6]: -689 > In [7]: a*b > Out[7]: 1382 > In [8]: a**a > Out[8]: 4 > In [9]: a/b > Out[9]: b'2/691' > > This is done using the latest python3 experimental branch. As you can see, > something works, but this is still very rough. > > Related tickets: https://trac.sagemath.org/ticket/23818 and > https://trac.sagemath.org/ticket/23812 That’s great! Which ticket took care of this problem at start up: /usr/lib64/python3.6/site-packages/sage/misc/sageinspect.py in _extract_embedded_signature(docstring=b'\nConstruct a new object of this class... # indirect doctest\nTrue\n', name='__classcall__') 245 246 EXAMPLES:: 247 248 sage: from sage.misc.sageinspect import _extract_embedded_signature 249 sage: from sage.misc.nested_class import MainClass 250 sage: print(_extract_embedded_signature(MainClass.NestedClass.NestedSubClass.dummy.__doc__, 'dummy')[0]) 251 File: sage/misc/nested_class.pyx (starting at line 314) 252 ... 253 sage: _extract_embedded_signature(MainClass.NestedClass.NestedSubClass.dummy.__doc__, 'dummy')[1] 254 ArgSpec(args=['self', 'x', 'r'], varargs='args', keywords='kwds', defaults=((1, 2, 3.4),)) 255 sage: _extract_embedded_signature(range.__call__.__doc__, '__call__') 256 ('x.__call__(...) <==> x(...)', None) 257 258 """ 259 # If there is an embedded signature, it is in the first line --> 260 L = docstring.split(os.linesep, 1) L = undefined docstring.split = global os.linesep = '\n' 261 firstline = L[0] 262 # It is possible that the signature is of the form ClassName.method_name, 263 # and thus we need to do the following: 264 if name not in firstline: 265 return docstring, None 266 signature = firstline.split(name, 1)[-1] 267 if signature.startswith("(") and signature.endswith(")"): 268 docstring = L[1] if len(L)>1 else '' # Remove first line, keep the rest 269 def_string = "def "+name+signature+": pass" 270 try: 271 return docstring, inspect.ArgSpec(*_sage_getargspec_cython(def_string)) 272 except SyntaxError: 273 docstring = os.linesep.join(L) 274 return docstring, None 275 TypeError: a bytes-like object is required, not ‘str' -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
[sage-devel] Re: 2+2 in python3
How to try to reproduce this: - create a fresh new clone of the git repo - switch to the branch public/python3-experiment-v2 - upload cypari1.1.1 in upstream/ - export SAGE_PYTHON3=yes - make build - ./sage -sh - ipython3 and then the commands given above. No guarantee at all ! Frédéric Le dimanche 10 septembre 2017 08:16:09 UTC+2, Frédéric Chapoton a écrit : > > Hello everybody, > > I just want to share the little pleasure that sage managed to add 2+2 in > python3. > > Here is a sample session in ipython3 > > In [1]: import sage.all > In [2]: from sage.combinat.q_bernoulli import * > In [3]: a=ZZ(2) > In [4]: b=ZZ(691) > In [5]: a+b > Out[5]: 693 > In [6]: a-b > Out[6]: -689 > In [7]: a*b > Out[7]: 1382 > In [8]: a**a > Out[8]: 4 > In [9]: a/b > Out[9]: b'2/691' > > This is done using the latest python3 experimental branch. As you can see, > something works, but this is still very rough. > > Related tickets: https://trac.sagemath.org/ticket/23818 and > https://trac.sagemath.org/ticket/23812 > > cheers, > Frédéric > -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
[sage-devel] Re: performance issue with initialization of trees
Hey Martin, I am also getting similar timings, but actually testing Permutations(7) both times. :P What is more interesting is %prun: sage: %prun L = [pi.binary_search_tree() for pi in Permutations(7)] 3430302 function calls (2949342 primitive calls) in 3.526 seconds Ordered by: internal time ncalls tottime percall cumtime percall filename:lineno(function) 2718721.4280.0001.4570.000 abstract_tree.py:2182(__eq__) 314784/1082880.8100.0002.7710.000 binary_tree.py:173( __init__) 314784/1082880.3200.0002.9130.000 abstract_tree.py:2037( __init__) 9694090.2640.0000.2640.000 {isinstance} 103248/352800.2190.0003.3620.000 binary_tree.py:4712( binary_search_insert) 1359360.0920.0000.1290.000 abstract_tree.py:1940( __getitem__) 1032480.0890.0002.9850.000 ordered_tree.py:1431( _element_constructor_) 3147840.0720.0000.0880.000 binary_tree.py:204(check) 50400.0630.0003.4520.001 permutation.py:4301( binary_search_tree) All of these equality calls probably comes from this line in the binary tree __init__: elif (children == [] or children == () or isinstance(children, (Integer, int))): So my thought is to change this to elif (isinstance(children, (list, tuple)) and not children or isinstance(children, (Integer, int))): That way you avoid all of those calls to __eq__, which is not that bad by itself, but bogs down by the number of calls. Best, Travis -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
[sage-devel] 2+2 in python3
Hello everybody, I just want to share the little pleasure that sage managed to add 2+2 in python3. Here is a sample session in ipython3 In [1]: import sage.all In [2]: from sage.combinat.q_bernoulli import * In [3]: a=ZZ(2) In [4]: b=ZZ(691) In [5]: a+b Out[5]: 693 In [6]: a-b Out[6]: -689 In [7]: a*b Out[7]: 1382 In [8]: a**a Out[8]: 4 In [9]: a/b Out[9]: b'2/691' This is done using the latest python3 experimental branch. As you can see, something works, but this is still very rough. Related tickets: https://trac.sagemath.org/ticket/23818 and https://trac.sagemath.org/ticket/23812 cheers, Frédéric -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
[sage-devel] Online Sage Days
Great idea, I especially like: * python 3 * sage infrastructure * sage packaging I plan to work on https://github.com/sagemath/sage_sample quite a bit. For which I hope that it falls under sage packaging ;) For python 3 it would be good to make some more documentation on how to get on the python 3 bandwagon, in order to get more momentum. I know that there are the meta tickets: https://trac.sagemath.org/ticket/15530 https://trac.sagemath.org/ticket/15980 https://trac.sagemath.org/ticket/16052 However the only thing on how to get started mentioned there is:: How to try to make sage with python3: export SAGE_PYTHON3=yes make build However these say nothing on how far we are on getting the commands ``sage`` and ``sage -t`` working. From reading the mailing list I have got the impression that some people already have these things working (albeit with significant failures), but the instruction above doesn't cut it for me. Also might it be good idea to put a py3 develop branch somewhere that contains the latest beta + all positive review py3 tickets? -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
[sage-devel] Re: From SageNB to jupyter
It is a server with 8 cores and 32GB of RAM, but with several other sagenb processes and twenty users on jupyterhub plus 60 on the sagenb instances cause no performance issue (usually) El sábado, 9 de septiembre de 2017, 15:03:53 (UTC+2), kcrisman escribió: > > > > On Saturday, September 9, 2017 at 6:12:49 AM UTC-4, Enrique Artal wrote: >> >> It is quite useful, indeed. We have installed it in our servers. >> > > Could it be made "even easier" to deploy? Sagenb really just required > someone who knew how to give things a domain name and commands to start a > server. > > Also, more formal testing of the requirements for memory would be helpful > - many local sagenb installs only had a couple gig of RAM available on a > virtual machine and so couldn't handle more than a dozen or so users at a > time. > -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
Re: [sage-devel] Re: SAGE_PATH and PYTHONPATH
Hi Ralf, Yes but considering you are on sage-devel I thought there might be a reasonable chance that you would run into this issue sooner or later (especially if you set pythonpath in your bashrc). I just wanted to shamelessly advertise that trac ticket to potentially interested people. The core issues you talk about is tracked at the ticket already mentioned by Nils https://trac.sagemath.org/ticket/23614 -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
[sage-devel] performance issue with initialization of trees
Dear all, I'm having a performance problem, and I believe I have successfully located it in the initialization code of LabelledBinaryTrees. Part of my code is simply computing the binary tree corresponding to a permutation. I have the following timing: sage: timeit("[pi.binary_search_tree() for pi in Permutations(7)]", number=1, repeat=1) 1 loops, best of 1: 18.4 s per loop %lprun tells me that almost all of the time is spent in constructing the tree - output below. Indeed, if I simply represent my tree as a triple (left, right, label) I get the much better sage: timeit("[binary_search_tree(pi) for pi in Permutations(6)]", number=1, repeat=1) 1 loops, best of 1: 455 ms per loop So, my question is: can we improve the sage version so it is only a constant factor slower than the triple-version? A very similar problem appears with Permutation.increasing_tree - so I think my question really is about improving the initialisation code. All the best, Martin My code: def binary_search_insert(self, letter): if not self: return ([[],[]], letter) else: if letter <= self[1]: fils = binary_search_insert(self[0][0], letter) return ([fils, self[0][1]], self[1]) else: fils = binary_search_insert(self[0][1], letter) return ([self[0][0], fils], self[1]) def binary_search_tree(self, left_to_right=True): res = None if left_to_right: gen = self else: gen = self[::-1] for i in gen: res = binary_search_insert(res, i) return res The output of %lprun for the sage code: Line # Hits Time Per Hit % Time Line Contents == 4712 def binary_search_insert(self, letter): ... 4801 1173641556 3.5 1.5 LT = self.parent()._element_constructor_ 4802 1173622672 1.9 0.8 if not self: 4803 4320 442039102.3 15.5 return LT([], label=letter) 4804 else: 4805 741638723 5.2 1.4 if letter <= self.label(): 4806 370853064 14.3 1.9 fils = self[0].binary_search_insert(letter) 4807 3708 1095138295.3 38.4 return LT([fils, self[1]], label=self.label()) 4808 else: 4809 370853589 14.5 1.9 fils = self[1].binary_search_insert(letter) 4810 3708 1107110298.6 38.8 return LT([self[0], fils], label=self.label()) Total time: 3.07859 s Function: binary_search_tree at line 4301 Line # Hits Time Per Hit % Time Line Contents == 4301 def binary_search_tree(self, left_to_right=True): ... 4340 72012063 16.8 0.4 from sage.combinat.binary_tree import LabelledBinaryTree as LBT 4341 72029644 41.2 1.0 res = LBT(None) 4342 720 1783 2.5 0.1 if left_to_right: 4343 720 1233 1.7 0.0 gen = self 4344 else: 4345 gen = self[::-1] 4346 504016727 3.3 0.5 for i in gen: 4347 4320 3015922698.1 98.0 res = res.binary_search_insert(i) 4348 720 1221 1.7 0.0 return res -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
Re: [sage-devel] Re: SAGE_PATH and PYTHONPATH
On 09/09/2017 05:05 PM, Maarten Derickx wrote: > In case people start setting pythonpath after reading this thread: > you will actually get some silly doctest failures if python path is > set. I don't need to set SAGE_PATH (or PYTHONPATH) for testing Sage. All I want is to tell Sage about a locally installed package that does not come from "sage -i". As I understand what Nils was saying is that instead of SAGE_PATH I should simply switch to PYTHONPATH directly. That would be OK for me. However, it's quite bad that the commit that removed SAGE_PATH did not also consider to change the documentation for Sage 8.0. It still says that SAGE_PATH is in use. http://doc.sagemath.org/html/en/reference/repl/environ.html But it should actually explain what to do when a user wants to tell Sage about some additional code. Ralf -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
Re: [sage-devel] Re: doctests: non-sorted output
On Sat, Sep 9, 2017 at 11:15 AM, Maarten Derickx < m.derickx.stud...@gmail.com> wrote: > Thanks for your input David. We discussed it on trac, and decided to leave > the situation as is on python 2.7 because it is stable enough as is given > the pynormaliz fix. > > For python 3 we propese to fix the sorting in upstream ipython. Using str > based sort only if the standard sorting raises an error because things are > not comparable. This strategy would be like 2.2 both for doctests and for > end user printing. > That seems reasonable to me. David > > -- > You received this message because you are subscribed to the Google Groups > "sage-devel" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to sage-devel+unsubscr...@googlegroups.com. > To post to this group, send email to sage-devel@googlegroups.com. > Visit this group at https://groups.google.com/group/sage-devel. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
Re: [sage-devel] Re: doctests: non-sorted output
Thanks for your input David. We discussed it on trac, and decided to leave the situation as is on python 2.7 because it is stable enough as is given the pynormaliz fix. For python 3 we propese to fix the sorting in upstream ipython. Using str based sort only if the standard sorting raises an error because things are not comparable. This strategy would be like 2.2 both for doctests and for end user printing. -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
[sage-devel] Re: SAGE_PATH and PYTHONPATH
In case people start setting pythonpath after reading this thread: you will actually get some silly doctest failures if python path is set. I have made a ticket for this which fixes these doctest: https://trac.sagemath.org/ticket/23613 It is a very Small change and it currently needs review. The patchbot shows some failing tests but these are known problems with glpk not caused by this change. -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
[sage-devel] Re: From SageNB to jupyter
On Saturday, September 9, 2017 at 6:12:49 AM UTC-4, Enrique Artal wrote: > > It is quite useful, indeed. We have installed it in our servers. > Could it be made "even easier" to deploy? Sagenb really just required someone who knew how to give things a domain name and commands to start a server. Also, more formal testing of the requirements for memory would be helpful - many local sagenb installs only had a couple gig of RAM available on a virtual machine and so couldn't handle more than a dozen or so users at a time. -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
[sage-devel] Re: From SageNB to jupyter
It is quite useful, indeed. We have installed it in our servers. El viernes, 8 de septiembre de 2017, 16:48:49 (UTC+2), kcrisman escribió: > > > > On Thursday, September 7, 2017 at 11:16:14 AM UTC-4, Dima Pasechnik wrote: >> >> did you see this: >> https://benjamin-hackl.at/2016/01/16/jupyterhub-with-sagemath-kernel/ >> >> It seems that all of the requirements you list are there... >> > > This seems very interesting, especially if it could be packaged up in a > box, so to speak, for deployment. > -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
[sage-devel] Online Sage Days
Hi everyone, I'd like to organize some online Sage Days, where people gather on zulip.sagemath.org and work on Sage together. The two things to be decided are 1. What topics should we focus on? 2. What days/times work for the most people? Some of these may transition into in-person working groups (the IMA has funding for small groups to meet there over this coming year to work on projects) I'll send out a survey for the scheduling part, but I wanted to solicit suggestions for topics first. Some ideas: * Python 3 Compatibility * Work on documentation tickets, discuss overall documentation structure, make docbuilding more robust * Sage Infrastructure (improving the patchbot; common login for trac, github, google, zulip using OAuth; investigate options for in-line code review) * Sage's packaging and build system * Infrastructure for more random testing, speed regression testing * Interacts and interactive mathematics * Comparing Magma and Sage * Additional interfaces (Macaulay2) And on the mathematical side: * p-adics * function fields * linear algebra * modular forms * representation theory * polyhedral geometry * Coxeter group/root systems and braid groups * Schubert polynomials If you'd like me to include other topics in the survey, chime in! David -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.