ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 23 Mar 2021 06:00:29 +0100How to load .sobj files into Jupyter Notebookhttps://ask.sagemath.org/question/56331/how-to-load-sobj-files-into-jupyter-notebook/Hello! I am medium-new with Sage, and I'm trying to figure out how best to load a list across notebooks. I want to keep one notebook up and computing further entries of a list, while saving what I have so far so that I can use it in other codes. However, I can't figure out how to load .sobj files.
When I'm in a notebook, I save my file by `save(list,'list')` and I see list.sobj in my Jupyter Home directory. But I can't figure out how to load it into another notebook. I've tried `load('list.sobj')` and various iterations of `load('C:\Users\myusername\list.sobj')`but it keep getting the same error:
`'(list.sobj)' was not found in history, as a file, url, nor in the user namespace.`
What am I missing?elcardinTue, 23 Mar 2021 06:00:29 +0100https://ask.sagemath.org/question/56331/can't load a saved filehttps://ask.sagemath.org/question/53724/cant-load-a-saved-file/ I saved a function as hypotenuse.sobj and it shows up in the local directory listing. Then I tried
load("hypotenuse.sobj") and get this error:
AttributeError: Can't get attribute 'dist' on <module 'sage.all_cmdline' from '/opt/sagemath-9.1/local/lib/python3.7/site-packages/sage/all_cmdline.py'>
cybervigilanteMon, 05 Oct 2020 02:20:24 +0200https://ask.sagemath.org/question/53724/Save/load huge dictionaryhttps://ask.sagemath.org/question/45651/saveload-huge-dictionary/I have a huge dictionary about 50 GB. After generating this dictionary, I do not have any space left on my memory. I still run Sagemath standard `save(mydict, 'myfile')`. However, the save runs almost forever.
What should I do? Storing it in multiple files is also fine to me. I really need to load it again to use in the future.
Maybe another approach is helpful. Besides the above dictionary, I have another huge redundant dictionary `mydict2`, which I tried using `del mydict2` to get some extra memory for the above Sagemath `save`; however, the memory usage still stays the same as before calling `del mydict2`. I guess its keys are still stored in memory. I do not need keys from `mydict2`, but its value is used in `mydict`.imnvshMon, 04 Mar 2019 17:08:10 +0100https://ask.sagemath.org/question/45651/another 'how to save a plot' questionhttps://ask.sagemath.org/question/44662/another-how-to-save-a-plot-question/ I use SageMath in CoCalc to generate images for worksheets, handouts, exams, etc. I am able to save simple plots to image files, but more complex plots like the one below vex me. Can someone tell me how to save the plot to an image file?
<pre>
plot1 = plot(-(x-1)^2+3, x, -3, 2.98)
plot2 = plot(-abs(2*(x-5))+2, x, 3,5.95)
plot3 = plot((x-7)^2-1,x,6.05,10)
pt1 = circle((6, 0),.1, edgecolor='black')
pt2 = point((6, 3), rgbcolor='black', pointsize=30)
pt3 = point((1, 2), rgbcolor='black', pointsize=30)
pt4 = circle((3, -1),.1, edgecolor='black')
pt3 = point((3, -2), rgbcolor='black', pointsize=30)
g3=(plot1+plot2+plot3+pt1+pt2+pt3+pt4).show(xmin=-2, xmax=10, ymin=-4, ymax=6,gridlines="minor").save('diagram2-finalexam01.png')
g3.save('diagram2-exam02.png')
</pre>
The last line throws the following error and no image file is saved:
<pre>
Error in lines 9-9
Traceback (most recent call last):
File "/cocalc/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 1188, in execute
flags=compile_flags) in namespace, locals
File "", line 1, in <module>
AttributeError: 'NoneType' object has no attribute 'save
</pre>
I've resorted to just taking a screenshot of the plot and using it, but I'd much rather do this in a pythonistic way. Can someone point me in the right direction?
jasonemillerThu, 13 Dec 2018 18:57:55 +0100https://ask.sagemath.org/question/44662/question about Python assignment of lists; meaning of equals sign; how to save a list?https://ask.sagemath.org/question/44324/question-about-python-assignment-of-lists-meaning-of-equals-sign-how-to-save-a-list/I have a list, then modify it, but want to save the old list to then modify in a different way.
I try to save the original using a different name and =, but it seems the two names are forever linked by the equals sign,
so the modification also changes the original. Why does this happen, and how do I deal with this?
Example:
sage: L1 = [1, 2]
sage: L2 = [3, 4]
sage: L3 = L1
sage: L1
[1, 2]
sage: L2
[3, 4]
sage: L3
[1, 2]
sage: L1.extend(L2)
sage: L1
[1, 2, 3, 4]
sage: L2
[3, 4]
sage: L3
[1, 2, 3, 4]
The same thing happens with "append".
Help please!!!
Note: this does not happen with variables with numerical (not list) values. For example:
sage: a = 4
sage: b = a
sage: a = 5
sage: a
5
sage: b
4
So it seems that the equals sign means two different things: for numbers it is an assignment;
for lists it is an identification. This is driving me crazy. I cannot find it explained anywhere (maybe because it is so "well-known"?)alSun, 18 Nov 2018 15:59:29 +0100https://ask.sagemath.org/question/44324/problem loading large filehttps://ask.sagemath.org/question/42124/problem-loading-large-file/I have a file which was generated and saved from a Sage notebook worksheet:
`save(G,'G4D200')`
where `G` is a list of vectors of length roughly 20 million, and the file 'G4D200.sobj` is about 370Mb.
When I try to load this file later to do some analysis
`new_G = load('/path_of_file.../G4D200.sobj')`
my computer goes deep into swap memory (with python eating it all up) and basically freezes. I have done the exact same thing for smaller file sizes (<10Mb) with no issues. I've tried waiting over 30 minutes and nothing seems to happen. Is this possibly a memory issue? Something with Sage? Possible workaround? I'm running the Sage notebook in fedora linux with an older laptop with 8Gb of RAM.
Thanks!Daniel LSun, 22 Apr 2018 20:45:13 +0200https://ask.sagemath.org/question/42124/temp22.sobj is not UTF-8 encodedhttps://ask.sagemath.org/question/41890/temp22sobj-is-not-utf-8-encoded/I get a temp22.sobj is not UTF-8 encoded after trying to open this file
I saved by using save(G.allsimplecycles, 'temp22') what am I doing wrong?
standardtrickynessFri, 06 Apr 2018 19:33:52 +0200https://ask.sagemath.org/question/41890/Problem with .stl and Graphhttps://ask.sagemath.org/question/41702/problem-with-stl-and-graph/Hi everyone!
I have a problem with SageMath, and I need your help :).
I want to save my personal Graph from a list to a .stl file
(.stl for 3d object representation, "stereolithography").
My code:
p = [[0,0,0],[1,2,3],[2,3,1],[2,1,0],[1,3,2],[3,2,1]]
points = PointConfiguration(p)
triang = points.triangulate()
triang.save('mygraph.stl')
triang.plot(axes=False)
___
When I try to save my file it's in the .sobj extension. (I research this extension
and it's just an extension SageObject, so it's not useful for me). I want to draw
a graph with a list of point and to convert them in a .stl file.
I already tried:
- save the plot:
triang.plot().save('mygraph.stl') # Fails as there is no attribute face_list
- save the all[-1]:
triang.all[-1].save('test.stl') # Fails as PointConfiguration don't have argument all.
I don't know what is the problem, so I ask for your help.
Thank you very much.haaggenWed, 21 Mar 2018 21:48:59 +0100https://ask.sagemath.org/question/41702/Save 3d plot as vector formathttps://ask.sagemath.org/question/9057/save-3d-plot-as-vector-format/Is there a way to export a 3d plot as a pdf file?
I know you can't do `p.save('filename.extension')` because 3dplot doesn't create a graphics item. But is there a way to do this?daniel.e2718Sun, 10 Jun 2012 15:19:24 +0200https://ask.sagemath.org/question/9057/remember and collect values/outputhttps://ask.sagemath.org/question/39749/remember-and-collect-valuesoutput/Hello, I am working with a function that involves random values. Thus, every time I run my code I get different values(in my case it is a set of values). When I get my output I want Sage to remember it and collect it every time I run my code. At the end I'd like to get a list of sets that has been accumulated every time I ran my code. Is there a way to do it?
I tried to research this topic and haven't found anything except saving a list to .txt file.XeniaThu, 23 Nov 2017 21:07:44 +0100https://ask.sagemath.org/question/39749/Where is the sage save or load dir and how do I change it?https://ask.sagemath.org/question/37832/where-is-the-sage-save-or-load-dir-and-how-do-i-change-it/ How in the heck does sage notebook (for Linux) manage files? I can't figure where it's saving them or how to load one. I tried os.getcwd() and got a temp file '/tmp/tmpJcEfeK' so I tried changing to the download directory, where it looked like an sws file was saved, with os.chdir("/home/jim/Downloads") That appeared to work since there was no error message. But then I did getcwd again and was still in the temp file. I just want to load a python script "diffusion.py" that's in the downloads folder but that fails. Finding where Sage actually is or changing it is a nightmare.cybervigilanteThu, 08 Jun 2017 01:21:35 +0200https://ask.sagemath.org/question/37832/Washed out colors when saving plots to filehttps://ask.sagemath.org/question/33540/washed-out-colors-when-saving-plots-to-file/I try to use the `save` command with a view of a 3d plot, like
mypic = implicit_plot3d(x^2 + y^2 + z^2 == distance, (x, -10, 10), (y, -10, 10), (z, -10, 10), opacity = 0.5) + point3d(vector([0, 0, 0]), color = 'red', size = 10)
mypic.save('mypic.png', compress = false)
but the colors (in particular, the opacities) are washed out.
There is no problem right-clicking to save as png from the notebook, but I want to save a bunch of pngs.
TumericTJTue, 24 May 2016 18:41:57 +0200https://ask.sagemath.org/question/33540/store python code from a notebook cell to a filehttps://ask.sagemath.org/question/33221/store-python-code-from-a-notebook-cell-to-a-file/ During a notebook session I enter a series of SAGE-statements (python code) in a notebook cell.
How can I let SAGE store/save this code automatically (not via copy&paste) in a file? The purpose is to reload the stored code in a cell of another session for later processing . I tried to perform this via the "save-session" -command. However, this results in a data volume of several MB, which is much larger than the total length of the code of the session. This I want to avoid.bekalphMon, 25 Apr 2016 00:09:59 +0200https://ask.sagemath.org/question/33221/How to save a 3d plot from sage cellhttps://ask.sagemath.org/question/27326/how-to-save-a-3d-plot-from-sage-cell/I've used plot3d to draw a simple plot in sage cell, however when I right click on the image nothing happens. In fact, if I hold the right button I can rotate the image just like when I left click.
I'm using Mozilla Firefox on Ubuntu and don't know if (1) I can change the settings of the browser so that I can save the image simply by right clicking, or (2) there is an alternative way of saving one's work from sage cell.
PS Right click works fine with, say plot command. There should be a conflict between plot3d and my browser that I don't know how to fix.
Thanks in advance for any input.EPSMon, 13 Jul 2015 23:25:30 +0200https://ask.sagemath.org/question/27326/How to save graphics into an image in sagemath online?https://ask.sagemath.org/question/24459/how-to-save-graphics-into-an-image-in-sagemath-online/ I am running sage cloud with a windows computer and I want to save graphics into an image. I found the following documentation:
sage: c = circle((1,1), 1, color='red')
sage: filename = os.path.join(SAGE_TMP, 'test.png')
sage: c.save(filename, xmin=-1, xmax=3, ymin=-1, ymax=3)
However it save nothing on my system or on the online folder. I suspect that this works when you have sagemath installed on the computer. How can I save on my system or on the online folder?
JorgeSat, 11 Oct 2014 01:32:32 +0200https://ask.sagemath.org/question/24459/save (and reuse) parametric_plot3d objecthttps://ask.sagemath.org/question/24390/save-and-reuse-parametric_plot3d-object/Hello,
I am a total newbie in Sage and I do not talk Python :-(
I was just trying to draw some surfaces for illustration when I came across a problem loading my saved computations.
NotImplementedError: You must override the get_grid method.
(code below.)
Is there a way to do what is suggested (override...)?
I found a bug ticket
[http://trac.sagemath.org/ticket/9957](http://trac.sagemath.org/ticket/9957)
and saw
[http://ask.sagemath.org/question/7704/importing-saved-3d-plot/](http://ask.sagemath.org/question/7704/importing-saved-3d-plot/)
I am not very hopeful, but since I basically do not understand what's written, maybe there's a way to override get-grid as the error message says.
Is there?
If not, is there a way to convert to an object that can be saved (and at least displayed again) or export it to an external format?
Thank you,
bb16
code:
sage: pam2=load(DATA+'pam2imt5000.sobj')
sage: type(pam2)
<html><script type="math/tex">\newcommand{\Bold}[1]{\mathbf{#1}}\verb|<type|\phantom{\verb!x!}\verb|'sage.plot.plot3d.parametric_surface.ParametricSurface'>|</script></html>
sage: show(pam2)
Traceback (most recent call last):
...
NotImplementedError: You must override the get_grid method.
sage: load(DATA+'pam3imt5000.sobj')
Traceback (most recent call last):
...
NotImplementedError: You must override the get_grid method.
bb16Sat, 04 Oct 2014 11:36:58 +0200https://ask.sagemath.org/question/24390/Transferring variables between worksheets?https://ask.sagemath.org/question/11014/transferring-variables-between-worksheets/How can I save an expression from one worksheet and load it in another? I can certainly do
save(myvar,"myvar")
so that it will be available for future uses of the worksheet, but I want to open it up in *another* worksheet (basically I don't want to clog up this second worksheet with all the machinery used to create this variable). Can this be done easily?
AlasdairSun, 09 Feb 2014 07:08:05 +0100https://ask.sagemath.org/question/11014/save_session runs foreverhttps://ask.sagemath.org/question/10566/save_session-runs-forever/Hello,
when I try to save a session (save_session command) with some expressions that are very long (composed by sums with hundred of terms) then the save session command runs for hours without producing any result nor writing anything to the file that should be created for storing the session on disk.
What can I do ?alessandroThu, 26 Sep 2013 09:22:48 +0200https://ask.sagemath.org/question/10566/Graph theory exporting problemshttps://ask.sagemath.org/question/10549/graph-theory-exporting-problems/I type in the following SAGE code and get the graph on the screen that I would expect to get.
g = Graph({0,[1,2,2]}); g
g.plot(graph_border = True)
When I try to export this to a file with the following code I get an "AssertionError" message.
g = Graph({0,[1,2,2]}); g
g.plot(graph_border = True).save('graph.pdf')
How can I fix this so that I can output this graph as a pdf file. I love how easy I can make nice looking graphs in SAGE, but it is useless if I can't export them to use in Latex.
Nick.BThu, 19 Sep 2013 20:20:10 +0200https://ask.sagemath.org/question/10549/save command in SAGEhttps://ask.sagemath.org/question/10496/save-command-in-sage/I'm trying to save a 'big' rational matrix in SAGE, but I'm running into problems.
After computing my matrix A, which has size 5 x 10,000 and each entry contains rational numbers in fraction form with total number of digits for numerator and denominator more than 10 pages, I run the following command:
save(A, DATA + 'A').
This gives me the following error message:
Traceback(most recent call last):
...
RuntimeError: Segmentation fault.
After this, I can't access A at all any more. In other words, when I try to compute say A[2,3], I get an error. However, before running the save command I was able to compute this entry. Also, I tried the same save command with a 'smaller' matrix and that worked fine. I should also note that I'm using a laptop with 64-bit operating system, x64-based processor, Windows 8, i7 CPU @ 2.40 GHz and 8 GB RAM. Let me know if you need further information. My questions are:
1. Why can't I save my matrix? Why do I get the above error message? What does it mean?
2. How can I save my matrix A? Is there any other way I can save it?Sandi XhumariSun, 01 Sep 2013 18:07:15 +0200https://ask.sagemath.org/question/10496/Save 3d plot to an imagehttps://ask.sagemath.org/question/10363/save-3d-plot-to-an-image/With a Jmol-produced 3d plot, saving to an image results in different output to that which is displayed on the screen.
I have
G.show(aspect_ratio=1)
and that looks lovely, but
G.save('tmp.png',aspect_ratio=1)
produces something quite different, I suspect because G.show() uses Jmol, and G.save() uses Tachyon. The "export" menu item of Jmol doesn't seem to produce very good results either, as the image is not properly centered on the page, and sometimes is even clipped. Any ideas how I can go from my Jmol image to a nice image file? (Other than taking a screenshot!)AlasdairFri, 19 Jul 2013 00:30:53 +0200https://ask.sagemath.org/question/10363/Save file from online notebookhttps://ask.sagemath.org/question/10353/save-file-from-online-notebook/Is it possible to save plot to svg file from online Sage notebook? bakantTue, 16 Jul 2013 10:07:26 +0200https://ask.sagemath.org/question/10353/workaround for graphics_array needing prior show?https://ask.sagemath.org/question/9593/workaround-for-graphics_array-needing-prior-show/I'm trying to use graphics_array to show a list of four simple plots. when I create the plots and display them straightaway in the graphics_array() it messes up the axis labeling and so on. I discovered via google that you can workaround that by first calling show() or save() on each of the graphs (I guess that finalizes their layout etc), and then call graphics array to combine them. But this results in each of the charts being shown individually before being shown in an array, which defeats the purpose.
The closest I've found is calling save('foo.pdf') on each of the charts, since it doesn't know how to display a PDF file you only get a link to 'foo.pdf'. I guess what I'd really like is save(filename, display=False) or something? (Of course ultimately I'd like graphics_array() to do the right thing in the first place and prepare each chart individually before compositing them)
Any ideas?PatrickSurryFri, 30 Nov 2012 13:52:41 +0100https://ask.sagemath.org/question/9593/Get list of coordinates from plot objecthttps://ask.sagemath.org/question/9262/get-list-of-coordinates-from-plot-object/I'm looking for a way to get a plain list of coordinates from a plot object. For instance, after creating an implicit plot of a circle
> p = implicit_plot(x^2+y^2-1,(x,-2,2),(y,-2,2))
I am able to save the image in .pdf or even .svg format (where coordinates are present), which is a very good start. What I really want, though, is a plain list of coordinates of, say, 2000 points lying on that circle. It should be possible to extract some from the .svg file, but is there a more convenient method? Maybe even one where I can set the sample size?
Thank you in advance for any suggestions.AnakondaWed, 22 Aug 2012 07:35:15 +0200https://ask.sagemath.org/question/9262/.svg fileshttps://ask.sagemath.org/question/9137/svg-files/I'm using SAGE remotely and I would like to know how to save .svg files to my computer.yapsterMon, 16 Jul 2012 17:52:46 +0200https://ask.sagemath.org/question/9137/How to save Sage worksheets to use on a different computer.https://ask.sagemath.org/question/9128/how-to-save-sage-worksheets-to-use-on-a-different-computer/How do I save a sage worksheet either to a flash drive or upload it to sagenb.org in order to open it on a different computer? I understand how to download/upload but cannot figure out where it is downloading to while using Sage in the Virtual Box which I need in order to upload it to sagenb.org.meganmopTue, 03 Jul 2012 23:27:28 +0200https://ask.sagemath.org/question/9128/Save data to text file - List_plot(...).save(Path, Name..)?https://ask.sagemath.org/question/9108/save-data-to-text-file-list_plotsavepath-name/Hey,
Is there a way to save data in list plot as a text file in stead/ in addition to showing it with .show() ?
In this way - I want to export the data from my list, say to Excel or Matlab in order to plot it using their tools. I wish the data would be arrange in the text file in a list of values that I could then copy (for example) to the Excel table.
Thanking u on advance! ErezMon, 25 Jun 2012 04:42:16 +0200https://ask.sagemath.org/question/9108/Date saved in Sage notebook not updatedhttps://ask.sagemath.org/question/9103/date-saved-in-sage-notebook-not-updated/I am using Sage 5.0 on a server. I use the notebook with Firefox 13.
Last Friday, I updated some code in a file from a while ago. I saved it. Today, I was looking for it and couldn't find it. The reason is, the date never got updated. It still says it was last updated 109 days ago and it's toward the bottom of the list of Active Worksheets. But, I opened it and it has the updates I made last week.
So, it's not a huge deal for me. I found it and my work is saved. But, just putting this out there in case it is a problem. Has any one else ever experienced this?
Just in case your first thought is, "Are you sure you updated it?", I know I did because one line of code I remember copying from another worksheet just last Friday. I hadn't even written the code I copied from 109 days ago. And, I ended my code with
for v in stuff:
# Figure out what stuff is
and then on the bus ride home, I figured out what stuff should be.G-SageFri, 22 Jun 2012 11:06:02 +0200https://ask.sagemath.org/question/9103/save definitionshttps://ask.sagemath.org/question/8794/save-definitions/Hello,
I want to use save a definition in the interactive shell. For example, I define
sage: def F(m):
....: return 2*m
....:
I put
sage: save(F,'function')
but it doesn't work. How can I do to save this definition and then load to work with it.
Thanks.-.
emiliocbaFri, 16 Mar 2012 07:53:13 +0100https://ask.sagemath.org/question/8794/How to save a function in sagehttps://ask.sagemath.org/question/8786/how-to-save-a-function-in-sage/I have a function in sage I want to save, but I cannot figure out how. I'm running sage on a mac through the terminal. I'm finding stuff online about save_session, or saving to a document.sage file or something but nothing really seems to be working, is there a straightforward way to do this? Thanks.
Edit: Also while I have your attention, say you have a function f, how do you display the contents of f without actually running it?ZaubertrankMon, 12 Mar 2012 14:54:04 +0100https://ask.sagemath.org/question/8786/