def test_get_variables(): result = parse_args([ '--from-numexpr', '(A & B) | sqrt(A) + 5.4**3.141592 ', '--variables' ]) assert result == 'A\nB' result = parse_args( ['--from-root', '(A && B) || TMath::Sqrt(A) + 5.4**pi', '--variables']) assert result == 'A\nB'
def test_get_unnamed_constants(): result = parse_args( ['--from-numexpr', '(A & B) | sqrt(A)', '--unnamed-constants']) assert result == '' result = parse_args( ['--from-root', '(A && B) || TMath::Sqrt(A)', '--unnamed-constants']) assert result == '' result = parse_args([ '--from-numexpr', '(A & B) | sqrt(A) + 5.4**3.141592', '--unnamed-constants' ]) assert result == '3.141592\n5.4' result = parse_args([ '--from-root', '(A && B) || TMath::Sqrt(A) + 5.4**pi', '--unnamed-constants' ]) assert result == '5.4'
def test_invalid_args(): with pytest.raises(SystemExit): parse_args(['--dsadasdsada'])
def test_numexpr2root_conversion(): result = parse_args(['--from-numexpr', '(A & B) | sqrt(A)', '--to-root']) assert result == '(A && B) || TMath::Sqrt(A)'