def test_wrap_3(): switch = [ lambda: Random.string(20), lambda: {"i": Random.int(2000)}, lambda: Data(i=Random.int(2000)), lambda: FlatList([{"i": Random.int(2000)}]), lambda: [{"i": Random.int(2000)}] ] inputs = [switch[min(len(switch) - 1, int(floor(-log(Random.float(), 2))))]() for i in range(NUM_INPUT)] for i in range(NUM_REPEAT): results = [] gc.collect() with Profiler("more string: slow_wrap"): for v in inputs: results.append(slow_wrap(v)) results = [] gc.collect() with Profiler("more string: wrap"): for v in inputs: results.append(wrap(v)) results = [] gc.collect() with Profiler("more string: baseline"): for v in inputs: results.append(baseline(v)) Log.note("Done {{i}} of {{num}}", {"i": i, "num": NUM_REPEAT})
def test_floor_mod_identity_w_ints(self): for i in range(100): x = Random.float()*200 - 100.0 m = floor(abs(random.gauss(0, 5))) if m == 0: self.assertEqual(Math.floor(x, m), None) self.assertEqual(Math.mod(x, m), None) else: self.assertAlmostEqual(Math.floor(x, m)+Math.mod(x, m), x, places=7)
def test_floor_mod_identity(self): for i in range(100): x = Random.float()*200 - 100.0 m = abs(random.gauss(0, 5)) self.assertAlmostEqual(Math.floor(x, m)+Math.mod(x, m), x, places=7)