code stringlengths 3 6.57k |
|---|
subtract
('a = (12,13) |
subscr
('a = 13 << 2', 52) |
lshift
('a = 13 >> 2', 3) |
rshift
('a = 13 & 7', 5) |
and
('a = 13 ^ 7', 10) |
xor
('a = 13 | 7', 15) |
compile(line, '', 'single') |
self.assertInBytecode(code, 'LOAD_CONST', elem) |
dis.get_instructions(code) |
self.assertFalse(instr.opname.startswith('BINARY_') |
compile('a=2+"b"', '', 'single') |
self.assertInBytecode(code, 'LOAD_CONST', 2) |
self.assertInBytecode(code, 'LOAD_CONST', 'b') |
compile('a="x"*10000', '', 'single') |
self.assertInBytecode(code, 'LOAD_CONST', 10000) |
self.assertNotIn("x"*10000, code.co_consts) |
compile('a=1<<1000', '', 'single') |
self.assertInBytecode(code, 'LOAD_CONST', 1000) |
self.assertNotIn(1<<1000, code.co_consts) |
compile('a=2**10000', '', 'single') |
self.assertInBytecode(code, 'LOAD_CONST', 10000) |
self.assertNotIn(2**10000, code.co_consts) |
test_binary_subscr_on_unicode(self) |
compile('"foo"[0]', '', 'single') |
self.assertInBytecode(code, 'LOAD_CONST', 'f') |
self.assertNotInBytecode(code, 'BINARY_SUBSCR') |
compile('"\u0061\uffff"[1]', '', 'single') |
self.assertInBytecode(code, 'LOAD_CONST', '\uffff') |
self.assertNotInBytecode(code,'BINARY_SUBSCR') |
compile('"\U00012345"[0]', '', 'single') |
self.assertInBytecode(code, 'LOAD_CONST', '\U00012345') |
self.assertNotInBytecode(code, 'BINARY_SUBSCR') |
compile('"fuu"[10]', '', 'single') |
self.assertInBytecode(code, 'BINARY_SUBSCR') |
test_folding_of_unaryops_on_constants(self) |
negative
('-0.0', -0.0) |
folding
('-0', 0) |
invert
('+1', 1) |
compile(line, '', 'single') |
self.assertInBytecode(code, 'LOAD_CONST', elem) |
dis.get_instructions(code) |
self.assertFalse(instr.opname.startswith('UNARY_') |
negzero() |
dis.get_instructions(code) |
self.assertFalse(instr.opname.startswith('UNARY_') |
compile(line, '', 'single') |
self.assertInBytecode(code, 'LOAD_CONST', elem) |
self.assertInBytecode(code, opname) |
test_elim_extra_return(self) |
f(x) |
self.assertNotInBytecode(f, 'LOAD_CONST', None) |
dis.get_instructions(f) |
self.assertEqual(len(returns) |
test_elim_jump_to_return(self) |
f(cond, true_value, false_value) |
self.assertNotInBytecode(f, 'JUMP_FORWARD') |
self.assertNotInBytecode(f, 'JUMP_ABSOLUTE') |
dis.get_instructions(f) |
self.assertEqual(len(returns) |
test_elim_jump_after_return1(self) |
f(cond1, cond2) |
self.assertNotInBytecode(f, 'JUMP_FORWARD') |
self.assertNotInBytecode(f, 'JUMP_ABSOLUTE') |
dis.get_instructions(f) |
self.assertEqual(len(returns) |
test_elim_jump_after_return2(self) |
f(cond1, cond2) |
self.assertNotInBytecode(f, 'JUMP_FORWARD') |
dis.get_instructions(f) |
self.assertEqual(len(returns) |
dis.get_instructions(f) |
self.assertEqual(len(returns) |
test_make_function_doesnt_bail(self) |
f() |
g() |
self.assertNotInBytecode(f, 'BINARY_ADD') |
test_constant_folding(self) |
compile(e, '', 'single') |
dis.get_instructions(code) |
self.assertFalse(instr.opname.startswith('UNARY_') |
self.assertFalse(instr.opname.startswith('BINARY_') |
self.assertFalse(instr.opname.startswith('BUILD_') |
TestBuglets(unittest.TestCase) |
test_bug_11510(self) |
f() |
self.assertRaises(ValueError) |
f() |
unittest.main() |
pytest.importorskip("iminuit") |
fcn(parameters) |
return ((x - x_opt) |
pytest.fixture() |
pars() |
Parameter("x", 2.1) |
Parameter("y", 3.1, scale=1e5) |
Parameter("z", 4.1, scale=1e-5) |
Parameters([x, y, z]) |
test_iminuit_basic(pars) |
optimize_iminuit(function=fcn, parameters=pars) |
assert_allclose(fcn(pars) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.