Ask Your Question

k1monfared's profile - activity

2019-05-17 22:37:18 +0200 received badge  Famous Question (source)
2018-09-20 12:21:53 +0200 received badge  Notable Question (source)
2018-04-11 05:45:39 +0200 received badge  Famous Question (source)
2018-04-04 19:32:16 +0200 received badge  Famous Question (source)
2018-02-21 12:47:43 +0200 received badge  Popular Question (source)
2017-11-11 20:47:13 +0200 received badge  Popular Question (source)
2017-11-11 20:47:13 +0200 received badge  Notable Question (source)
2017-10-28 13:17:45 +0200 received badge  Notable Question (source)
2017-07-19 06:23:56 +0200 asked a question ImportError: No module named

I just did a fresh install of fedora 26 (4.11.8-300.fc26.x86_64) and installed a jupyter notebook using pip3 and then installed the sage from the repositories. Upon calling sage I get the following error. Any ideas why this happens and how to resolve this?

┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 7.6, Release Date: 2017-03-25                     │
│ Type "notebook()" for the browser-based notebook interface.        │
│ Type "help()" for help.                                            │
└────────────────────────────────────────────────────────────────────┘
Traceback (most recent call last):
  File "/usr/lib64/sagemath/local/bin/sage-ipython", line 7, in <module>
    from sage.repl.interpreter import SageTerminalApp
  File "/usr/lib64/python2.7/site-packages/sage/repl/interpreter.py", line 108, in <module>
    from sage.repl.prompts import SagePrompts, InterfacePrompts
  File "/usr/lib64/python2.7/site-packages/sage/repl/prompts.py", line 16, in <module>
    from IPython.terminal.prompts import Prompts
  File "/usr/lib64/sagemath/site-packages/IPython/__init__.py", line 48, in <module>
    from .core.application import Application
  File "/usr/lib64/sagemath/site-packages/IPython/core/application.py", line 23, in <module>
    from traitlets.config.application import Application, catch_config_error
ImportError: No module named traitlets.config.application
2017-07-19 00:36:34 +0200 received badge  Famous Question (source)
2017-06-16 03:48:05 +0200 received badge  Popular Question (source)
2017-05-17 16:07:54 +0200 received badge  Popular Question (source)
2017-04-14 21:13:55 +0200 commented answer networkx can't compute algebraic connectivity

Practically speaking, I don't want to compute all the eigenvalues, that's why I'm using networkx's implemented method.

2017-04-13 03:55:30 +0200 asked a question networkx can't compute algebraic connectivity

I can compute the algebraic connectivity of the complete graph on 20 vertices in a fraction of a second using

import networkx
D = {}
for i in range(20):
    D[i] = [j for j in range(20)]
G = networkx.Graph(D)
networkx.algebraic_connectivity(G)

However, in a process I generate a graph (on 20 nodes) that I ask networkx to compute its algebraic connectivity, and it keeps running for ever with no errors. Here is the graph:

import networkx

D = {0: [32, 33, 19, 5, 21, 37, 6, 38, 39, 41, 26, 42, 11, 43, 28, 44, 15, 31], 5: [32, 0, 33, 19, 37, 21, 6, 22, 38, 39, 41, 26, 42, 11, 43, 44, 28, 15, 31], 6: [0, 32, 33, 19, 5, 37, 21, 22, 38, 39, 41, 26, 42, 11, 43, 28, 44, 15, 31], 11: [32, 0, 33, 19, 21, 37, 5, 6, 22, 38, 39, 41, 26, 42, 43, 28, 44, 15, 31], 15: [0, 32, 33, 19, 5, 21, 37, 6, 22, 38, 39, 41, 26, 42, 11, 43, 28, 44, 31], 19: [0, 32, 33, 5, 21, 37, 6, 22, 38, 39, 41, 26, 42, 11, 43, 28, 44, 15, 31], 21: [32, 0, 33, 19, 37, 5, 6, 22, 38, 39, 41, 26, 42, 11, 43, 28, 44, 15, 31], 22: [32, 33, 19, 5, 21, 37, 6, 38, 39, 41, 26, 42, 11, 43, 28, 44, 15, 31], 26: [0, 32, 33, 19, 5, 21, 37, 6, 22, 38, 39, 41, 42, 11, 43, 28, 44, 15, 31], 28: [32, 0, 33, 19, 21, 37, 5, 6, 22, 38, 39, 41, 26, 42, 11, 43, 44, 15, 31], 31: [32, 0, 33, 19, 5, 21, 37, 6, 22, 38, 39, 41, 26, 42, 11, 43, 28, 44, 15], 32: [0, 33, 19, 5, 21, 37, 6, 22, 38, 39, 41, 26, 42, 11, 43, 28, 44, 31, 15], 33: [0, 32, 19, 5, 21, 37, 6, 22, 38, 39, 41, 26, 42, 11, 43, 28, 44, 15, 31], 37: [32, 0, 33, 19, 5, 21, 6, 22, 38, 39, 41, 26, 42, 11, 43, 28, 44, 31, 15], 38: [32, 0, 33, 19, 21, 37, 5, 6, 22, 39, 41, 26, 42, 11, 43, 28, 44, 15, 31], 39: [0, 32, 33, 19, 5, 21, 37, 6, 22, 38, 41, 26, 42, 11, 43, 28, 44, 15, 31], 41: [32, 0, 33, 19, 21, 37, 5, 38, 6, 22, 39, 26, 42, 11, 43, 28, 44, 15, 31],  42: [32, 0, 33, 19, 21, 37, 5, 6, 22, 38, 39, 41, 26, 11, 43, 28, 44, 15, 31], 43: [32, 0, 33, 19, 21, 37, 5, 6, 22, 38, 39, 41, 26, 42, 11, 28, 44, 15, 31], 44: [32, 0, 33, 19, 5, 21, 37, 38, 6, 22, 39, 41, 42, 26, 11, 43, 28, 15, 31]}

