Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
(base) Davids-MacBook-Pro-4:~ dpsanders$ conda activate base
(base) Davids-MacBook-Pro-4:~ dpsanders$ bash install_conda.sh
Setting up conda with 'source /usr/local/Caskroom/miniconda/base/etc/profile.d/conda.sh'
Preventing conda from looking in ~/.local with 'export PYTHONNOUSERSITE=1'
Preventing conda from looking in PYTHONPATH with 'unset PYTHONPATH'
Building new conda environment 'dedalus'
Collecting package metadata (current_repodata.json): ...working... done
Solving environment: ...working... done
## Package Plan ##
environment location: /usr/local/Caskroom/miniconda/base/envs/dedalus
added / updated specs:
- python=3.8
The following packages will be downloaded:
package | build
---------------------------|-----------------
ca-certificates-2020.12.5 | h033912b_0 138 KB conda-forge
certifi-2020.12.5 | py38h50d1736_1 143 KB conda-forge
libcxx-11.1.0 | habf9029_0 1.0 MB conda-forge
libffi-3.3 | h046ec9c_2 45 KB conda-forge
ncurses-6.2 | h2e338ed_4 881 KB conda-forge
openssl-1.1.1k | h0d85af4_0 1.9 MB conda-forge
pip-21.1.1 | pyhd8ed1ab_0 1.1 MB conda-forge
python-3.8.8 |h4e93d89_0_cpython 12.4 MB conda-forge
python_abi-3.8 | 1_cp38 4 KB conda-forge
readline-8.1 | h05e3726_0 266 KB conda-forge
setuptools-49.6.0 | py38h50d1736_3 931 KB conda-forge
sqlite-3.35.5 | h44b9ce1_0 1.7 MB conda-forge
tk-8.6.10 | h0419947_1 3.3 MB conda-forge
wheel-0.36.2 | pyhd3deb0d_0 31 KB conda-forge
xz-5.2.5 | haf1e3a3_1 228 KB conda-forge
zlib-1.2.11 | h7795811_1010 102 KB conda-forge
------------------------------------------------------------
Total: 24.1 MB
The following NEW packages will be INSTALLED:
ca-certificates conda-forge/osx-64::ca-certificates-2020.12.5-h033912b_0
certifi conda-forge/osx-64::certifi-2020.12.5-py38h50d1736_1
libcxx conda-forge/osx-64::libcxx-11.1.0-habf9029_0
libffi conda-forge/osx-64::libffi-3.3-h046ec9c_2
ncurses conda-forge/osx-64::ncurses-6.2-h2e338ed_4
openssl conda-forge/osx-64::openssl-1.1.1k-h0d85af4_0
pip conda-forge/noarch::pip-21.1.1-pyhd8ed1ab_0
python conda-forge/osx-64::python-3.8.8-h4e93d89_0_cpython
python_abi conda-forge/osx-64::python_abi-3.8-1_cp38
readline conda-forge/osx-64::readline-8.1-h05e3726_0
setuptools conda-forge/osx-64::setuptools-49.6.0-py38h50d1736_3
sqlite conda-forge/osx-64::sqlite-3.35.5-h44b9ce1_0
tk conda-forge/osx-64::tk-8.6.10-h0419947_1
wheel conda-forge/noarch::wheel-0.36.2-pyhd3deb0d_0
xz conda-forge/osx-64::xz-5.2.5-haf1e3a3_1
zlib conda-forge/osx-64::zlib-1.2.11-h7795811_1010
Preparing transaction: ...working... done
Verifying transaction: ...working... done
Executing transaction: ...working... done
Updating conda-forge pip, wheel, setuptools, cython
Collecting package metadata (current_repodata.json): ...working... done
Solving environment: ...working... done
## Package Plan ##
environment location: /usr/local/Caskroom/miniconda/base/envs/dedalus
added / updated specs:
- cython
- pip
- setuptools
- wheel
The following packages will be downloaded:
package | build
---------------------------|-----------------
cython-0.29.23 | py38ha048514_0 2.0 MB conda-forge
------------------------------------------------------------
Total: 2.0 MB
The following NEW packages will be INSTALLED:
cython conda-forge/osx-64::cython-0.29.23-py38ha048514_0
Preparing transaction: ...working... done
Verifying transaction: ...working... done
Executing transaction: ...working... done
Installing conda-forge openblas, numpy, scipy
Collecting package metadata (current_repodata.json): ...working... done
Solving environment: ...working... done
## Package Plan ##
environment location: /usr/local/Caskroom/miniconda/base/envs/dedalus
added / updated specs:
- libblas[build=*openblas]
- numpy
- scipy
The following packages will be downloaded:
package | build
---------------------------|-----------------
libblas-3.9.0 | 9_openblas 11 KB conda-forge
libcblas-3.9.0 | 9_openblas 11 KB conda-forge
libgfortran-5.0.0 |9_3_0_h6c81a4c_22 19 KB conda-forge
libgfortran5-9.3.0 | h6c81a4c_22 1.7 MB conda-forge
liblapack-3.9.0 | 9_openblas 11 KB conda-forge
libopenblas-0.3.15 |openmp_h5e1b9a4_0 8.7 MB conda-forge
llvm-openmp-11.1.0 | hda6cdc1_1 268 KB conda-forge
numpy-1.20.2 | py38had91d27_0 5.5 MB conda-forge
scipy-1.6.3 | py38h431c0a8_0 18.6 MB conda-forge
------------------------------------------------------------
Total: 34.8 MB
The following NEW packages will be INSTALLED:
libblas conda-forge/osx-64::libblas-3.9.0-9_openblas
libcblas conda-forge/osx-64::libcblas-3.9.0-9_openblas
libgfortran conda-forge/osx-64::libgfortran-5.0.0-9_3_0_h6c81a4c_22
libgfortran5 conda-forge/osx-64::libgfortran5-9.3.0-h6c81a4c_22
liblapack conda-forge/osx-64::liblapack-3.9.0-9_openblas
libopenblas conda-forge/osx-64::libopenblas-0.3.15-openmp_h5e1b9a4_0
llvm-openmp conda-forge/osx-64::llvm-openmp-11.1.0-hda6cdc1_1
numpy conda-forge/osx-64::numpy-1.20.2-py38had91d27_0
scipy conda-forge/osx-64::scipy-1.6.3-py38h431c0a8_0
kPreparing transaction: ...working... done
Verifying transaction: ...working... ^R
done
Executing transaction: ...working... done
Installing conda-forge openmpi, mpi4py
Collecting package metadata (current_repodata.json): ...working... done
Solving environment: ...working... done
## Package Plan ##
environment location: /usr/local/Caskroom/miniconda/base/envs/dedalus
added / updated specs:
- mpi4py
- openmpi
- openmpi-mpicc
The following packages will be downloaded:
package | build
---------------------------|-----------------
cctools_osx-64-949.0.1 | h6407bdd_21 1.8 MB conda-forge
clang-11.1.0 | h694c41f_0 124 KB conda-forge
clang-11-11.1.0 |default_he082bbe_0 686 KB conda-forge
clang_osx-64-11.1.0 | hb91bd55_1 16 KB conda-forge
clangxx-11.1.0 |default_he082bbe_0 124 KB conda-forge
compiler-rt-11.1.0 | h654b07c_0 78 KB conda-forge
compiler-rt_osx-64-11.1.0 | h8c5fa43_0 5.6 MB conda-forge
ld64_osx-64-530 | he8994da_21 1.3 MB conda-forge
ldid-2.1.2 | h7660a38_2 55 KB conda-forge
libclang-cpp11.1-11.1.0 |default_he082bbe_0 12.6 MB conda-forge
libllvm11-11.1.0 | hd011deb_2 22.5 MB conda-forge
llvm-tools-11.1.0 | hd011deb_2 11.7 MB conda-forge
mpi-1.0 | openmpi 4 KB conda-forge
mpi4py-3.0.3 | py38h1087cf1_7 578 KB conda-forge
openmpi-4.1.1 | hd3cd54c_0 3.2 MB conda-forge
openmpi-mpicc-4.1.1 | h0d85af4_0 9 KB conda-forge
tapi-1100.0.11 | h9ce4665_0 196 KB conda-forge
------------------------------------------------------------
Total: 60.5 MB
The following NEW packages will be INSTALLED:
cctools_osx-64 conda-forge/osx-64::cctools_osx-64-949.0.1-h6407bdd_21
clang conda-forge/osx-64::clang-11.1.0-h694c41f_0
clang-11 conda-forge/osx-64::clang-11-11.1.0-default_he082bbe_0
clang_osx-64 conda-forge/osx-64::clang_osx-64-11.1.0-hb91bd55_1
clangxx conda-forge/osx-64::clangxx-11.1.0-default_he082bbe_0
compiler-rt conda-forge/osx-64::compiler-rt-11.1.0-h654b07c_0
compiler-rt_osx-64 conda-forge/noarch::compiler-rt_osx-64-11.1.0-h8c5fa43_0
ld64_osx-64 conda-forge/osx-64::ld64_osx-64-530-he8994da_21
ldid conda-forge/osx-64::ldid-2.1.2-h7660a38_2
libclang-cpp11.1 conda-forge/osx-64::libclang-cpp11.1-11.1.0-default_he082bbe_0
libllvm11 conda-forge/osx-64::libllvm11-11.1.0-hd011deb_2
llvm-tools conda-forge/osx-64::llvm-tools-11.1.0-hd011deb_2
mpi conda-forge/osx-64::mpi-1.0-openmpi
mpi4py conda-forge/osx-64::mpi4py-3.0.3-py38h1087cf1_7
openmpi conda-forge/osx-64::openmpi-4.1.1-hd3cd54c_0
openmpi-mpicc conda-forge/osx-64::openmpi-mpicc-4.1.1-h0d85af4_0
tapi conda-forge/osx-64::tapi-1100.0.11-h9ce4665_0
Preparing transaction: ...working... done
Verifying transaction: ...working... done
Executing transaction: ...working... done
Installing conda-forge fftw
Collecting package metadata (current_repodata.json): ...working... done
Solving environment: ...working... done
## Package Plan ##
environment location: /usr/local/Caskroom/miniconda/base/envs/dedalus
added / updated specs:
- fftw[build=*openmpi*]
The following packages will be downloaded:
package | build
---------------------------|-----------------
fftw-3.3.9 |mpi_openmpi_hb67d103_1 5.4 MB conda-forge
------------------------------------------------------------
Total: 5.4 MB
The following NEW packages will be INSTALLED:
fftw conda-forge/osx-64::fftw-3.3.9-mpi_openmpi_hb67d103_1
Preparing transaction: ...working... done
Verifying transaction: ...working... done
Executing transaction: ...working... done
Installing conda-forge hdf5, h5py
Collecting package metadata (current_repodata.json): ...working... done
Solving environment: ...working... done
## Package Plan ##
environment location: /usr/local/Caskroom/miniconda/base/envs/dedalus
added / updated specs:
- h5py
- hdf5
The following packages will be downloaded:
package | build
---------------------------|-----------------
c-ares-1.17.1 | h0d85af4_1 95 KB conda-forge
cached-property-1.5.2 | hd8ed1ab_1 4 KB conda-forge
cached_property-1.5.2 | pyha770c72_1 11 KB conda-forge
h5py-3.2.1 |nompi_py38h9a16e60_100 1.1 MB conda-forge
hdf5-1.10.6 |nompi_hc5d9132_1114 3.1 MB conda-forge
krb5-1.17.2 | h60d9502_0 1.2 MB conda-forge
libcurl-7.76.1 | h8ef9fac_1 309 KB conda-forge
libedit-3.1.20191231 | h0678c8f_2 103 KB conda-forge
libev-4.33 | haf1e3a3_1 99 KB conda-forge
libnghttp2-1.43.0 | h07e645a_0 837 KB conda-forge
libssh2-1.9.0 | h52ee1ee_6 214 KB conda-forge
------------------------------------------------------------
Total: 7.0 MB
The following NEW packages will be INSTALLED:
c-ares conda-forge/osx-64::c-ares-1.17.1-h0d85af4_1
cached-property conda-forge/noarch::cached-property-1.5.2-hd8ed1ab_1
cached_property conda-forge/noarch::cached_property-1.5.2-pyha770c72_1
h5py conda-forge/osx-64::h5py-3.2.1-nompi_py38h9a16e60_100
hdf5 conda-forge/osx-64::hdf5-1.10.6-nompi_hc5d9132_1114
krb5 conda-forge/osx-64::krb5-1.17.2-h60d9502_0
libcurl conda-forge/osx-64::libcurl-7.76.1-h8ef9fac_1
libedit conda-forge/osx-64::libedit-3.1.20191231-h0678c8f_2
libev conda-forge/osx-64::libev-4.33-haf1e3a3_1
libnghttp2 conda-forge/osx-64::libnghttp2-1.43.0-h07e645a_0
libssh2 conda-forge/osx-64::libssh2-1.9.0-h52ee1ee_6
Preparing transaction: ...working... done
Verifying transaction: ...working... done
Executing transaction: ...working... done
Installing conda-forge docopt, matplotlib
Collecting package metadata (current_repodata.json): ...working... done
Solving environment: ...working... done
## Package Plan ##
environment location: /usr/local/Caskroom/miniconda/base/envs/dedalus
added / updated specs:
- docopt
- matplotlib
The following packages will be downloaded:
package | build
---------------------------|-----------------
cycler-0.10.0 | py_2 9 KB conda-forge
docopt-0.6.2 | py_1 14 KB conda-forge
freetype-2.10.4 | h4cff582_1 890 KB conda-forge
jpeg-9d | hbcb3906_0 250 KB conda-forge
kiwisolver-1.3.1 | py38hd9c93a9_1 57 KB conda-forge
lcms2-2.12 | h577c468_0 404 KB conda-forge
libpng-1.6.37 | h7cec526_2 313 KB conda-forge
libtiff-4.2.0 | h7c11950_1 623 KB conda-forge
libwebp-base-1.2.0 | h0d85af4_2 700 KB conda-forge
lz4-c-1.9.3 | h046ec9c_0 155 KB conda-forge
matplotlib-3.4.2 | py38h50d1736_0 7 KB conda-forge
matplotlib-base-3.4.2 | py38h6152e83_0 7.3 MB conda-forge
olefile-0.46 | pyh9f0ad1d_1 32 KB conda-forge
openjpeg-2.4.0 | h6cbf5cd_0 446 KB conda-forge
pillow-8.1.2 | py38h83525de_1 657 KB conda-forge
pyparsing-2.4.7 | pyh9f0ad1d_0 60 KB conda-forge
python-dateutil-2.8.1 | py_0 220 KB conda-forge
six-1.16.0 | pyh6c4a22f_0 14 KB conda-forge
tornado-6.1 | py38h5406a74_1 643 KB conda-forge
zstd-1.4.9 | h582d3a0_0 460 KB conda-forge
------------------------------------------------------------
Total: 13.1 MB
The following NEW packages will be INSTALLED:
cycler conda-forge/noarch::cycler-0.10.0-py_2
docopt conda-forge/noarch::docopt-0.6.2-py_1
freetype conda-forge/osx-64::freetype-2.10.4-h4cff582_1
jpeg conda-forge/osx-64::jpeg-9d-hbcb3906_0
kiwisolver conda-forge/osx-64::kiwisolver-1.3.1-py38hd9c93a9_1
lcms2 conda-forge/osx-64::lcms2-2.12-h577c468_0
libpng conda-forge/osx-64::libpng-1.6.37-h7cec526_2
libtiff conda-forge/osx-64::libtiff-4.2.0-h7c11950_1
libwebp-base conda-forge/osx-64::libwebp-base-1.2.0-h0d85af4_2
lz4-c conda-forge/osx-64::lz4-c-1.9.3-h046ec9c_0
matplotlib conda-forge/osx-64::matplotlib-3.4.2-py38h50d1736_0
matplotlib-base conda-forge/osx-64::matplotlib-base-3.4.2-py38h6152e83_0
olefile conda-forge/noarch::olefile-0.46-pyh9f0ad1d_1
openjpeg conda-forge/osx-64::openjpeg-2.4.0-h6cbf5cd_0
pillow conda-forge/osx-64::pillow-8.1.2-py38h83525de_1
pyparsing conda-forge/noarch::pyparsing-2.4.7-pyh9f0ad1d_0
python-dateutil conda-forge/noarch::python-dateutil-2.8.1-py_0
six conda-forge/noarch::six-1.16.0-pyh6c4a22f_0
tornado conda-forge/osx-64::tornado-6.1-py38h5406a74_1
zstd conda-forge/osx-64::zstd-1.4.9-h582d3a0_0
Preparing transaction: ...working... done
Verifying transaction: ...working... done
Executing transaction: ...working... done
Installing dedalus with pip
Collecting dedalus
Downloading dedalus-2.2006.tar.gz (123 kB)
|████████████████████████████████| 123 kB 3.3 MB/s
Preparing wheel metadata ... done
Collecting pytest
Downloading pytest-6.2.4-py3-none-any.whl (280 kB)
|████████████████████████████████| 280 kB 4.2 MB/s
Requirement already satisfied: numpy in /usr/local/Caskroom/miniconda/base/envs/dedalus/lib/python3.8/site-packages (from dedalus) (1.20.2)
Requirement already satisfied: mpi4py>=2.0.0 in /usr/local/Caskroom/miniconda/base/envs/dedalus/lib/python3.8/site-packages (from dedalus) (3.0.3)
Requirement already satisfied: h5py>=2.10.0 in /usr/local/Caskroom/miniconda/base/envs/dedalus/lib/python3.8/site-packages (from dedalus) (3.2.1)
Collecting pytest-cov
Downloading pytest_cov-2.11.1-py2.py3-none-any.whl (20 kB)
Requirement already satisfied: matplotlib in /usr/local/Caskroom/miniconda/base/envs/dedalus/lib/python3.8/site-packages (from dedalus) (3.4.2)
Collecting pytest-benchmark
Downloading pytest_benchmark-3.4.1-py2.py3-none-any.whl (50 kB)
|████████████████████████████████| 50 kB 5.0 MB/s
Requirement already satisfied: docopt in /usr/local/Caskroom/miniconda/base/envs/dedalus/lib/python3.8/site-packages (from dedalus) (0.6.2)
Requirement already satisfied: scipy>=0.13.0 in /usr/local/Caskroom/miniconda/base/envs/dedalus/lib/python3.8/site-packages (from dedalus) (1.6.3)
Requirement already satisfied: python-dateutil>=2.7 in /usr/local/Caskroom/miniconda/base/envs/dedalus/lib/python3.8/site-packages (from matplotlib->dedalus) (2.8.1)
Requirement already satisfied: cycler>=0.10 in /usr/local/Caskroom/miniconda/base/envs/dedalus/lib/python3.8/site-packages (from matplotlib->dedalus) (0.10.0)
Requirement already satisfied: pyparsing>=2.2.1 in /usr/local/Caskroom/miniconda/base/envs/dedalus/lib/python3.8/site-packages (from matplotlib->dedalus) (2.4.7)
Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/Caskroom/miniconda/base/envs/dedalus/lib/python3.8/site-packages (from matplotlib->dedalus) (1.3.1)
Requirement already satisfied: pillow>=6.2.0 in /usr/local/Caskroom/miniconda/base/envs/dedalus/lib/python3.8/site-packages (from matplotlib->dedalus) (8.1.2)
Requirement already satisfied: six in /usr/local/Caskroom/miniconda/base/envs/dedalus/lib/python3.8/site-packages (from cycler>=0.10->matplotlib->dedalus) (1.16.0)
Collecting pluggy<1.0.0a1,>=0.12
Downloading pluggy-0.13.1-py2.py3-none-any.whl (18 kB)
Collecting attrs>=19.2.0
Downloading attrs-21.2.0-py2.py3-none-any.whl (53 kB)
|████████████████████████████████| 53 kB 12.4 MB/s
Collecting packaging
Downloading packaging-20.9-py2.py3-none-any.whl (40 kB)
|████████████████████████████████| 40 kB 10.0 MB/s
Collecting toml
Downloading toml-0.10.2-py2.py3-none-any.whl (16 kB)
Collecting iniconfig
Downloading iniconfig-1.1.1-py2.py3-none-any.whl (5.0 kB)
Collecting py>=1.8.2
Downloading py-1.10.0-py2.py3-none-any.whl (97 kB)
|████████████████████████████████| 97 kB 10.8 MB/s
Collecting py-cpuinfo
Downloading py-cpuinfo-8.0.0.tar.gz (99 kB)
|████████████████████████████████| 99 kB 9.3 MB/s
Collecting coverage>=5.2.1
Downloading coverage-5.5-cp38-cp38-macosx_10_9_x86_64.whl (207 kB)
|████████████████████████████████| 207 kB 12.9 MB/s
Building wheels for collected packages: dedalus, py-cpuinfo
Building wheel for dedalus (PEP 517) ... done
Created wheel for dedalus: filename=dedalus-2.2006-cp38-cp38-macosx_10_9_x86_64.whl size=406087 sha256=17a3ab444f2ad8b7897377b9f326bc1ac9b14a130e6cde02da5d33d701773f7f
Stored in directory: /private/var/folders/4d/hcl8czhx38nfdd_h2gm56v700000gn/T/pip-ephem-wheel-cache-clo4rx5m/wheels/2a/41/99/145eb206ab25b66ae61a36c3007b3adfb595349e057aa9dce8
Building wheel for py-cpuinfo (setup.py) ... done
Created wheel for py-cpuinfo: filename=py_cpuinfo-8.0.0-py3-none-any.whl size=22245 sha256=a0fdeb5e6865eede3578e7ce2091075e49a6bbcf2d8d9f44ffff01c66f0ceb3b
Stored in directory: /private/var/folders/4d/hcl8czhx38nfdd_h2gm56v700000gn/T/pip-ephem-wheel-cache-clo4rx5m/wheels/57/cb/6d/bab2257f26c5be4a96ff65c3d2a7122c96529b73773ee37f36
Successfully built dedalus py-cpuinfo
Installing collected packages: toml, py, pluggy, packaging, iniconfig, attrs, pytest, py-cpuinfo, coverage, pytest-cov, pytest-benchmark, dedalus
Successfully installed attrs-21.2.0 coverage-5.5 dedalus-2.2006 iniconfig-1.1.1 packaging-20.9 pluggy-0.13.1 py-1.10.0 py-cpuinfo-8.0.0 pytest-6.2.4 pytest-benchmark-3.4.1 pytest-cov-2.11.1 toml-0.10.2
Installation complete in conda environment 'dedalus'
(base) Davids-MacBook-Pro-4:~ dpsanders$ conda activate dedalus
(dedalus) Davids-MacBook-Pro-4:~ dpsanders$ python3 -m dedalus test
============================= test session starts ==============================
platform darwin -- Python 3.8.8, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
benchmark: 3.4.1 (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: /usr/local/Caskroom/miniconda/base/envs/dedalus/lib/python3.8/site-packages/dedalus/tests
plugins: benchmark-3.4.1, cov-2.11.1
collected 201 items
../../usr/local/Caskroom/miniconda/base/envs/dedalus/lib/python3.8/site-packages/dedalus/tests/test_bvp.py . [ 0%]
...............................FF.......................... [ 29%]
../../usr/local/Caskroom/miniconda/base/envs/dedalus/lib/python3.8/site-packages/dedalus/tests/test_evp.py . [ 30%]
......F.... [ 35%]
../../usr/local/Caskroom/miniconda/base/envs/dedalus/lib/python3.8/site-packages/dedalus/tests/test_ivp.py . [ 36%]
............................................... [ 59%]
../../usr/local/Caskroom/miniconda/base/envs/dedalus/lib/python3.8/site-packages/dedalus/tests/test_matsolvers.py s [ 60%]
..s...ss...s..s...ss...s..s...ss..xs..s...ss...s..s...ss...s..s...ss..x [ 95%]
../../usr/local/Caskroom/miniconda/base/envs/dedalus/lib/python3.8/site-packages/dedalus/tests/test_nlbvp.py . [ 96%]
....... [ 99%]
../../usr/local/Caskroom/miniconda/base/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()
/usr/local/Caskroom/miniconda/base/envs/dedalus/lib/python3.8/site-packages/dedalus/tests/test_bvp.py:180:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/local/Caskroom/miniconda/base/envs/dedalus/lib/python3.8/site-packages/dedalus/core/problems.py:313: in build_solver
return self.solver_class(self, *args, **kw)
/usr/local/Caskroom/miniconda/base/envs/dedalus/lib/python3.8/site-packages/dedalus/core/solvers.py:191: in __init__
pencil.build_matrices(self.pencils, problem, ['L'])
/usr/local/Caskroom/miniconda/base/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)
/usr/local/Caskroom/miniconda/base/envs/dedalus/lib/python3.8/site-packages/dedalus/core/operators.py:440: in operator_dict
op1 = self.args[1].operator_dict(index, vars, **kw)
/usr/local/Caskroom/miniconda/base/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)
/usr/local/Caskroom/miniconda/base/envs/dedalus/lib/python3.8/site-packages/dedalus/tools/cache.py:71: in __call__
self.cache[call] = result = self.function(*args, **kw)
/usr/local/Caskroom/miniconda/base/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)
/usr/local/Caskroom/miniconda/base/envs/dedalus/lib/python3.8/site-packages/dedalus/tools/cache.py:71: in __call__
self.cache[call] = result = self.function(*args, **kw)
/usr/local/Caskroom/miniconda/base/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)
/usr/local/Caskroom/miniconda/base/envs/dedalus/lib/python3.8/site-packages/dedalus/tools/cache.py:71: in __call__
self.cache[call] = result = self.function(*args, **kw)
/usr/local/Caskroom/miniconda/base/envs/dedalus/lib/python3.8/site-packages/dedalus/core/field.py:556: in as_ncc_operator
self.require_coeff_space()
/usr/local/Caskroom/miniconda/base/envs/dedalus/lib/python3.8/site-packages/dedalus/core/field.py:440: in require_coeff_space
self.towards_coeff_space()
/usr/local/Caskroom/miniconda/base/envs/dedalus/lib/python3.8/site-packages/dedalus/core/field.py:423: in towards_coeff_space
self.domain.dist.paths[index-1].decrement([self])
/usr/local/Caskroom/miniconda/base/envs/dedalus/lib/python3.8/site-packages/dedalus/core/distributor.py:372: in decrement
self.decrement_single(*fields)
/usr/local/Caskroom/miniconda/base/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])
/usr/local/Caskroom/miniconda/base/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'])
/usr/local/Caskroom/miniconda/base/envs/dedalus/lib/python3.8/site-packages/dedalus/tools/cache.py:71: in __call__
self.cache[call] = result = self.function(*args, **kw)
/usr/local/Caskroom/miniconda/base/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
/usr/local/Caskroom/miniconda/base/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()
/usr/local/Caskroom/miniconda/base/envs/dedalus/lib/python3.8/site-packages/dedalus/tests/test_bvp.py:180:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/local/Caskroom/miniconda/base/envs/dedalus/lib/python3.8/site-packages/dedalus/core/problems.py:313: in build_solver
return self.solver_class(self, *args, **kw)
/usr/local/Caskroom/miniconda/base/envs/dedalus/lib/python3.8/site-packages/dedalus/core/solvers.py:191: in __init__
pencil.build_matrices(self.pencils, problem, ['L'])
/usr/local/Caskroom/miniconda/base/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)
/usr/local/Caskroom/miniconda/base/envs/dedalus/lib/python3.8/site-packages/dedalus/core/operators.py:440: in operator_dict
op1 = self.args[1].operator_dict(index, vars, **kw)
/usr/local/Caskroom/miniconda/base/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)
/usr/local/Caskroom/miniconda/base/envs/dedalus/lib/python3.8/site-packages/dedalus/tools/cache.py:71: in __call__
self.cache[call] = result = self.function(*args, **kw)
/usr/local/Caskroom/miniconda/base/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)
/usr/local/Caskroom/miniconda/base/envs/dedalus/lib/python3.8/site-packages/dedalus/tools/cache.py:71: in __call__
self.cache[call] = result = self.function(*args, **kw)
/usr/local/Caskroom/miniconda/base/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)
/usr/local/Caskroom/miniconda/base/envs/dedalus/lib/python3.8/site-packages/dedalus/tools/cache.py:71: in __call__
self.cache[call] = result = self.function(*args, **kw)
/usr/local/Caskroom/miniconda/base/envs/dedalus/lib/python3.8/site-packages/dedalus/core/field.py:556: in as_ncc_operator
self.require_coeff_space()
/usr/local/Caskroom/miniconda/base/envs/dedalus/lib/python3.8/site-packages/dedalus/core/field.py:440: in require_coeff_space
self.towards_coeff_space()
/usr/local/Caskroom/miniconda/base/envs/dedalus/lib/python3.8/site-packages/dedalus/core/field.py:423: in towards_coeff_space
self.domain.dist.paths[index-1].decrement([self])
/usr/local/Caskroom/miniconda/base/envs/dedalus/lib/python3.8/site-packages/dedalus/core/distributor.py:372: in decrement
self.decrement_single(*fields)
/usr/local/Caskroom/miniconda/base/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])
/usr/local/Caskroom/miniconda/base/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'])
/usr/local/Caskroom/miniconda/base/envs/dedalus/lib/python3.8/site-packages/dedalus/tools/cache.py:71: in __call__
self.cache[call] = result = self.function(*args, **kw)
/usr/local/Caskroom/miniconda/base/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
/usr/local/Caskroom/miniconda/base/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])
/usr/local/Caskroom/miniconda/base/envs/dedalus/lib/python3.8/site-packages/dedalus/tests/test_evp.py:128:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/local/Caskroom/miniconda/base/envs/dedalus/lib/python3.8/site-packages/dedalus/core/solvers.py:95: in solve_dense
pencil.build_matrices(self.problem, ['M', 'L'], cacheid=cacheid)
/usr/local/Caskroom/miniconda/base/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)
/usr/local/Caskroom/miniconda/base/envs/dedalus/lib/python3.8/site-packages/dedalus/core/operators.py:440: in operator_dict
op1 = self.args[1].operator_dict(index, vars, **kw)
/usr/local/Caskroom/miniconda/base/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)
/usr/local/Caskroom/miniconda/base/envs/dedalus/lib/python3.8/site-packages/dedalus/tools/cache.py:71: in __call__
self.cache[call] = result = self.function(*args, **kw)
/usr/local/Caskroom/miniconda/base/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)
/usr/local/Caskroom/miniconda/base/envs/dedalus/lib/python3.8/site-packages/dedalus/tools/cache.py:71: in __call__
self.cache[call] = result = self.function(*args, **kw)
/usr/local/Caskroom/miniconda/base/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)
/usr/local/Caskroom/miniconda/base/envs/dedalus/lib/python3.8/site-packages/dedalus/tools/cache.py:71: in __call__
self.cache[call] = result = self.function(*args, **kw)
/usr/local/Caskroom/miniconda/base/envs/dedalus/lib/python3.8/site-packages/dedalus/core/field.py:556: in as_ncc_operator
self.require_coeff_space()
/usr/local/Caskroom/miniconda/base/envs/dedalus/lib/python3.8/site-packages/dedalus/core/field.py:440: in require_coeff_space
self.towards_coeff_space()
/usr/local/Caskroom/miniconda/base/envs/dedalus/lib/python3.8/site-packages/dedalus/core/field.py:423: in towards_coeff_space
self.domain.dist.paths[index-1].decrement([self])
/usr/local/Caskroom/miniconda/base/envs/dedalus/lib/python3.8/site-packages/dedalus/core/distributor.py:372: in decrement
self.decrement_single(*fields)
/usr/local/Caskroom/miniconda/base/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])
/usr/local/Caskroom/miniconda/base/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'])
/usr/local/Caskroom/miniconda/base/envs/dedalus/lib/python3.8/site-packages/dedalus/tools/cache.py:71: in __call__
self.cache[call] = result = self.function(*args, **kw)
/usr/local/Caskroom/miniconda/base/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
/usr/local/Caskroom/miniconda/base/envs/dedalus/lib/python3.8/site-packages/scipy/special/_basic.py:2352: TypeError
----------------------------- Captured stdout call -----------------------------
2021-05-09 21:46:33,367 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)
=============================== warnings summary ===============================
test_output.py::test_1d_output[Chebyshev-32-RK222-float64]
/usr/local/Caskroom/miniconda/base/envs/dedalus/lib/python3.8/site-packages/dedalus/core/evaluator.py:496: DeprecationWarning: `np.int` is a deprecated alias for the builtin `int`. To silence this warning, use `int` by itself. Doing this will not modify any behavior and is safe. When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
('iteration', np.int),
test_output.py::test_1d_output[Chebyshev-32-RK222-float64]
/usr/local/Caskroom/miniconda/base/envs/dedalus/lib/python3.8/site-packages/dedalus/core/evaluator.py:497: DeprecationWarning: `np.int` is a deprecated alias for the builtin `int`. To silence this warning, use `int` by itself. Doing this will not modify any behavior and is safe. When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
('write_number', np.int)]:
-- Docs: https://docs.pytest.org/en/stable/warnings.html
=========================== short test summary info ============================
FAILED ../../usr/local/Caskroom/miniconda/base/envs/dedalus/lib/python3.8/site-packages/dedalus/tests/test_bvp.py::test_gaussian_free[Hermite-128-float64]
FAILED ../../usr/local/Caskroom/miniconda/base/envs/dedalus/lib/python3.8/site-packages/dedalus/tests/test_bvp.py::test_gaussian_free[Hermite-128-complex128]
FAILED ../../usr/local/Caskroom/miniconda/base/envs/dedalus/lib/python3.8/site-packages/dedalus/tests/test_evp.py::test_qho_dense_evp[Hermite-128-complex128]
====== 3 failed, 172 passed, 24 skipped, 2 xfailed, 2 warnings in 11.68s =======
(dedalus) Davids-MacBook-Pro-4:~ dpsanders$
(dedalus) Davids-MacBook-Pro-4:~ dpsanders$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment