コード例 #1
0
 def test_bits_per_layer(self):
     gh = G(bits_per_layer=-1)
     self.assertTrue(gh.bits_per_layer > 0 and gh.bits_per_layer < 256)
     gh = G(bits_per_layer=0)
     self.assertTrue(gh.bits_per_layer > 0 and gh.bits_per_layer < 256)
     gh = G(bits_per_layer=255)
     self.assertTrue(gh.bits_per_layer > 0 and gh.bits_per_layer < 256)
     gh = G(bits_per_layer=256)
     self.assertTrue(gh.bits_per_layer > 0 and gh.bits_per_layer < 256)
     gh = G(bits_per_layer=1)
     self.assertTrue(gh.bits_per_layer > 0 and gh.bits_per_layer < 256)
コード例 #2
0
 def test_maximum_possible_layers(self):
     gh = G(maximum_possible_layers=-1)
     self.assertTrue(gh.maximum_possible_layers > 0
                     and gh.maximum_possible_layers < 256)
     gh = G(maximum_possible_layers=0)
     self.assertTrue(gh.maximum_possible_layers > 0
                     and gh.maximum_possible_layers < 256)
     gh = G(maximum_possible_layers=255)
     self.assertTrue(gh.maximum_possible_layers > 0
                     and gh.maximum_possible_layers < 256)
     gh = G(maximum_possible_layers=256)
     self.assertTrue(gh.maximum_possible_layers > 0
                     and gh.maximum_possible_layers < 256)
     gh = G(maximum_possible_layers=1)
     self.assertTrue(gh.maximum_possible_layers > 0
                     and gh.maximum_possible_layers < 256)
コード例 #3
0
 def test_generate_structure_prepend(self):
     for i in range(10000):
         rand_max_layers = rand.randint(-256, 256)
         rand_bits_per_layer = rand.randint(-256, 256)
         gh = G(maximum_possible_layers=rand_max_layers,
                bits_per_layer=rand_bits_per_layer)
         structure = gh._generate_structure_prepend()
         layers, bits, _ = structure.split('t')
         layers = _bitstring_to_binary(layers)
         bits = _bitstring_to_binary(bits)
         self.assertEqual(layers, gh.maximum_possible_layers)
         self.assertEqual(bits, gh.bits_per_layer)
コード例 #4
0
 def test_perplexity_is_between_5_50(self):
     gh = G()
     for i in range(10000):
         perp = gh._generate_perplexity_prepend()
         perp = _bitstring_to_binary(perp)
         self.assertTrue(perp >= 5 and perp <= 50)
コード例 #5
0
 def test_perplexity_is_six_bits(self):
     gh = G()
     for i in range(10000):
         perp = gh._generate_perplexity_prepend()
         self.assertEqual(len(perp), 6)
コード例 #6
0
 def test_basic(self):
     gh = G()
コード例 #7
0
def _get_random_G():
    rand_max_layers = rand.randint(-256, 256)
    rand_bits_per_layer = rand.randint(-256, 256)
    gh = G(maximum_possible_layers=rand_max_layers,
           bits_per_layer=rand_bits_per_layer)
    return gh