repo_id stringclasses 409
values | prefix large_stringlengths 34 36.3k | target large_stringlengths 1 498 | assertion_type stringclasses 31
values | difficulty stringclasses 8
values | test_file stringlengths 10 121 | test_function stringlengths 1 104 | test_class stringlengths 0 51 | lineno int32 2 11.3k | commit_idx int32 |
|---|---|---|---|---|---|---|---|---|---|
nvbn/thefuck | import os
import pytest
import zipfile
from thefuck.rules.dirty_unzip import match, get_new_command, side_effect
from thefuck.types import Command
from unicodedata import normalize
def zip_error_inner(filename):
path = os.path.join(str(tmpdir), filename)
def reset(path):
with zipfile.Z... | {'e'} | assert | collection | tests/rules/test_dirty_unzip.py | zip_error_inner | 34 | null | |
nvbn/thefuck | import pytest
from thefuck.rules.brew_unknown_command import match, get_new_command
from thefuck.rules.brew_unknown_command import _brew_commands
from thefuck.types import Command
def brew_unknown_cmd():
return '''Error: Unknown command: inst'''
def brew_unknown_cmd2():
return '''Error: Unknown command: insta... | cmds | assert | variable | tests/rules/test_brew_unknown_command.py | test_get_new_command | 28 | null | |
nvbn/thefuck | import pytest
from thefuck.shells.tcsh import Tcsh
class TestTcsh(object):
def shell(self):
return Tcsh()
def Popen(self, mocker):
mock = mocker.patch('thefuck.shells.tcsh.Popen')
mock.return_value.stdout.read.return_value = (
b'fuck\teval $(thefuck $(fc -ln -1))\n'
... | ['tcsh', '--version'] | assert | collection | tests/shells/test_tcsh.py | test_info | TestTcsh | 69 | null |
nvbn/thefuck | import pytest
from itertools import islice
from thefuck import ui
from thefuck.types import CorrectedCommand
from thefuck import const
def patch_get_key(monkeypatch):
def patch(vals):
vals = iter(vals)
monkeypatch.setattr('thefuck.ui.get_key', lambda: next(vals))
return patch
class TestSelect... | commands[1] | assert | complex_expr | tests/test_ui.py | test_with_confirmation_select_second | TestSelectCommand | 103 | null |
nvbn/thefuck | import pytest
import warnings
from mock import Mock, call, patch
from thefuck.utils import default_settings, \
memoize, get_closest, get_all_executables, replace_argument, \
get_all_matched_commands, is_app, for_app, cache, \
get_valid_history_without_current, _cache, get_close_matches
from thefuck.types im... | Path_mock.mock_calls | assert | complex_expr | tests/test_utils.py | test_get_all_executables_exclude_paths | 107 | null | |
nvbn/thefuck | import pytest
from thefuck.shells.tcsh import Tcsh
class TestTcsh(object):
def shell(self):
return Tcsh()
def Popen(self, mocker):
mock = mocker.patch('thefuck.shells.tcsh.Popen')
mock.return_value.stdout.read.return_value = (
b'fuck\teval $(thefuck $(fc -ln -1))\n'
... | 'ls || cd' | assert | string_literal | tests/shells/test_tcsh.py | test_or_ | TestTcsh | 38 | null |
nvbn/thefuck | import os
import pytest
import zipfile
from thefuck.rules.dirty_unzip import match, get_new_command, side_effect
from thefuck.types import Command
from unicodedata import normalize
def zip_error_inner(filename):
path = os.path.join(str(tmpdir), filename)
def reset(path):
with zipfile.Z... | {filename, 'a', 'b', 'c', 'd'} | assert | collection | tests/rules/test_dirty_unzip.py | zip_error_inner | 33 | null | |
nvbn/thefuck | import pytest
from thefuck.rules.scm_correction import match, get_new_command
from thefuck.types import Command
def get_actual_scm_mock(mocker):
return mocker.patch('thefuck.rules.scm_correction._get_actual_scm',
return_value=None)
@pytest.mark.parametrize('script, actual_scm, result', [
... | result | assert | variable | tests/rules/test_scm_correction.py | test_get_new_command | 46 | null | |
nvbn/thefuck | import pytest
from thefuck.rules.git_rebase_merge_dir import match, get_new_command
from thefuck.types import Command
def output():
return ('\n\nIt seems that there is already a rebase-merge directory, and\n'
'I wonder if you are in the middle of another rebase. If that is the\n'
'case, pl... | result | assert | variable | tests/rules/test_git_rebase_merge_dir.py | test_get_new_command | 42 | null | |
nvbn/thefuck | import pytest
from thefuck.shells import Generic
class TestGeneric(object):
def shell(self):
return Generic()
def test_app_alias(self, shell):
assert 'alias fuck' in | shell.app_alias('fuck') | assert | func_call | tests/shells/test_generic.py | test_app_alias | TestGeneric | 28 | null |
nvbn/thefuck | import pytest
from thefuck.shells.tcsh import Tcsh
class TestTcsh(object):
def shell(self):
return Tcsh()
def Popen(self, mocker):
mock = mocker.patch('thefuck.shells.tcsh.Popen')
mock.return_value.stdout.read.return_value = (
b'fuck\teval $(thefuck $(fc -ln -1))\n'
... | exception) | pytest.raises | variable | tests/shells/test_tcsh.py | test_get_version_error | TestTcsh | 75 | null |
pyccel/pyccel | from typing import TypeVar
import pytest
import numpy as np
from pyccel import epyccel
def test_f4(language):
def f4(x : 'bool' = True):
if x:
return 1
else:
return 2
f = epyccel(f4, language = language)
# ...
assert f(True) == | f4(True) | assert | func_call | tests/epyccel/test_epyccel_default_args.py | test_f4 | 74 | null | |
pyccel/pyccel | import pytest
import numpy as np
from modules import loops
from pyccel import epyccel
def test_less_than_100(language):
f1 = loops.less_than_100
f2 = epyccel( f1, language = language )
assert f1(10) == f2(10)
assert f1(101) == | f2(101) | assert | func_call | tests/epyccel/test_loops.py | test_less_than_100 | 238 | null | |
pyccel/pyccel | import pytest
import numpy as np
import modules.generic_functions as mod
import modules.generic_functions_2 as mod2
from pyccel import epyccel
def modnew(language):
return epyccel(mod, language = language)
def test_optional_var_4(language):
f1 = epyccel(mod2.optional_var_4 , language = language)
f2 = mod2... | f2(4.2) | assert | func_call | tests/epyccel/test_generic_functions.py | test_optional_var_4 | 179 | null | |
pyccel/pyccel | from numpy.random import randint, rand
import numpy as np
from numpy import iinfo
from pyccel import epyccel
min_int = iinfo(np.int32).min
max_int = iinfo(np.int32).max
def test_swap_basic(language):
def swp(a : int, b : int):
(a, b) = (b, a)
return a, b
f = epyccel(swp, language=language)
... | swp(-2,4) | assert | func_call | tests/epyccel/test_epyccel_expressions.py | test_swap_basic | 18 | null | |
pyccel/pyccel | import sys
from typing import TypeVar, Final
import numpy as np
import pytest
from pyccel import epyccel
from pyccel.errors.errors import PyccelError
def test_type_alias_context(language):
T = int
def f(a : T) -> T:
return 2*a
epyc_f = epyccel(f, language=language)
assert f(3) == | epyc_f(3) | assert | func_call | tests/epyccel/test_epyccel_context_clues.py | test_type_alias_context | 34 | null | |
pyccel/pyccel | import numpy as np
import pytest
from pyccel import epyccel
@pytest.mark.parametrize( 'language', (
pytest.param("fortran", marks = [pytest.mark.fortran]),
pytest.param("c", marks = [pytest.mark.c]),
pytest.param("python", marks = [
pytest.mark.skip(reason=("isinstance is evaluated ... | f(x) | assert | func_call | tests/epyccel/test_epyccel_compile_time_if.py | test_rank_differentiation_1 | 27 | null | |
pyccel/pyccel | from cmath import nanj, infj, pi
import os
import sys
from typing import TypeVar
import pytest
from numpy.random import rand, uniform
from numpy import isclose
from pyccel import epyccel
RTOL = sys.float_info.epsilon*1000
ATOL = sys.float_info.epsilon*100
max_float = 3.40282e5 # maximum positive float
min_fl... | f1(y) | assert | func_call | tests/epyccel/recognised_functions/test_cmath_funcs.py | test_isfinite_call | 295 | null | |
pyccel/pyccel | import pytest
import numpy as np
import modules.generic_functions as mod
import modules.generic_functions_2 as mod2
from pyccel import epyccel
def modnew(language):
return epyccel(mod, language = language)
def test_default_var_3(language):
f1 = epyccel(mod2.default_var_3, language = language)
f2 = mod2.de... | f1(5.3) | assert | func_call | tests/epyccel/test_generic_functions.py | test_default_var_3 | 128 | null | |
pyccel/pyccel | from numpy.random import randint, rand
import numpy as np
from numpy import iinfo
from pyccel import epyccel
min_int = iinfo(np.int32).min
max_int = iinfo(np.int32).max
def test_swap_index_2(language):
def swp(i : int, j : int):
l = [1,2,3]
l[i], l[j] = l[j], l[i]
return l[0], l[1], l[2]
... | swp(2,1) | assert | func_call | tests/epyccel/test_epyccel_expressions.py | test_swap_index_2 | 89 | null | |
pyccel/pyccel | import subprocess
import json
import os
import platform
import shutil
import sys
import re
import random
import pytest
import numpy as np
from filelock import FileLock
from pyccel.codegen.pipeline import execute_pyccel
from pyccel.ast.utilities import python_builtin_libs
from pyccel.compilers.default_compilers import a... | out2 | assert | variable | tests/pyccel/test_pyccel.py | test_module_name_containing_conflict | 1,279 | null | |
pyccel/pyccel | from numpy.random import randint, rand
import numpy as np
from numpy import iinfo
from pyccel import epyccel
min_int = iinfo(np.int32).min
max_int = iinfo(np.int32).max
def test_swap_index_2(language):
def swp(i : int, j : int):
l = [1,2,3]
l[i], l[j] = l[j], l[i]
return l[0], l[1], l[2]
... | swp(1,0) | assert | func_call | tests/epyccel/test_epyccel_expressions.py | test_swap_index_2 | 88 | null | |
pyccel/pyccel | from typing import TypeVar, Final
import pytest
import numpy as np
from pyccel import epyccel
from pyccel.decorators import private, inline
def test_inline_array_return(language):
def f():
@inline
def tmp():
return np.ones(2, dtype=int)
b = tmp()
c = np.sum(tmp())
... | out_pycc[1] | assert | complex_expr | tests/epyccel/test_epyccel_decorators.py | test_inline_array_return | 212 | null | |
pyccel/pyccel | import subprocess
import json
import os
import platform
import shutil
import sys
import re
import random
import pytest
import numpy as np
from filelock import FileLock
from pyccel.codegen.pipeline import execute_pyccel
from pyccel.ast.utilities import python_builtin_libs
from pyccel.compilers.default_compilers import a... | f | assert | variable | tests/pyccel/test_pyccel.py | compare_pyth_fort_output_by_type | 272 | null | |
pyccel/pyccel | import pytest
from pyccel import epyccel
def test_f8(language):
def f8(x : 'int'):
a = (1+0j, 2+0j) if x < 5 else (complex(5, 1), complex(2, 2))
return a[0]
def f8wp(x : 'int'):
a = (1+0j, 2+0j) if x < 5 else ((complex(5, 1), complex(2, 2)) if x > 5 else (complex(7, 2), complex(3, 3))... | f8(4) | assert | func_call | tests/epyccel/test_epyccel_IfTernaryOperator.py | test_f8 | 167 | null | |
pyccel/pyccel | import sys
from typing import TypeVar, Final
import numpy as np
import pytest
from pyccel import epyccel
from pyccel.errors.errors import PyccelError
def test_numpy_context(language):
def f():
a = np.ones(5)
return a.sum()
epyc_f = epyccel(f, language=language)
assert f() == | epyc_f() | assert | func_call | tests/epyccel/test_epyccel_context_clues.py | test_numpy_context | 15 | null | |
pyccel/pyccel | from cmath import nanj, infj, pi
import os
import sys
from typing import TypeVar
import pytest
from numpy.random import rand, uniform
from numpy import isclose
from pyccel import epyccel
RTOL = sys.float_info.epsilon*1000
ATOL = sys.float_info.epsilon*100
max_float = 3.40282e5 # maximum positive float
min_fl... | f1(nanj) | assert | func_call | tests/epyccel/recognised_functions/test_cmath_funcs.py | test_isfinite_call | 298 | null | |
pyccel/pyccel | import os
import pytest
import numpy as np
from numpy import iinfo, finfo
from numpy.random import randint, uniform
from pyccel import epyccel
from modules import arrays
RTOL = 1e-12
ATOL = 1e-16
def check_array_equal(a, b):
"""
Check that two arrays are equal.
Check that two arrays are equal. To... | f2(a) | assert | func_call | tests/epyccel/test_arrays.py | test_argument_negative_index_1 | 2,184 | null | |
pyccel/pyccel | import os
import sys
from typing import TypeVar
import pytest
from numpy.random import rand, randn, uniform
from numpy import isclose, iinfo, finfo, complex64, complex128
import numpy as np
from pyccel import epyccel
min_int8 = iinfo('int8').min
max_int8 = iinfo('int8').max
min_int16 = iinfo('int16').min
max_int16 =... | f_x_pyth | assert | variable | tests/epyccel/recognised_functions/test_numpy_funcs.py | test_sum_initial | 2,688 | null | |
pyccel/pyccel | import multiprocessing
import os
import sys
import pytest
import numpy as np
from numpy import random
from numpy import matmul
from modules import openmp
from pyccel import epyccel
from pyccel.utilities.introspect import get_compiler_info
@pytest.mark.external
def test_directive_in_else(language):
f1 = epyccel(o... | 0 | assert | numeric_literal | tests/epyccel/test_epyccel_openmp.py | test_directive_in_else | 20 | null | |
pyccel/pyccel | from math import nan, inf, modf
import os
import sys
from typing import TypeVar
import pytest
from numpy.random import rand, randint, uniform
from numpy import isclose
from pyccel import epyccel
RTOL = 1e-13
ATOL = 1e-14
max_float = 3.40282e5 # maximum positive float
min_float = sys.float_info.min # Minimum ... | f1(-inf) | assert | func_call | tests/epyccel/recognised_functions/test_math_funcs.py | test_isfinite_call | 569 | null | |
pyccel/pyccel | import os
import sys
from numpy.random import randint, uniform
from numpy import allclose
from pyccel import epyccel
def test_modulo_int_int(language):
def modulo_i_i(x : int, y : int):
return x % y, x % -y, -x % y, -x % -y, y % -y, -y % y
f = epyccel(modulo_i_i, language=language)
x = randint(0,... | f_output | assert | variable | tests/epyccel/test_epyccel_mod.py | test_modulo_int_int | 32 | null | |
pyccel/pyccel | import os
import pytest
from pyccel.parser.parser import Parser
from pyccel.errors.errors import Errors
from pyccel.ast.basic import PyccelAstNode
from pyccel.ast.core import Assign, Return, FunctionDef, AugAssign, FunctionDefArgument
from pyccel.ast.datatypes import PythonNativeInt
from pyccel.as... | 1 | assert | numeric_literal | tests/ast/test_basic.py | test_get_attribute_nodes_exclude | 63 | null | |
pyccel/pyccel | from typing import TypeVar
import pytest
import numpy as np
from pyccel import epyccel
def test_f4(language):
def f4(x : 'bool' = True):
if x:
return 1
else:
return 2
f = epyccel(f4, language = language)
# ...
assert f(True) == f4(True)
assert f(False) ... | f4() | assert | func_call | tests/epyccel/test_epyccel_default_args.py | test_f4 | 76 | null | |
pyccel/pyccel | import inspect
import pytest
from modules import strings_module
from pyccel import epyccel
string_funcs = [getattr(strings_module,f) for f in strings_module.__all__ if inspect.isfunction(getattr(strings_module,f))]
failing_tests = {
'concatenate':'C does not support string concatenation',
'concatenat... | f() | assert | func_call | tests/epyccel/test_strings.py | test_string_compare | 44 | null | |
pyccel/pyccel | from cmath import nanj, infj, pi
import os
import sys
from typing import TypeVar
import pytest
from numpy.random import rand, uniform
from numpy import isclose
from pyccel import epyccel
RTOL = sys.float_info.epsilon*1000
ATOL = sys.float_info.epsilon*100
max_float = 3.40282e5 # maximum positive float
min_fl... | f1(infj) | assert | func_call | tests/epyccel/recognised_functions/test_cmath_funcs.py | test_isfinite_call | 300 | null | |
pyccel/pyccel | import multiprocessing
import os
import sys
import pytest
import numpy as np
from numpy import random
from numpy import matmul
from modules import openmp
from pyccel import epyccel
from pyccel.utilities.introspect import get_compiler_info
@pytest.mark.parametrize( 'language', (
pytest.param('fortran', marks = py... | 4 | assert | numeric_literal | tests/epyccel/test_epyccel_openmp.py | test_module_1 | 40 | null | |
pyccel/pyccel | import sys
import pytest
from pyccel import epyccel
from modules import bitwise
@pytest.mark.parametrize("a, b", [(True, False), (True, True)])
def test_right_shift_b_b(language, a, b):
f1 = bitwise.right_shift_b_b
f2 = epyccel(f1, language=language)
r1 = f1(a, b)
r2 = f2(a, b)
assert r1 == | r2 | assert | variable | tests/epyccel/test_bitwise.py | test_right_shift_b_b | 15 | null | |
pyccel/pyccel | import pytest
import numpy as np
import modules.generic_functions as mod
import modules.generic_functions_2 as mod2
from pyccel import epyccel
def modnew(language):
return epyccel(mod, language = language)
@pytest.mark.parametrize( 'language', (
pytest.param("fortran", marks = pytest.mark.fortran),
... | fl_2 | assert | variable | tests/epyccel/test_generic_functions.py | test_zeros_types | 440 | null | |
pyccel/pyccel | import subprocess
import json
import os
import platform
import shutil
import sys
import re
import random
import pytest
import numpy as np
from filelock import FileLock
from pyccel.codegen.pipeline import execute_pyccel
from pyccel.ast.utilities import python_builtin_libs
from pyccel.compilers.default_compilers import a... | f_list | assert | variable | tests/pyccel/test_pyccel.py | compare_pyth_fort_output_by_type | 249 | null | |
pyccel/pyccel | import sys
from typing import TypeVar
import pytest
from numpy.random import randint, uniform
from numpy import iinfo, finfo
import numpy as np
from pyccel import epyccel
ATOL = 1e-15
RTOL = 2e-14
min_int = iinfo(np.int32).min
max_int = iinfo(np.int32).max
min_float = finfo(float).min
max_float = finfo(float).max
... | f_output | assert | variable | tests/epyccel/test_builtins.py | test_round_int | 537 | null | |
pyccel/pyccel | from typing import TypeVar, Final
import pytest
import numpy as np
from pyccel import epyccel
from pyccel.decorators import private, inline
def test_inline_1_out(language):
def f():
@inline
def cube(s : int):
return s * s * s
a = cube(3)
b = cube(8+3)
c = cube((b... | g() | assert | func_call | tests/epyccel/test_epyccel_decorators.py | test_inline_1_out | 36 | null | |
pyccel/pyccel | import pytest
import numpy as np
from modules import loops
from pyccel import epyccel
def test_sum_natural_numbers(language):
f1 = loops.sum_natural_numbers
f2 = epyccel( f1, language = language )
assert f1( 42 ) == | f2( 42 ) | assert | func_call | tests/epyccel/test_loops.py | test_sum_natural_numbers | 14 | null | |
pyccel/pyccel | import pytest
import numpy as np
import modules.generic_functions as mod
import modules.generic_functions_2 as mod2
from pyccel import epyccel
def modnew(language):
return epyccel(mod, language = language)
def test_default_var_4(language):
f1 = epyccel(mod2.default_var_4 , language = language)
f2 = mod2.d... | f2(5.2) | assert | func_call | tests/epyccel/test_generic_functions.py | test_default_var_4 | 140 | null | |
pyccel/pyccel | import gc
import sys
import numpy as np
import pytest
from pyccel import epyccel
def test_getter(language):
import classes.array_attribute as mod_pyt
mod = epyccel(mod_pyt, language=language)
a = mod.A(10)
start_ref_count_a = sys.getrefcount(a)
b = a.x
ref_count_a = sys.getrefcount(a)
... | a | assert | variable | tests/epyccel/test_epyccel_garbage_collection.py | test_getter | 266 | null | |
pyccel/pyccel | import pytest
from pyccel import epyccel
def test_f2(language):
def f2(x : 'int'):
a = 5.5 if x < 5 else x
return a
f = epyccel(f2, language = language)
# ...
assert f(6) == | f2(6) | assert | func_call | tests/epyccel/test_epyccel_IfTernaryOperator.py | test_f2 | 29 | null | |
pyccel/pyccel | import pytest
import numpy as np
from pyccel import epyccel
RTOL = 2e-14
ATOL = 1e-15
def Module_5(language):
import modules.Module_5 as mod
modnew = epyccel(mod, language = language)
return mod, modnew
def test_f4(language):
def f4(x : 'bool' = None):
if x is None :
return Tr... | f4(False) | assert | func_call | tests/epyccel/test_epyccel_optional_args.py | test_f4 | 84 | null | |
pyccel/pyccel | import numpy as np
from numpy.random import randint
from pyccel import epyccel
from modules import python_annotations
def test_fib(language):
f1 = python_annotations.fib
f2 = epyccel(f1, language=language)
assert f1(10) == | f2(10) | assert | func_call | tests/epyccel/test_epyccel_python_annotations.py | test_fib | 138 | null | |
pyccel/pyccel | from numpy.random import randint, rand
import numpy as np
from numpy import iinfo
from pyccel import epyccel
min_int = iinfo(np.int32).min
max_int = iinfo(np.int32).max
def test_swap_index_2(language):
def swp(i : int, j : int):
l = [1,2,3]
l[i], l[j] = l[j], l[i]
return l[0], l[1], l[2]
... | swp(0,1) | assert | func_call | tests/epyccel/test_epyccel_expressions.py | test_swap_index_2 | 87 | null | |
pyccel/pyccel | import pytest
from pyccel import epyccel
def test_f5(language):
def f5(x : 'int'):
a = x if x < 5 else 5 if x == 5 else 5.5
return a
def f5wp(x : 'int'):
a = x if x < 5 else (5 if x == 5 else 5.5)
return a
f = epyccel(f5, language = language)
fwp = epyccel(f5wp, langu... | f5(5) | assert | func_call | tests/epyccel/test_epyccel_IfTernaryOperator.py | test_f5 | 89 | null | |
pyccel/pyccel | import pytest
import numpy as np
from pyccel import epyccel
RTOL = 2e-14
ATOL = 1e-15
def Module_5(language):
import modules.Module_5 as mod
modnew = epyccel(mod, language = language)
return mod, modnew
def test_f14(language):
def f14(x : 'int' = None, y : 'int' = None):
if x is None :
... | f14() | assert | func_call | tests/epyccel/test_epyccel_optional_args.py | test_f14 | 207 | null | |
pyccel/pyccel | import sys
from typing import TypeVar, Final
import pytest
import numpy as np
from numpy.random import randint
from pyccel import epyccel
RTOL = 2e-14
ATOL = 1e-15
def test_func_no_return_1(language):
'''Test function with args and no return '''
def p_func(x : int):
x *= 2
c_func = epyccel(p_fu... | p_func(x) | assert | func_call | tests/epyccel/test_epyccel_functions.py | test_func_no_return_1 | 48 | null | |
pyccel/pyccel | from math import nan, inf, modf
import os
import sys
from typing import TypeVar
import pytest
from numpy.random import rand, randint, uniform
from numpy import isclose
from pyccel import epyccel
RTOL = 1e-13
ATOL = 1e-14
max_float = 3.40282e5 # maximum positive float
min_float = sys.float_info.min # Minimum ... | f1(x) | assert | func_call | tests/epyccel/recognised_functions/test_math_funcs.py | test_ceil_call_r | 398 | null | |
pyccel/pyccel | import os
import pytest
from pyccel.parser.parser import Parser
from pyccel.errors.errors import Errors
from pyccel.ast.basic import PyccelAstNode
from pyccel.ast.core import Assign, Return, FunctionDef, AugAssign, FunctionDefArgument
from pyccel.ast.datatypes import PythonNativeInt
from pyccel.as... | 4 | assert | numeric_literal | tests/ast/test_basic.py | test_get_all_user_nodes | 121 | null | |
pyccel/pyccel | import gc
import sys
import numpy as np
import pytest
from pyccel import epyccel
def test_return_multiple_pointers(language):
def return_pointer(x : 'float[:]', y : 'float[:]'):
return x, y
f = epyccel(return_pointer, language=language)
x_pyc = np.ones(10)
x_pyt = np.ones(10)
y_pyc = np.... | y_pyc | assert | variable | tests/epyccel/test_epyccel_garbage_collection.py | test_return_multiple_pointers | 78 | null | |
pyccel/pyccel | from pathlib import Path
import shutil
import subprocess
import sys
import pytest
from test_pyccel import get_python_output, compare_pyth_fort_output
current_folder = Path(__file__).parent
def build_system(request):
"""
Test with the chosen build system.
"""
return request.param
def pyccel_make_test(... | p.stdout | assert | complex_expr | tests/pyccel/test_pyccel_make.py | test_circular_dependencies | 153 | null | |
pyccel/pyccel | import pytest
import numpy as np
from modules import loops
from pyccel import epyccel
def test_for_loops(language):
f1 = loops.for_loop1
g1 = epyccel(f1, language=language)
f2 = loops.for_loop2
g2 = epyccel(f2, language=language)
f3 = loops.for_loop2
g3 = epyccel(f3, language=language)
a... | g3() | assert | func_call | tests/epyccel/test_loops.py | test_for_loops | 188 | null | |
pyccel/pyccel | import pytest
from pyccel import epyccel
def test_f1(language):
def f1(x : 'int'):
a = 5 if x < 5 else x
return a
f = epyccel(f1, language = language)
# ...
assert f(6) == | f1(6) | assert | func_call | tests/epyccel/test_epyccel_IfTernaryOperator.py | test_f1 | 16 | null | |
pyccel/pyccel | from numpy.random import randint, rand
import numpy as np
from numpy import iinfo
from pyccel import epyccel
min_int = iinfo(np.int32).min
max_int = iinfo(np.int32).max
def test_swap_basic(language):
def swp(a : int, b : int):
(a, b) = (b, a)
return a, b
f = epyccel(swp, language=language)
... | swp(4,100) | assert | func_call | tests/epyccel/test_epyccel_expressions.py | test_swap_basic | 19 | null | |
pyccel/pyccel | import subprocess
import json
import os
import platform
import shutil
import sys
import re
import random
import pytest
import numpy as np
from filelock import FileLock
from pyccel.codegen.pipeline import execute_pyccel
from pyccel.ast.utilities import python_builtin_libs
from pyccel.compilers.default_compilers import a... | pyth_out | assert | variable | tests/pyccel/test_pyccel.py | test_exit | 1,028 | null | |
pyccel/pyccel | import pytest
from numpy import ones
from pyccel import epyccel
from pyccel.decorators import inline
@pytest.mark.python
def test_import_python_unused_inline():
import modules.Module_13 as mod
mod_epyc = epyccel(mod, language='python')
ui = mod.UnusedInline()
val = ui.sin_2(3.0)
ui_e = mod_epyc.Un... | val_e | assert | variable | tests/epyccel/test_imports.py | test_import_python_unused_inline | 59 | null | |
pyccel/pyccel | import pytest
from numpy import ones
from pyccel import epyccel
from pyccel.decorators import inline
def test_import(language):
def f1(x : 'int[:]'):
import numpy
s = numpy.shape(x)[0]
return s
f = epyccel(f1, language = language)
x = ones(10, dtype=int)
assert f(x) == | f1(x) | assert | func_call | tests/epyccel/test_imports.py | test_import | 19 | null | |
pyccel/pyccel | import pytest
import numpy as np
from modules import loops
from pyccel import epyccel
def test_factorial_while(language):
f1 = loops.factorial_while
f2 = epyccel( f1, language = language )
assert f1( 10 ) == | f2( 10 ) | assert | func_call | tests/epyccel/test_loops.py | test_factorial_while | 34 | null | |
pyccel/pyccel | import sys
from typing import TypeVar
import pytest
from numpy.random import randint, uniform
from numpy import iinfo, finfo
import numpy as np
from pyccel import epyccel
ATOL = 1e-15
RTOL = 2e-14
min_int = iinfo(np.int32).min
max_int = iinfo(np.int32).max
min_float = finfo(float).min
max_float = finfo(float).max
... | f(x, y) | assert | func_call | tests/epyccel/test_builtins.py | test_min_temp_var_first_arg | 224 | null | |
pyccel/pyccel | import sys
import numpy as np
import pytest
from pyccel import epyccel
RTOL = 2e-14
ATOL = 1e-15
def test_module_11(language):
import modules.Module_11 as mod
modnew = epyccel(mod, language=language)
len_pyt = mod.update_multiple()
len_pyc = modnew.update_multiple()
assert len_pyt == | len_pyc | assert | variable | tests/epyccel/test_epyccel_modules.py | test_module_11 | 255 | null | |
pyccel/pyccel | import pytest
from pyccel import epyccel
@pytest.mark.parametrize( 'language', (
pytest.param("fortran", marks = [
pytest.mark.skip(reason="Copy of a list not yet supported (required to handle the generated temporary)."),
pytest.mark.fortran]
),
pytest.param("c", marks ... | f7(4) | assert | func_call | tests/epyccel/test_epyccel_IfTernaryOperator.py | test_f7 | 146 | null | |
pyccel/pyccel | import pytest
import numpy as np
from modules import loops
from pyccel import epyccel
def test_for_loops(language):
f1 = loops.for_loop1
g1 = epyccel(f1, language=language)
f2 = loops.for_loop2
g2 = epyccel(f2, language=language)
f3 = loops.for_loop2
g3 = epyccel(f3, language=language)
... | g1(1,10,1) | assert | func_call | tests/epyccel/test_loops.py | test_for_loops | 183 | null | |
pyccel/pyccel | import sys
import pytest
import numpy as np
import scipy.linalg.blas as sp_blas
import modules.external_functions as mod
from pyccel import epyccel
@pytest.mark.fortran
def test_idamax_1():
blas_idamax = epyccel( mod.blas_idamax, language = 'fortran' )
np.random.seed(2021)
n = 10
x = np.random.random... | expected | assert | variable | tests/epyccel/test_external_functions.py | test_idamax_1 | 88 | null | |
pyccel/pyccel | from typing import TypeVar
import pytest
import numpy as np
from pyccel import epyccel
def test_f4(language):
def f4(x : 'bool' = True):
if x:
return 1
else:
return 2
f = epyccel(f4, language = language)
# ...
assert f(True) == f4(True)
assert f(False)... | f4(False) | assert | func_call | tests/epyccel/test_epyccel_default_args.py | test_f4 | 75 | null | |
pyccel/pyccel | import os
import pytest
from pyccel.parser.parser import Parser
from pyccel.errors.errors import Errors
from pyccel.ast.basic import PyccelAstNode
from pyccel.ast.core import Assign, Return, FunctionDef, AugAssign, FunctionDefArgument
from pyccel.ast.datatypes import PythonNativeInt
from pyccel.as... | a | assert | variable | tests/ast/test_basic.py | test_get_attribute_nodes_exclude | 69 | null | |
pyccel/pyccel | import os
import pytest
from pyccel.parser.parser import Parser
from pyccel.errors.errors import Errors
from pyccel.ast.basic import PyccelAstNode
from pyccel.ast.core import Assign, Return, FunctionDef, AugAssign, FunctionDefArgument
from pyccel.ast.datatypes import PythonNativeInt
from pyccel.as... | 2 | assert | numeric_literal | tests/ast/test_basic.py | test_get_user_nodes_excluded | 103 | null | |
pyccel/pyccel | from typing import TypeVar, Final
import numpy as np
import pytest
from numpy.random import randint, uniform
from pyccel import epyccel
int_types = ['int8', 'int16', 'int32', 'int64']
float_types = ['float32', 'float64']
complex_types = ['complex64', 'complex128']
def test_array_final(language):
def array_final(... | f2(x1) | assert | func_call | tests/epyccel/test_array_as_func_args.py | test_array_final | 150 | null | |
pyccel/pyccel | from typing import TypeVar
import pytest
import numpy as np
from pyccel import epyccel
def test_f5(language):
def f5(x : 'complex' = 1j):
y = x - 1
return y
f = epyccel(f5, language = language)
# ...
assert f(2.9+3j) == | f5(2.9+3j) | assert | func_call | tests/epyccel/test_epyccel_default_args.py | test_f5 | 88 | null | |
pyccel/pyccel | from mpi4py import MPI
import pytest
import numpy as np
from pyccel import epyccel
RTOL = 2e-14
ATOL = 1e-15
@pytest.mark.mpi
def test_function(language):
from modules.Module_1 import f, g, h
comm = MPI.COMM_WORLD
f_fast = epyccel(f, comm=comm, language=language)
g_fast = epyccel(g, comm=comm, lang... | h | assert | variable | tests/epyccel/test_parallel_epyccel.py | test_function | 63 | null | |
pyccel/pyccel | import os
import pytest
from pyccel.parser.parser import Parser
from pyccel.errors.errors import Errors
from pyccel.ast.basic import PyccelAstNode
from pyccel.ast.core import Assign, Return, FunctionDef, AugAssign, FunctionDefArgument
from pyccel.ast.datatypes import PythonNativeInt
from pyccel.as... | b | assert | variable | tests/ast/test_basic.py | test_get_attribute_nodes_exclude | 70 | null | |
pyccel/pyccel | import pytest
from numpy import ones
from pyccel import epyccel
from pyccel.decorators import inline
def test_import_method(language):
def f5(x : 'int[:]'):
s = x.shape[0]
return s
f = epyccel(f5, language = language)
x = ones(10, dtype=int)
assert f(x) == | f5(x) | assert | func_call | tests/epyccel/test_imports.py | test_import_method | 49 | null | |
pyccel/pyccel | import os
from typing import TypeVar
from numpy.random import randint
import numpy as np
import pytest
from pyccel import epyccel
int_types = (bool, np.int8, np.int64)
IT = TypeVar('IT', *int_types)
IT2 = TypeVar('IT2', *int_types)
@pytest.mark.skipif(os.environ.get('PYCCEL_DEFAULT_COMPILER', 'GNU') == 'intel',
... | epyc_z.dtype | assert | complex_expr | tests/epyccel/recognised_functions/test_numpy_operators.py | test_numpy_bit_invert | 204 | null | |
pyccel/pyccel | import pytest
import numpy as np
import modules.generic_functions as mod
import modules.generic_functions_2 as mod2
from pyccel import epyccel
def modnew(language):
return epyccel(mod, language = language)
def test_default_var_3(language):
f1 = epyccel(mod2.default_var_3, language = language)
f2 = mod2.de... | f1(5) | assert | func_call | tests/epyccel/test_generic_functions.py | test_default_var_3 | 129 | null | |
pyccel/pyccel | import subprocess
import json
import os
import platform
import shutil
import sys
import re
import random
import pytest
import numpy as np
from filelock import FileLock
from pyccel.codegen.pipeline import execute_pyccel
from pyccel.ast.utilities import python_builtin_libs
from pyccel.compilers.default_compilers import a... | dict_2 | assert | variable | tests/pyccel/test_pyccel.py | test_json | 1,101 | null | |
pyccel/pyccel | import pytest
import numpy as np
from modules import loops
from pyccel import epyccel
def test_less_than_100(language):
f1 = loops.less_than_100
f2 = epyccel( f1, language = language )
assert f1(10) == | f2(10) | assert | func_call | tests/epyccel/test_loops.py | test_less_than_100 | 237 | null | |
pyccel/pyccel | import sys
from typing import TypeVar, Final
import pytest
import numpy as np
from numpy.random import randint
from pyccel import epyccel
RTOL = 2e-14
ATOL = 1e-15
def test_decorator_f2(language):
def f2(x : 'int [:]'):
y = x[0] - 1
return y
f = epyccel(f2, language=language)
# ...
... | f2(x) | assert | func_call | tests/epyccel/test_epyccel_functions.py | test_decorator_f2 | 105 | null | |
pyccel/pyccel | from typing import TypeVar, Final
import pytest
import numpy as np
from pyccel import epyccel
from pyccel.decorators import private, inline
def test_indexed_template(language):
T = TypeVar('T', 'float[:]', 'complex[:]')
def my_sum(v: Final[T]):
return v.sum()
pyccel_sum = epyccel(my_sum, language... | pyccel_fl | assert | variable | tests/epyccel/test_epyccel_decorators.py | test_indexed_template | 303 | null | |
pyccel/pyccel | import pytest
import numpy as np
from modules import loops
from pyccel import epyccel
def test_for_loops(language):
f1 = loops.for_loop1
g1 = epyccel(f1, language=language)
f2 = loops.for_loop2
g2 = epyccel(f2, language=language)
f3 = loops.for_loop2
g3 = epyccel(f3, language=language)
a... | g2() | assert | func_call | tests/epyccel/test_loops.py | test_for_loops | 187 | null | |
pyccel/pyccel | import os
import pytest
import numpy as np
from numpy import iinfo, finfo
from numpy.random import randint, uniform
from pyccel import epyccel
from modules import arrays
RTOL = 1e-12
ATOL = 1e-16
def check_array_equal(a, b):
"""
Check that two arrays are equal.
Check that two arrays are equal. To... | s2 | assert | variable | tests/epyccel/test_arrays.py | test_array_random_size | 2,225 | null | |
pyccel/pyccel | import pytest
from pyccel import epyccel
def test_f2(language):
def f2(x : 'int'):
a = 5.5 if x < 5 else x
return a
f = epyccel(f2, language = language)
# ...
assert f(6) == f2(6)
assert f(4) == | f2(4) | assert | func_call | tests/epyccel/test_epyccel_IfTernaryOperator.py | test_f2 | 30 | null | |
pyccel/pyccel | import pytest
import numpy as np
import modules.expose_classes as mod
from pyccel import epyccel
RTOL = 2e-14
ATOL = 1e-15
def modnew(language):
return epyccel(mod, language = language)
def test_classes_2(language):
import classes.classes_2 as mod
modnew = epyccel(mod, language = language)
p_py = mo... | a_l | assert | variable | tests/epyccel/test_epyccel_classes.py | test_classes_2 | 122 | null | |
pyccel/pyccel | import pytest
import modules.function_call_before_definition as mod1
import modules.function_call_before_definition_2 as mod2
from pyccel import epyccel
def test_fun_1(language):
modnew = epyccel(mod1, language = language)
assert mod1.x1 == | modnew.x1 | assert | complex_expr | tests/epyccel/test_function_call_before_definition.py | test_fun_1 | 10 | null | |
pyccel/pyccel | import pytest
import numpy as np
import modules.generic_functions as mod
import modules.generic_functions_2 as mod2
from pyccel import epyccel
def modnew(language):
return epyccel(mod, language = language)
@pytest.mark.parametrize( 'language', (
pytest.param("fortran", marks = pytest.mark.fortran),
... | i_2 | assert | variable | tests/epyccel/test_generic_functions.py | test_zeros_types | 437 | null | |
pyccel/pyccel | import gc
import sys
import numpy as np
import pytest
from pyccel import epyccel
def test_return_pointer(language):
def return_pointer(x : 'float[:]'):
return x
f = epyccel(return_pointer, language=language)
x_pyc = np.ones(10)
x_pyt = np.ones(10)
start_ref_count_pyc = sys.getrefcount(x_... | x_pyc | assert | variable | tests/epyccel/test_epyccel_garbage_collection.py | test_return_pointer | 31 | null | |
pyccel/pyccel | import numpy as np
from numpy.random import randint, uniform
from modules import types
from pyccel import epyccel
def test_int_default(language):
f1 = types.test_int_default
f2 = epyccel(f1, language = language)
a = randint(low = -1e9, high = 0, dtype = int) # negative
b = randint(low = 0, high = 1e9... | f2(b) | assert | func_call | tests/epyccel/test_epyccel_types.py | test_int_default | 17 | null | |
pyccel/pyccel | import pytest
import numpy as np
from pyccel import epyccel
RTOL = 2e-14
ATOL = 1e-15
def Module_5(language):
import modules.Module_5 as mod
modnew = epyccel(mod, language = language)
return mod, modnew
def test_f14(language):
def f14(x : 'int' = None, y : 'int' = None):
if x is None :
... | f14(y=0) | assert | func_call | tests/epyccel/test_epyccel_optional_args.py | test_f14 | 209 | null | |
pyccel/pyccel | import os
import sys
import warnings
import pytest
from pyccel import epyccel
def test_with_capitalised_language(language):
def free_gift():
gift = 10
return gift
c_gift = epyccel(free_gift, language=language.capitalize())
assert c_gift() == | free_gift() | assert | func_call | tests/epyccel/test_epyccel_args.py | test_with_capitalised_language | 19 | null | |
pyccel/pyccel | from typing import TypeVar
import pytest
import numpy as np
from pyccel import epyccel
def test_f1(language):
def f1(x : 'int' = 1):
y = x - 1
return y
f = epyccel(f1, language = language)
# ...
assert f(2) == f1(2)
assert f() == | f1() | assert | func_call | tests/epyccel/test_epyccel_default_args.py | test_f1 | 19 | null | |
pyccel/pyccel | import pytest
from pyccel import epyccel
def test_f4(language):
def f4(x : 'int'):
a = x if x < 5 else 5 >> 2
return a
def f4wp(x : 'int'):
a = (x if x < 5 else 5) >> 2
return a
f = epyccel(f4, language = language)
fwp = epyccel(f4wp, language = language)
# ...
... | f4(6) | assert | func_call | tests/epyccel/test_epyccel_IfTernaryOperator.py | test_f4 | 67 | null | |
pyccel/pyccel | from numpy.random import randint, rand
import numpy as np
from numpy import iinfo
from pyccel import epyccel
min_int = iinfo(np.int32).min
max_int = iinfo(np.int32).max
def test_swap_basic(language):
def swp(a : int, b : int):
(a, b) = (b, a)
return a, b
f = epyccel(swp, language=language)
... | swp(x,y) | assert | func_call | tests/epyccel/test_epyccel_expressions.py | test_swap_basic | 22 | null | |
pyccel/pyccel | import pytest
from pyccel import epyccel
def test_f6(language):
def f6(x : 'int'):
# a = x if x < 0 else (1 if x < 5 else (complex(0, 1) if x == 5 else 6.5))
a = x if x < 0 else 1 if x < 5 else complex(0, 1) if x == 5 else 6.5
return a
def f6wp(x : 'int'):
a = x if x < 0 else ... | f6(6) | assert | func_call | tests/epyccel/test_epyccel_IfTernaryOperator.py | test_f6 | 110 | null | |
pyccel/pyccel | import os
from typing import TypeVar
from numpy.random import randint
import numpy as np
import pytest
from pyccel import epyccel
int_types = (bool, np.int8, np.int64)
IT = TypeVar('IT', *int_types)
IT2 = TypeVar('IT2', *int_types)
def test_numpy_bit_and(language):
def f(a : 'IT[:,:,:]', b : 'IT2[:,:,:]'):
... | epyc_z2.dtype | assert | complex_expr | tests/epyccel/recognised_functions/test_numpy_operators.py | test_numpy_bit_and | 41 | null | |
pyccel/pyccel | import numpy as np
import pytest
from numpy.random import randint
from pyccel import epyccel
def test_complex_imag(language):
def f():
a = 1+2j
return a.imag
epyc_f = epyccel(f, language=language)
r = f()
epyc_r = epyc_f()
assert r == | epyc_r | assert | variable | tests/epyccel/test_class_expressions.py | test_complex_imag | 17 | null | |
pyccel/pyccel | import sys
from typing import TypeVar, Final
import pytest
import numpy as np
from numpy.random import randint
from pyccel import epyccel
RTOL = 2e-14
ATOL = 1e-15
def test_decorator_f8(language):
def f8(x : 'int', b : 'bool'):
a = x if b else 2
return a
f = epyccel(f8, language=language)
... | f8(3,True) | assert | func_call | tests/epyccel/test_epyccel_functions.py | test_decorator_f8 | 213 | null | |
pyccel/pyccel | import sys
import pytest
import numpy as np
from numpy.random import rand, randint
import modules.complex_func as mod
from pyccel import epyccel
ATOL = 1e-15
RTOL = 2e-14
deprecation = (sys.version_info >= (3, 14))
deprecation_reason = 'Since Python 3.14 complex() requires real arguments'
def test_create_complex__... | f(a) | assert | func_call | tests/epyccel/test_epyccel_complex_func.py | test_create_complex__int_int | 86 | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.