G = networkx.Graph(D)
networkx.algebraic_connectivity(G)

Any reasons why it is so, and any idea on how to fix it?

2017-04-13 03:51:22 +0200 received badge  Notable Question (source)
2016-12-13 14:45:13 +0200 received badge  Popular Question (source)
2016-11-22 22:25:04 +0200 commented answer ImportError: No module named 'sage'

@roi.holtzman yes, I believe they are the same. Here is a more in depth explanation: http://www.joshstaiger.org/archives/2...

2016-11-10 01:05:05 +0200 received badge  Supporter (source)
2016-09-29 23:16:56 +0200 commented answer How to show the steps of Gauss' method

Hi, thanks for the nice code, I've added a little bits to it and changed some of the small parts. Take a look at the updated version here: http://sagecell.sagemath.org/?z=eJytV...

2016-08-11 22:47:44 +0200 received badge  Teacher (source)
2016-08-11 22:47:44 +0200 received badge  Self-Learner (source)
2016-08-11 18:29:49 +0200 answered a question ImportError: No module named 'sage'

As slelievre pointed it out there was a path added to my .bashrc file after installing anaconda. After removing that line sage started working.

2016-08-11 18:28:19 +0200 commented question ImportError: No module named 'sage'

Yes, that does it. Anaconda had added a path to my bashrc. After deleting it sage started working. Thanks.

2016-08-11 12:26:29 +0200 received badge  Student (source)
2016-08-11 00:09:00 +0200 received badge  Editor (source)
2016-08-11 00:00:51 +0200 asked a question ImportError: No module named 'sage'

I had a Sage 6.5 installed from the repository, running on my Fedora 22 nicely. But today when I went to run it I get the following error:

sage
┌────────────────────────────────────────────────────────────────────┐
│ Sage Version 6.5, Release Date: 2015-02-17                         │
│ Type "notebook()" for the browser-based notebook interface.        │
│ Type "help()" for help.                                            │
└────────────────────────────────────────────────────────────────────┘
Traceback (most recent call last):
  File "/usr/lib64/sagemath/local/bin/sage-ipython", line 6, in <module>
    from sage.repl.interpreter import SageTerminalApp
ImportError: No module named 'sage'

I reinstalled Sage, but I still get the same error. Any ideas on why do I get this error and how to resolve it?

2016-08-02 21:50:21 +0200 commented answer latex in plots

I didn't know I can use latex command inside a text command. Thanks, that helps.

2016-06-15 23:05:48 +0200 asked a question latex in plots

I want to display the formula for the graph of a function that sage has plotted without typing the expression manually, because sage has calculated it. For example the n-th Taylor polynomial expansion of a function:

f = sin(x)
g = f.taylor(x, 0, 13)
P = plot(f,(x,-10, 10), ymin =-4, ymax = 4, color="blue", axes=True, aspect_ratio=1, thickness=3)
Q = plot(g,(x,-10, 10), ymin =-4, ymax = 4, color="red", axes=True, aspect_ratio=1)
R = text(r"$%s \approx %s$" %(f,g),(0,yzoom[1]+1),rgbcolor=(1,0,0))
show(P + Q + R)

Everything works fine except for two things in the displayed formula:

  1. the * s are shown (which I can live with)
  2. The two digit exponents are not shown correctly which I assume it is because there are no curly brackets around them in the string g.

Are there better ways of doing this?

P.S. Are there ways of writing up the parts of the text in different colors, without defining two pieces of text and trying to figure out their relative positions?

2016-04-22 18:11:11 +0200 received badge  Scholar (source)
2016-04-22 18:11:03 +0200 commented answer What's a common way to save and load a list?

Thank you very much. Your answer for part b was exactly what I was looking for. Thanks. Still out of curiosity, for a. I get a list that looks like [['1','2'],['3','4']]. Any suggestions on how to avoid going through the whole list and turning strings into numbers?

2016-04-22 14:18:31 +0200 asked a question What's a common way to save and load a list?

I have calculated a list through a long calculation to do some other calculations with it. So I saved the list in a .txt file and in the file it looks like this:

[[[-1/10, 1.02421477975960],
  [-99/1000, 1.02369404664481],
  [-49/500, 1.02317986236459],
  [-97/1000, 1.02267219319285], 
  ...

Now that I want to load it again, I realized that I have to strip the \n's and then get rid of the brackets and extra commas etc. While I still have to do this for the current file, I want to know what are the common ways to save a list (and other similar python objects) so that I don't have to do all of this again? In other words:

a. How can I save the each element of a list in a line of a file? That is, to get something like:

-1/10, 1.02421477975960
-99/1000, 1.02369404664481
-49/500, 1.02317986236459
-97/1000, 1.02267219319285
...

b. How can I save a list (higher dimensional array) into a file and then read it. I tried the following but I seem to be unable to read it:

L = [ [ [1,2], [1,2] ], [ [1,2,3], [1,3], [1,2,3] ], 1 ]
out = file('out','w')
out.write(str(L))
out.close()

And then

L = open('out','r')

to only get

'[ [ [1,2], [1,2] ], [ [1,2,3], [1,3], [1,2,3] ], 1 ]'