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
curvefi/curve-dao-contracts
import brownie def test_updates_reward_duration(alice, stream): pre_update = stream.reward_duration() stream.set_reward_duration(86400 * 365, {"from": alice}) assert pre_update == 86400 * 10 assert stream.reward_duration() ==
86400 * 365
assert
complex_expr
tests/unitary/RewardStream/test_set_reward_duration.py
test_updates_reward_duration
9
null
curvefi/curve-dao-contracts
import brownie import pytest def setup(accounts, gauge_controller, minter, gauge_v2, token, mock_lp_token): token.set_minter(minter, {"from": accounts[0]}) gauge_controller.add_type(b"Liquidity", 10 ** 10, {"from": accounts[0]}) gauge_controller.add_gauge(gauge_v2, 0, 0, {"from": accounts[0]}) mock_l...
True
assert
bool_literal
tests/unitary/LiquidityGaugeV2/test_transfer.py
test_returns_true
48
null
curvefi/curve-dao-contracts
def test_burner(WrappedBurner, WETH, alice, receiver): initial_balance = receiver.balance() burner = WrappedBurner.deploy(WETH, receiver, {"from": alice}) amount = 12 * 10 ** 18 WETH._mint_for_testing(alice, amount, {"from": alice}) WETH.approve(burner, 2 ** 256 - 1, {"from": alice}) WETH._mint_...
3 * amount
assert
complex_expr
tests/fork/Burners/test_wrapped_burner.py
test_burner
14
null
curvefi/curve-dao-contracts
import pytest from brownie import ETH_ADDRESS, ZERO_ADDRESS, Contract def receiver(UnderlyingBurner, alice, receiver): yield UnderlyingBurner.deploy(receiver, receiver, alice, alice, {"from": alice}) def burner(SynthBurner, alice, receiver): contract = SynthBurner.deploy(receiver, receiver, alice, alice, {"fr...
0
assert
numeric_literal
tests/fork/Burners/test_synth_burner.py
test_swap
74
null
curvefi/curve-dao-contracts
import brownie import pytest def setup( accounts, gauge_controller, minter, liquidity_gauge_reward, reward_gauge_wrapper, token, mock_lp_token, ): token.set_minter(minter, {"from": accounts[0]}) gauge_controller.add_type(b"Liquidity", 10 ** 10, {"from": accounts[0]}) gauge_cont...
0
assert
numeric_literal
tests/unitary/LiquidityGaugeRewardWrapper/test_transferFrom.py
test_transfer_full_balance
108
null
curvefi/curve-dao-contracts
import pytest from tests.conftest import approx REWARD = 10 ** 20 WEEK = 7 * 86400 LP_AMOUNT = 10 ** 18 def initial_setup(accounts, coin_reward, reward_contract, mock_lp_token, liquidity_gauge_reward): # Fund coin_reward._mint_for_testing(accounts[0], REWARD) coin_reward.transfer(reward_contract, REWARD,...
0
assert
numeric_literal
tests/unitary/LiquidityGaugeReward/test_claim_rewards.py
test_claim_for_other
40
null
curvefi/curve-dao-contracts
import brownie import pytest def setup(accounts, gauge_controller, minter, gauge_v2, token, mock_lp_token): token.set_minter(minter, {"from": accounts[0]}) gauge_controller.add_type(b"Liquidity", 10 ** 10, {"from": accounts[0]}) gauge_controller.add_gauge(gauge_v2, 0, 0, {"from": accounts[0]}) mock_l...
True
assert
bool_literal
tests/unitary/LiquidityGaugeV2/test_transferFrom.py
test_returns_true
83
null
curvefi/curve-dao-contracts
import pytest from brownie.test import given, strategy from tests.conftest import INITIAL_SUPPLY, YEAR, YEAR_1_SUPPLY, approx def initial_setup(chain, token): chain.sleep(86401) token.update_mining_parameters() @given(start=strategy("uint", max_value=YEAR * 6), duration=strategy("uint", max_value=YEAR)) def ...
rate * end
assert
complex_expr
tests/integration/ERC20CRV/test_mintable_in_timeframe.py
test_random_range_multiple_epochs
62
null
curvefi/curve-dao-contracts
import brownie MAX_UINT256 = 2 ** 256 - 1 WEEK = 7 * 86400 def test_kick(chain, accounts, gauge_v2, voting_escrow, token, mock_lp_token): alice, bob = accounts[:2] chain.sleep(2 * WEEK + 5) token.approve(voting_escrow, MAX_UINT256, {"from": alice}) voting_escrow.create_lock(10 ** 20, chain.time() + 4...
10 ** 21
assert
complex_expr
tests/unitary/LiquidityGaugeV2/test_kick.py
test_kick
17
null
curvefi/curve-dao-contracts
import pytest from brownie import ZERO_ADDRESS, Contract from brownie_tokens import MintableForkToken coins = { "usdt": "0xdAC17F958D2ee523a2206206994597C13D831ec7", "wsteth": "0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0", "wbtc": "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599", "usdc": "0xA0b86991c6218b36...
0
assert
numeric_literal
tests/fork/Burners/test_tricrypto_factory_lp_burner.py
test_first_coin
60
null
curvefi/curve-dao-contracts
import brownie def test_commit_transfer_ownership(vesting, accounts): vesting.commit_transfer_ownership(accounts[1], {"from": accounts[0]}) assert vesting.admin() ==
accounts[0]
assert
complex_expr
tests/unitary/VestingEscrow/test_vesting_escrow_admin.py
test_commit_transfer_ownership
17
null
curvefi/curve-dao-contracts
import math from datetime import datetime from functools import wraps from typing import List, Tuple import rlp from brownie import Contract, RootForwarder, accounts, chain, network, web3 from brownie.project import get_loaded_projects from eth_utils import keccak from hexbytes import HexBytes from tqdm import tqdm, t...
1
assert
numeric_literal
scripts/burners/exit_polygon.py
__init__
MerkleTree
138
null
curvefi/curve-dao-contracts
from random import random, randrange from tests.conftest import YEAR, approx MAX_UINT256 = 2 ** 256 - 1 WEEK = 7 * 86400 def test_mining_with_votelock( accounts, chain, history, mock_lp_token, token, liquidity_gauge, gauge_controller, voting_escrow, ): alice, bob = accounts[:2] ...
0
assert
numeric_literal
tests/integration/LiquidityGauge/test_liquidity_gauge.py
test_mining_with_votelock
152
null
curvefi/curve-dao-contracts
import brownie def test_set_name(accounts, token): token.set_name("Foo Token", "FOO", {"from": accounts[0]}) assert token.name() ==
"Foo Token"
assert
string_literal
tests/unitary/ERC20CRV/test_setters.py
test_set_name
34
null
curvefi/curve-dao-contracts
import brownie import pytest ZERO_ADDRESS = "0x0000000000000000000000000000000000000000" AMOUNTS = [10 ** 17 * i for i in range(1, 101)] def initial_setup(accounts, vesting): vesting.add_tokens(10 ** 21, {"from": accounts[0]}) def test_one_recipient(vesting, accounts): recipients = [accounts[5]] + [ZERO_ADDR...
10 ** 20
assert
complex_expr
tests/unitary/VestingEscrow/test_fund.py
test_one_recipient
55
null
curvefi/curve-dao-contracts
import brownie def test_set_approve_deposit_toggle(accounts, liquidity_gauge): for value in [True, True, False, False, True, False, True]: liquidity_gauge.set_approve_deposit(accounts[0], value, {"from": accounts[1]}) assert liquidity_gauge.approved_to_deposit(accounts[0], accounts[1]) is
value
assert
variable
tests/unitary/LiquidityGauge/test_deposit_for.py
test_set_approve_deposit_toggle
33
null
curvefi/curve-dao-contracts
import brownie def test_commit_transfer_ownership(vesting_factory, accounts): vesting_factory.commit_transfer_ownership(accounts[1], {"from": accounts[0]}) assert vesting_factory.admin() ==
accounts[0]
assert
complex_expr
tests/unitary/VestingEscrowFactory/test_admin_factory.py
test_commit_transfer_ownership
17
null
curvefi/curve-dao-contracts
REWARD = 10 ** 20 WEEK = 7 * 86400 LP_AMOUNT = 10 ** 18 def test_claim_no_deposit(accounts, chain, liquidity_gauge_reward, reward_contract, coin_reward): # Fund coin_reward._mint_for_testing(accounts[0], REWARD) coin_reward.transfer(reward_contract, REWARD, {"from": accounts[0]}) reward_contract.notify...
0
assert
numeric_literal
tests/unitary/LiquidityGaugeReward/test_claim_rewards_none.py
test_claim_no_deposit
16
null
curvefi/curve-dao-contracts
import brownie WEEK = 7 * 86400 YEAR = 365 * 86400 TYPE_WEIGHTS = [5 * 10 ** 17, 2 * 10 ** 18] GAUGE_WEIGHTS = [2 * 10 ** 18, 10 ** 18, 5 * 10 ** 17] def test_n_gauges_same_gauge(accounts, gauge_controller, three_gauges): assert gauge_controller.n_gauges() == 0 gauge_controller.add_gauge(three_gauges[0], 0,...
1
assert
numeric_literal
tests/unitary/GaugeController/test_gauges_weights.py
test_n_gauges_same_gauge
34
null
curvefi/curve-dao-contracts
import brownie from tests.conftest import approx def to_int(*args): # Helper function for readability return [int(a) for a in args] def test_mint(accounts, chain, mock_lp_token, gauge_controller, three_gauges, minter, token): admin, bob, charlie, dan = accounts[:4] token.set_minter(minter, {"from": ...
amount
assert
variable
tests/integration/Minter/test_minter_integration.py
test_mint
63
null
curvefi/curve-dao-contracts
import brownie import pytest from brownie import ZERO_ADDRESS, Contract from brownie_tokens import MintableForkToken coins = { "weth": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", "yfi": "0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e", "stg": "0xAf5191B0De278C7286d6C7CC6ab6BB8A73bA2Cd6", "usdc": "0xA0b86...
2
assert
numeric_literal
tests/fork/Burners/test_crypto_factory_lp_burner.py
test_manager
212
null
curvefi/curve-dao-contracts
import brownie import pytest def fee_distributor(FeeDistributor, accounts, chain, voting_escrow, coin_a): yield FeeDistributor.deploy( voting_escrow, chain.time(), coin_a, accounts[0], accounts[1], {"from": accounts[0]} ) def test_assumptions(fee_distributor, accounts): assert not fee_distributor....
accounts[1]
assert
complex_expr
tests/unitary/FeeDistribution/test_kill_fee_distro.py
test_assumptions
14
null
curvefi/curve-dao-contracts
import brownie import pytest def root_gauge(GaugeController, Minter, RootGaugeArbitrum, alice, chain): gauge_controller = GaugeController.at("0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB") minter = Minter.at("0xd061D61a4d941c39E5453435B6345Dc261C2fcE0") root_gauge = RootGaugeArbitrum.deploy( minter,...
0
assert
numeric_literal
tests/fork/test_root_gauge.py
test_modify_gas
52
null
curvefi/curve-dao-contracts
import pytest from brownie import ZERO_ADDRESS, Contract from brownie_tokens import MintableForkToken LP_TOKENS = [ "0x4DEcE678ceceb27446b35C672dC7d61F30bAD69E", # USDC/crvUSD "0x34d655069f4cac1547e4c8ca284ffff5ad4a8db0", # TUSD/crvUSD "0x390f3595bca2df7d23783dfd126427cceb997bf4", # USDT/crvUSD "0xc...
sum(initial_amounts)
assert
func_call
tests/fork/Burners/test_crvburner.py
test_crvusd
135
null
curvefi/curve-dao-contracts
import brownie import pytest def deposit_setup(accounts, liquidity_gauge_reward, mock_lp_token): mock_lp_token.approve(liquidity_gauge_reward, 2 ** 256 - 1, {"from": accounts[0]}) def test_deposit_zero(accounts, liquidity_gauge_reward, mock_lp_token, reward_contract): balance = mock_lp_token.balanceOf(account...
balance
assert
variable
tests/unitary/LiquidityGaugeReward/test_deposit_withdraw_reward.py
test_deposit_zero
25
null
curvefi/curve-dao-contracts
from brownie import ETH_ADDRESS, web3 from brownie.convert import to_bytes from hexbytes import HexBytes WEEK = 86400 * 7 def test_anyswap_root_gauge_transfer_crv(alice, chain, gauge_controller, anyswap_root_gauge, token): gauge_controller.add_type("Test", 10 ** 18, {"from": alice}) gauge_controller.add_gauge...
[ETH_ADDRESS, amount]
assert
collection
tests/unitary/Sidechain/test_sending_to_bridge.py
test_anyswap_root_gauge_transfer_crv
22
null
curvefi/curve-dao-contracts
import pytest def burner(USDNBurner, alice, receiver, pool_proxy, swap): contract = USDNBurner.deploy(pool_proxy, receiver, receiver, alice, alice, {"from": alice}) pool_proxy.set_donate_approval(swap, contract, True, {"from": alice}) yield contract def swap(Contract): yield Contract("0x0f9cb53Ebe405...
0
assert
numeric_literal
tests/fork/Burners/test_usdn_burner.py
test_swap
53
null
curvefi/curve-dao-contracts
import math import brownie import pytest from brownie import ZERO_ADDRESS, compile_source from tests.conftest import approx REWARD = 10 ** 20 WEEK = 7 * 86400 LP_AMOUNT = 10 ** 18 code = """ # @version 0.2.7 from vyper.interfaces import ERC20 first: address second: address @external def __init__(_first: address,...
REWARD
assert
variable
tests/unitary/LiquidityGaugeV3/test_claim_rewards_multiple.py
test_claim_for_other
97
null
curvefi/curve-dao-contracts
from random import random, randrange from tests.conftest import YEAR, approx MAX_UINT256 = 2 ** 256 - 1 WEEK = 7 * 86400 def test_mining_with_votelock( accounts, chain, history, mock_lp_token, token, liquidity_gauge, gauge_controller, voting_escrow, ): alice, bob = accounts[:2] ...
d_bob
assert
variable
tests/integration/LiquidityGauge/test_liquidity_gauge.py
test_mining_with_votelock
179
null
curvefi/curve-dao-contracts
import brownie import pytest from brownie import ZERO_ADDRESS REWARD = 10 ** 20 WEEK = 7 * 86400 LP_AMOUNT = 10 ** 18 def reward_contract_2(CurveRewards, mock_lp_token, accounts, coin_a): contract = CurveRewards.deploy(mock_lp_token, coin_a, {"from": accounts[0]}) contract.setRewardDistribution(accounts[0], {...
[ZERO_ADDRESS] * 8
assert
collection
tests/unitary/LiquidityGaugeV2/test_set_rewards_no_deposit.py
test_unset_no_totalsupply
29
null
curvefi/curve-dao-contracts
import brownie import pytest from brownie.test import given, strategy from tests.conftest import YEAR def initial_setup(chain, token): chain.sleep(86401) token.update_mining_parameters() @given(durations=strategy("uint[5]", min_value=YEAR * 0.33, max_value=YEAR * 0.9)) def test_mint_multiple(accounts, chain,...
balance
assert
variable
tests/integration/ERC20CRV/test_mint_integration.py
test_mint_multiple
60
null
curvefi/curve-dao-contracts
import pytest def burner(BTCBurner, alice, receiver): yield BTCBurner.deploy(receiver, receiver, alice, alice, {"from": alice}) def test_execute(SUSD, USDC, alice, burner, receiver): SUSD._mint_for_testing(burner, 10 ** 18, {"from": alice}) burner.execute({"from": alice}) assert SUSD.balanceOf(alic...
0
assert
numeric_literal
tests/fork/Burners/test_btc_burner.py
test_execute
52
null
curvefi/curve-dao-contracts
import pytest def test_approve(gauge_v2, accounts): gauge_v2.approve(accounts[1], 10 ** 19, {"from": accounts[0]}) assert gauge_v2.allowance(accounts[0], accounts[1]) ==
10 ** 19
assert
complex_expr
tests/unitary/LiquidityGaugeV2/test_approve.py
test_approve
12
null
curvefi/curve-dao-contracts
import math import brownie import pytest from brownie import ZERO_ADDRESS, compile_source from tests.conftest import approx REWARD = 10 ** 20 WEEK = 7 * 86400 LP_AMOUNT = 10 ** 18 code = """ # @version 0.2.7 from vyper.interfaces import ERC20 first: address second: address @external def __init__(_first: address,...
claimed[1]
assert
complex_expr
tests/unitary/RewardsOnlyGauge/test_claim_rewards_multiple.py
test_claim_duration
172
null
curvefi/curve-dao-contracts
import brownie import pytest ZERO_ADDRESS = "0x0000000000000000000000000000000000000000" def test_set_admins(accounts, crypto_pool_proxy): crypto_pool_proxy.commit_set_admins( accounts[1], accounts[2], accounts[3], {"from": accounts[0]} ) crypto_pool_proxy.apply_set_admins() assert crypto_po...
accounts[1]
assert
complex_expr
tests/unitary/CryptoPoolProxy/test_set_admins_crypto.py
test_set_admins
13
null
curvefi/curve-dao-contracts
import brownie import pytest ZERO_ADDRESS = "0x0000000000000000000000000000000000000000" AMOUNTS = [10 ** 17 * i for i in range(1, 101)] def initial_setup(accounts, vesting): vesting.add_tokens(10 ** 21, {"from": accounts[0]}) def test_partial_recipients(vesting, accounts): recipients = accounts[:5] + [ZERO_...
sum(AMOUNTS[:5])
assert
func_call
tests/unitary/VestingEscrow/test_fund.py
test_partial_recipients
48
null
curvefi/curve-dao-contracts
import pytest ZERO_ADDRESS = "0x0000000000000000000000000000000000000000" def initial_funding(vesting, accounts): recipients = [accounts[1]] + [ZERO_ADDRESS] * 99 vesting.add_tokens(10 ** 21, {"from": accounts[0]}) vesting.fund(recipients, [10 ** 20] + [0] * 99, {"from": accounts[0]}) def test_claim_full...
10 ** 20
assert
complex_expr
tests/unitary/VestingEscrow/test_claim.py
test_claim_full
17
null
curvefi/curve-dao-contracts
from collections import defaultdict import brownie from brownie import RewardStream, chain from brownie.test import strategy from brownie_tokens import ERC20 DAY = 60 * 60 * 24 class StateMachine: st_uint = strategy("uint64") st_receiver = strategy("address") def __init__(cls, accounts, owner, distribu...
val
assert
variable
tests/integration/test_reward_stream_state.py
invariant_state_getters
StateMachine
233
null
curvefi/curve-dao-contracts
import brownie WEEK = 86400 * 7 YEAR = 365 * 86400 ZERO_ADDRESS = "0x0000000000000000000000000000000000000000" def test_burn_all(accounts, token): initial_supply = token.totalSupply() token.burn(initial_supply, {"from": accounts[0]}) assert token.balanceOf(accounts[0]) ==
0
assert
numeric_literal
tests/unitary/ERC20CRV/test_burn.py
test_burn_all
30
null
curvefi/curve-dao-contracts
import brownie import pytest def test_event_emitted(alice, bob, root_gauge): tx = root_gauge.commit_transfer_ownership(bob, {"from": alice}) assert "CommitOwnership" in
tx.events
assert
complex_expr
tests/unitary/Sidechain/test_commit_transfer_ownership.py
test_event_emitted
29
null
curvefi/curve-dao-contracts
import brownie import pytest from brownie.test import given, strategy from tests.conftest import YEAR def initial_setup(chain, token): chain.sleep(86401) token.update_mining_parameters() @given(duration=strategy("uint", min_value=86500, max_value=YEAR)) def test_mint(accounts, chain, token, duration): to...
amount
assert
variable
tests/integration/ERC20CRV/test_mint_integration.py
test_mint
25
null
zwicker-group/py-pde
import collections import copy import gc import sys import numpy as np import pytest from pde.tools import cache def deep_getsizeof(obj, ids=None): """Find the memory footprint of a Python object. This is a recursive function that drills down a Python object graph like a dictionary holding nested dictio...
2
assert
numeric_literal
tests/tools/test_cache.py
test_method_cache_extra_args
420
null
zwicker-group/py-pde
import numpy as np import pytest import pde from pde.tools.misc import module_available @pytest.mark.skipif( not module_available("modelrunner"), reason="requires `py-modelrunner` package" ) def test_storage_write_trajectory(tmp_path): """Test simple storage writing.""" import modelrunner as mr path ...
3
assert
numeric_literal
tests/storage/test_modelrunner_storages.py
test_storage_write_trajectory
33
null
zwicker-group/py-pde
import contextlib import functools import platform import numpy as np import pytest from pde import ( DiffusionPDE, FileStorage, MemoryStorage, MovieStorage, UnitGrid, storage, ) from pde.fields import FieldCollection, ScalarField, Tensor2Field, VectorField from pde.storage.base import Storage...
2
assert
numeric_literal
tests/storage/test_generic_storages.py
test_storage_apply
249
null
zwicker-group/py-pde
import gc import numpy as np import pytest from fixtures.fields import get_cartesian_grid, iter_grids from pde.backends import backends from pde.fields.base import FieldBase from pde.fields.scalar import ScalarField from pde.grids import CartesianGrid, PolarSymGrid, UnitGrid, boundaries from pde.grids._mesh import Gr...
s2
assert
variable
tests/fields/test_scalar_fields.py
test_scalars
86
null
zwicker-group/py-pde
import logging import numba as nb import numpy as np import pytest from pde import FieldCollection, ScalarField, Tensor2Field, UnitGrid, VectorField from pde.backends.numba import numba_backend from pde.tools.expressions import ( BCDataError, ScalarExpression, TensorExpression, evaluate, parse_exp...
f
assert
variable
tests/tools/test_expressions.py
test_const
84
null
zwicker-group/py-pde
import numpy as np import pytest from pde import CartesianGrid, ScalarField, SphericalSymGrid, Tensor2Field, VectorField @pytest.mark.parametrize("r_inner", [0, 1]) def test_gradient_squared(r_inner, rng): """Compare gradient squared operator.""" grid = SphericalSymGrid((r_inner, 5), 64) field = ScalarFie...
s2.data)
assert_*
complex_expr
tests/backends/numba/operators/test_numba_spherical_operators.py
test_gradient_squared
128
null
zwicker-group/py-pde
import itertools import numpy as np import pytest from pde import PolarSymGrid, ScalarField, UnitGrid from pde.backends import backends from pde.grids.base import PeriodicityError from pde.grids.boundaries.axes import ( BCDataError, BoundariesBase, BoundariesList, BoundariesSetter, ) from pde.grids.bo...
2
assert
numeric_literal
tests/grids/boundaries/test_axes_boundaries.py
test_boundaries
34
null
zwicker-group/py-pde
import numpy as np import pytest import pde from pde import DiffusionPDE, FileStorage, ScalarField, UnitGrid from pde.tools.misc import module_available @pytest.mark.skipif(not module_available("h5py"), reason="requires `h5py` module") def test_keep_opened(tmp_path): """Test the keep opened option.""" path = ...
3
assert
numeric_literal
tests/storage/test_file_storages.py
test_keep_opened
179
null
zwicker-group/py-pde
import numpy as np import pytest from pde.tools.cuboid import Cuboid, asanyarray_flags def test_cuboid_2d(): """Test Cuboid class in 2d.""" c = Cuboid([-1, -1], [2, 2]) assert c.dim == 2 assert c.volume ==
4
assert
numeric_literal
tests/tools/test_cuboid.py
test_cuboid_2d
15
null
zwicker-group/py-pde
import numpy as np import pytest from pde.tools.mpi import mpi_allreduce, mpi_recv, mpi_send, rank, size @pytest.mark.multiprocessing @pytest.mark.parametrize("operator", ["MAX", "MIN", "SUM"]) def test_allreduce(operator, rng): """Test MPI allreduce function.""" data = rng.uniform(size=size) result = mpi...
data.sum()
assert
func_call
tests/tools/test_mpi.py
test_allreduce
38
null
zwicker-group/py-pde
import numpy as np import pytest from pde.tools.cuboid import Cuboid, asanyarray_flags def test_cuboid_2d(): """Test Cuboid class in 2d.""" c = Cuboid([-1, -1], [2, 2]) assert c.dim ==
2
assert
numeric_literal
tests/tools/test_cuboid.py
test_cuboid_2d
14
null
zwicker-group/py-pde
import numpy as np from pde import ( CartesianGrid, CylindricalSymGrid, ScalarField, Tensor2Field, VectorField, ) def test_laplacian_field_cyl(): """Test the gradient operator.""" grid = CylindricalSymGrid(2 * np.pi, [0, 2 * np.pi], [8, 16], periodic_z=True) r, z = grid.cell_coords[......
res)
assert_*
variable
tests/backends/numba/operators/test_numba_cylindrical_operators.py
test_laplacian_field_cyl
24
null
zwicker-group/py-pde
import platform import numpy as np import pytest from pde import ( CartesianGrid, CylindricalSymGrid, ScalarField, Tensor2Field, VectorField, ) pytest.importorskip("torch") def test_laplacian_field_cyl(): """Test the gradient operator.""" grid = CylindricalSymGrid(2 * np.pi, [0, 2 * np.p...
(8, 16)
assert
collection
tests/backends/torch/operators/test_torch_cylindrical_operators.py
test_laplacian_field_cyl
29
null
zwicker-group/py-pde
import numpy as np import pytest from fixtures.fields import iter_grids from pde import FieldCollection, ScalarField, Tensor2Field, UnitGrid, VectorField from pde.fields.base import FieldBase from pde.tools.misc import module_available def test_collections(rng): """Test field collections.""" grid = UnitGrid([...
1
assert
numeric_literal
tests/fields/test_field_collections.py
test_collections
55
null
zwicker-group/py-pde
import collections import copy import gc import sys import numpy as np import pytest from pde.tools import cache def deep_getsizeof(obj, ids=None): """Find the memory footprint of a Python object. This is a recursive function that drills down a Python object graph like a dictionary holding nested dictio...
1
assert
numeric_literal
tests/tools/test_cache.py
test_method_cache_extra_args
416
null
zwicker-group/py-pde
import contextlib import functools import platform import numpy as np import pytest from pde import ( DiffusionPDE, FileStorage, MemoryStorage, MovieStorage, UnitGrid, storage, ) from pde.fields import FieldCollection, ScalarField, Tensor2Field, VectorField from pde.storage.base import Storage...
j
assert
variable
tests/storage/test_generic_storages.py
test_storage_view
398
null
zwicker-group/py-pde
import numpy as np import pytest from pde import PDE, DiffusionPDE, FieldCollection, ScalarField, UnitGrid from pde.solvers import Controller, ExplicitMPISolver from pde.tools import mpi @pytest.mark.multiprocessing @pytest.mark.parametrize("backend", ["numpy", "numba"]) @pytest.mark.parametrize( ("adaptive", "de...
mpi.size
assert
complex_expr
tests/solvers/test_explicit_mpi_solvers.py
test_simple_pde_mpi
53
null
zwicker-group/py-pde
import numpy as np import pytest from scipy import fftpack, stats from pde import CartesianGrid, UnitGrid from pde.tools.spectral import make_correlated_noise def spectral_density(data, dx=1.0): """Calculate the power spectral density of a field. Args: data (:class:`~numpy.ndarray`): Data...
pytest.approx(0)
assert
func_call
tests/tools/test_spectral.py
test_gaussian_correlation
119
null
zwicker-group/py-pde
import numpy as np import pytest from pde import PDE, DiffusionPDE, MemoryStorage, ScalarField, UnitGrid from pde.pdes import PDEBase from pde.solvers import Controller, EulerSolver, ExplicitMPISolver, RungeKuttaSolver from pde.tools import mpi @pytest.mark.parametrize("solver", [EulerSolver, RungeKuttaSolver]) @pyte...
20 / dt
assert
complex_expr
tests/solvers/test_explicit_solvers.py
test_solvers_time_dependent
85
null
zwicker-group/py-pde
import pytest from pde.tools.config import ( Config, GlobalConfig, Parameter, environment, packages_from_requirements, ) def test_config_backends(): """Test configuration system.""" # initialize config without anything to test whether it refers to backends c = GlobalConfig() asser...
c
assert
variable
tests/tools/test_config.py
test_config_backends
42
null
zwicker-group/py-pde
import numpy as np import pytest from pde.tools.cuboid import Cuboid, asanyarray_flags def test_cuboid_add(): """Test adding two cuboids.""" assert Cuboid([1], [2]) + Cuboid([1], [2]) ==
Cuboid([1], [2])
assert
func_call
tests/tools/test_cuboid.py
test_cuboid_add
76
null
zwicker-group/py-pde
import contextlib import functools import platform import numpy as np import pytest from pde import ( DiffusionPDE, FileStorage, MemoryStorage, MovieStorage, UnitGrid, storage, ) from pde.fields import FieldCollection, ScalarField, Tensor2Field, VectorField from pde.storage.base import Storage...
s1[0]
assert
complex_expr
tests/storage/test_generic_storages.py
test_storage_copy
281
null
zwicker-group/py-pde
import platform import numpy as np import pytest from pde import ( CartesianGrid, CylindricalSymGrid, ScalarField, Tensor2Field, VectorField, ) pytest.importorskip("torch") def test_gradient_squared_cyl(rng): """Compare gradient squared operator.""" grid = CylindricalSymGrid(2 * np.pi, [...
s3.data)
assert_*
complex_expr
tests/backends/torch/operators/test_torch_cylindrical_operators.py
test_gradient_squared_cyl
133
null
zwicker-group/py-pde
import numpy as np from pde import ( CartesianGrid, CylindricalSymGrid, ScalarField, Tensor2Field, VectorField, ) def test_gradient_squared_cyl(rng): """Compare gradient squared operator.""" grid = CylindricalSymGrid(2 * np.pi, [0, 2 * np.pi], 64) field = ScalarField.random_harmonic(gr...
s3.data)
assert_*
complex_expr
tests/backends/numba/operators/test_numba_cylindrical_operators.py
test_gradient_squared_cyl
125
null
zwicker-group/py-pde
import collections import copy import gc import sys import numpy as np import pytest from pde.tools import cache def deep_getsizeof(obj, ids=None): """Find the memory footprint of a Python object. This is a recursive function that drills down a Python object graph like a dictionary holding nested dictio...
d
assert
variable
tests/tools/test_cache.py
test_serialized_dict
524
null
zwicker-group/py-pde
import logging from pathlib import Path import numpy as np import pytest import pde from pde import FileStorage, MovieStorage from pde.tools.ffmpeg import formats from pde.tools.misc import module_available RESOURCES_PATH = Path(__file__).resolve().parent / "resources" @pytest.mark.skipif(not module_available("ffmp...
b.data)
assert_*
complex_expr
tests/storage/test_movie_storages.py
test_stored_files
208
null
zwicker-group/py-pde
import logging from pathlib import Path import numpy as np import pytest import pde from pde import FileStorage, MovieStorage from pde.tools.ffmpeg import formats from pde.tools.misc import module_available RESOURCES_PATH = Path(__file__).resolve().parent / "resources" @pytest.mark.skipif(not module_available("ffmp...
[0, 2])
assert_*
collection
tests/storage/test_movie_storages.py
test_movie_storage_scalar
40
null
zwicker-group/py-pde
import itertools import numpy as np import pytest from pde import PolarSymGrid, ScalarField, UnitGrid from pde.backends import backends from pde.grids.base import PeriodicityError from pde.grids.boundaries.axes import ( BCDataError, BoundariesBase, BoundariesList, BoundariesSetter, ) from pde.grids.bo...
g2(d))
assert_*
func_call
tests/grids/boundaries/test_axes_boundaries.py
test_mixed_boundary_condition
102
null
zwicker-group/py-pde
import pickle import numpy as np import pytest from pde.grids import coordinates def iter_coordinates(): """Generator providing some test coordinate systems.""" yield coordinates.CartesianCoordinates(1) yield coordinates.CartesianCoordinates(2) yield coordinates.CartesianCoordinates(3) yield coor...
np.eye(c.dim))
assert_*
func_call
tests/grids/test_coordinates.py
test_coordinate_vector_fields
98
null
zwicker-group/py-pde
import numpy as np import pytest from pde import PDE, DiffusionPDE, ScalarField, UnitGrid from pde.solvers import Controller, ImplicitSolver from pde.tools import mpi @pytest.mark.parametrize("backend", ["numpy", "numba"]) def test_implicit_solvers_simple_fixed(backend): """Test implicit solvers.""" grid = Un...
xs * np.exp(10))
assert_*
func_call
tests/solvers/test_implicit_solvers.py
test_implicit_solvers_simple_fixed
27
null
zwicker-group/py-pde
import numpy as np from pde import ( CartesianGrid, CylindricalSymGrid, ScalarField, Tensor2Field, VectorField, ) def test_gradient_squared_cyl(rng): """Compare gradient squared operator.""" grid = CylindricalSymGrid(2 * np.pi, [0, 2 * np.pi], 64) field = ScalarField.random_harmonic(gr...
s2.data)
assert_*
complex_expr
tests/backends/numba/operators/test_numba_cylindrical_operators.py
test_gradient_squared_cyl
123
null
zwicker-group/py-pde
import pickle import numpy as np import pytest from pde.grids import coordinates def iter_coordinates(): """Generator providing some test coordinate systems.""" yield coordinates.CartesianCoordinates(1) yield coordinates.CartesianCoordinates(2) yield coordinates.CartesianCoordinates(3) yield coor...
c
assert
variable
tests/grids/test_coordinates.py
test_basic_coordinates
36
null
zwicker-group/py-pde
import contextlib import functools import platform import numpy as np import pytest from pde import ( DiffusionPDE, FileStorage, MemoryStorage, MovieStorage, UnitGrid, storage, ) from pde.fields import FieldCollection, ScalarField, Tensor2Field, VectorField from pde.storage.base import Storage...
3
assert
numeric_literal
tests/storage/test_generic_storages.py
test_storage_write
111
null
zwicker-group/py-pde
import numpy as np import pytest from pde import CartesianGrid, ScalarField, SphericalSymGrid, Tensor2Field, VectorField def test_findiff_sph(): """Test operator for a simple spherical grid.""" grid = SphericalSymGrid(1.5, 3) _, r1, r2 = grid.axes_coords[0] assert grid.discretization ==
(0.5,)
assert
collection
tests/backends/numba/operators/test_numba_spherical_operators.py
test_findiff_sph
15
null
zwicker-group/py-pde
import numpy as np import pytest from pde import PDE, DiffusionPDE, FieldCollection, MemoryStorage, ScalarField, UnitGrid from pde.solvers import ( AdamsBashforthSolver, Controller, CrankNicolsonSolver, EulerSolver, ImplicitSolver, RungeKuttaSolver, ScipySolver, registered_solvers, ) S...
s2.data)
assert_*
complex_expr
tests/solvers/test_generic_solvers.py
test_compare_solvers
60
null
zwicker-group/py-pde
import numpy as np import pytest from fixtures.fields import iter_grids from pde import ( CartesianGrid, PolarSymGrid, ScalarField, Tensor2Field, UnitGrid, VectorField, ) from pde.backends import backends from pde.fields.base import FieldBase def test_tensors_basic(rng): """Test some tenso...
t2
assert
variable
tests/fields/test_tensorial_fields.py
test_tensors_basic
70
null
zwicker-group/py-pde
import numpy as np import pytest from pde import CartesianGrid, DiffusionPDE, PolarSymGrid, ScalarField, UnitGrid from pde.backends import backends from pde.grids._mesh import GridMesh from pde.grids.boundaries.local import ( _MPIBC, BCBase, BCDataError, ExpressionValueBC, _get_arr_1d, register...
0
assert
numeric_literal
tests/grids/boundaries/test_local_boundaries.py
test_get_arr_1d
34
null
zwicker-group/py-pde
import pytest from pde.tools.config import ( Config, GlobalConfig, Parameter, environment, packages_from_requirements, ) def test_config_contexts(): """Test context manager temporarily changing configuration.""" c = Config({"key": 3}) assert c["key"] ==
3
assert
numeric_literal
tests/tools/test_config.py
test_config_contexts
110
null
zwicker-group/py-pde
import platform from pathlib import Path import numpy as np import pytest from pde import CartesianGrid, DiffusionPDE, FileStorage, PDEBase, ScalarField, UnitGrid from pde.tools import misc, mpi from pde.tools.misc import module_available @pytest.mark.skipif( platform.system() == "Windows", reason="submit_jobs h...
2
assert
numeric_literal
tests/test_integration.py
test_modelrunner_storage_many
292
null
zwicker-group/py-pde
import random import numpy as np import pytest from pde import CartesianGrid, ScalarField, UnitGrid from pde.backends.numba.operators.common import make_derivative from pde.grids.boundaries import BoundariesBase, PeriodicityError def _get_cartesian_grid(dim=2, periodic=True): """Return a random Cartesian grid of...
1
assert
numeric_literal
tests/grids/test_cartesian_grids.py
test_unit_grid_1d
63
null
zwicker-group/py-pde
import gc import numpy as np import pytest from fixtures.fields import get_cartesian_grid, iter_grids from pde.backends import backends from pde.fields.base import FieldBase from pde.fields.scalar import ScalarField from pde.grids import CartesianGrid, PolarSymGrid, UnitGrid, boundaries from pde.grids._mesh import Gr...
s3
assert
variable
tests/fields/test_scalar_fields.py
test_scalars
98
null
zwicker-group/py-pde
import itertools import numpy as np import pytest from pde import PolarSymGrid, ScalarField, UnitGrid from pde.backends import backends from pde.grids.base import PeriodicityError from pde.grids.boundaries.axes import ( BCDataError, BoundariesBase, BoundariesList, BoundariesSetter, ) from pde.grids.bo...
3
assert
numeric_literal
tests/grids/boundaries/test_axes_boundaries.py
test_bc_values
139
null
zwicker-group/py-pde
import numpy as np import pytest from fixtures.fields import iter_grids from pde import ( CartesianGrid, PolarSymGrid, ScalarField, Tensor2Field, UnitGrid, VectorField, ) from pde.backends import backends from pde.fields.base import FieldBase def test_from_expressions(): """Test initializi...
xs**2)
assert_*
complex_expr
tests/fields/test_tensorial_fields.py
test_from_expressions
249
null
zwicker-group/py-pde
import platform import numpy as np import pytest from pde import ( CartesianGrid, CylindricalSymGrid, ScalarField, Tensor2Field, VectorField, ) pytest.importorskip("torch") def test_gradient_field_cyl(): """Test the gradient operator.""" grid = CylindricalSymGrid(2 * np.pi, [0, 2 * np.pi...
-np.sin(r))
assert_*
func_call
tests/backends/torch/operators/test_torch_cylindrical_operators.py
test_gradient_field_cyl
41
null
zwicker-group/py-pde
import logging from pathlib import Path import numpy as np import pytest import pde from pde import FileStorage, MovieStorage from pde.tools.ffmpeg import formats from pde.tools.misc import module_available RESOURCES_PATH = Path(__file__).resolve().parent / "resources" @pytest.mark.skipif(not module_available("ffmp...
dim
assert
variable
tests/storage/test_movie_storages.py
test_movie_storage_vector
86
null
zwicker-group/py-pde
import numpy as np import pytest from fixtures.fields import iter_grids from pde import ( CartesianGrid, PolarSymGrid, ScalarField, Tensor2Field, UnitGrid, VectorField, ) from pde.backends import backends from pde.fields.base import FieldBase def test_tensor_invariants(rng): """Test the in...
invs[2])
assert_*
complex_expr
tests/fields/test_tensorial_fields.py
test_tensor_invariants
164
null
zwicker-group/py-pde
import numpy as np import pytest from pde import PDE, DiffusionPDE, FieldCollection, ScalarField, UnitGrid from pde.solvers import Controller, ExplicitMPISolver from pde.tools import mpi @pytest.mark.multiprocessing @pytest.mark.parametrize("backend", ["numba", "numpy"]) def test_stochastic_mpi_solvers(backend, rng):...
s2.data)
assert_*
complex_expr
tests/solvers/test_explicit_mpi_solvers.py
test_stochastic_mpi_solvers
73
null
zwicker-group/py-pde
import pickle import numpy as np import pytest from pde.grids import coordinates def iter_coordinates(): """Generator providing some test coordinate systems.""" yield coordinates.CartesianCoordinates(1) yield coordinates.CartesianCoordinates(2) yield coordinates.CartesianCoordinates(3) yield coor...
x)
assert_*
variable
tests/grids/test_coordinates.py
test_basic_coordinates
34
null
zwicker-group/py-pde
from pde.tools import output def test_display_progress(capsys): """Test whether this works.""" for _ in output.display_progress(range(2)): pass out, err = capsys.readouterr() assert out ==
""
assert
string_literal
tests/tools/test_output.py
test_display_progress
27
null
zwicker-group/py-pde
import numpy as np import pytest from pde import PDEBase, ScalarField, UnitGrid from pde.solvers import Controller def test_controller_foreign_solver(): """Test whether the Controller can deal with a minimal foreign solver.""" class MySolver: def make_stepper(self, state, dt): def stepper...
np.arange(3))
assert_*
func_call
tests/solvers/test_controller.py
test_controller_foreign_solver
45
null
zwicker-group/py-pde
import itertools from copy import copy, deepcopy import numpy as np import pytest from pde import grids from pde.grids.base import ( GridBase, discretize_interval, registered_operators, ) from pde.tools.misc import module_available def iter_grids(): """Generator providing some test grids.""" for ...
0
assert
numeric_literal
tests/grids/test_generic_grids.py
test_coordinate_conversion
95
null
zwicker-group/py-pde
import itertools import pytest from pde import UnitGrid from pde.grids.boundaries.axis import BoundaryPair, get_boundary_axis from pde.grids.boundaries.local import BCBase def test_get_axis_boundaries(): """Test setting boundary conditions including periodic ones.""" for data in ["value", "derivative", "peri...
c
assert
variable
tests/grids/boundaries/test_axis_boundaries.py
test_get_axis_boundaries
77
null
zwicker-group/py-pde
import numpy as np import pytest from pde import PDEBase, ScalarField, UnitGrid from pde.solvers import Controller def test_controller_abort(): """Test how controller deals with errors.""" class ErrorPDEException(RuntimeError): ... class ErrorPDE(PDEBase): def evolution_rate(self, state, t): ...
0
assert
numeric_literal
tests/solvers/test_controller.py
test_controller_abort
29
null
zwicker-group/py-pde
import itertools from copy import copy, deepcopy import numpy as np import pytest from pde import grids from pde.grids.base import ( GridBase, discretize_interval, registered_operators, ) from pde.tools.misc import module_available def iter_grids(): """Generator providing some test grids.""" for ...
g._cache_hash()
assert
func_call
tests/grids/test_generic_grids.py
test_serialization
56
null
zwicker-group/py-pde
import numba import numpy as np import pytest from pde.backends.numba.utils import ( Counter, flat_idx, jit, make_array_constructor, numba_dict, numba_environment, ) def test_counter(): """Test Counter implementation.""" c1 = Counter() assert int(c1) == 0 assert c1 == 0 ass...
3
assert
numeric_literal
tests/backends/numba/test_numba_utils.py
test_counter
52
null
zwicker-group/py-pde
import numpy as np import pytest from pde import CartesianGrid, DiffusionPDE, PolarSymGrid, ScalarField, UnitGrid from pde.backends import backends from pde.grids._mesh import GridMesh from pde.grids.boundaries.local import ( _MPIBC, BCBase, BCDataError, ExpressionValueBC, _get_arr_1d, register...
up
assert
variable
tests/grids/boundaries/test_local_boundaries.py
test_virtual_points
132
null
zwicker-group/py-pde
import numpy as np import pytest from pde.tools.cuboid import Cuboid, asanyarray_flags def test_cuboid_add(): """Test adding two cuboids.""" assert Cuboid([1], [2]) + Cuboid([1], [2]) == Cuboid([1], [2]) assert Cuboid([1], [2]) + Cuboid([0], [1]) ==
Cuboid([0], [3])
assert
func_call
tests/tools/test_cuboid.py
test_cuboid_add
77
null
zwicker-group/py-pde
import numba as nb import numpy as np import pytest from scipy import ndimage from fixtures.fields import iter_fields, iter_grids from pde.fields import FieldCollection, ScalarField, Tensor2Field, VectorField from pde.fields.base import FieldBase from pde.fields.datafield_base import DataFieldBase, _symmetrize_vmin_vm...
f2
assert
variable
tests/fields/test_generic_fields.py
test_hdf_input_output
230
null
zwicker-group/py-pde
import numpy as np import pytest from pde import CartesianGrid, PolarSymGrid, ScalarField, SphericalSymGrid from pde.grids.boundaries.local import NeumannBC def test_polar_grid(rng): """Test simple polar grid.""" grid = PolarSymGrid(4, 8) assert grid.dim == 2 assert grid.num_cells == 8 assert gri...
(8,)
assert
collection
tests/grids/test_spherical_grids.py
test_polar_grid
17
null