DedalusProject / dedalus

A flexible framework for solving PDEs with modern spectral methods.
http://dedalus-project.org/
GNU General Public License v3.0
504 stars 119 forks source link

Test scripts fails #110

Closed dibondar closed 3 years ago

dibondar commented 3 years ago

I am looking forward to using this great library!

Initially I had a difficulty installing it using conda 4.9.2 on macOS Catalina 10.15.7, but I followed this discussion and used the provided script install_conda_clang9.sh, and successfully installed dedalus.

Then I run the tests

conda activate dedalus
python3 -m dedalus test

and got the following output

=========================================================================== test session starts ============================================================================
platform darwin -- Python 3.8.6, pytest-6.2.1, py-1.10.0, pluggy-0.13.1
benchmark: 3.2.3 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
rootdir: /Users/dbondar
plugins: cov-2.10.1, benchmark-3.2.3
collected 201 items                                                                                                                                                        

../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/tests/test_bvp.py ................................FF..........................                     [ 29%]
../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/tests/test_evp.py .......F....                                                                     [ 35%]
../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/tests/test_ivp.py ................................................                                 [ 59%]
../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/tests/test_matsolvers.py s..s...ss...s..s...ss...s..s...ss..xs..s...ss...s..s...ss...s..s...ss..x  [ 95%]
../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/tests/test_nlbvp.py ........                                                                       [ 99%]
../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/tests/test_output.py .                                                                             [100%]

================================================================================= FAILURES =================================================================================
_________________________________________________________________ test_gaussian_free[Hermite-128-float64] __________________________________________________________________

benchmark = None, x_basis_class = <class 'dedalus.core.basis.Hermite'>, Nx = 128, dtype = <class 'numpy.float64'>

    @pytest.mark.parametrize('dtype', [np.float64, np.complex128])
    @pytest.mark.parametrize('Nx', [128])
    @pytest.mark.parametrize('x_basis_class', [de.Hermite, DoubleLaguerre, LCCL])
    @bench_wrapper
    def test_gaussian_free(benchmark, x_basis_class, Nx, dtype):
        # Stretch Laguerres
        if x_basis_class is de.Hermite:
            stretch = 1.0
        else:
            stretch = 0.1
        # Bases and domain
        x_basis = x_basis_class('x', Nx, center=0, stretch=stretch)
        domain = de.Domain([x_basis], grid_dtype=dtype)
        # Problem
        problem = de.LBVP(domain, variables=['u'])
        problem.parameters['pi'] = np.pi
        problem.add_equation("dx(u) + 2*x*u = 0", tau=True)
        problem.add_bc("integ(u) = sqrt(pi)")
        # Solver
>       solver = problem.build_solver()

../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/tests/test_bvp.py:180: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/core/problems.py:313: in build_solver
    return self.solver_class(self, *args, **kw)
../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/core/solvers.py:191: in __init__
    pencil.build_matrices(self.pencils, problem, ['L'])
../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/core/pencil.py:62: in build_matrices
    expr.operator_dict(test_index, vars, cacheid=cacheid, **problem.ncc_kw)
../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/core/operators.py:440: in operator_dict
    op1 = self.args[1].operator_dict(index, vars, **kw)
../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/core/operators.py:719: in operator_dict
    op0 = self.args[0].as_ncc_operator(frozen_arg1_basis_meta, **kw)
../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/tools/cache.py:71: in __call__
    self.cache[call] = result = self.function(*args, **kw)
../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/core/future.py:208: in as_ncc_operator
    return ncc.as_ncc_operator(frozen_arg_basis_meta, cutoff, max_terms, cacheid=None)
../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/tools/cache.py:71: in __call__
    self.cache[call] = result = self.function(*args, **kw)
../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/core/field.py:289: in as_ncc_operator
    return ncc.as_ncc_operator(frozen_arg_basis_meta, cutoff, max_terms, cacheid=None)
../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/tools/cache.py:71: in __call__
    self.cache[call] = result = self.function(*args, **kw)
../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/core/field.py:556: in as_ncc_operator
    self.require_coeff_space()
../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/core/field.py:440: in require_coeff_space
    self.towards_coeff_space()
../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/core/field.py:423: in towards_coeff_space
    self.domain.dist.paths[index-1].decrement([self])
../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/core/distributor.py:372: in decrement
    self.decrement_single(*fields)
