Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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

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.find('def ')
-> 1009     assert defpos > -1, "The given source does not contain 'def'"
   1010     s = source[defpos:].strip()
   1011     while s:

AssertionError: The given source does not contain 'def'