[sage-support] Handling of backslashes in functions
Hey Sage, So I'm trying to make a really long function that I wanted to put on multiple lines to look nice. However, Sage's backslash preprocessing, combined with the preprocessing of making functions, doesn't allow me to do this: sage: botrk(h0_prime, a0, s0, c0) = h0_prime / ceil(log(20 * (a0 + 25) / (h0_prime + 20 * (a0 + 25)), 0.95)) * File ipython-input-51-0e90997af202, line 1 __tmp__=var(h0_prime,a0,s0,c0); botrk = symbolic_expression(h0_prime / ceil(log(Integer(20) * (a0 + Integer(25)) / (h0_prime + Integer(20) * (a0 + Integer(25))), RealNumber('0.95'))) *).function(h0_prime,a0,s0,c0) ^ SyntaxError: invalid syntax sage: botrk(h0_prime, a0, s0, c0) = h0_prime / ceil(log(20 * (a0 + 25) / (h0_prime + 20 * (a0 + 25)), 0.95)) * \ File ipython-input-52-fe3774a6c1a7, line 1 __tmp__=var(h0_prime,a0,s0,c0); botrk = symbolic_expression(h0_prime / ceil(log(Integer(20) * (a0 + Integer(25)) / (h0_prime + Integer(20) * (a0 + Integer(25))), RealNumber('0.95'))) * * BackslashOperator() * ).function(h0_prime,a0,s0,c0) ^ SyntaxError: invalid syntax Does anyone know more about this? If there's planning to be a patch to fix this, or I'm doing something wrong, or otherwise? If it's an easy fix I'd be down to help fix it. -- You received this message because you are subscribed to the Google Groups sage-support group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
[sage-support] Numerical approximation of ceiling functions?
Hi Sage, I'm not sure if it's that I'm not doing this right, but I have this function that has a ceiling in it. I defined it like so: botrk(h0_prime, a0, s0, c0) = h0_prime / ceil(log(20 * (a0 + 25) / (h0_prime + 20 * (a0 + 25)), 0.95)) * (s0 + 0.4) * (1 + c0) But it won't do approximations of the ceiling, only returning another symbolic expression that can't be approximated. sage: botrk(3000, 10, 1, 0.1) 4620.000/ceil(-19.4957257462237*log(7/37)) sage: botrk(3000, 10, 1, 0.1).n() --- TypeError Traceback (most recent call last) ipython-input-63-503406e1b435 in module() 1 botrk(Integer(3000), Integer(10), Integer(1), RealNumber('0.1')).n() /usr/lib/sagemath/local/lib/python2.7/site-packages/sage/symbolic/expression.so in sage.symbolic.expression.Expression._numerical_approx (sage/symbolic/expression.cpp:21011)() TypeError: cannot evaluate symbolic expression numerically Does anyone know how to approximate ceilings? For my purpose, I could just plug this in again and get a result, but I was hoping for a better, cleaner way of doing it. -- You received this message because you are subscribed to the Google Groups sage-support group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
[sage-support] Polyhedron construction fails on specific list of vertices
Hi, while trying to render the intersection of a 4-cube and a 3-cube (I guess that really doesn't matter), I stopped on trouble with the following: sage: point_list = [[0.132, -1.028, 0.028],[0.5, 0.5, -1.5],[-0.5, 1.5, -0.5],[0.5, 0.5, 0.5],[1.5, -0.5, -0.5],[-0.332, -0.332, -0.668],[-1.332, 0.668, 0.332],[-0.932, 0.068, 0.932],[-0.38, -0.38, 1.38],[-0.744, -0.12, 1.12],[-0.7781818182, -0.12, 0.9490909091],[0.62, -1.38, 0.38],[0.144, -1.04, 0.04],[0.1309090909, -1.0290909091, 0.04]] sage: P = Polyhedron(vertices = point_list) So far, no error gets raised. But any method call on P will now result in a traceback ending in has no attribute '_Vrepresentation': sage: P --- AttributeErrorTraceback (most recent call last) ipython-input-74-5c6d81c07f7c in module() 1 P /opt/sage-5.7/local/lib/python2.7/site-packages/IPython/core/displayhook.pyc in __call__(self, result) 236 self.start_displayhook() 237 self.write_output_prompt() -- 238 format_dict = self.compute_format_data(result) 239 self.write_format_data(format_dict) 240 self.update_user_ns(result) /opt/sage-5.7/local/lib/python2.7/site-packages/IPython/core/displayhook.pyc in compute_format_data(self, result) 148 MIME type representation of the object. 149 -- 150 return self.shell.display_formatter.format(result) 151 152 def write_format_data(self, format_dict): /opt/sage-5.7/local/lib/python2.7/site-packages/IPython/core/formatters.pyc in format(self, obj, include, exclude) 124 continue 125 try: -- 126 data = formatter(obj) 127 except: 128 # FIXME: log the exception /opt/sage-5.7/local/lib/python2.7/site-packages/sage/misc/sage_extension.pyc in __call__(self, obj) 236 s = format_obj(obj) 237 if s is None: -- 238 s = super(SagePlainTextFormatter, self).__call__(obj) 239 return s 240 /opt/sage-5.7/local/lib/python2.7/site-packages/IPython/core/formatters.pyc in __call__(self, obj) 445 type_pprinters=self.type_printers, 446 deferred_pprinters=self.deferred_printers) -- 447 printer.pretty(obj) 448 printer.flush() 449 return stream.getvalue() /opt/sage-5.7/local/lib/python2.7/site-packages/IPython/lib/pretty.pyc in pretty(self, obj) 358 if callable(meth): 359 return meth(obj, self, cycle) -- 360 return _default_pprint(obj, self, cycle) 361 finally: 362 self.end_group() /opt/sage-5.7/local/lib/python2.7/site-packages/IPython/lib/pretty.pyc in _default_pprint(obj, p, cycle) 478 if getattr(klass, '__repr__', None) not in _baseclass_reprs: 479 # A user-provided repr. -- 480 p.text(repr(obj)) 481 return 482 p.begin_group(1, '') /opt/sage-5.7/local/lib/python2.7/site-packages/sage/structure/sage_object.so in sage.structure.sage_object.SageObject.__repr__ (sage/structure/sage_object.c:1769)() /opt/sage-5.7/local/lib/python2.7/site-packages/sage/geometry/polyhedron/base.pyc in _repr_(self) 466 467 desc = '' -- 468 if self.n_vertices()==0: 469 desc += 'The empty polyhedron' 470 else: /opt/sage-5.7/local/lib/python2.7/site-packages/sage/misc/cachefunc.so in sage.misc.cachefunc.CachedMethodCallerNoArgs.__call__ (sage/misc/cachefunc.c:8762)() /opt/sage-5.7/local/lib/python2.7/site-packages/sage/geometry/polyhedron/base.pyc in n_vertices(self) 622 2 623 -- 624 return len(self.vertices()) 625 626 @cached_method /opt/sage-5.7/local/lib/python2.7/site-packages/sage/misc/cachefunc.so in sage.misc.cachefunc.CachedMethodCallerNoArgs.__call__ (sage/misc/cachefunc.c:8762)() /opt/sage-5.7/local/lib/python2.7/site-packages/sage/geometry/polyhedron/base.pyc in vertices(self) 1218 A vertex at (0, 0, 1, 0), A vertex at (0, 0, 0, 1)) 1219 - 1220 return tuple(self.vertex_generator()) 1221 1222 @cached_method /opt/sage-5.7/local/lib/python2.7/site-packages/sage/geometry/polyhedron/base.pyc in vertex_generator(self) 1193 [A vertex at (0, 1), A vertex at (1, 0), A vertex at (1, 1)] 1194 - 1195 for V in self.Vrepresentation(): 1196 if V.is_vertex(): 1197 yield V /opt/sage-5.7/local/lib/python2.7/site-packages/sage/geometry/polyhedron/base.pyc in Vrepresentation(self, index) 746 747 if index is None: -- 748 return self._Vrepresentation 749 else: 750 return
[sage-support] Re: Numerical approximation of ceiling functions?
On 04/21/2013 09:50 AM, Kenneth Lin wrote: Hi Sage, I'm not sure if it's that I'm not doing this right, but I have this function that has a ceiling in it. I defined it like so: | botrk(h0_prime,a0,s0,c0)=h0_prime /ceil(log(20*(a0 +25)/(h0_prime +20*(a0 +25)),0.95))*(s0 +0.4)*(1+c0) | But it won't do approximations of the ceiling, only returning another symbolic expression that can't be approximated. | sage: botrk(3000, 10, 1, 0.1) 4620.000/ceil(-19.4957257462237*log(7/37)) sage: botrk(3000, 10, 1, 0.1).n() --- TypeError Traceback (most recent call last) ipython-input-63-503406e1b435 in module() 1 botrk(Integer(3000), Integer(10), Integer(1), RealNumber('0.1')).n() /usr/lib/sagemath/local/lib/python2.7/site-packages/sage/symbolic/expression.so in sage.symbolic.expression.Expression._numerical_approx (sage/symbolic/expression.cpp:21011)() TypeError: cannot evaluate symbolic expression numerically | Does anyone know how to approximate ceilings? For my purpose, I could just plug this in again and get a result, but I was hoping for a better, cleaner way of doing it. Don't know why it stumbles on the ceiling. A function works on the other hand, since it avoids symbolics. sage: def botrk(h0_prime, a0, s0, c0): return h0_prime / ceil(log(20 * (a0 + 25) / (h0_prime + 20 * (a0 + 25)), 0.95)) * (s0 + 0.4) * (1 + c0) : sage: botrk(3000, 10, 1, 0.1) 140. -- You received this message because you are subscribed to the Google Groups sage-support group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
[sage-support] No DPI information in PNG files (parametric_plot3d)
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 I've attached a sample tex file. If you typeset it (i'm using XeLaTeX and SageTeX), you'll see that png files are upscaled (badly, i might add). Turns out - they lack DPI information. If you typeset it (completely, with XeLaTex+Sage+XeLaTeX dance) once, then open up the png file it produces and change its DPI metadata (in Gimp - Image-Print size...) to 300ppi, save it, then typeset it again (without running Sage to re-generate the image this time), it would render correctly on a page. In the attached file i'm using width=4.2cm to do the same thing indirectly, to demonstrate how the image should look, but that's inconvenient (you have to do the math yourself and specify correct width and figsize (if needed) separately). I suspect that mathplotlib is to blame, and wanted to dig further, but i thought i'd ask here first. P.S. Note that i have to specify [png] when invoking sageplot, otherwise SageTeX will fall back to png, but then claim that png is unsupported (bullshit) and advice to use pdflatex. The use of [imagemagick] in sagetex invocation doesn't change anything. -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.11 (MingW32) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBAgAGBQJRdl86AAoJEOs4Jb6SI2CwknMH/ikknqJ1LJ1/BQQUp5m+UM3j mEvl3rsYAd9x+YZVwZHLqpQ9ws1AHa3f5AwDNHNeUdyXQhz8+ZDn4N5yaB7Blbcy B3+d+8ACiAf8gvxLOcN/sw+GZ4Lw2yBDWKhmAMXFGY6AZxVVpE3TZ0AaZ58sPdnN TfmXh2z2k1dUi7nCXbgIXyTRRco8I/0FSmK9qCIo5yACi1xTxvTMbt9IsBzZPzuV sc+3jq8BOYHUO54KFS50RxdRlHRd3xW/dSbE0RrvvCUXUaZYlmRInRLl7G7yIaIT 7tNnZIwYPXsbQ5Op6MA0iLW4++yRAcB+4E5n9ML/ZhG51nPJsEPWxEohTTnrlFk= =pLck -END PGP SIGNATURE- -- You received this message because you are subscribed to the Google Groups sage-support group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support?hl=en. For more options, visit https://groups.google.com/groups/opt_out. \documentclass[a4paper]{article} \usepackage{fullpage} \usepackage[cm-default]{fontspec} \setromanfont{FreeSerif} \setsansfont{FreeSans} \setmonofont{FreeMono} \usepackage{polyglossia} \setdefaultlanguage{russian} \setotherlanguage{english} \usepackage{sagetex} \begin{document} С помощью Sage\TeX{} можно использовать Sage для вычислений, и вставлять результаты в документ \LaTeX. Например, существует $\sage{number_of_partitions(1269)}$ разбиений числа $1269$. Вычислять это самостоятельно нет необходимости, и не нужно даже вырезать и вставлять откуда-то это значение. Вот пример кода Sage: \begin{sageblock} f(x,y) = exp(x) * sin(2*x) + y \end{sageblock} Вторая производная функции $f$ - это \[ \frac{ \mathrm{d}^{2} }{ \mathrm{d}x^{2} } \sage{f(x,y)} = \sage{diff(f, x, 2)(x)}. \] Вот график функции $f$ от $-1$ до $1$: \sageplot[ scale=0.5 ]{ implicit_plot(f, (x, -1, 1), (y, -1, 1)) } А вот трёхмерный график: \begin{sagesilent} u, v = var('u,v') fx = (3+sin(v)+cos(u))*cos(2*v) fy = (3+sin(v)+cos(u))*sin(2*v) fz = sin(u)+2*cos(v) \end{sagesilent} \begin{english} This 3d plot looks awful: \end{english} {\fbox{\sageplot[][png]{parametric_plot3d([fx, fy, fz], (u, 0, 2*pi), (v, 0, 2*pi),frame=False,dpi=300)}} \begin{english} This 3d plot looks OK (scaled to match its actual dpi - its actual resolution is 500x500, so at 300dpi (118 dots per cm) its size should have been 4.2cm): \end{english} {\fbox{\sageplot[width=4.2cm][png]{parametric_plot3d([fx, fy, fz], (u, 0, 2*pi), (v, 0, 2*pi),frame=False,dpi=300)}} \end{document}
[sage-support] Re: Polyhedron construction fails on specific list of vertices
I can confirm this. The problem is that cdd errors out with *Error: Numerical inconsistency is found. Use the GMP exact arithmetic.. Gee, thanks ;) On Tuesday, April 23, 2013 9:09:08 AM UTC+1, Felix Wellen wrote: while trying to render the intersection of a 4-cube and a 3-cube (I guess that really doesn't matter), I stopped on trouble with the following: -- You received this message because you are subscribed to the Google Groups sage-support group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
[sage-support] Re: Polyhedron construction fails on specific list of vertices
This is now http://trac.sagemath.org/14479 (needs review) -- You received this message because you are subscribed to the Google Groups sage-support group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
[sage-support] Substituting a combination of variables in a matrix
Hi all, this is my first post on thins group :) I've been searching for a solution to this problem but I didn't find any (yet). Basically, I've been performing various matrix operations, with symbolic elements. The final result is very complex, but I can see patterns within it, so i wanted to rename those patterns with new variable names. That way, I can express the final result in terms of these new variables only. Since I'll apply this finding in a numerical method which will be called billion times, in this way, I would compute those sub-expression only once, saving a lot of time and, most important, i can be sure results will be correct. A huge plus would be a method to search automatically for those patterns, but I think that would be a much harder problem Thanks -- You received this message because you are subscribed to the Google Groups sage-support group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
[sage-support] Re: Polyhedron construction fails on specific list of vertices
This is now http://trac.sagemath.org/14479 (needs review) I love your style ! :-D It says Welcome in the world of Sage, where no known bug makes it past the day :-D Nathann -- You received this message because you are subscribed to the Google Groups sage-support group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: [sage-support] No DPI information in PNG files (parametric_plot3d)
On Tue, 23 Apr 2013 at 02:15PM +0400, LRN wrote: If you typeset it (i'm using XeLaTeX and SageTeX), you'll see that png files are upscaled (badly, i might add). Turns out - they lack DPI information. If you typeset it (completely, with XeLaTex+Sage+XeLaTeX dance) once, then open up the png file it produces and change its DPI metadata (in Gimp - Image-Print size...) to 300ppi, save it, then typeset it again (without running Sage to re-generate the image this time), it would render correctly on a page. In the attached file i'm using width=4.2cm to do the same thing indirectly, to demonstrate how the image should look, but that's inconvenient (you have to do the math yourself and specify correct width and figsize (if needed) separately). The 3D plot handling has never been very good; it's harder to work with PNG files from TeX than vector formats such as EPS or PDF. And with so many options for the graphics commands, it's hard to come up with defaults that will make users happy while still allowing some people to fiddle with them. The rendering, I think, is by Tachyon, not matplotlib. P.S. Note that i have to specify [png] when invoking sageplot, otherwise SageTeX will fall back to png, but then claim that png is unsupported (bullshit) SageTeX uses the ifpdf package to detect PDF output; that message is printed whenever \ifpdf is false. But that package doesn't work with XeLaTeX. I can add in a check for that. Dan -- --- Dan Drake - http://math.pugetsound.edu/~ddrake --- signature.asc Description: Digital signature
Re: [sage-support] No DPI information in PNG files (parametric_plot3d)
The 3D plot handling has never been very good; it's harder to work with PNG files from TeX than vector formats such as EPS or PDF. And with so many options for the graphics commands, it's hard to come up with defaults that will make users happy while still allowing some people to fiddle with them. The rendering, I think, is by Tachyon, not matplotlib. No, these look like Jmol static pictures to me (at least in the command I used), courtesy of Jonathan's upgrades there, perhaps. P.S. Note that i have to specify [png] when invoking sageplot, otherwise SageTeX will fall back to png, but then claim that png is unsupported (bullshit) SageTeX uses the ifpdf package to detect PDF output; that message is printed whenever \ifpdf is false. But that package doesn't work with XeLaTeX. I can add in a check for that. -- You received this message because you are subscribed to the Google Groups sage-support group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
[sage-support] Re: Polyhedron construction fails on specific list of vertices
With backend='ppl', base_ring=QQ it works! Thanks again ;) Am Dienstag, 23. April 2013 14:10:26 UTC+2 schrieb Volker Braun: This is now http://trac.sagemath.org/14479 (needs review) -- You received this message because you are subscribed to the Google Groups sage-support group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
[sage-support] Re: Substituting a combination of variables in a matrix
On 2013-04-23, Lorenzo Ricciardi lorenzo.a.riccia...@gmail.com wrote: Basically, I've been performing various matrix operations, with symbolic elements. The final result is very complex, but I can see patterns within it, so i wanted to rename those patterns with new variable names. That way, I can express the final result in terms of these new variables only. The Maxima function 'optimize' replaces common subexpressions with made-up variables, and the result is an expression which can be evaluated to give the same result as the original (ignoring order-of-evaluation effects). Dunno what might be available in Sage proper. best Robert Dodier -- You received this message because you are subscribed to the Google Groups sage-support group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: [sage-support] Re: Segmentation fault in Matrix(QQ).rank()
Yep, it might have switched to another internal library because of the matrix size, and that library might have appeared incompatible with debian (may be to new glibc version or like that) or just broken. It could be interesting to try to reinstall from sources with system ATLAS. I tried by ldd the installed sage binary libraries to find incompatibility, but found nothing. Is it possible to rebuild them one by one? On Monday, April 22, 2013 1:07:24 AM UTC+4, Jeroen Demeyer wrote: In any case, I fail to see how missing CPU features could lead to a Segmentation Fault. It's more likely a library incompatibility or something. -- You received this message because you are subscribed to the Google Groups sage-support group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
[sage-support] Re: Handling of backslashes in functions
Kenneth Lin kenlinn...@gmail.com writes: Hey Sage, So I'm trying to make a really long function that I wanted to put on multiple lines to look nice. However, Sage's backslash preprocessing, combined with the preprocessing of making functions, doesn't allow me to do this: sage: botrk(h0_prime, a0, s0, c0) = h0_prime / ceil(log(20 * (a0 + 25) / (h0_prime + 20 * (a0 + 25)), 0.95)) * File ipython-input-51-0e90997af202, line 1 __tmp__=var(h0_prime,a0,s0,c0); botrk = symbolic_expression (h0_prime / ceil(log(Integer(20) * (a0 + Integer(25)) / (h0_prime + Integer(20) * (a0 + Integer(25))), RealNumber('0.95'))) *).function (h0_prime,a0,s0,c0) ^ SyntaxError: invalid syntax sage: botrk(h0_prime, a0, s0, c0) = h0_prime / ceil(log(20 * (a0 + 25) / (h0_prime + 20 * (a0 + 25)), 0.95)) * \ File ipython-input-52-fe3774a6c1a7, line 1 __tmp__=var(h0_prime,a0,s0,c0); botrk = symbolic_expression (h0_prime / ceil(log(Integer(20) * (a0 + Integer(25)) / (h0_prime + Integer(20) * (a0 + Integer(25))), RealNumber('0.95'))) * * BackslashOperator() * ).function(h0_prime,a0,s0,c0) ^ SyntaxError: invalid syntax Does anyone know more about this? If there's planning to be a patch to fix this, or I'm doing something wrong, or otherwise? If it's an easy fix I'd be down to help fix it. I would guess this is a bug in the preparser, but in any case, backslash-based line continuations are frowned upon in Python (and in Sage). Instead of f(x) = x + \ y you should use f(x) = (x + 3) Sadly, this seems to be broken in the preprocessor as well, so I don't know what to tell you... -Keshav -- You received this message because you are subscribed to the Google Groups sage-support group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
[sage-support] Re: Memory
On Tuesday, 23 April 2013 00:00:33 UTC+8, Volker Braun wrote: The first question is, are you actually running out of ram? The garbage collector seems to have triggered full collections at the 4gb mark, and memory fragmentation might have left you with 900mb of address space that is mainly empty. Also, do you really need all 4 million graphs in memory simultaneously? Use @parallel to iterate over them if thats all you need. No, I am not running out of RAM with the small sample, but I will certainly run out of RAM if everything scales as it appears to be doing. The real issue for me is that the file of 4.2 million graphs occupies about 0.6 Gb on disk, and so when I was roughly working out what to do, it never occurred to me that there would be the slightest problem in storing it in memory (my machine has 16Gb RAM). Ultimately I need to create matroids from the graphs and keep only pairwise non-isomorphic ones. With those sizes, it seemed that it would be easy to just store everything in memory, and work from there. I could write a more complicated and clever routine to work in batches or use some additional theory etc, but I like to do that only when necessary. So when this happened to my tiny sample file, I assumed that I must be doing something spectacularly stupid, for example accidentally calling a method that keeps producing new objects (rather than mutating an existing object), hence the posting. I did some more experiments: I took a file with about 1 million lines and deleted all references to Graph, so that it was just a big bunch of tuples, and I wrapped it up into one big array rather than repeatedly calling append). gs = [ [(0,1,0),(0,1,1),(0,1,2),(0,1,3),(0,1,4),(0,1,5),(0,1,6),(0,2,7),(0,2,8),(0,2,9),(0,1,10),(0,1,11),(1,2,12),(1,2,13),(1,2,14),(3,4,15)], [(0,1,0),(0,1,1),(0,1,2),(0,1,3),(0,1,4),(0,1,5),(0,1,6),(0,2,7),(0,2,8),(0,2,9),(0,1,10),(0,1,11),(1,2,12),(1,2,13),(1,3,14),(2,4,15)], ... a million more lines This file occupies 157Mb on disk. I made a variant of this file suitable for input into another computer algebra system, in this case Magma gs := [ [[0,1,0],[0,1,1],[0,1,2],[0,1,3],[0,1,4],[0,1,5],[0,1,6],[0,2,7],[0,2,8],[0,2,9],[0,1,10],[0,1,11],[1,2,12],[1,2,13],[1,2,14],[3,4,15]], [[0,1,0],[0,1,1],[0,1,2],[0,1,3],[0,1,4],[0,1,5],[0,1,6],[0,2,7],[0,2,8],[0,2,9],[0,1,10],[0,1,11],[1,2,12],[1,2,13],[1,3,14],[2,4,15]], ... a million more lines Then I tried load tst.magma (in Magma) %runfile tst.sage (in Sage) to see the difference... With Magma, it took 45 seconds to read in the file, and the memory usage (as reported by ps) went up seemingly monotonically from about 10Mb to about 4.8Gb over that time period. With Sage, I had to kill the job after 12 minutes because the process had blown out to 12Gb or Real Mem and 36 Gb of virtual memory and the computer was barely responsive. This is making it hard for me to work with large data sets, but perhaps Sage is simply the wrong tool for this job? -- You received this message because you are subscribed to the Google Groups sage-support group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
[sage-support] Re: Memory
On 4/23/13 10:54 PM, Gordon wrote: On Tuesday, 23 April 2013 00:00:33 UTC+8, Volker Braun wrote: The first question is, are you actually running out of ram? The garbage collector seems to have triggered full collections at the 4gb mark, and memory fragmentation might have left you with 900mb of address space that is mainly empty. Also, do you really need all 4 million graphs in memory simultaneously? Use @parallel to iterate over them if thats all you need. No, I am not running out of RAM with the small sample, but I will certainly run out of RAM if everything scales as it appears to be doing. The real issue for me is that the file of 4.2 million graphs occupies about 0.6 Gb on disk, and so when I was roughly working out what to do, it never occurred to me that there would be the slightest problem in storing it in memory (my machine has 16Gb RAM). Ultimately I need to create matroids from the graphs and keep only pairwise non-isomorphic ones. With those sizes, it seemed that it would be easy to just store everything in memory, and work from there. I could write a more complicated and clever routine to work in batches or use some additional theory etc, but I like to do that only when necessary. So when this happened to my tiny sample file, I assumed that I must be doing something spectacularly stupid, for example accidentally calling a method that keeps producing new objects (rather than mutating an existing object), hence the posting. I did some more experiments: I took a file with about 1 million lines and deleted all references to Graph, so that it was just a big bunch of tuples, and I wrapped it up into one big array rather than repeatedly calling append). gs = [ [(0,1,0),(0,1,1),(0,1,2),(0,1,3),(0,1,4),(0,1,5),(0,1,6),(0,2,7),(0,2,8),(0,2,9),(0,1,10),(0,1,11),(1,2,12),(1,2,13),(1,2,14),(3,4,15)], [(0,1,0),(0,1,1),(0,1,2),(0,1,3),(0,1,4),(0,1,5),(0,1,6),(0,2,7),(0,2,8),(0,2,9),(0,1,10),(0,1,11),(1,2,12),(1,2,13),(1,3,14),(2,4,15)], ... a million more lines This file occupies 157Mb on disk. I made a variant of this file suitable for input into another computer algebra system, in this case Magma gs := [ [[0,1,0],[0,1,1],[0,1,2],[0,1,3],[0,1,4],[0,1,5],[0,1,6],[0,2,7],[0,2,8],[0,2,9],[0,1,10],[0,1,11],[1,2,12],[1,2,13],[1,2,14],[3,4,15]], [[0,1,0],[0,1,1],[0,1,2],[0,1,3],[0,1,4],[0,1,5],[0,1,6],[0,2,7],[0,2,8],[0,2,9],[0,1,10],[0,1,11],[1,2,12],[1,2,13],[1,3,14],[2,4,15]], ... a million more lines Then I tried load tst.magma (in Magma) %runfile tst.sage (in Sage) to see the difference... With Magma, it took 45 seconds to read in the file, and the memory usage (as reported by ps) went up seemingly monotonically from about 10Mb to about 4.8Gb over that time period. With Sage, I had to kill the job after 12 minutes because the process had blown out to 12Gb or Real Mem and 36 Gb of virtual memory and the computer was barely responsive. This is making it hard for me to work with large data sets, but perhaps Sage is simply the wrong tool for this job? I think if you used python ints instead of Sage Integers, it would make a big difference in the storage. Try renaming that test file to tst.py and runnig %runfile tst.py. Then Sage won't preparse the integers to be Sage Integers (based on MPIR), but instead will interpret them as straight python ints. Some preliminary experiments suggest that %runfile tst.py should take dramatically less time and memory. You'll probably have even more memory savings, probably, if you do something like: import numpy gs = numpy.asarray(dtype=numpy.int8, a=[ million lines ]) (assuming your integers fit into an 8-bit integer) Thanks, Jason Thanks, Jason -- Jason Grout -- You received this message because you are subscribed to the Google Groups sage-support group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support?hl=en. For more options, visit https://groups.google.com/groups/opt_out.