Repository: numba/numba

Issue:
float // float unsupported
```
>>> def f(x, y):
...     return x // y
...
>>> 1.5 // 0.6
2.0
>>> jit(f)(1.5, 0.6)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "numba\dispatcher.py", line 125, in _compile_and_call
    self.jit(sig)
  File "numba\dispatcher.py", line 120, in jit
    return self.compile(sig, **kws)
  File "numba\dispatcher.py", line 108, in compile
    flags=flags, locals=locs)
  File "numba\compiler.py", line 94, in compile_extra
    return_type, flags, locals)
  File "numba\compiler.py", line 164, in compile_bytecode
    flags.no_compile)
  File "numba\compiler.py", line 301, in native_lowering_stage
    lower.lower()
  File "numba\lowering.py", line 214, in lower
    self.lower_block(block)
  File "numba\lowering.py", line 239, in lower_block
    raise LoweringError(msg, inst.loc)
numba.lowering.LoweringError: Internal error:
Exception: No definition for lowering //(float64, float64) -> int64
File "<stdin>", line 2
```



Discussion:

Resolving patch:
diff --git a/numba/targets/builtins.py b/numba/targets/builtins.py
--- a/numba/targets/builtins.py
+++ b/numba/targets/builtins.py
@@ -599,6 +599,13 @@ def real_mod_impl(context, builder, sig, args):
     return rem
 
 
+def real_floordiv_impl(context, builder, sig, args):
+    x, y = args
+    cgutils.guard_zero(context, builder, y)
+    quot, _ = real_divmod(context, builder, x, y)
+    return quot
+
+
 def real_power_impl(context, builder, sig, args):
     x, y = args
     module = cgutils.get_module(builder)
@@ -699,6 +706,7 @@ def real_sign_impl(context, builder, sig, args):
     builtin(implement('-', ty, ty)(real_sub_impl))
     builtin(implement('*', ty, ty)(real_mul_impl))
     builtin(implement('/?', ty, ty)(real_div_impl))
+    builtin(implement('//', ty, ty)(real_floordiv_impl))
     builtin(implement('/', ty, ty)(real_div_impl))
     builtin(implement('%', ty, ty)(real_mod_impl))
     builtin(implement('**', ty, ty)(real_power_impl))
diff --git a/numba/targets/operatorimpl.py b/numba/targets/operatorimpl.py
--- a/numba/targets/operatorimpl.py
+++ b/numba/targets/operatorimpl.py
@@ -1,3 +1,7 @@
+"""
+Definition of implementations for the `operator` module.
+"""
+
 import operator
 from numba.targets.imputils import implement, Registry
 from numba.targets import builtins
@@ -54,6 +58,7 @@
     register(implement(operator.mul, ty, ty)(builtins.real_mul_impl))
     if not utils.IS_PY3:
         register(implement(operator.div, ty, ty)(builtins.real_div_impl))
+    register(implement(operator.floordiv, ty, ty)(builtins.real_floordiv_impl))
     register(implement(operator.truediv, ty, ty)(builtins.real_div_impl))
     register(implement(operator.mod, ty, ty)(builtins.real_mod_impl))
     register(implement(operator.pow, ty, ty)(builtins.real_power_impl))
diff --git a/numba/typing/builtins.py b/numba/typing/builtins.py
--- a/numba/typing/builtins.py
+++ b/numba/typing/builtins.py
@@ -187,10 +187,7 @@ class BinOpFloorDiv(ConcreteTemplate):
              for op in sorted(types.signed_domain)]
     cases += [signature(op, op, op)
               for op in sorted(types.unsigned_domain)]
-    cases += [
-        signature(types.int32, types.float32, types.float32),
-        signature(types.int64, types.float64, types.float64),
-    ]
+    cases += [signature(op, op, op) for op in sorted(types.real_domain)]
 
 
 @builtin


Test patch:
diff --git a/numba/tests/test_operators.py b/numba/tests/test_operators.py
--- a/numba/tests/test_operators.py
+++ b/numba/tests/test_operators.py
@@ -732,23 +732,20 @@ def test_truediv_floats(self, flags=enable_pyobj_flags):
     def test_truediv_floats_npm(self):
         self.test_truediv_floats(flags=Noflags)
 
-    if 0:
-        # Floor division isn't implement for floats. These tests used to
-        # pass mistakingly because of a typo in floordiv_usecase()
-        def test_floordiv_floats(self, flags=enable_pyobj_flags):
-            pyfunc = self.op.floordiv_usecase
+    def test_floordiv_floats(self, flags=enable_pyobj_flags):
+        pyfunc = self.op.floordiv_usecase
 
-            x_operands = [-111.111, 0.0, 2.2]
-            y_operands = [-2.2, 1.0, 111.111]
+        x_operands = [-111.111, 0.0, 2.2]
+        y_operands = [-2.2, 1.0, 111.111]
 
-            types_list = [(types.float32, types.float32),
-                          (types.float64, types.float64)]
+        types_list = [(types.float32, types.float32),
+                      (types.float64, types.float64)]
 
-            self.run_test_floats(pyfunc, x_operands, y_operands, types_list,
-                                 flags=flags)
+        self.run_test_floats(pyfunc, x_operands, y_operands, types_list,
+                             flags=flags)
 
-        def test_floordiv_floats_npm(self):
-            self.test_floordiv_floats(flags=Noflags)
+    def test_floordiv_floats_npm(self):
+        self.test_floordiv_floats(flags=Noflags)
 
     def test_mod_ints(self, flags=enable_pyobj_flags):