Skip to content

Updates to numba broke old code #269

Closed
@cc7768

Description

@cc7768

Not sure exactly what is happening. Here is at least one example of the break.

QuantEcon.py|master ⇒ ipython
imporPython 3.5.2 |Anaconda custom (64-bit)| (default, Jul  2 2016, 17:53:06) 
Type "copyright", "credits" or "license" for more information.

IPython 5.1.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: import quantecon as qe
import numpy as np

In [2]: import numpy as np

In [3]: A = np.array([[0.9, 0.0], [0.0, 0.9]])

In [4]: C = np.eye(2)

In [5]: G = np.eye(2)

In [6]: lss = qe.LinearStateSpace(A, C, G)

In [7]: lss.simulate(5)
---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
/home/chase/Programming/anaconda3/lib/python3.5/site-packages/numba/errors.py in new_error_context(fmt_, *args, **kwargs)
    242     try:
--> 243         yield
    244     except NumbaError as e:

/home/chase/Programming/anaconda3/lib/python3.5/site-packages/numba/lowering.py in lower_block(self, block)
    200                                    loc=self.loc, errcls_=defaulterrcls):
--> 201                 self.lower_inst(inst)
    202 

/home/chase/Programming/anaconda3/lib/python3.5/site-packages/numba/objmode.py in lower_inst(self, inst)
    144         else:
--> 145             raise NotImplementedError(type(inst), inst)
    146 

NotImplementedError: (<class 'numba.ir.StaticSetItem'>, x[(slice(None, None, None), 0)] = x0)

During handling of the above exception, another exception occurred:

LoweringError                             Traceback (most recent call last)
<ipython-input-7-8e1fb21a5c6b> in <module>()
----> 1 lss.simulate(5)

/home/chase/Documents/Academic/Projects/QE/QuantEcon.py/quantecon/lss.py in simulate(self, ts_length)
    165         v = self.C.dot(w) # Multiply each w_t by C to get v_t = C w_t
    166         # == simulate time series == #
--> 167         x = simulate_linear_model(self.A, x0, v, ts_length)
    168 
    169         if self.H is not None:

/home/chase/Programming/anaconda3/lib/python3.5/site-packages/numba/dispatcher.py in _compile_for_args(self, *args, **kws)
    284                 argtypes.append(self.typeof_pyval(a))
    285         try:
--> 286             return self.compile(tuple(argtypes))
    287         except errors.TypingError as e:
    288             # Intercept typing error that may be due to an argument

/home/chase/Programming/anaconda3/lib/python3.5/site-packages/numba/dispatcher.py in compile(self, sig)
    530 
    531             self._cache_misses[sig] += 1
--> 532             cres = self._compiler.compile(args, return_type)
    533             self.add_overload(cres)
    534             self._cache.save_overload(sig, cres)

/home/chase/Programming/anaconda3/lib/python3.5/site-packages/numba/dispatcher.py in compile(self, args, return_type)
     79                                       impl,
     80                                       args=args, return_type=return_type,
---> 81                                       flags=flags, locals=self.locals)
     82         # Check typing error if object mode is used
     83         if cres.typing_error is not None and not flags.enable_pyobject:

/home/chase/Programming/anaconda3/lib/python3.5/site-packages/numba/compiler.py in compile_extra(typingctx, targetctx, func, args, return_type, flags, locals, library)
    682     pipeline = Pipeline(typingctx, targetctx, library,
    683                         args, return_type, flags, locals)
--> 684     return pipeline.compile_extra(func)
    685 
    686 

/home/chase/Programming/anaconda3/lib/python3.5/site-packages/numba/compiler.py in compile_extra(self, func)
    346         self.lifted = ()
    347         self.lifted_from = None
--> 348         return self._compile_bytecode()
    349 
    350     def compile_ir(self, func_ir, lifted=(), lifted_from=None):