../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/core/distributor.py:357: in decrement_single
    self.basis.forward(gdata, cdata, self.axis, field.meta[self.axis], field.scales[self.axis])
../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/core/basis.py:1090: in _forward_mmt
    forward_mat, _ = self._mmt_setup(gdata.shape[axis], cdata.shape[axis], meta['envelope'])
../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/tools/cache.py:71: in __call__
    self.cache[call] = result = self.function(*args, **kw)
../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/core/basis.py:1081: in _mmt_setup
    N2 = np.sqrt(np.pi) * 2**n * special.factorial(n, exact=True)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

n = array([[  0.],
       [  1.],
       [  2.],
       [  3.],
       [  4.],
       [  5.],
       [  6.],
       [  7.]...     [121.],
       [122.],
       [123.],
       [124.],
       [125.],
       [126.],
       [127.]], dtype=float128)
exact = True

    def factorial(n, exact=False):
        """
        The factorial of a number or array of numbers.

        The factorial of non-negative integer `n` is the product of all
        positive integers less than or equal to `n`::

            n! = n * (n - 1) * (n - 2) * ... * 1

        Parameters
        ----------
        n : int or array_like of ints
            Input values.  If ``n < 0``, the return value is 0.
        exact : bool, optional
            If True, calculate the answer exactly using long integer arithmetic.
            If False, result is approximated in floating point rapidly using the
            `gamma` function.
            Default is False.

        Returns
        -------
        nf : float or int or ndarray
            Factorial of `n`, as integer or float depending on `exact`.

        Notes
        -----
        For arrays with ``exact=True``, the factorial is computed only once, for
        the largest input, with each other result computed in the process.
        The output dtype is increased to ``int64`` or ``object`` if necessary.

        With ``exact=False`` the factorial is approximated using the gamma
        function:

        .. math:: n! = \\Gamma(n+1)

        Examples
        --------
        >>> from scipy.special import factorial
        >>> arr = np.array([3, 4, 5])
        >>> factorial(arr, exact=False)
        array([   6.,   24.,  120.])
        >>> factorial(arr, exact=True)
        array([  6,  24, 120])
        >>> factorial(5, exact=True)
        120

        """
        if exact:
            if np.ndim(n) == 0:
                if np.isnan(n):
                    return n
                return 0 if n < 0 else math.factorial(n)
            else:
                n = asarray(n)
                un = np.unique(n).astype(object)

                # Convert to object array of long ints if np.int_ can't handle size
                if np.isnan(n).any():
                    dt = float
                elif un[-1] > 20:
                    dt = object
                elif un[-1] > 12:
                    dt = np.int64
                else:
                    dt = np.int_

                out = np.empty_like(n, dtype=dt)

                # Handle invalid/trivial values
                # Ignore runtime warning when less operator used w/np.nan
                with np.errstate(all='ignore'):
                    un = un[un > 1]
                    out[n < 2] = 1
                    out[n < 0] = 0

                # Calculate products of each range of numbers
                if un.size:
>                   val = math.factorial(un[0])
E                   TypeError: 'numpy.float128' object cannot be interpreted as an integer

../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/scipy/special/_basic.py:2352: TypeError
---------------------------------------------------------------------------- Captured log call -----------------------------------------------------------------------------
DEBUG    domain:domain.py:55 Global coeff shape: [128]
DEBUG    distributor:distributor.py:92 Mesh: []
DEBUG    problems:problems.py:127 Parsing Eqn 0
DEBUG    problems:problems.py:146   Condition: True
DEBUG    problems:problems.py:147   LHS string form: dx(u) + 2*x*u
DEBUG    problems:problems.py:148   RHS string form: 0
DEBUG    problems:problems.py:155   LHS object form: dx(u) + ((2*x)*u)
DEBUG    problems:problems.py:156   RHS object form: 0
DEBUG    problems:problems.py:308   L linear form: dx(u) + ((2*x)*u)
DEBUG    problems:problems.py:127 Parsing Eqn 1
DEBUG    problems:problems.py:146   Condition: True
DEBUG    problems:problems.py:147   LHS string form: integ(u)
DEBUG    problems:problems.py:148   RHS string form: sqrt(pi)
DEBUG    problems:problems.py:155   LHS object form: integ_x(u)
DEBUG    problems:problems.py:156   RHS object form: sqrt(pi)
DEBUG    problems:problems.py:308   L linear form: integ_x(u)
DEBUG    solvers:solvers.py:180 Beginning LBVP instantiation
DEBUG    basis:basis.py:1064 Building Hermite MMT matrices for (gsize, csize, env) = (128, 128, False)
________________________________________________________________ test_gaussian_free[Hermite-128-complex128] ________________________________________________________________

