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.Fri, 30 Jun 2023 20:03:36 +0200SageTex - Initializing plots directory fails in external drive.https://ask.sagemath.org/question/69631/sagetex-initializing-plots-directory-fails-in-external-drive/Hello,
MacOS 13.4.1 - TexLive 2023 - SageMath version 10.0, Release Date: 2023-05-20 │
│ Using Python 3.11.1.
When I run
% !TEX TS-program = sage
\documentclass{article}
\usepackage{sagetex}
\begin{document}
\begin{sagesilent}
G = plot(sin(x),-pi,pi)
\end{sagesilent}
This is
\sageplot{G}
my plot
\end{document}
I have 3 different results for these two cases:
a) Whether the sage-plots-for-Untitled.tex directory exists or not.
b) whether the location is an external device or not.
If the directory does not exist (running for the first time or has been deleted), the result is as expected for both cases, where the files are on the internal or external hard drive.
If the directory already exists, the result is as expected if the files are on the internal hard drive.
If the files are on an external drive and the directory exists, sagetex fails with:
Processing Sage code for Untitled.tex...
Code block (line 7) begin...end
Initializing plots directory
**** Error in Sage code on line 12 of Untitled.tex! Traceback follows.
Traceback (most recent call last):
File "/Volumes/TOSHIBA4T/teste/Untitled.sagetex.sage.py", line 19, in <module>
_st_.plot(_sage_const_0 , format='notprovided', _p_=G)
File "/private/var/tmp/sage-10.0-current/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/sagetex.py", line 225, in plot
self.initplot()
File "/private/var/tmp/sage-10.0-current/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/sagetex.py", line 107, in initplot
shutil.rmtree(self.plotdir)
File "/private/var/tmp/sage-10.0-current/local/var/lib/sage/venv-python3.11.1/lib/python3.11/shutil.py", line 732, in rmtree
_rmtree_safe_fd(fd, path, onerror)
File "/private/var/tmp/sage-10.0-current/local/var/lib/sage/venv-python3.11.1/lib/python3.11/shutil.py", line 683, in _rmtree_safe_fd
onerror(os.unlink, fullname, sys.exc_info())
File "/private/var/tmp/sage-10.0-current/local/var/lib/sage/venv-python3.11.1/lib/python3.11/shutil.py", line 681, in _rmtree_safe_fd
os.unlink(entry.name, dir_fd=topfd)
FileNotFoundError: [Errno 2] No such file or directory: '._plot-0.pdf'
**** Running Sage on Untitled.sage failed! Fix Untitled.tex and try again.
Anyone else had these problem? Can you help me? Is this a VenturaOS Privacy & Security issue?
Thanks,
FilipeqgfreireFri, 30 Jun 2023 20:03:36 +0200https://ask.sagemath.org/question/69631/Attempting to enrich quiver class yields "unexpected keyword argument" errorhttps://ask.sagemath.org/question/49636/attempting-to-enrich-quiver-class-yields-unexpected-keyword-argument-error/ I would like to do some computations with preprojective algebras, variations on the path algebra of a quiver in which every arrow has a partner going the other direction. I will want to construct representations of the "double quiver" in which I can conveniently compare the linear map associated to each arrow to that of its partner.
I figured I should create a class (something I haven't done in Python before) inheriting from DiGraph which has the extra data of a dictionary pairing the edges. My code to do this, with the constructor taking an arbitrary quiver and adding reversed copies of all the edges, is as follows:
class DoubleQuiver(sage.graphs.digraph.DiGraph):
def __init__(self, digraph):
edges = []
self._edgePairs = {}
for e in digraph.edges():
self._edgePairs[(e[0], e[1], e[2] + '0')] = (e[1], e[0], e[2] + '1')
self._edgePairs[(e[1], e[0], e[2] + '1')] = (e[0], e[1], e[2] + '0')
edges.append((e[0], e[1], e[2] + '0'))
edges.append((e[1], e[0], e[2] + '1'))
super(DoubleQuiver, self).__init__(edges, multiedges=True)
def flip(self, edge):
assert edge in self.edges()
return self._edgePairs[edge]
If I make a test digraph and run
DoubleQuiver(test)
it runs fine, and running methods like edges() or vertices() produces the results I expected. However, when I attempt to evaluate
DoubleQuiver(test).path_semigroup()
I get an error:
Error in lines 1-1
Traceback (most recent call last):
File "/cocalc/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 1234, in execute
flags=compile_flags), namespace, locals)
File "", line 1, in <module>
File "/ext/sage/sage-8.9_1804/local/lib/python2.7/site-packages/sage/graphs/digraph.py", line 2511, in path_semigroup
return PathSemigroup(self)
File "sage/misc/classcall_metaclass.pyx", line 335, in sage.misc.classcall_metaclass.ClasscallMetaclass.__call__ (build/cythonized/sage/misc/classcall_metaclass.c:1741)
return cls.classcall(cls, *args, **kwds)
File "/ext/sage/sage-8.9_1804/local/lib/python2.7/site-packages/sage/quivers/path_semigroup.py", line 118, in __classcall__
Q = Q.copy(immutable=True, weighted=True)
File "/ext/sage/sage-8.9_1804/local/lib/python2.7/site-packages/sage/graphs/generic_graph.py", line 1206, in copy
data_structure=data_structure)
TypeError: __init__() got an unexpected keyword argument 'weighted'
How should I modify my class definition to avoid this error, or is there a better way of accomplishing what I'm trying to do? (Also, is it relevant that I'm trying this on CoCalc?)Will DanaWed, 22 Jan 2020 01:03:17 +0100https://ask.sagemath.org/question/49636/Problem with Sequence commandhttps://ask.sagemath.org/question/34956/problem-with-sequence-command/ Computation of gcd of objects of a class a created fails. I investigated the case and traced down that the problem lies in Sequence command. Consider the following example class:
class foo(object) :
def __init__(self, L_) :
self.L = deepcopy(L_)
def __getitem__(self, j) :
return self.L[j]
def size(self) :
return len(self.L)
Create and example object:
a = foo( [1,2,3] )
print a.size()
>> 3
Build a nested object:
A = foo([ foo([1,2,3]), foo([2,4,8]), foo([1,1]), foo([1]) ])
print A.size()
>> 4
Everything works as expected. So let's iterate over A:
for a in A :
print a.size()
>> 3
>> 3
>> 2
>> 1
So far so good. Let's use Sequence as gcd internally does:
S = Sequence(A)
for s in S :
print s.size()
>> `TypeError: object of type 'foo' has no len()`
And boom! Something went wrong. Try to call len explicitly:
for s in S :
print len(s.L)
>> `TypeError: object of type 'foo' has no len()`
The same error! Surprisingly the following code actually works (but IMHO it should not):
for s in S :
print len(s.L.L)
>> 3
>> 3
>> 2
>> 1
It seems like something strange happens in initialization. When creating a sequence, all objects get initialized by themselves.
Ok. So here is my question: what's up? Do I do something wrong or is this a bug in `Sequence`? I know that Python does not provide copy constructors, hence how to initialize objects to avoid this kind of problems?
Thanks in advance,
Przemek
_pkMon, 26 Sep 2016 18:24:23 +0200https://ask.sagemath.org/question/34956/