/home/chase/Programming/anaconda3/lib/python3.5/site-packages/numba/compiler.py in _compile_bytecode(self)
    647         """
    648         assert self.func_ir is None
--> 649         return self._compile_core()
    650 
    651     def _compile_ir(self):

/home/chase/Programming/anaconda3/lib/python3.5/site-packages/numba/compiler.py in _compile_core(self)
    634 
    635         pm.finalize()
--> 636         res = pm.run(self.status)
    637         if res is not None:
    638             # Early pipeline completion

/home/chase/Programming/anaconda3/lib/python3.5/site-packages/numba/compiler.py in run(self, status)
    233                     # No more fallback pipelines?
    234                     if is_final_pipeline:
--> 235                         raise patched_exception
    236                     # Go to next fallback pipeline
    237                     else:

/home/chase/Programming/anaconda3/lib/python3.5/site-packages/numba/compiler.py in run(self, status)
    225                 try:
    226                     event(stage_name)
--> 227                     stage()
    228                 except _EarlyPipelineCompletion as e:
    229                     return e.result

/home/chase/Programming/anaconda3/lib/python3.5/site-packages/numba/compiler.py in stage_objectmode_frontend(self)
    413         if self.flags.enable_looplift:
    414             assert not self.lifted
--> 415             cres = self.frontend_looplift()
    416             if cres is not None:
    417                 raise _EarlyPipelineCompletion(cres)

/home/chase/Programming/anaconda3/lib/python3.5/site-packages/numba/compiler.py in frontend_looplift(self)
    404                               self.args, self.return_type,
    405                               outer_flags, self.locals,
--> 406                               lifted=tuple(loops), lifted_from=None)
    407             return cres
    408 

/home/chase/Programming/anaconda3/lib/python3.5/site-packages/numba/compiler.py in compile_ir(typingctx, targetctx, func_ir, args, return_type, flags, locals, lifted, lifted_from, library)
    696                         args, return_type, flags, locals)
    697     return pipeline.compile_ir(func_ir=func_ir, lifted=lifted,
--> 698                                lifted_from=lifted_from)
    699 
    700 

/home/chase/Programming/anaconda3/lib/python3.5/site-packages/numba/compiler.py in compile_ir(self, func_ir, lifted, lifted_from)
    354 
    355         self._set_and_check_ir(func_ir)
--> 356         return self._compile_ir()
    357 
    358     def stage_analyze_bytecode(self):

/home/chase/Programming/anaconda3/lib/python3.5/site-packages/numba/compiler.py in _compile_ir(self)
    654         """
    655         assert self.func_ir is not None
--> 656         return self._compile_core()
    657 
    658 

/home/chase/Programming/anaconda3/lib/python3.5/site-packages/numba/compiler.py in _compile_core(self)
    634 
    635         pm.finalize()
--> 636         res = pm.run(self.status)
    637         if res is not None:
    638             # Early pipeline completion

/home/chase/Programming/anaconda3/lib/python3.5/site-packages/numba/compiler.py in run(self, status)
    233                     # No more fallback pipelines?
    234                     if is_final_pipeline:
--> 235                         raise patched_exception
    236                     # Go to next fallback pipeline
    237                     else:

/home/chase/Programming/anaconda3/lib/python3.5/site-packages/numba/compiler.py in run(self, status)
    225                 try:
    226                     event(stage_name)
--> 227                     stage()
    228                 except _EarlyPipelineCompletion as e:
    229                     return e.result