benchmark = None, x_basis_class = <class 'dedalus.core.basis.Hermite'>, Nx = 128, dtype = <class 'numpy.complex128'>

    @pytest.mark.parametrize('dtype', [np.float64, np.complex128])
    @pytest.mark.parametrize('Nx', [128])
    @pytest.mark.parametrize('x_basis_class', [de.Hermite, DoubleLaguerre, LCCL])
    @bench_wrapper
    def test_gaussian_free(benchmark, x_basis_class, Nx, dtype):
        # Stretch Laguerres
        if x_basis_class is de.Hermite:
            stretch = 1.0
        else:
            stretch = 0.1
        # Bases and domain
        x_basis = x_basis_class('x', Nx, center=0, stretch=stretch)
        domain = de.Domain([x_basis], grid_dtype=dtype)
        # Problem
        problem = de.LBVP(domain, variables=['u'])
        problem.parameters['pi'] = np.pi
        problem.add_equation("dx(u) + 2*x*u = 0", tau=True)
        problem.add_bc("integ(u) = sqrt(pi)")
        # Solver
>       solver = problem.build_solver()

../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/tests/test_bvp.py:180: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/core/problems.py:313: in build_solver
    return self.solver_class(self, *args, **kw)
../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/core/solvers.py:191: in __init__
    pencil.build_matrices(self.pencils, problem, ['L'])
../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/core/pencil.py:62: in build_matrices
    expr.operator_dict(test_index, vars, cacheid=cacheid, **problem.ncc_kw)
../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/core/operators.py:440: in operator_dict
    op1 = self.args[1].operator_dict(index, vars, **kw)
../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/core/operators.py:719: in operator_dict
    op0 = self.args[0].as_ncc_operator(frozen_arg1_basis_meta, **kw)
../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/tools/cache.py:71: in __call__
    self.cache[call] = result = self.function(*args, **kw)
../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/core/future.py:208: in as_ncc_operator
    return ncc.as_ncc_operator(frozen_arg_basis_meta, cutoff, max_terms, cacheid=None)
../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/tools/cache.py:71: in __call__
    self.cache[call] = result = self.function(*args, **kw)
../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/core/field.py:289: in as_ncc_operator
    return ncc.as_ncc_operator(frozen_arg_basis_meta, cutoff, max_terms, cacheid=None)
../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/tools/cache.py:71: in __call__
    self.cache[call] = result = self.function(*args, **kw)
../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/core/field.py:556: in as_ncc_operator
    self.require_coeff_space()
../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/core/field.py:440: in require_coeff_space
    self.towards_coeff_space()
../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/core/field.py:423: in towards_coeff_space
    self.domain.dist.paths[index-1].decrement([self])
../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/core/distributor.py:372: in decrement
    self.decrement_single(*fields)
../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/core/distributor.py:357: in decrement_single
    self.basis.forward(gdata, cdata, self.axis, field.meta[self.axis], field.scales[self.axis])
../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/core/basis.py:1090: in _forward_mmt
    forward_mat, _ = self._mmt_setup(gdata.shape[axis], cdata.shape[axis], meta['envelope'])
../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/tools/cache.py:71: in __call__
    self.cache[call] = result = self.function(*args, **kw)
../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/core/basis.py:1081: in _mmt_setup
    N2 = np.sqrt(np.pi) * 2**n * special.factorial(n, exact=True)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

n = array([[  0.],
       [  1.],
       [  2.],
       [  3.],
       [  4.],
       [  5.],
       [  6.],
       [  7.]...     [121.],
       [122.],
       [123.],
       [124.],
       [125.],
       [126.],
       [127.]], dtype=float128)
exact = True

    def factorial(n, exact=False):
        """
        The factorial of a number or array of numbers.

        The factorial of non-negative integer `n` is the product of all
        positive integers less than or equal to `n`::

            n! = n * (n - 1) * (n - 2) * ... * 1

        Parameters
        ----------
        n : int or array_like of ints
            Input values.  If ``n < 0``, the return value is 0.
        exact : bool, optional
            If True, calculate the answer exactly using long integer arithmetic.
            If False, result is approximated in floating point rapidly using the
            `gamma` function.
            Default is False.

        Returns
        -------
        nf : float or int or ndarray
            Factorial of `n`, as integer or float depending on `exact`.

        Notes
        -----
        For arrays with ``exact=True``, the factorial is computed only once, for
        the largest input, with each other result computed in the process.
        The output dtype is increased to ``int64`` or ``object`` if necessary.

        With ``exact=False`` the factorial is approximated using the gamma
        function:

        .. math:: n! = \\Gamma(n+1)

        Examples
        --------
        >>> from scipy.special import factorial
        >>> arr = np.array([3, 4, 5])
        >>> factorial(arr, exact=False)
        array([   6.,   24.,  120.])
        >>> factorial(arr, exact=True)
        array([  6,  24, 120])
        >>> factorial(5, exact=True)
        120

        """
        if exact:
            if np.ndim(n) == 0:
                if np.isnan(n):
                    return n
                return 0 if n < 0 else math.factorial(n)
            else:
                n = asarray(n)
                un = np.unique(n).astype(object)

                # Convert to object array of long ints if np.int_ can't handle size
                if np.isnan(n).any():
                    dt = float
                elif un[-1] > 20:
                    dt = object
                elif un[-1] > 12:
                    dt = np.int64
                else:
                    dt = np.int_

                out = np.empty_like(n, dtype=dt)

                # Handle invalid/trivial values
                # Ignore runtime warning when less operator used w/np.nan
                with np.errstate(all='ignore'):
                    un = un[un > 1]
                    out[n < 2] = 1
                    out[n < 0] = 0

                # Calculate products of each range of numbers
                if un.size:
>                   val = math.factorial(un[0])
E                   TypeError: 'numpy.float128' object cannot be interpreted as an integer

../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/scipy/special/_basic.py:2352: TypeError
---------------------------------------------------------------------------- Captured log call -----------------------------------------------------------------------------
DEBUG    domain:domain.py:55 Global coeff shape: [128]
DEBUG    distributor:distributor.py:92 Mesh: []
DEBUG    problems:problems.py:127 Parsing Eqn 0
DEBUG    problems:problems.py:146   Condition: True
DEBUG    problems:problems.py:147   LHS string form: dx(u) + 2*x*u
DEBUG    problems:problems.py:148   RHS string form: 0
DEBUG    problems:problems.py:155   LHS object form: dx(u) + ((2*x)*u)
DEBUG    problems:problems.py:156   RHS object form: 0
DEBUG    problems:problems.py:308   L linear form: dx(u) + ((2*x)*u)
DEBUG    problems:problems.py:127 Parsing Eqn 1
DEBUG    problems:problems.py:146   Condition: True
DEBUG    problems:problems.py:147   LHS string form: integ(u)
DEBUG    problems:problems.py:148   RHS string form: sqrt(pi)
DEBUG    problems:problems.py:155   LHS object form: integ_x(u)
DEBUG    problems:problems.py:156   RHS object form: sqrt(pi)
DEBUG    problems:problems.py:308   L linear form: integ_x(u)
DEBUG    solvers:solvers.py:180 Beginning LBVP instantiation
DEBUG    basis:basis.py:1064 Building Hermite MMT matrices for (gsize, csize, env) = (128, 128, False)
________________________________________________________________ test_qho_dense_evp[Hermite-128-complex128] ________________________________________________________________

benchmark = None, x_basis_class = <class 'dedalus.core.basis.Hermite'>, Nx = 128, dtype = <class 'numpy.complex128'>

    @pytest.mark.parametrize('dtype', [np.complex128])
    @pytest.mark.parametrize('Nx', [128])
    @pytest.mark.parametrize('x_basis_class', [de.Hermite])
    @bench_wrapper
    def test_qho_dense_evp(benchmark, x_basis_class, Nx, dtype):
        n_comp = 10
        # Stretch Laguerres
        if x_basis_class is de.Hermite:
            stretch = 1.0
        else:
            stretch = 0.4
        # Domain
        x_basis = x_basis_class('x', Nx, center=0, stretch=stretch)
        domain = de.Domain([x_basis], np.float64)
        # Problem
        problem = de.EVP(domain, variables=['ψ', 'ψx'], eigenvalue='E')
        problem.substitutions["V"] = "x**2 / 2"
        problem.substitutions["H(ψ,ψx)"] = "-dx(ψx)/2 + V*ψ"
        problem.add_equation("ψx - dx(ψ) = 0", tau=False)
        problem.add_equation("H(ψ,ψx) - E*ψ = 0", tau=False)
        # Solver
        solver = problem.build_solver()
>       solver.solve_dense(solver.pencils[0])

../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/tests/test_evp.py:128: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/core/solvers.py:95: in solve_dense
    pencil.build_matrices(self.problem, ['M', 'L'], cacheid=cacheid)
../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/core/pencil.py:259: in _build_coupled_matrices
    Ei = eq_expr.operator_dict(global_index, eq_vars, cacheid=cacheid, **problem.ncc_kw)
../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/core/operators.py:440: in operator_dict
    op1 = self.args[1].operator_dict(index, vars, **kw)
../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/core/operators.py:719: in operator_dict
    op0 = self.args[0].as_ncc_operator(frozen_arg1_basis_meta, **kw)
../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/tools/cache.py:71: in __call__
    self.cache[call] = result = self.function(*args, **kw)
../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/core/future.py:208: in as_ncc_operator
    return ncc.as_ncc_operator(frozen_arg_basis_meta, cutoff, max_terms, cacheid=None)
../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/tools/cache.py:71: in __call__
    self.cache[call] = result = self.function(*args, **kw)
../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/core/field.py:289: in as_ncc_operator
    return ncc.as_ncc_operator(frozen_arg_basis_meta, cutoff, max_terms, cacheid=None)
../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/tools/cache.py:71: in __call__
    self.cache[call] = result = self.function(*args, **kw)
../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/core/field.py:556: in as_ncc_operator
    self.require_coeff_space()
../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/core/field.py:440: in require_coeff_space
    self.towards_coeff_space()
../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/core/field.py:423: in towards_coeff_space
    self.domain.dist.paths[index-1].decrement([self])
../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/core/distributor.py:372: in decrement
    self.decrement_single(*fields)
../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/core/distributor.py:357: in decrement_single
    self.basis.forward(gdata, cdata, self.axis, field.meta[self.axis], field.scales[self.axis])
../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/core/basis.py:1090: in _forward_mmt
    forward_mat, _ = self._mmt_setup(gdata.shape[axis], cdata.shape[axis], meta['envelope'])
../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/tools/cache.py:71: in __call__
    self.cache[call] = result = self.function(*args, **kw)
../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/core/basis.py:1081: in _mmt_setup
    N2 = np.sqrt(np.pi) * 2**n * special.factorial(n, exact=True)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

n = array([[  0.],
       [  1.],
       [  2.],
       [  3.],
       [  4.],
       [  5.],
       [  6.],
       [  7.]...     [121.],
       [122.],
       [123.],
       [124.],
       [125.],
       [126.],
       [127.]], dtype=float128)
exact = True

    def factorial(n, exact=False):
        """
        The factorial of a number or array of numbers.

        The factorial of non-negative integer `n` is the product of all
        positive integers less than or equal to `n`::

            n! = n * (n - 1) * (n - 2) * ... * 1

        Parameters
        ----------
        n : int or array_like of ints
            Input values.  If ``n < 0``, the return value is 0.
        exact : bool, optional
            If True, calculate the answer exactly using long integer arithmetic.
            If False, result is approximated in floating point rapidly using the
            `gamma` function.
            Default is False.

        Returns
        -------
        nf : float or int or ndarray
            Factorial of `n`, as integer or float depending on `exact`.

        Notes
        -----
        For arrays with ``exact=True``, the factorial is computed only once, for
        the largest input, with each other result computed in the process.
        The output dtype is increased to ``int64`` or ``object`` if necessary.

        With ``exact=False`` the factorial is approximated using the gamma
        function:

        .. math:: n! = \\Gamma(n+1)

        Examples
        --------
        >>> from scipy.special import factorial
        >>> arr = np.array([3, 4, 5])
        >>> factorial(arr, exact=False)
        array([   6.,   24.,  120.])
        >>> factorial(arr, exact=True)
        array([  6,  24, 120])
        >>> factorial(5, exact=True)
        120

        """
        if exact:
            if np.ndim(n) == 0:
                if np.isnan(n):
                    return n
                return 0 if n < 0 else math.factorial(n)
            else:
                n = asarray(n)
                un = np.unique(n).astype(object)

                # Convert to object array of long ints if np.int_ can't handle size
                if np.isnan(n).any():
                    dt = float
                elif un[-1] > 20:
                    dt = object
                elif un[-1] > 12:
                    dt = np.int64
                else:
                    dt = np.int_

                out = np.empty_like(n, dtype=dt)

                # Handle invalid/trivial values
                # Ignore runtime warning when less operator used w/np.nan
                with np.errstate(all='ignore'):
                    un = un[un > 1]
                    out[n < 2] = 1
                    out[n < 0] = 0

                # Calculate products of each range of numbers
                if un.size:
>                   val = math.factorial(un[0])
E                   TypeError: 'numpy.float128' object cannot be interpreted as an integer

../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/scipy/special/_basic.py:2352: TypeError
--------------------------------------------------------------------------- Captured stdout call ---------------------------------------------------------------------------
2021-01-09 13:57:44,266 problems 0/1 INFO :: Solving EVP with homogeneity tolerance of 1.000e-10
---------------------------------------------------------------------------- Captured log call -----------------------------------------------------------------------------
DEBUG    domain:domain.py:55 Global coeff shape: [128]
DEBUG    distributor:distributor.py:92 Mesh: []
INFO     problems:problems.py:523 Solving EVP with homogeneity tolerance of 1.000e-10
DEBUG    problems:problems.py:127 Parsing Eqn 0
DEBUG    problems:problems.py:146   Condition: True
DEBUG    problems:problems.py:147   LHS string form: ψx - dx(ψ)
DEBUG    problems:problems.py:148   RHS string form: 0
DEBUG    problems:problems.py:155   LHS object form: ψx + (-1*dx(ψ))
DEBUG    problems:problems.py:156   RHS object form: 0
DEBUG    problems:problems.py:308   M linear form: 0
DEBUG    problems:problems.py:308   L linear form: ψx + (-1*dx(ψ))
DEBUG    problems:problems.py:127 Parsing Eqn 1
DEBUG    problems:problems.py:146   Condition: True
DEBUG    problems:problems.py:147   LHS string form: H(ψ,ψx) - E*ψ
DEBUG    problems:problems.py:148   RHS string form: 0
DEBUG    problems:problems.py:155   LHS object form: (((-1*dx(ψx))*0.5) + (((x**2)*0.5)*ψ)) + (-1*(E*ψ))
DEBUG    problems:problems.py:156   RHS object form: 0
DEBUG    problems:problems.py:308   M linear form: -1*ψ
DEBUG    problems:problems.py:308   L linear form: (-0.5*dx(ψx)) + (((x**2)*0.5)*ψ)
DEBUG    solvers:solvers.py:58 Beginning EVP instantiation
DEBUG    solvers:solvers.py:73 Finished EVP instantiation
DEBUG    basis:basis.py:1064 Building Hermite MMT matrices for (gsize, csize, env) = (128, 128, False)
========================================================================= short test summary info ==========================================================================
FAILED ../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/tests/test_bvp.py::test_gaussian_free[Hermite-128-float64] - TypeError: 'numpy.float128' object ...
FAILED ../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/tests/test_bvp.py::test_gaussian_free[Hermite-128-complex128] - TypeError: 'numpy.float128' obje...
FAILED ../opt/anaconda3/envs/dedalus/lib/python3.8/site-packages/dedalus/tests/test_evp.py::test_qho_dense_evp[Hermite-128-complex128] - TypeError: 'numpy.float128' obje...
========================================================== 3 failed, 172 passed, 24 skipped, 2 xfailed in 15.07s ===========================================================
kburns commented 3 years ago

Hi! Thanks for bringing this up -- I think you're seeing a known issue with platform-specific support for extended precision, which is only needed for using the Laguerre and Hermite bases. If you're interested in using these, you can try pulling from master here instead of using the latest pip release. This issue should be fixed with this commit on master: efb13bdaa09816dde3eee897bc2a15fc284ea2f1. Please report back if you try and that doesn't fix it!

williamgilpin commented 3 years ago

I also encountered this issue on macOS 10.15.7 (19H524) / Python 3.8.8.

I found that pulling the latest GitHub version resolved the problem.

Thanks very much for this amazing library!