odlgroup / odl

Operator Discretization Library https://odlgroup.github.io/odl/
Mozilla Public License 2.0
374 stars 105 forks source link

about pytest #1573

Closed mimeng123 closed 4 years ago

mimeng123 commented 4 years ago

when I run the command python -c "import odl; odl.test()" ,receive a error as follow . what should I do ?

__ test_L1_norm[ space=power_space_unif_discr - sigma=10 - tspace_impl='numpy' ] __

space = ProductSpace(uniform_discr(0.0, 1.0, 7), 2), sigma = 10.0

def test_L1_norm(space, sigma):
    """Test the L1-norm."""
    sigma = float(sigma)
    func = odl.solvers.L1Norm(space)
    x = noise_element(space)

    # Test functional evaluation
    expected_result = np.abs(x).inner(space.one())
    assert func(x) == pytest.approx(expected_result)

    # Test gradient - expecting sign function
    expected_result = func.domain.element(np.sign(x))
    assert all_almost_equal(func.gradient(x), expected_result)

    # Test proximal - expecting the following:
    #                            |  x_i + sigma, if x_i < -sigma
    #                      z_i = {  0,           if -sigma <= x_i <= sigma
    #                            |  x_i - sigma, if x_i > sigma
    tmp = np.zeros(space.shape)
    orig = x.asarray()
    tmp[orig > sigma] = orig[orig > sigma] - sigma
    tmp[orig < -sigma] = orig[orig < -sigma] + sigma
    expected_result = space.element(tmp)
    assert all_almost_equal(func.proximal(sigma)(x), expected_result)

    # Test convex conjugate - expecting 0 if |x|_inf <= 1, infty else
    func_cc = func.convex_conj
  norm_larger_than_one = 1.1 * x / np.max(np.abs(x))

anaconda3/envs/ct_odl/lib/python3.7/site-packages/odl/test/solvers/functional/default_functionals_test.py:79:


<__array_function__ internals>:6: in amax ??? anaconda3/envs/ct_odl/lib/python3.7/site-packages/numpy/core/fromnumeric.py:2706: in amax keepdims=keepdims, initial=initial, where=where) anaconda3/envs/ct_odl/lib/python3.7/site-packages/numpy/core/fromnumeric.py:87: in _wrapreduction return ufunc.reduce(obj, axis, dtype, out, **passkwargs) anaconda3/envs/ct_odl/lib/python3.7/site-packages/odl/space/pspace.py:1083: in __array_wrap__ return self.space.element(array) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = ProductSpace(uniform_discr(0.0, 1.0, 7), 2), inp = array(2.31920335778775), cast = True def element(self, inp=None, cast=True): """Create an element in the product space. Parameters ---------- inp : optional If ``inp`` is ``None``, a new element is created from scratch by allocation in the spaces. If ``inp`` is already an element of this space, it is re-wrapped. Otherwise, a new element is created from the components by calling the ``element()`` methods in the component spaces. cast : bool, optional If ``True``, casting is allowed. Otherwise, a ``TypeError`` is raised for input that is not a sequence of elements of the spaces that make up this product space. Returns ------- element : `ProductSpaceElement` The new element Examples -------- >>> r2, r3 = odl.rn(2), odl.rn(3) >>> vec_2, vec_3 = r2.element(), r3.element() >>> r2x3 = ProductSpace(r2, r3) >>> vec_2x3 = r2x3.element() >>> vec_2.space == vec_2x3[0].space True >>> vec_3.space == vec_2x3[1].space True Create an element of the product space >>> r2, r3 = odl.rn(2), odl.rn(3) >>> prod = ProductSpace(r2, r3) >>> x2 = r2.element([1, 2]) >>> x3 = r3.element([1, 2, 3]) >>> x = prod.element([x2, x3]) >>> x ProductSpace(rn(2), rn(3)).element([ [ 1., 2.], [ 1., 2., 3.] ]) """ # If data is given as keyword arg, prefer it over arg list if inp is None: inp = [space.element() for space in self.spaces] if inp in self: return inp > if len(inp) != len(self): E TypeError: len() of unsized object anaconda3/envs/ct_odl/lib/python3.7/site-packages/odl/space/pspace.py:492: TypeError