Skip to content

Commit

Permalink
fix flaky path coverage in var.backward()
Browse files Browse the repository at this point in the history
  • Loading branch information
rsokl committed Mar 3, 2021
1 parent 028af6b commit e8ab7a2
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/math/sequence/test_sequential_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
import numpy as np
import pytest
from hypothesis import given, settings
from numpy.testing import assert_allclose
from pytest import raises

import mygrad as mg
from mygrad import amax, amin, cumprod, cumsum, mean, prod, std, sum, var
from tests.utils.numerical_gradient import numerical_gradient_full

from ...custom_strategies import tensors, valid_axes
from ...wrappers.uber import (
Expand Down Expand Up @@ -474,3 +476,14 @@ def test_cumsum_fwd():
)
def test_cumsum_bkwd():
pass


def test_patch_coverage_on_var():
# this path coverage through var was flaky
x = mg.arange(6.0).reshape((2, 3))
o = mg.var(x, axis=1, keepdims=False)
o.backward()
(num_grad,) = numerical_gradient_full(
_var, x.data, kwargs=dict(axis=1, keepdims=False), back_grad=np.ones(o.shape)
)
assert_allclose(x.grad, num_grad)

0 comments on commit e8ab7a2

Please sign in to comment.