/home/chase/Programming/anaconda3/lib/python3.5/site-packages/numba/compiler.py in stage_objectmode_backend(self)
    552         """
    553         lowerfn = self.backend_object_mode
--> 554         self._backend(lowerfn, objectmode=True)
    555 
    556         # Warn if compiled function in object mode and force_pyobject not set

/home/chase/Programming/anaconda3/lib/python3.5/site-packages/numba/compiler.py in _backend(self, lowerfn, objectmode)
    529             self.library.enable_object_caching()
    530 
--> 531         lowered = lowerfn()
    532         signature = typing.signature(self.return_type, *self.args)
    533         self.cr = compile_result(typing_context=self.typingctx,

/home/chase/Programming/anaconda3/lib/python3.5/site-packages/numba/compiler.py in backend_object_mode(self)
    503                                      self.library,
    504                                      self.func_ir,
--> 505                                      self.flags)
    506 
    507     def backend_nopython_mode(self):

/home/chase/Programming/anaconda3/lib/python3.5/site-packages/numba/compiler.py in py_lowering_stage(targetctx, library, interp, flags)
    824     fndesc = funcdesc.PythonFunctionDescriptor.from_object_mode_function(interp)
    825     lower = objmode.PyLower(targetctx, library, fndesc, interp)
--> 826     lower.lower()
    827     if not flags.no_cpython_wrapper:
    828         lower.create_cpython_wrapper()

/home/chase/Programming/anaconda3/lib/python3.5/site-packages/numba/lowering.py in lower(self)
    124         if self.generator_info is None:
    125             self.genlower = None
--> 126             self.lower_normal_function(self.fndesc)
    127         else:
    128             self.genlower = self.GeneratorLower(self)

/home/chase/Programming/anaconda3/lib/python3.5/site-packages/numba/lowering.py in lower_normal_function(self, fndesc)
    159         # Init argument values
    160         self.extract_function_arguments()
--> 161         entry_block_tail = self.lower_function_body()
    162 
    163         # Close tail of entry block

/home/chase/Programming/anaconda3/lib/python3.5/site-packages/numba/lowering.py in lower_function_body(self)
    184             bb = self.blkmap[offset]
    185             self.builder.position_at_end(bb)
--> 186             self.lower_block(block)
    187 
    188         self.post_lower()

/home/chase/Programming/anaconda3/lib/python3.5/site-packages/numba/lowering.py in lower_block(self, block)
    199             with new_error_context('lowering "{inst}" at {loc}', inst=inst,
    200                                    loc=self.loc, errcls_=defaulterrcls):
--> 201                 self.lower_inst(inst)
    202 
    203     def create_cpython_wrapper(self, release_gil=False):

/home/chase/Programming/anaconda3/lib/python3.5/contextlib.py in __exit__(self, type, value, traceback)
     75                 value = type()
     76             try:
---> 77                 self.gen.throw(type, value, traceback)
     78                 raise RuntimeError("generator didn't stop after throw()")
     79             except StopIteration as exc:

/home/chase/Programming/anaconda3/lib/python3.5/site-packages/numba/errors.py in new_error_context(fmt_, *args, **kwargs)
    247     except Exception as e:
    248         newerr = errcls(e).add_context(_format_msg(fmt_, args, kwargs))
--> 249         six.reraise(type(newerr), newerr, sys.exc_info()[2])
    250 
    251 

/home/chase/Programming/anaconda3/lib/python3.5/site-packages/numba/six.py in reraise(tp, value, tb)
    656             value = tp()
    657         if value.__traceback__ is not tb:
--> 658             raise value.with_traceback(tb)
    659         raise value
    660 

/home/chase/Programming/anaconda3/lib/python3.5/site-packages/numba/errors.py in new_error_context(fmt_, *args, **kwargs)
    241     errcls = kwargs.pop('errcls_', InternalError)
    242     try:
--> 243         yield
    244     except NumbaError as e:
    245         e.add_context(_format_msg(fmt_, args, kwargs))

/home/chase/Programming/anaconda3/lib/python3.5/site-packages/numba/lowering.py in lower_block(self, block)
    199             with new_error_context('lowering "{inst}" at {loc}', inst=inst,
    200                                    loc=self.loc, errcls_=defaulterrcls):
--> 201                 self.lower_inst(inst)
    202 
    203     def create_cpython_wrapper(self, release_gil=False):

/home/chase/Programming/anaconda3/lib/python3.5/site-packages/numba/objmode.py in lower_inst(self, inst)
    143 
    144         else:
--> 145             raise NotImplementedError(type(inst), inst)
    146 
    147     def lower_assign(self, inst):

LoweringError: Failed at object (object mode frontend)
Failed at object (object mode backend)
(<class 'numba.ir.StaticSetItem'>, x[(slice(None, None, None), 0)] = x0)
File "quantecon/lss.py", line 48
[1] During: lowering "x[(slice(None, None, None), 0)] = x0" at /home/chase/Documents/Academic/Projects/QE/QuantEcon.py/quantecon/lss.py (48)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions