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 |
|---|---|---|---|---|---|---|---|---|---|
bayespy/bayespy | import numpy as np
from bayespy.nodes import (Gate,
GaussianARD,
Gamma,
Categorical,
Bernoulli,
Multinomial)
from bayespy.inference.vmp.nodes.gaussian import GaussianMoments
from bay... | (4,)) | self.assertEqual | collection | bayespy/inference/vmp/nodes/tests/test_gate.py | test_init | TestGate | 58 | null |
bayespy/bayespy | import numpy as np
from ..gaussian_markov_chain import GaussianMarkovChain
from ..gaussian_markov_chain import VaryingGaussianMarkovChain
from ..gaussian import Gaussian, GaussianMoments
from ..gaussian import GaussianARD
from ..gaussian import GaussianGamma
from ..wishart import Wishart, WishartMoments
from ..gamma i... | A) | assert_* | variable | bayespy/inference/vmp/nodes/tests/test_gaussian_markov_chain.py | test_message_to_parents | TestGaussianMarkovChain | 237 | null |
bayespy/bayespy | import numpy as np
from scipy import special
from numpy import testing
from .. import gaussian
from bayespy.nodes import (Gaussian,
GaussianARD,
GaussianGamma,
Gamma,
Wishart,
Concat... | mu) | assert_* | variable | bayespy/inference/vmp/nodes/tests/test_gaussian.py | check | TestGaussianGamma | 1,123 | null |
bayespy/bayespy | import unittest
import numpy as np
import scipy
from numpy import testing
from ..dot import Dot, SumMultiply
from ..gaussian import Gaussian, GaussianARD
from bayespy.nodes import GaussianGamma
from ...vmp import VB
from bayespy.utils import misc
from bayespy.utils import linalg
from bayespy.utils import random
f... | B.get_moments()[2]) | assert_* | func_call | bayespy/inference/vmp/nodes/tests/test_dot.py | test_message_to_child | TestSumMultiply | 489 | null |
bayespy/bayespy | import numpy as np
from .. import misc
from .. import linalg
class TestBandedSolve(misc.TestCase):
def test_block_banded_solve(self):
r"""
Test the Gaussian elimination algorithm for block-banded matrices.
"""
#
# Create a block-banded matrix
#
# Number o... | N-1) | self.assertEqual | complex_expr | bayespy/utils/tests/test_linalg.py | test_block_banded_solve | TestBandedSolve | 162 | null |
bayespy/bayespy | import unittest
import warnings
import numpy as np
from scipy.special import psi
from numpy import testing
from .. import misc
class TestMultiplyShapes(unittest.TestCase):
def test_multiply_shapes(self):
f = lambda *shapes: tuple(misc.multiply_shapes(*shapes))
# Basic test
self.assert... | (24,)) | self.assertEqual | collection | bayespy/utils/tests/test_misc.py | test_multiply_shapes | TestMultiplyShapes | 140 | null |
bayespy/bayespy | import unittest
import numpy as np
import scipy
from numpy import testing
from ..node import Node, Moments
from ...vmp import VB
from bayespy.utils import misc
class TestSlice(misc.TestCase):
def test_message_to_child(self):
r"""
Test message to child of X[..] node operator.
"""
... | Y._message_to_child() is not X.u) | self.assertTrue | func_call | bayespy/inference/vmp/nodes/tests/test_node.py | test_message_to_child | TestSlice | 645 | null |
bayespy/bayespy | from scipy.optimize import approx_fprime
import functools
import itertools
import operator
import sys
import getopt
import numpy as np
import scipy as sp
import scipy.linalg as linalg
import scipy.special as special
import scipy.optimize as optimize
import scipy.sparse as sparse
import tempfile as tmp
import unitte... | len(u) | assert | func_call | bayespy/utils/misc.py | assert_moments | TestCase | 427 | null |
bayespy/bayespy | import unittest
import numpy as np
import scipy
from numpy import testing
from ..dot import Dot, SumMultiply
from ..gaussian import Gaussian, GaussianARD
from bayespy.nodes import GaussianGamma
from ...vmp import VB
from bayespy.utils import misc
from bayespy.utils import linalg
from bayespy.utils import random
f... | ((), ())) | self.assertEqual | collection | bayespy/inference/vmp/nodes/tests/test_dot.py | test_parent_validity | TestSumMultiply | 44 | null |
bayespy/bayespy | import numpy as np
from .. import misc
from .. import linalg
class TestDot(misc.TestCase):
def test_dot(self):
r"""
Test dot product multiple multi-dimensional arrays.
"""
# If no arrays, return 0
self.assertAllClose(linalg.dot(),
0)
# ... | ValueError) | self.assertRaises | variable | bayespy/utils/tests/test_linalg.py | test_dot | TestDot | 79 | null |
bayespy/bayespy | import numpy as np
from scipy import special
from bayespy.nodes import Dirichlet
from bayespy.utils import random
from bayespy.utils.misc import TestCase
class TestDirichlet(TestCase):
def test_init(self):
r"""
Test the creation of Dirichlet nodes.
"""
# Some simple initializat... | ValueError) | self.assertRaises | variable | bayespy/inference/vmp/nodes/tests/test_dirichlet.py | test_init | TestDirichlet | 44 | null |
bayespy/bayespy | import numpy as np
from scipy import special
from numpy import testing
from .. import gaussian
from bayespy.nodes import (Gaussian,
GaussianARD,
GaussianGamma,
Gamma,
Wishart,
Concat... | beta) | assert_* | variable | bayespy/inference/vmp/nodes/tests/test_gaussian.py | check | TestGaussianGamma | 1,132 | null |
bayespy/bayespy | import warnings
import numpy as np
import scipy
from bayespy.nodes import (Categorical,
Dirichlet,
Mixture,
Gamma)
from bayespy.utils import random
from bayespy.utils import misc
from bayespy.utils.misc import TestCase
class TestCateg... | (3,4)) | self.assertEqual | collection | bayespy/inference/vmp/nodes/tests/test_categorical.py | test_init | TestCategorical | 45 | null |
bayespy/bayespy | import unittest
import warnings
import numpy as np
from scipy.special import psi
from numpy import testing
from .. import misc
class TestMultiplyShapes(unittest.TestCase):
def test_multiply_shapes(self):
f = lambda *shapes: tuple(misc.multiply_shapes(*shapes))
# Basic test
self.assert... | (5,)) | self.assertEqual | collection | bayespy/utils/tests/test_misc.py | test_multiply_shapes | TestMultiplyShapes | 153 | null |
bayespy/bayespy | import numpy as np
from scipy import special
from bayespy.nodes import Dirichlet
from bayespy.utils import random
from bayespy.utils.misc import TestCase
class TestDirichlet(TestCase):
def test_init(self):
r"""
Test the creation of Dirichlet nodes.
"""
# Some simple initializat... | (4,3)) | self.assertEqual | collection | bayespy/inference/vmp/nodes/tests/test_dirichlet.py | test_init | TestDirichlet | 37 | null |
bayespy/bayespy | import warnings
import numpy as np
from bayespy.utils import misc
from bayespy.inference.vmp.nodes import CategoricalMarkovChain, \
Dirichlet
class TestCategoricalMarkovChain(misc.TestCase):
def test_init(self):
r"""
Test the creation of CategoricalMarkovC... | Z.dims) | self.assertEqual | complex_expr | bayespy/inference/vmp/nodes/tests/test_categorical_markov_chain.py | test_init | TestCategoricalMarkovChain | 36 | null |
bayespy/bayespy | import numpy as np
from .. import misc
from .. import random
class TestCeilDiv(misc.TestCase):
def test_categorical(self):
# Test dummy one category
y = random.categorical([1])
self.assertEqual(y, | 0) | self.assertEqual | numeric_literal | bayespy/utils/tests/test_random.py | test_categorical | TestCeilDiv | 23 | null |
bayespy/bayespy | import unittest
import numpy as np
import scipy
from numpy import testing
from ..node import Node, Moments
from ...vmp import VB
from bayespy.utils import misc
class TestSlice(misc.TestCase):
def test_init(self):
r"""
Test the constructor of the X[..] node operator.
"""
class... | (3,)) | self.assertEqual | collection | bayespy/inference/vmp/nodes/tests/test_node.py | test_init | TestSlice | 495 | null |
bayespy/bayespy | import numpy as np
from scipy import special
from bayespy.nodes import Beta
from bayespy.utils import random
from bayespy.utils.misc import TestCase
class TestBeta(TestCase):
def test_init(self):
r"""
Test the creation of beta nodes.
"""
# Some simple initializations
p ... | ValueError) | self.assertRaises | variable | bayespy/inference/vmp/nodes/tests/test_beta.py | test_init | TestBeta | 44 | null |
bayespy/bayespy | import numpy as np
from scipy import special
from numpy import testing
from .. import gaussian
from bayespy.nodes import (Gaussian,
GaussianARD,
GaussianGamma,
Gamma,
Wishart,
Concat... | (4,3,2,4,3,2)) | self.assertEqual | collection | bayespy/inference/vmp/nodes/tests/test_gaussian.py | test_message_to_child | TestGaussianARD | 311 | null |
bayespy/bayespy | import numpy as np
from ..gaussian_markov_chain import GaussianMarkovChain
from ..gaussian_markov_chain import VaryingGaussianMarkovChain
from ..gaussian import Gaussian, GaussianMoments
from ..gaussian import GaussianARD
from ..gaussian import GaussianGamma
from ..wishart import Wishart, WishartMoments
from ..gamma i... | X) | assert_* | variable | bayespy/inference/vmp/nodes/tests/test_gaussian_markov_chain.py | test_message_to_parents | TestGaussianMarkovChain | 214 | null |
bayespy/bayespy | import numpy as np
from scipy import special
from numpy import testing
from .. import gaussian
from bayespy.nodes import (Gaussian,
GaussianARD,
GaussianGamma,
Gamma,
Wishart)
from ...vmp import VB
from baye... | a * np.log(b) + (a - 1) * np.log(y) - b * y - special.gammaln(a)) | assert_* | func_call | bayespy/inference/vmp/nodes/tests/test_gamma.py | test_lower_bound_contribution | TestGamma | 44 | null |
bayespy/bayespy | import numpy as np
import scipy
from bayespy.nodes import (Binomial,
Beta,
Mixture)
from bayespy.utils import random
from bayespy.utils.misc import TestCase
class TestBinomial(TestCase):
def test_init(self):
r"""
Test the creation of binomia... | (4,3)) | self.assertEqual | collection | bayespy/inference/vmp/nodes/tests/test_binomial.py | test_init | TestBinomial | 41 | null |
bayespy/bayespy | import numpy as np
import scipy
from bayespy.nodes import (Multinomial,
Dirichlet,
Mixture)
from bayespy.utils import random
from bayespy.utils.misc import TestCase
class TestMultinomial(TestCase):
def test_moments(self):
r"""
Test the momen... | 1) | self.assertEqual | numeric_literal | bayespy/inference/vmp/nodes/tests/test_multinomial.py | test_moments | TestMultinomial | 106 | null |
bayespy/bayespy | import warnings
import numpy as np
from bayespy.nodes import (GaussianARD,
Gamma,
Mixture,
Categorical,
Bernoulli,
Multinomial,
Beta,
... | ()) | self.assertEqual | collection | bayespy/inference/vmp/nodes/tests/test_mixture.py | test_message_to_child | TestMixture | 79 | null |
bayespy/bayespy | import numpy as np
import scipy
from bayespy.nodes import Poisson
from bayespy.nodes import Gamma
from bayespy.utils import random
from bayespy.utils.misc import TestCase
class TestPoisson(TestCase):
def test_init(self):
r"""
Test the creation of Poisson nodes.
"""
# Some simpl... | (2,3)) | self.assertEqual | collection | bayespy/inference/vmp/nodes/tests/test_poisson.py | test_init | TestPoisson | 40 | null |
bayespy/bayespy | import numpy as np
from ..gaussian_markov_chain import GaussianMarkovChain
from ..gaussian_markov_chain import VaryingGaussianMarkovChain
from ..gaussian import Gaussian, GaussianMoments
from ..gaussian import GaussianARD
from ..gaussian import GaussianGamma
from ..wishart import Wishart, WishartMoments
from ..gamma i... | Lambda) | assert_* | variable | bayespy/inference/vmp/nodes/tests/test_gaussian_markov_chain.py | test_message_to_parents | TestGaussianMarkovChain | 228 | null |
bayespy/bayespy | import unittest
import warnings
import numpy as np
from scipy.special import psi
from numpy import testing
from .. import misc
class TestBroadcasting(unittest.TestCase):
def test_is_shape_subset(self):
f = misc.is_shape_subset
self.assertTrue( | f( (), () )) | self.assertTrue | func_call | bayespy/utils/tests/test_misc.py | test_is_shape_subset | TestBroadcasting | 112 | null |
bayespy/bayespy | import warnings
import numpy as np
import scipy
from bayespy.nodes import (Categorical,
Dirichlet,
Mixture,
Gamma)
from bayespy.utils import random
from bayespy.utils import misc
from bayespy.utils.misc import TestCase
class TestCateg... | ValueError) | self.assertRaises | variable | bayespy/inference/vmp/nodes/tests/test_categorical.py | test_init | TestCategorical | 56 | null |
bayespy/bayespy | import warnings
import numpy as np
import scipy
from bayespy.nodes import (Categorical,
Dirichlet,
Mixture,
Gamma)
from bayespy.utils import random
from bayespy.utils import misc
from bayespy.utils.misc import TestCase
class TestCateg... | (2,3)) | self.assertEqual | collection | bayespy/inference/vmp/nodes/tests/test_categorical.py | test_init | TestCategorical | 48 | null |
bayespy/bayespy | import unittest
import numpy as np
import scipy
from numpy import testing
from ..node import Node, Moments
from ..deterministic import tile
from ..stochastic import Stochastic
class TestTile(unittest.TestCase):
def check_message_to_children(self, tiles, u_parent, u_tiled,
dims... | np.shape(y)) | self.assertEqual | func_call | bayespy/inference/vmp/nodes/tests/test_deterministic.py | check_message_to_children | TestTile | 42 | null |
bayespy/bayespy | import numpy as np
import scipy
from bayespy.nodes import (Bernoulli,
Beta,
Mixture)
from bayespy.utils import random
from bayespy.utils.misc import TestCase
class TestBernoulli(TestCase):
def test_init(self):
r"""
Test the creation of Berno... | ValueError) | self.assertRaises | variable | bayespy/inference/vmp/nodes/tests/test_bernoulli.py | test_init | TestBernoulli | 51 | null |
bayespy/bayespy | from scipy.optimize import approx_fprime
import functools
import itertools
import operator
import sys
import getopt
import numpy as np
import scipy as sp
import scipy.linalg as linalg
import scipy.special as special
import scipy.optimize as optimize
import scipy.sparse as sparse
import tempfile as tmp
import unitte... | B) | assert_* | variable | bayespy/utils/misc.py | assertAllClose | TestCase | 323 | null |
bayespy/bayespy | from scipy.optimize import approx_fprime
import functools
import itertools
import operator
import sys
import getopt
import numpy as np
import scipy as sp
import scipy.linalg as linalg
import scipy.special as special
import scipy.optimize as optimize
import scipy.sparse as sparse
import tempfile as tmp
import unitte... | np.shape(B)) | self.assertEqual | func_call | bayespy/utils/misc.py | assertAllClose | TestCase | 322 | null |
bayespy/bayespy | import numpy as np
import scipy
from bayespy.nodes import (Bernoulli,
Beta,
Mixture)
from bayespy.utils import random
from bayespy.utils.misc import TestCase
class TestBernoulli(TestCase):
def test_moments(self):
r"""
Test the moments of Ber... | 1) | self.assertEqual | numeric_literal | bayespy/inference/vmp/nodes/tests/test_bernoulli.py | test_moments | TestBernoulli | 81 | null |
bayespy/bayespy | import numpy as np
from .. import misc
from .. import random
class TestAlphaBetaRecursion(misc.TestCase):
def test(self):
r"""
Test the results of alpha-beta recursion for Markov chains
"""
np.seterr(divide='ignore')
# Deterministic oscillator
p0 = np.array([1.0,... | np.all(~np.isnan(z0))) | self.assertTrue | func_call | bayespy/utils/tests/test_random.py | test | TestAlphaBetaRecursion | 254 | null |
bayespy/bayespy | import numpy as np
from scipy import special
from numpy import testing
from .. import gaussian
from bayespy.nodes import (Gaussian,
GaussianARD,
GaussianGamma,
Gamma,
Wishart,
Concat... | (true_shape, true_shape+true_shape)) | self.assertEqual | collection | bayespy/inference/vmp/nodes/tests/test_gaussian.py | check_init | TestGaussianARD | 137 | null |
bayespy/bayespy | import numpy as np
from .. import misc
from .. import random
class TestAlphaBetaRecursion(misc.TestCase):
def test(self):
r"""
Test the results of alpha-beta recursion for Markov chains
"""
np.seterr(divide='ignore')
# Deterministic oscillator
p0 = np.array([1.0,... | np.all(~np.isnan(zz))) | self.assertTrue | func_call | bayespy/utils/tests/test_random.py | test | TestAlphaBetaRecursion | 256 | null |
bayespy/bayespy | import unittest
import numpy as np
import scipy
from numpy import testing
from ..dot import Dot, SumMultiply
from ..gaussian import Gaussian, GaussianARD
from bayespy.nodes import GaussianGamma
from ...vmp import VB
from bayespy.utils import misc
from bayespy.utils import linalg
from bayespy.utils import random
f... | B.get_moments()[3]) | assert_* | func_call | bayespy/inference/vmp/nodes/tests/test_dot.py | test_message_to_child | TestSumMultiply | 493 | null |
bayespy/bayespy | import numpy as np
from .. import misc
from .. import linalg
class TestBandedSolve(misc.TestCase):
def test_block_banded_solve(self):
r"""
Test the Gaussian elimination algorithm for block-banded matrices.
"""
#
# Create a block-banded matrix
#
# Number o... | N) | self.assertEqual | variable | bayespy/utils/tests/test_linalg.py | test_block_banded_solve | TestBandedSolve | 161 | null |
bayespy/bayespy | import numpy as np
import scipy
from bayespy.nodes import Poisson
from bayespy.nodes import Gamma
from bayespy.utils import random
from bayespy.utils.misc import TestCase
class TestPoisson(TestCase):
def test_moments(self):
r"""
Test the moments of Poisson nodes.
"""
# Simple t... | 1) | self.assertEqual | numeric_literal | bayespy/inference/vmp/nodes/tests/test_poisson.py | test_moments | TestPoisson | 74 | null |
bayespy/bayespy | import numpy as np
from scipy import special
from numpy import testing
from .. import gaussian
from bayespy.nodes import (Gaussian,
GaussianARD,
GaussianGamma,
Gamma,
Wishart,
Concat... | X) | assert_* | variable | bayespy/inference/vmp/nodes/tests/test_gaussian.py | test_message_to_parents | TestGaussianARD | 686 | null |
bayespy/bayespy | import unittest
import numpy as np
import scipy
from numpy import testing
from ..dot import Dot, SumMultiply
from ..gaussian import Gaussian, GaussianARD
from bayespy.nodes import GaussianGamma
from ...vmp import VB
from bayespy.utils import misc
from bayespy.utils import linalg
from bayespy.utils import random
f... | np.einsum('nmi,mi->nm', a, B.get_moments()[0])) | assert_* | func_call | bayespy/inference/vmp/nodes/tests/test_dot.py | test_message_to_child | TestSumMultiply | 481 | null |
bayespy/bayespy | import unittest
import warnings
import numpy as np
from scipy.special import psi
from numpy import testing
from .. import misc
class TestAddAxes(misc.TestCase):
def test_add_axes(self):
r"""
Test the add_axes method.
"""
f = lambda X, **kwargs: np.shape(misc.add_axes(X, **kwarg... | (3,1)) | self.assertEqual | collection | bayespy/utils/tests/test_misc.py | test_add_axes | TestAddAxes | 84 | null |
bayespy/bayespy | import numpy as np
from scipy import special
from numpy import testing
from .. import gaussian
from bayespy.nodes import (Gaussian,
GaussianARD,
GaussianGamma,
Gamma,
Wishart,
Concat... | (4,)) | self.assertEqual | collection | bayespy/inference/vmp/nodes/tests/test_gaussian.py | test_init | TestGaussianGamma | 942 | null |
bayespy/bayespy | import numpy as np
import scipy
from bayespy.nodes import (Bernoulli,
Beta,
Mixture)
from bayespy.utils import random
from bayespy.utils.misc import TestCase
class TestBernoulli(TestCase):
def test_init(self):
r"""
Test the creation of Berno... | (4,3)) | self.assertEqual | collection | bayespy/inference/vmp/nodes/tests/test_bernoulli.py | test_init | TestBernoulli | 41 | null |
bayespy/bayespy | import numpy as np
from ..gaussian_markov_chain import GaussianMarkovChain
from ..gaussian_markov_chain import VaryingGaussianMarkovChain
from ..gaussian import Gaussian, GaussianMoments
from ..gaussian import GaussianARD
from ..gaussian import GaussianGamma
from ..wishart import Wishart, WishartMoments
from ..gamma i... | U) | assert_* | variable | bayespy/inference/vmp/nodes/tests/test_gaussian_markov_chain.py | check | TestGaussianMarkovChain | 283 | null |
bayespy/bayespy | import numpy as np
from ..gaussian_markov_chain import GaussianMarkovChain
from ..gaussian_markov_chain import VaryingGaussianMarkovChain
from ..gaussian import Gaussian, GaussianMoments
from ..gaussian import GaussianARD
from ..gaussian import GaussianGamma
from ..wishart import Wishart, WishartMoments
from ..gamma i... | np.allclose(CovXh_vb, CovXh)) | self.assertTrue | func_call | bayespy/inference/vmp/nodes/tests/test_gaussian_markov_chain.py | test_smoothing | TestGaussianMarkovChain | 768 | null |
bayespy/bayespy | import numpy as np
from .. import misc
from .. import random
class TestCeilDiv(misc.TestCase):
def test_categorical(self):
# Test dummy one category
y = random.categorical([1])
self.assertEqual(y, 0)
# Test multiple categories
y = random.categorical([1,0,0])
self... | 1) | self.assertEqual | numeric_literal | bayespy/utils/tests/test_random.py | test_categorical | TestCeilDiv | 29 | null |
bayespy/bayespy | import unittest
import numpy as np
import scipy
from numpy import testing
from ..node import Node, Moments
from ..deterministic import tile
from ..stochastic import Stochastic
class TestTile(unittest.TestCase):
def check_message_to_children(self, tiles, u_parent, u_tiled,
dims... | y) | assert_* | variable | bayespy/inference/vmp/nodes/tests/test_deterministic.py | check_message_to_children | TestTile | 44 | null |
bayespy/bayespy | import numpy as np
import scipy
from bayespy.nodes import (Multinomial,
Dirichlet,
Mixture)
from bayespy.utils import random
from bayespy.utils.misc import TestCase
class TestMultinomial(TestCase):
def test_init(self):
r"""
Test the creation... | (3,4)) | self.assertEqual | collection | bayespy/inference/vmp/nodes/tests/test_multinomial.py | test_init | TestMultinomial | 41 | null |
bayespy/bayespy | import numpy as np
from scipy import special
from numpy import testing
from .. import gaussian
from bayespy.nodes import (Gaussian,
GaussianARD,
GaussianGamma,
Gamma,
Wishart)
from ...vmp import VB
from baye... | special.gammaln((nu+1)/2) - special.gammaln(nu/2) - 0.5 * np.log(nu) - 0.5 * np.log(np.pi) - 0.5 * np.log(s2) - 0.5 * (nu + 1) * np.log( 1 + (y - mu)**2 / (nu * s2) )) | assert_* | func_call | bayespy/inference/vmp/nodes/tests/test_gamma.py | test_lower_bound_contribution | TestGamma | 74 | null |
bayespy/bayespy | import numpy as np
import scipy
from bayespy.nodes import (Multinomial,
Dirichlet,
Mixture)
from bayespy.utils import random
from bayespy.utils.misc import TestCase
class TestMultinomial(TestCase):
def test_init(self):
r"""
Test the creation... | ValueError) | self.assertRaises | variable | bayespy/inference/vmp/nodes/tests/test_multinomial.py | test_init | TestMultinomial | 56 | null |
bayespy/bayespy | import numpy as np
from ..gaussian_markov_chain import GaussianMarkovChain
from ..gaussian_markov_chain import VaryingGaussianMarkovChain
from ..gaussian import Gaussian, GaussianMoments
from ..gaussian import GaussianARD
from ..gaussian import GaussianGamma
from ..wishart import Wishart, WishartMoments
from ..gamma i... | np.allclose(Xh_vb, Xh)) | self.assertTrue | func_call | bayespy/inference/vmp/nodes/tests/test_gaussian_markov_chain.py | test_smoothing | TestGaussianMarkovChain | 767 | null |
bayespy/bayespy | import unittest
import numpy as np
import scipy
from numpy import testing
from ..dot import Dot, SumMultiply
from ..gaussian import Gaussian, GaussianARD
from bayespy.nodes import GaussianGamma
from ...vmp import VB
from bayespy.utils import misc
from bayespy.utils import linalg
from bayespy.utils import random
f... | np.einsum('ni,i->n', a, B.get_moments()[0])) | assert_* | func_call | bayespy/inference/vmp/nodes/tests/test_dot.py | test_message_to_child | TestSumMultiply | 433 | null |
bayespy/bayespy | import unittest
import numpy as np
import scipy
from numpy import testing
from ..node import Node, Moments
from ...vmp import VB
from bayespy.utils import misc
class TestMoments(unittest.TestCase):
def test_converter(self):
r"""
Tests complex conversions for moment classes
"""
... | 4) | self.assertEqual | numeric_literal | bayespy/inference/vmp/nodes/tests/test_node.py | test_converter | TestMoments | 44 | null |
bayespy/bayespy | import unittest
import numpy as np
import scipy
from numpy import testing
from ..node import Node, Moments
from ..deterministic import tile
from ..stochastic import Stochastic
class TestTile(unittest.TestCase):
def check_message_to_children(self, tiles, u_parent, u_tiled,
dims... | np.shape(mask_true)) | self.assertEqual | func_call | bayespy/inference/vmp/nodes/tests/test_deterministic.py | check_mask_to_parent | TestTile | 267 | null |
bayespy/bayespy | import numpy as np
from bayespy.nodes import GaussianARD
from bayespy.nodes import Take
from bayespy.inference import VB
from bayespy.utils.misc import TestCase
class TestTake(TestCase):
def test_parent_validity(self):
r"""
Test that the parent nodes are validated properly
"""
... | (4,)) | self.assertEqual | collection | bayespy/inference/vmp/nodes/tests/test_take.py | test_parent_validity | TestTake | 45 | null |
bayespy/bayespy | import numpy as np
import scipy
from bayespy.nodes import (Binomial,
Beta,
Mixture)
from bayespy.utils import random
from bayespy.utils.misc import TestCase
class TestBinomial(TestCase):
def test_moments(self):
r"""
Test the moments of binom... | 1) | self.assertEqual | numeric_literal | bayespy/inference/vmp/nodes/tests/test_binomial.py | test_moments | TestBinomial | 99 | null |
bayespy/bayespy | import unittest
import numpy as np
import scipy
from numpy import testing
from ..node import Node, Moments
from ...vmp import VB
from bayespy.utils import misc
class TestMoments(unittest.TestCase):
def test_converter(self):
r"""
Tests complex conversions for moment classes
"""
... | 3) | self.assertEqual | numeric_literal | bayespy/inference/vmp/nodes/tests/test_node.py | test_converter | TestMoments | 40 | null |
bayespy/bayespy | import numpy as np
from scipy import special
from numpy import testing
from .. import gaussian
from bayespy.nodes import (Gaussian,
GaussianARD,
GaussianGamma,
Gamma,
Wishart)
from ...vmp import VB
from baye... | tau.phi) | assert_* | complex_expr | bayespy/inference/vmp/nodes/tests/test_gamma.py | test_lower_bound_contribution | TestGamma | 70 | null |
bayespy/bayespy | import unittest
import warnings
import numpy as np
from scipy.special import psi
from numpy import testing
from .. import misc
class TestAddAxes(misc.TestCase):
def test_add_axes(self):
r"""
Test the add_axes method.
"""
f = lambda X, **kwargs: np.shape(misc.add_axes(X, **kwarg... | (1,3)) | self.assertEqual | collection | bayespy/utils/tests/test_misc.py | test_add_axes | TestAddAxes | 76 | null |
bayespy/bayespy | import numpy as np
from scipy import special
from bayespy.nodes import Beta
from bayespy.utils import random
from bayespy.utils.misc import TestCase
class TestBeta(TestCase):
def test_init(self):
r"""
Test the creation of beta nodes.
"""
# Some simple initializations
p ... | (4,3)) | self.assertEqual | collection | bayespy/inference/vmp/nodes/tests/test_beta.py | test_init | TestBeta | 37 | null |
bayespy/bayespy | import numpy as np
from .. import misc
from .. import random
class TestCeilDiv(misc.TestCase):
def test_categorical(self):
# Test dummy one category
y = random.categorical([1])
self.assertEqual(y, 0)
# Test multiple categories
y = random.categorical([1,0,0])
self... | 2) | self.assertEqual | numeric_literal | bayespy/utils/tests/test_random.py | test_categorical | TestCeilDiv | 31 | null |
bayespy/bayespy | import unittest
import warnings
import numpy as np
from scipy.special import psi
from numpy import testing
from .. import misc
class TestCeilDiv(misc.TestCase):
def test_ceildiv(self):
r"""
Test the ceil division
"""
self.assertEqual(misc.ceildiv(3, 1),
... | 2) | self.assertEqual | numeric_literal | bayespy/utils/tests/test_misc.py | test_ceildiv | TestCeilDiv | 33 | null |
bayespy/bayespy | import numpy as np
import scipy
from bayespy.nodes import Poisson
from bayespy.nodes import Gamma
from bayespy.utils import random
from bayespy.utils.misc import TestCase
class TestPoisson(TestCase):
def test_init(self):
r"""
Test the creation of Poisson nodes.
"""
# Some simpl... | ValueError) | self.assertRaises | variable | bayespy/inference/vmp/nodes/tests/test_poisson.py | test_init | TestPoisson | 47 | null |
bayespy/bayespy | import unittest
import warnings
import numpy as np
from scipy.special import psi
from numpy import testing
from .. import misc
class TestSumMultiply(unittest.TestCase):
def check_sum_multiply(self, *shapes, **kwargs):
# The set of arrays
x = list()
for (ind, shape) in enumerate(shapes... | ValueError) | self.assertRaises | variable | bayespy/utils/tests/test_misc.py | test_sum_multiply | TestSumMultiply | 208 | null |
bayespy/bayespy | import warnings
import numpy as np
from bayespy.nodes import (Concatenate,
GaussianARD,
Gamma)
from bayespy.utils import random
from bayespy.utils.misc import TestCase
class TestConcatenate(TestCase):
def test_init(self):
r"""
Test the crea... | (5,)) | self.assertEqual | collection | bayespy/inference/vmp/nodes/tests/test_concatenate.py | test_init | TestConcatenate | 51 | null |
bayespy/bayespy | import warnings
import numpy as np
from bayespy.nodes import (Concatenate,
GaussianARD,
Gamma)
from bayespy.utils import random
from bayespy.utils.misc import TestCase
class TestConcatenate(TestCase):
def test_init(self):
r"""
Test the crea... | (3,)) | self.assertEqual | collection | bayespy/inference/vmp/nodes/tests/test_concatenate.py | test_init | TestConcatenate | 39 | null |
bayespy/bayespy | import unittest
import numpy as np
import scipy
from numpy import testing
from ..node import Node, Moments
from ...vmp import VB
from bayespy.utils import misc
class TestSlice(misc.TestCase):
def test_init(self):
r"""
Test the constructor of the X[..] node operator.
"""
class... | ()) | self.assertEqual | collection | bayespy/inference/vmp/nodes/tests/test_node.py | test_init | TestSlice | 473 | null |
syrupy-project/syrupy | import base64
import pytest
from syrupy.extensions.image import PNGImageSnapshotExtension
actual_png = base64.b64decode(
b"iVBORw0KGgoAAAANSUhEUgAAADIAAAAyBAMAAADsEZWCAAAAG1BMVEXMzMy"
b"Wlpaqqqq3t7exsbGcnJy+vr6jo6PFxcUFpPI/AAAACXBIWXMAAA7EAAAOxA"
b"GVKw4bAAAAQUlEQVQ4jWNgGAWjgP6ASdncAEaiAhaGiACmFhCJLsMaIi... | None | assert | none_literal | tests/syrupy/extensions/image/test_image_png.py | test_multiple_snapshot_extensions | 32 | null | |
syrupy-project/syrupy | from collections import (
OrderedDict,
namedtuple,
)
import pytest
from syrupy.extensions.amber.serializer import AmberDataSerializer
from syrupy.extensions.json import JSONSnapshotExtension
def snapshot_json(snapshot):
return snapshot.use_extension(JSONSnapshotExtension)
def test_ordered_dict(snapshot_... | d | assert | variable | tests/syrupy/extensions/json/test_json_serializer.py | test_ordered_dict | 234 | null | |
syrupy-project/syrupy | def test_raises_informative_type_error_when_serializing_non_bytes(testdir):
testdir.makepyfile(
test_file="""
from syrupy.extensions.single_file import SingleFileSnapshotExtension
def test_case(snapshot):
assert {"x": 0} == snapshot(extension_class=SingleFileSnapshotExtension)
... | 1 | assert | numeric_literal | tests/integration/test_invalid_bytes_single_file.py | test_raises_informative_type_error_when_serializing_non_bytes | 12 | null | |
syrupy-project/syrupy | from types import MappingProxyType
import pytest
def test_snapshot_diff_id(snapshot):
my_dict = {
"field_0": True,
"field_1": "no_value",
"field_2": 0,
"field_3": None,
"field_4": 1,
"field_5": False,
"field_6": (True, "hey", 2, None),
"field_7": {Fa... | snapshot(diff="large snapshot") | assert | func_call | tests/syrupy/extensions/amber/test_amber_snapshot_diff.py | test_snapshot_diff_id | 45 | null | |
syrupy-project/syrupy | def test_ignores_non_function_nodes(testdir, plugin_args):
conftest = """
import pytest
class CustomItem(pytest.Item):
def __init__(self, name, **kwargs):
super().__init__(name, **kwargs)
self._nodeid += "::CUSTOM"
def runtest(self):
... | 0 | assert | numeric_literal | tests/integration/test_pytest_extension.py | test_ignores_non_function_nodes | 28 | null | |
syrupy-project/syrupy | from pathlib import Path
from unittest.mock import MagicMock
import pytest
from syrupy.constants import PYTEST_NODE_SEP
from syrupy.location import PyTestLocation
def mock_pytest_item(node_id: str, method_name: str) -> "pytest.Item":
mock_node = MagicMock(spec=pytest.Item)
mock_node.nodeid = node_id
[fil... | expected_classname | assert | variable | tests/syrupy/test_location.py | test_location_properties | 56 | null | |
syrupy-project/syrupy | from pathlib import Path
import pytest
from syrupy.exceptions import FailedToLoadModuleMember
from syrupy.utils import (
import_module_member,
walk_snapshot_dir,
)
def makefiles(testdir, filetree, root=""):
for filename, contents in filetree.items():
filepath = Path(root).joinpath(filename)
... | 123 | assert | numeric_literal | tests/syrupy/test_utils.py | test_import_module_member_imports_member | 89 | null | |
syrupy-project/syrupy | import datetime
import random
import pytest
from syrupy.extensions.json import JSONSnapshotExtension
from syrupy.matchers import path_type
def snapshot_json(snapshot):
return snapshot.use_extension(JSONSnapshotExtension)
def test_matcher(snapshot_json):
content = {
"int": random.randint(1, 100),
... | content | assert | variable | tests/syrupy/extensions/json/test_json_matchers.py | test_matcher | 31 | null | |
syrupy-project/syrupy | import pytest
def testcases_initial(testdir):
testdir.makeconftest(
"""
import pytest
import math
from syrupy.extensions.amber import AmberSnapshotExtension
class CustomSnapshotExtension(AmberSnapshotExtension):
def matches(self, *, serialized_data, snapshot_da... | 1 | assert | numeric_literal | tests/integration/test_custom_comparator.py | test_failed_snapshots | 79 | null | |
syrupy-project/syrupy | from pathlib import Path
from unittest.mock import MagicMock
import pytest
from syrupy.constants import PYTEST_NODE_SEP
from syrupy.location import PyTestLocation
def mock_pytest_item(node_id: str, method_name: str) -> "pytest.Item":
mock_node = MagicMock(spec=pytest.Item)
mock_node.nodeid = node_id
[fil... | expected_snapshotname | assert | variable | tests/syrupy/test_location.py | test_location_properties | 58 | null | |
syrupy-project/syrupy | from syrupy.extensions.amber.serializer import AmberDataSerializer
from syrupy.filters import props
from syrupy.matchers import path_type
def test_snapshot_object_as_named_tuple_class(snapshot):
"""
Show helper `object_as_named_tuple` to revert representation to amber standard
"""
assert MyCustomReprC... | snapshot( exclude=props("prop1"), matcher=path_type( types=(MyCustomReprClass,), replacer=lambda data, _: AmberDataSerializer.object_as_named_tuple(data), ), ) | assert | func_call | tests/examples/test_custom_object_repr.py | test_snapshot_object_as_named_tuple_class | 34 | null | |
syrupy-project/syrupy | import base64
import pytest
from syrupy.extensions.image import PNGImageSnapshotExtension
actual_png = base64.b64decode(
b"iVBORw0KGgoAAAANSUhEUgAAADIAAAAyBAMAAADsEZWCAAAAG1BMVEXMzMy"
b"Wlpaqqqq3t7exsbGcnJy+vr6jo6PFxcUFpPI/AAAACXBIWXMAAA7EAAAOxA"
b"GVKw4bAAAAQUlEQVQ4jWNgGAWjgP6ASdncAEaiAhaGiACmFhCJLsMaIi... | snapshot_png | assert | variable | tests/syrupy/extensions/image/test_image_png.py | test_image | 22 | null | |
syrupy-project/syrupy | import pytest
def testcases():
return {
"used": (
"""
def test_used(snapshot):
assert snapshot == 'used'
"""
),
"unused": (
"""
def test_unused(snapshot):
assert snapshot == 'unused'
"""
... | 0 | assert | numeric_literal | tests/integration/test_snapshot_option_warn_unused.py | test_unused_snapshots_warning | 56 | null | |
syrupy-project/syrupy | import datetime
import pytest
from syrupy.extensions.json import JSONSnapshotExtension
from syrupy.filters import (
paths,
props,
)
def snapshot_json(snapshot):
return snapshot.use_extension(JSONSnapshotExtension)
@pytest.mark.parametrize(
"content",
[
{},
["an array"],
{... | content | assert | variable | tests/syrupy/extensions/json/test_json_filters.py | test_serializer | 33 | null | |
syrupy-project/syrupy | from types import MappingProxyType
import pytest
def test_snapshot_diff_id(snapshot):
my_dict = {
"field_0": True,
"field_1": "no_value",
"field_2": 0,
"field_3": None,
"field_4": 1,
"field_5": False,
"field_6": (True, "hey", 2, None),
"field_7": {Fa... | snapshot(name="large snapshot") | assert | func_call | tests/syrupy/extensions/amber/test_amber_snapshot_diff.py | test_snapshot_diff_id | 38 | null | |
syrupy-project/syrupy | from collections import (
OrderedDict,
namedtuple,
)
import pytest
from syrupy.extensions.amber.serializer import AmberDataSerializer
def test_tuple(snapshot):
assert snapshot == ("this", "is", ("a", "tuple"))
assert snapshot == ExampleTuple(a="this", b="is", c="a", d={"named", "tuple"})
assert ... | () | assert | collection | tests/syrupy/extensions/amber/test_amber_serializer.py | test_tuple | 99 | null | |
syrupy-project/syrupy | import datetime
import pytest
from syrupy.filters import (
paths,
paths_include,
props,
)
def test_filters_expected_paths(snapshot):
actual = {
0: "some value",
"date": datetime.datetime.now(),
"nested": {"id": 4, "other": "value"},
"list": [1, 2],
}
assert ac... | snapshot(exclude=paths("0", "date", "nested.id", "list.0")) | assert | func_call | tests/syrupy/extensions/amber/test_amber_filters.py | test_filters_expected_paths | 24 | null | |
syrupy-project/syrupy | import pytest
from syrupy.extensions.json import JSONSnapshotExtension
from syrupy.filters import paths
from syrupy.matchers import path_type
def snapshot_matcher(snapshot):
return snapshot.with_defaults(matcher=path_type(mapping={"my-field": (str, int)}))
def snapshot_exclude(snapshot_matcher):
return snaps... | snapshot_matcher | assert | variable | tests/examples/test_custom_defaults.py | test_asserting_multiple_times | 32 | null | |
syrupy-project/syrupy | from pathlib import Path
from typing import TYPE_CHECKING
import pytest
from syrupy.data import (
Snapshot,
SnapshotCollection,
)
from syrupy.extensions.single_file import (
SingleFileSnapshotExtension,
WriteMode,
)
def snapshot_single(snapshot):
return snapshot.use_extension(SingleFileSnapshotEx... | b"orange" | assert | string_literal | tests/syrupy/extensions/test_single_file.py | test_____underscore | 59 | null | |
syrupy-project/syrupy | from pathlib import Path
import pytest
def testcases():
return {
"base": (
"""
def test_a(snapshot):
assert snapshot(name="xyz") == "case 1"
assert snapshot(name="zyx") == "case 2"
"""
),
"modified": (
"""
... | str(result.stdout) | assert | func_call | tests/integration/test_snapshot_option_dirname.py | test_update | 77 | null | |
syrupy-project/syrupy | import pytest
def testcases():
return {
"used": (
"""
def test_used(snapshot):
assert snapshot == 'used'
"""
),
"raise-skipped": (
"""
import pytest
def test_skipped(snapshot):
pytest.ski... | 0 | assert | numeric_literal | tests/integration/test_snapshot_skipped.py | test_mark_skipped_snapshots | 54 | null | |
syrupy-project/syrupy | from types import MappingProxyType
import pytest
def test_snapshot_diff(snapshot):
my_dict = {
"field_0": True,
"field_1": "no_value",
"nested": {
"field_0": 1,
},
}
assert my_dict == | snapshot | assert | variable | tests/syrupy/extensions/amber/test_amber_snapshot_diff.py | test_snapshot_diff | 14 | null | |
syrupy-project/syrupy | import datetime
import uuid
import pytest
from syrupy.extensions.amber.serializer import (
AmberDataSerializer,
Repr,
)
from syrupy.matchers import (
PathTypeError,
compose_matchers,
path_type,
path_value,
)
def test_matches_non_deterministic_snapshots(snapshot):
def matcher(data, path):
... | snapshot(matcher=matcher) | assert | func_call | tests/syrupy/extensions/amber/test_amber_matchers.py | test_matches_non_deterministic_snapshots | 66 | null | |
syrupy-project/syrupy | import pytest
_TEST = """
def test_foo(snapshot):
assert {**base} == snapshot(name="a")
assert {**base, **extra} == snapshot(name="b", diff="a")
"""
def _make_file(testdir, base, extra):
testdir.makepyfile(
test_file="\n\n".join([f"base = {base!r}", f"extra = {extra!r}", _TEST])
)
def _run_te... | 0 | assert | numeric_literal | tests/integration/test_snapshot_diff.py | _run_test | 25 | null | |
syrupy-project/syrupy | import pytest
def testcases():
return {
"a": (
"""
def test_a(snapshot):
assert snapshot == b"a"
"""
),
"b": (
"""
def test_b(snapshot):
assert snapshot == b"b"
"""
),
"a_... | 0 | assert | numeric_literal | tests/integration/test_snapshot_similar_names_file_extension.py | test_run_all | 53 | null | |
syrupy-project/syrupy | from collections import (
OrderedDict,
namedtuple,
)
import pytest
from syrupy.extensions.amber.serializer import AmberDataSerializer
def test_multiple_snapshots(snapshot):
assert "First." == snapshot
snapshot.assert_match("Second.")
assert snapshot == | "Third." | assert | string_literal | tests/syrupy/extensions/amber/test_amber_serializer.py | test_multiple_snapshots | 90 | null | |
syrupy-project/syrupy | import pytest
def testcases(testdir, tmp_path, request):
dirname = tmp_path.joinpath(request.param)
testdir.makeconftest(
f"""
import pytest
from syrupy.extensions.amber import AmberSnapshotExtension
class CustomSnapshotExtension(AmberSnapshotExtension):
@classmeth... | result.stdout.str() | assert | func_call | tests/integration/test_snapshot_outside_directory.py | test_generated_snapshots | 56 | null | |
syrupy-project/syrupy | from collections import (
OrderedDict,
namedtuple,
)
import pytest
from syrupy.extensions.amber.serializer import AmberDataSerializer
def test_empty_snapshot(snapshot):
assert snapshot == None # noqa: E711
assert snapshot == | "" | assert | string_literal | tests/syrupy/extensions/amber/test_amber_serializer.py | test_empty_snapshot | 25 | null | |
syrupy-project/syrupy | from collections import (
OrderedDict,
namedtuple,
)
import pytest
from syrupy.extensions.amber.serializer import AmberDataSerializer
def test_reflection(snapshot):
"""assert [expected|snapshot] == [actual|received]"""
assert snapshot(name="reflectionA") == | snapshot | assert | variable | tests/syrupy/extensions/amber/test_amber_serializer.py | test_reflection | 18 | null | |
syrupy-project/syrupy | from collections import (
OrderedDict,
namedtuple,
)
import pytest
from syrupy.extensions.amber.serializer import AmberDataSerializer
def test_empty_snapshot(snapshot):
assert snapshot == | None | assert | none_literal | tests/syrupy/extensions/amber/test_amber_serializer.py | test_empty_snapshot | 24 | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.