Ask Your Question
0

calling MixedIntegerLinearProgram gives AssertionError: The given source does not contain 'def'. How to fix this?

asked 2015-10-22 04:18:39 +0100

lutherdriggers gravatar image

When I call MixedIntegerLinearProgram I get the error AssertionError: The given source does not contain 'def'. This occurs both when calling any of its methods, like MixedIntegerLinearProgram.show(), and when viewing its documentation I get a backtrace in place of the documentation.

I am running Mac OS 10.11 (El Capitan). I get the same error in my emacs sage interpreter and Terminal. I recently tried to upgrade from sage 6.5 to 6.9 and the build failed; ask me about that if you think it's related. sage is installed to my home directory. Please ask if more details are needed.

Below is a full backtrace for a command I tried.

sage: g=Graph({0:[1,3],1:[0,2],2:[1,3],3:[2,0]})
sage: g
Graph on 4 vertices
sage: plot(g) #I checked my graph
sage: g.vertex_cut(0,2)
---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-17-b3f3e7c533ca> in <module>()
----> 1 g.vertex_cut(Integer(0),Integer(2))

/Users/alejo/sage/local/lib/python2.7/site-packages/sage/graphs/generic_graph.pyc in vertex_cut(self, s, t, value_only, vertices, solver, verbose)
   5525 
   5526         # Some vertices belong to part 1, some others to part 0
-> 5527         p.add_constraint(v[s] == 0)
   5528         p.add_constraint(v[t] == 1)
   5529 

/Users/alejo/sage/src/sage/numerical/mip.pyx in sage.numerical.mip.MIPVariable.__getitem__ (build/cythonized/sage/numerical/mip.c:16841)()
   2560         :meth:`MixedIntegerLinearProgram.new_variable`.
   2561     """
-> 2562 
   2563     def __init__(self, parent, mip, vtype, name, lower_bound, upper_bound):
   2564         r"""

/Users/alejo/sage/src/sage/numerical/mip.pyx in sage.numerical.mip.MixedIntegerLinearProgram.__call__ (build/cythonized/sage/numerical/mip.c:3714)()
    490             self._linear_constraints_parent = LinearConstraintsParent(LF)
    491         return self._linear_constraints_parent
--> 492 
    493     def __call__(self, x):
    494         """

/Users/alejo/sage/src/sage/numerical/mip.pyx in sage.numerical.mip.MixedIntegerLinearProgram.linear_functions_parent (build/cythonized/sage/numerical/mip.c:3376)()
    453         # Check for redundant constraints
    454         self._check_redundant = check_redundant
--> 455         if check_redundant:
    456             self._constraints = list()
    457 

/Users/alejo/sage/src/sage/misc/cachefunc.pyx in sage.misc.cachefunc.CachedFunction.__call__ (build/cythonized/sage/misc/cachefunc.c:4678)()
    917             True
    918             sage: f(y) is not f(x)
--> 919             True
    920 
    921         """

/Users/alejo/sage/src/sage/misc/cachefunc.pyx in sage.misc.cachefunc.CachedFunction.argfix_init (build/cythonized/sage/misc/cachefunc.c:3203)()
    719         """
    720         A = ArgumentFixer(self.f,classmethod=self.is_classmethod)
--> 721         self._argument_fixer = A
    722         if self.key:
    723             self._fix_to_pos = self._fix_to_pos_and_create_key

/Users/alejo/sage/src/sage/misc/function_mangling.pyx in sage.misc.function_mangling.ArgumentFixer.__init__ (build/cythonized/sage/misc/function_mangling.c:862)()
    122     cdef public tuple _default_tuple
    123     def __init__(self, f, classmethod = False):
--> 124         try:
    125             arg_names, varargs, varkw, defaults = sage_getargspec(f)
    126         except AttributeError:

/Users/alejo/sage/local/lib/python2.7/site-packages/sage/misc/sageinspect.pyc in sage_getargspec(obj)
   1382         source = sage_getsource(obj, is_binary=True)
   1383         if source:
-> 1384             return inspect.ArgSpec(*_sage_getargspec_cython(source))
   1385         else:
   1386             func_obj = obj

/Users/alejo/sage/local/lib/python2.7/site-packages/sage/misc/sageinspect.pyc in _sage_getargspec_cython(source)
   1007     """
   1008     defpos = source ...
(more)
edit retag flag offensive close merge delete

Comments

It works fine on my computer (with sage-6.10.beta1)

sage: g=Graph({0:[1,3],1:[0,2],2:[1,3],3:[2,0]})
sage: g.vertex_cut(0,2)
2
vdelecroix gravatar imagevdelecroix ( 2015-10-22 04:46:34 +0100 )edit

Thanks for comment. I have also confirmed it works with the precompiled binary for sage 6.9. I'll close if I manage to compile a fresh copy of sage-6.9 and not reproduce this.

lutherdriggers gravatar imagelutherdriggers ( 2015-10-22 05:27:46 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-11-04 05:57:39 +0100

It works fine in my computer. Try to re-install the sage via binary. I guess you can use the following:

apt-add-repository -y ppa:aims/sagemath
apt-get update
apt-get install sagemath-upstream-binary
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2015-10-22 04:18:39 +0100

Seen: 2,081 times

Last updated: Nov 04 '15