import numpy as np
import unittest

from chainer import testing

from chainercv.utils import assert_is_bbox
from chainercv.utils import generate_random_bbox


class TestGenerateRandomBbox(unittest.TestCase):

    def test_generate_random_bbox(self):
        n = 32
        img_size = (128, 256)
        min_length = 16
        max_length = 48

        bbox = generate_random_bbox(n, img_size, min_length, max_length)

        assert_is_bbox(bbox, img_size)
        self.assertEqual(bbox.shape[0], n)

        h = bbox[:, 2] - bbox[:, 0]
        w = bbox[:, 3] - bbox[:, 1]
        self.assertTrue(np.all(h < max_length))
        self.assertTrue(np.all(h >= min_length))
        self.assertTrue(np.all(w < max_length))
        self.assertTrue(np.all(w >= min_length))


testing.run_module(__name__, __file__)

@@ -152,16 +152,69 @@
 _bbox%0A%0A%0A
+@testing.parameterize(%0A    %7B'n': 0%7D,%0A    %7B'n': 32%7D%0A)%0A
 class Te
@@ -300,23 +300,8 @@
 f):%0A
-        n = 32%0A
     
@@ -411,16 +411,21 @@
 om_bbox(
+self.
 n, img_s
@@ -537,12 +537,44 @@
 0%5D, 
+self.
 n)%0A%0A
+        if self.n %3E 0:%0A    
     
@@ -605,16 +605,20 @@
 x%5B:, 0%5D%0A
+    
         
@@ -645,32 +645,36 @@
 x%5B:, 1%5D%0A        
+  
+  
 self.assertTrue(
@@ -689,32 +689,36 @@
  %3C max_length))%0A
+    
         self.ass
@@ -750,32 +750,36 @@
 ength))%0A        
+ 
+   
 self.assertTrue(
@@ -794,32 +794,36 @@
  %3C max_length))%0A
+    
         self.ass

check that n can be 0 for generate-random-bbox