Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dictionary/map support request #2796

Closed
danagilliann opened this issue Mar 8, 2018 · 3 comments
Closed

dictionary/map support request #2796

danagilliann opened this issue Mar 8, 2018 · 3 comments

Comments

@danagilliann
Copy link

danagilliann commented Mar 8, 2018

Hello! I was wondering if numba is planning to support dictionaries or maps any time soon? I noticed numba fails when I try to create a dictionary:

def new_dict():
   my_dict = {}

nd = nb.jit(nopython=True)(new_dict)
nd()

Error Message:

---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
<ipython-input-62-40fe5eb57ebc> in <module>()
      3 
      4 nd = nb.jit(nopython=True)(new_dict)
----> 5 nd()

~/anaconda3/envs/env1/lib/python3.5/site-packages/numba/dispatcher.py in _compile_for_args(self, *args, **kws)
    305                 argtypes.append(self.typeof_pyval(a))
    306         try:
--> 307             return self.compile(tuple(argtypes))
    308         except errors.TypingError as e:
    309             # Intercept typing error that may be due to an argument

~/anaconda3/envs/env1/lib/python3.5/site-packages/numba/dispatcher.py in compile(self, sig)
    577 
    578                 self._cache_misses[sig] += 1
--> 579                 cres = self._compiler.compile(args, return_type)
    580                 self.add_overload(cres)
    581                 self._cache.save_overload(sig, cres)

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

~/anaconda3/envs/env1/lib/python3.5/site-packages/numba/compiler.py in compile_extra(typingctx, targetctx, func, args, return_type, flags, locals, library)
    764     pipeline = Pipeline(typingctx, targetctx, library,
    765                         args, return_type, flags, locals)
--> 766     return pipeline.compile_extra(func)
    767 
    768 

~/anaconda3/envs/env1/lib/python3.5/site-packages/numba/compiler.py in compile_extra(self, func)
    360         self.lifted = ()
    361         self.lifted_from = None
--> 362         return self._compile_bytecode()
    363 
    364     def compile_ir(self, func_ir, lifted=(), lifted_from=None):

~/anaconda3/envs/env1/lib/python3.5/site-packages/numba/compiler.py in _compile_bytecode(self)
    723         """
    724         assert self.func_ir is None
--> 725         return self._compile_core()
    726 
    727     def _compile_ir(self):

~/anaconda3/envs/env1/lib/python3.5/site-packages/numba/compiler.py in _compile_core(self)
    710 
    711         pm.finalize()
--> 712         res = pm.run(self.status)
    713         if res is not None:
    714             # Early pipeline completion

~/anaconda3/envs/env1/lib/python3.5/site-packages/numba/compiler.py in run(self, status)
    246                     # No more fallback pipelines?
    247                     if is_final_pipeline:
--> 248                         raise patched_exception
    249                     # Go to next fallback pipeline
    250                     else:

~/anaconda3/envs/env1/lib/python3.5/site-packages/numba/compiler.py in run(self, status)
    238                 try:
    239                     event(stage_name)
--> 240                     stage()
    241                 except _EarlyPipelineCompletion as e:
    242                     return e.result

~/anaconda3/envs/env1/lib/python3.5/site-packages/numba/compiler.py in stage_nopython_frontend(self)
    452                 self.args,
    453                 self.return_type,
--> 454                 self.locals)
    455 
    456         with self.fallback_context('Function "%s" has invalid return type'

~/anaconda3/envs/env1/lib/python3.5/site-packages/numba/compiler.py in type_inference_stage(typingctx, interp, args, return_type, locals)
    865             infer.seed_type(k, v)
    866 
--> 867         infer.build_constraint()
    868         infer.propagate()
    869         typemap, restype, calltypes = infer.unify()

~/anaconda3/envs/env1/lib/python3.5/site-packages/numba/typeinfer.py in build_constraint(self)
    798         for blk in utils.itervalues(self.blocks):
    799             for inst in blk.body:
--> 800                 self.constrain_statement(inst)
    801 
    802     def return_types_from_partial(self):

~/anaconda3/envs/env1/lib/python3.5/site-packages/numba/typeinfer.py in constrain_statement(self, inst)
    957     def constrain_statement(self, inst):
    958         if isinstance(inst, ir.Assign):
--> 959             self.typeof_assign(inst)
    960         elif isinstance(inst, ir.SetItem):
    961             self.typeof_setitem(inst)

~/anaconda3/envs/env1/lib/python3.5/site-packages/numba/typeinfer.py in typeof_assign(self, inst)
   1023             self.typeof_arg(inst, inst.target, value)
   1024         elif isinstance(value, ir.Expr):
-> 1025             self.typeof_expr(inst, inst.target, value)
   1026         elif isinstance(value, ir.Yield):
   1027             self.typeof_yield(inst, inst.target, value)

~/anaconda3/envs/env1/lib/python3.5/site-packages/numba/typeinfer.py in typeof_expr(self, inst, target, expr)
   1211             self.lock_type(target.name, types.pyfunc_type, loc=inst.loc)
   1212         else:
-> 1213             raise NotImplementedError(type(expr), expr)
   1214 
   1215     def typeof_call(self, inst, target, call):

NotImplementedError: Failed at nopython (nopython frontend)
(<class 'numba.ir.Expr'>, build_map(size=0, items=[]))

Are there any possible work arounds?

@synapticarbors
Copy link
Contributor

See previous discussion in #2096

@danagilliann
Copy link
Author

Thank you!!!!

@danagilliann danagilliann reopened this Mar 8, 2018
@seibert seibert added this to Needs Design in Major Features Aug 27, 2018
@stuartarchibald
Copy link
Contributor

Version 0.43 has support for typed dictionaries. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Major Features
Needs Design
Development

No branches or pull requests

3 participants