In [1]:
Copied!
import os
os.environ["SPARSE_BACKEND"] = "Finch"
import sparse
import numpy as np
import os
os.environ["SPARSE_BACKEND"] = "Finch"
import sparse
import numpy as np
/home/docs/checkouts/readthedocs.org/user_builds/sparse-nd/checkouts/latest/sparse/__init__.py:24: SparseFutureWarning: Changing back-ends is a development feature, please do not rely on it in production. warnings.warn(
[juliapkg] Found dependencies: /home/docs/checkouts/readthedocs.org/user_builds/sparse-nd/envs/latest/lib/python3.12/site-packages/juliacall/juliapkg.json [juliapkg] Found dependencies: /home/docs/checkouts/readthedocs.org/user_builds/sparse-nd/envs/latest/lib/python3.12/site-packages/juliapkg/juliapkg.json [juliapkg] Found dependencies: /home/docs/checkouts/readthedocs.org/user_builds/sparse-nd/envs/latest/lib/python3.12/site-packages/finch/juliapkg.json [juliapkg] Locating Julia 1.10.3 - 1.11 [juliapkg] Querying Julia versions from https://julialang-s3.julialang.org/bin/versions.json [juliapkg] WARNING: About to install Julia 1.11.9 to /home/docs/checkouts/readthedocs.org/user_builds/sparse-nd/envs/latest/julia_env/pyjuliapkg/install. [juliapkg] If you use juliapkg in more than one environment, you are likely to [juliapkg] have Julia installed in multiple locations. It is recommended to [juliapkg] install JuliaUp (https://github.com/JuliaLang/juliaup) or Julia [juliapkg] (https://julialang.org/downloads) yourself. [juliapkg] Downloading Julia from https://julialang-s3.julialang.org/bin/linux/x64/1.11/julia-1.11.9-linux-x86_64.tar.gz
download complete [juliapkg] Verifying download [juliapkg] Installing Julia 1.11.9 to /home/docs/checkouts/readthedocs.org/user_builds/sparse-nd/envs/latest/julia_env/pyjuliapkg/install
[juliapkg] Using Julia 1.11.9 at /home/docs/checkouts/readthedocs.org/user_builds/sparse-nd/envs/latest/julia_env/pyjuliapkg/install/bin/julia
[juliapkg] Finding libjulia:
| using Libdl
| print(abspath(Libdl.dlpath("libjulia")))
[juliapkg] Using Julia project at /home/docs/checkouts/readthedocs.org/user_builds/sparse-nd/envs/latest/julia_env
[juliapkg] Writing Project.toml:
| [deps]
| PythonCall = "6099a3de-0909-46bc-b1f4-468b9a2dfc0d"
| OpenSSL_jll = "458c3c95-2e84-50aa-8efc-19380b2a3a95"
| Finch = "9177782c-1635-4eb9-9bfb-d9dfa25e6bce"
| HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f"
| NPZ = "15e1cf62-19b3-5cfa-8e77-841668bca605"
| TensorMarket = "8b7d4fe7-0b45-4d0d-9dd8-5cc9b23b4b77"
|
| [compat]
| PythonCall = "=0.9.35"
| OpenSSL_jll = "~3.0"
| Finch = "^1.2.10"
| HDF5 = "^0.17.2"
| NPZ = "^0.4.3"
| TensorMarket = "^0.2"
[juliapkg] Installing packages:
| import Pkg
| Pkg.Registry.update()
| Pkg.add([
| Pkg.PackageSpec(name="PythonCall", uuid="6099a3de-0909-46bc-b1f4-468b9a2dfc0d"),
| Pkg.PackageSpec(name="OpenSSL_jll", uuid="458c3c95-2e84-50aa-8efc-19380b2a3a95"),
| Pkg.PackageSpec(name="Finch", uuid="9177782c-1635-4eb9-9bfb-d9dfa25e6bce"),
| Pkg.PackageSpec(name="HDF5", uuid="f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f"),
| Pkg.PackageSpec(name="NPZ", uuid="15e1cf62-19b3-5cfa-8e77-841668bca605"),
| Pkg.PackageSpec(name="TensorMarket", uuid="8b7d4fe7-0b45-4d0d-9dd8-5cc9b23b4b77"),
| ])
| Pkg.resolve()
| Pkg.precompile()
Installing known registries into `~/.julia`
Added `General` registry to ~/.julia/registries
Updating registry at `~/.julia/registries/General.toml` Resolving package versions...
Installed GPUArraysCore ─────────────── v0.2.0 Installed libaec_jll ────────────────── v1.1.7+0 Installed Scratch ───────────────────── v1.3.0 Installed MPIABI_jll ────────────────── v0.1.5+0 Installed MPICH_jll ─────────────────── v5.0.1+0 Installed MicroMamba ────────────────── v0.1.15 Installed IrrationalConstants ───────── v0.2.6 Installed AutoHashEquals ────────────── v2.2.0 Installed Adapt ─────────────────────── v4.7.0 Installed HypergeometricFunctions ───── v0.3.29 Installed PythonCall ────────────────── v0.9.35 Installed aws_c_common_jll ──────────── v0.12.6+0 Installed JSON ──────────────────────── v1.6.1 Installed StatsFuns ─────────────────── v2.2.0
Installed Rmath ─────────────────────── v0.9.0 Installed aws_c_auth_jll ────────────── v0.9.6+0 Installed XML2_jll ──────────────────── v2.13.9+0 Installed dlfcn_win32_jll ───────────── v1.4.2+0 Installed Xorg_libpciaccess_jll ─────── v0.19.0+0 Installed Accessors ─────────────────── v0.1.45 Installed NPZ ───────────────────────── v0.4.3 Installed IterTools ─────────────────── v1.10.0 Installed aws_c_compression_jll ─────── v0.3.2+0 Installed TableTraits ───────────────── v1.0.1 Installed Hwloc_jll ─────────────────── v2.14.0+0 Installed ArgCheck ──────────────────── v2.5.0 Installed Preferences ───────────────── v1.5.2 Installed Parsers ───────────────────── v2.8.6 Installed SpecialFunctions ──────────── v2.8.0 Installed Tables ────────────────────── v1.13.0 Installed PDMats ────────────────────── v0.11.40 Installed DataAPI ───────────────────── v1.16.0
Installed MicrosoftMPI_jll ──────────── v10.1.4+3 Installed SyntaxInterface ───────────── v0.2.1 Installed ZipFile ───────────────────── v0.10.1 Installed OpenSSL_jll ───────────────── v3.0.20+0 Installed Pidfile ───────────────────── v1.3.0 Installed PtrArrays ─────────────────── v1.4.0 Installed micromamba_jll ────────────── v2.3.1+0 Installed aws_c_http_jll ────────────── v0.10.13+0 Installed Roots ─────────────────────── v3.0.4
Installed OpenMPI_jll ───────────────── v5.0.11+0 Installed StaticArrays ──────────────── v1.9.18 Installed JLLWrappers ───────────────── v1.8.0 Installed aws_c_io_jll ──────────────── v0.26.3+0 Installed AcceleratedKernels ────────── v0.4.3 Installed PrecompileTools ───────────── v1.2.1 Installed IteratorInterfaceExtensions ─ v1.0.0 Installed StaticArraysCore ──────────── v1.4.4 Installed Libiconv_jll ──────────────── v1.18.0+0 Installed ConstructionBase ──────────── v1.6.0 Installed DataValueInterfaces ───────── v1.0.0
Installed AbstractTrees ─────────────── v0.4.5 Installed OrderedCollections ────────── v1.8.2 Installed RewriteTools ──────────────── v0.2.4 Installed aws_checksums_jll ─────────── v0.2.10+0 Installed FillArrays ────────────────── v1.16.0 Installed Finch ─────────────────────── v1.3.0
Installed Reexport ──────────────────── v1.2.2 Installed QuadGK ────────────────────── v2.11.3 Installed TensorMarket ──────────────── v0.2.2 Installed FileIO ────────────────────── v1.19.0 Installed Rmath_jll ─────────────────── v0.5.1+0 Installed Statistics ────────────────── v1.11.1 Installed MPIPreferences ────────────── v0.1.12 Installed DataStructures ────────────── v0.19.5 Installed mpif_jll ──────────────────── v0.1.7+0 Installed LogExpFunctions ───────────── v1.0.1 Installed HDF5 ──────────────────────── v0.17.3
Installed aws_c_sdkutils_jll ────────── v0.2.4+1 Installed MPItrampoline_jll ─────────── v5.5.6+0 Installed Gamma ─────────────────────── v1.1.0 Installed AliasTables ───────────────── v1.1.3 Installed KernelAbstractions ────────── v0.9.42 Installed Distributions ─────────────── v0.25.129 Installed StatsAPI ──────────────────── v1.8.0 Installed CompositionsBase ──────────── v0.1.2 Installed UnsafePointers ────────────── v1.0.0 Installed OpenSpecFun_jll ───────────── v0.5.6+0 Installed MacroTools ────────────────── v0.5.16 Installed InverseFunctions ──────────── v0.1.17 Installed CommonSolve ───────────────── v0.2.11 Installed CondaPkg ──────────────────── v0.2.36 Installed SortingAlgorithms ─────────── v1.2.3
Installed aws_c_cal_jll ─────────────── v0.9.13+0 Installed Missings ──────────────────── v1.2.0 Installed StatsBase ─────────────────── v0.34.12 Installed Requires ──────────────────── v1.3.1 Installed aws_c_s3_jll ──────────────── v0.11.5+0 Installed UnsafeAtomics ─────────────── v0.3.1 Installed DocStringExtensions ───────── v0.9.5 Installed pixi_jll ──────────────────── v0.63.2+0 Installed Compat ────────────────────── v4.18.1 Installed StructUtils ───────────────── v2.8.2 Installed Atomix ────────────────────── v1.1.3
Installed s2n_tls_jll ───────────────── v1.7.3+0 Installed HDF5_jll ──────────────────── v2.1.2+0
Updating `~/checkouts/readthedocs.org/user_builds/sparse-nd/envs/latest/julia_env/Project.toml`
[9177782c] + Finch v1.3.0
[f67ccb44] + HDF5 v0.17.3
[15e1cf62] + NPZ v0.4.3
[6099a3de] + PythonCall v0.9.35
[8b7d4fe7] + TensorMarket v0.2.2
⌅ [458c3c95] + OpenSSL_jll v3.0.20+0
Updating `~/checkouts/readthedocs.org/user_builds/sparse-nd/envs/latest/julia_env/Manifest.toml`
[1520ce14] + AbstractTrees v0.4.5
[6a4ca0a5] + AcceleratedKernels v0.4.3
[7d9f7c33] + Accessors v0.1.45
[79e6a3ab] + Adapt v4.7.0
[66dad0bd] + AliasTables v1.1.3
[dce04be8] + ArgCheck v2.5.0
[a9b6321e] + Atomix v1.1.3
[15f4f7f2] + AutoHashEquals v2.2.0
[38540f10] + CommonSolve v0.2.11
[34da2185] + Compat v4.18.1
[a33af91c] + CompositionsBase v0.1.2
[992eb4ea] + CondaPkg v0.2.36
[187b0558] + ConstructionBase v1.6.0
[9a962f9c] + DataAPI v1.16.0
[864edb3b] + DataStructures v0.19.5
[e2d170a0] + DataValueInterfaces v1.0.0
[31c24e10] + Distributions v0.25.129
[ffbed154] + DocStringExtensions v0.9.5
[5789e2e9] + FileIO v1.19.0
[1a297f60] + FillArrays v1.16.0
[9177782c] + Finch v1.3.0
[46192b85] + GPUArraysCore v0.2.0
[a0844989] + Gamma v1.1.0
[f67ccb44] + HDF5 v0.17.3
[34004b35] + HypergeometricFunctions v0.3.29
[3587e190] + InverseFunctions v0.1.17
[92d709cd] + IrrationalConstants v0.2.6
[c8e1da08] + IterTools v1.10.0
[82899510] + IteratorInterfaceExtensions v1.0.0
[692b3bcd] + JLLWrappers v1.8.0
[682c06a0] + JSON v1.6.1
[63c18a36] + KernelAbstractions v0.9.42
[2ab3a3ac] + LogExpFunctions v1.0.1
[3da0fdf6] + MPIPreferences v0.1.12
[1914dd2f] + MacroTools v0.5.16
[0b3b1443] + MicroMamba v0.1.15
[e1d29d7a] + Missings v1.2.0
[15e1cf62] + NPZ v0.4.3
⌅ [bac558e1] + OrderedCollections v1.8.2
[90014a1f] + PDMats v0.11.40
[69de0a69] + Parsers v2.8.6
[fa939f87] + Pidfile v1.3.0
⌅ [aea7be01] + PrecompileTools v1.2.1
[21216c6a] + Preferences v1.5.2
[43287f4e] + PtrArrays v1.4.0
[6099a3de] + PythonCall v0.9.35
[1fd47b50] + QuadGK v2.11.3
[189a3867] + Reexport v1.2.2
[ae029012] + Requires v1.3.1
[5969e224] + RewriteTools v0.2.4
[79098fc4] + Rmath v0.9.0
[f2b01f46] + Roots v3.0.4
[6c6a2e73] + Scratch v1.3.0
[a2af1166] + SortingAlgorithms v1.2.3
[276daf66] + SpecialFunctions v2.8.0
[90137ffa] + StaticArrays v1.9.18
[1e83bf80] + StaticArraysCore v1.4.4
[10745b16] + Statistics v1.11.1
[82ae8749] + StatsAPI v1.8.0
[2913bbd2] + StatsBase v0.34.12
[4c63d2b9] + StatsFuns v2.2.0
[ec057cc2] + StructUtils v2.8.2
[b33eeca9] + SyntaxInterface v0.2.1
[3783bdb8] + TableTraits v1.0.1
[bd369af6] + Tables v1.13.0
[8b7d4fe7] + TensorMarket v0.2.2
[013be700] + UnsafeAtomics v0.3.1
[e17b2a0c] + UnsafePointers v1.0.0
[a5390f91] + ZipFile v0.10.1
[0234f1f7] + HDF5_jll v2.1.2+0
[e33a78d0] + Hwloc_jll v2.14.0+0
[94ce4f54] + Libiconv_jll v1.18.0+0
[b5ada748] + MPIABI_jll v0.1.5+0
[7cb0a576] + MPICH_jll v5.0.1+0
[f1f71cc9] + MPItrampoline_jll v5.5.6+0
[9237b28f] + MicrosoftMPI_jll v10.1.4+3
[fe0851c0] + OpenMPI_jll v5.0.11+0
⌅ [458c3c95] + OpenSSL_jll v3.0.20+0
[efe28fd5] + OpenSpecFun_jll v0.5.6+0
[f50d1b31] + Rmath_jll v0.5.1+0
⌅ [02c8fc9c] + XML2_jll v2.13.9+0
[a65dc6b1] + Xorg_libpciaccess_jll v0.19.0+0
⌅ [2b3700d1] + aws_c_auth_jll v0.9.6+0
[70f11efc] + aws_c_cal_jll v0.9.13+0
[73048d1d] + aws_c_common_jll v0.12.6+0
[73a04cd5] + aws_c_compression_jll v0.3.2+0
[3254fc65] + aws_c_http_jll v0.10.13+0
[13c41daa] + aws_c_io_jll v0.26.3+0
⌅ [bd1f34fb] + aws_c_s3_jll v0.11.5+0
[1282aa60] + aws_c_sdkutils_jll v0.2.4+1
[b2a88e68] + aws_checksums_jll v0.2.10+0
[c4b69c83] + dlfcn_win32_jll v1.4.2+0
[477f73a3] + libaec_jll v1.1.7+0
[f8abcde7] + micromamba_jll v2.3.1+0
[9aeb927a] + mpif_jll v0.1.7+0
[4d7b5844] + pixi_jll v0.63.2+0
[cddc5d3d] + s2n_tls_jll v1.7.3+0
[0dad84c5] + ArgTools v1.1.2
[56f22d72] + Artifacts v1.11.0
[2a0f44e3] + Base64 v1.11.0
[ade2ca70] + Dates v1.11.0
[f43a241f] + Downloads v1.6.0
[7b1f6079] + FileWatching v1.11.0
[b77e0a4c] + InteractiveUtils v1.11.0
[4af54fe1] + LazyArtifacts v1.11.0
[b27032c2] + LibCURL v0.6.4
[76f85450] + LibGit2 v1.11.0
[8f399da3] + Libdl v1.11.0
[37e2e46d] + LinearAlgebra v1.11.0
[56ddb016] + Logging v1.11.0
[d6f4376e] + Markdown v1.11.0
[a63ad114] + Mmap v1.11.0
[ca575930] + NetworkOptions v1.2.0
[44cfe95a] + Pkg v1.11.0
[de0858da] + Printf v1.11.0
[9a3f8284] + Random v1.11.0
[ea8e919c] + SHA v0.7.0
[9e88b42a] + Serialization v1.11.0
[2f01184e] + SparseArrays v1.11.0
[4607b0f0] + SuiteSparse
[fa267f1f] + TOML v1.0.3
[a4e569a6] + Tar v1.10.0
[8dfed614] + Test v1.11.0
[cf7118a7] + UUIDs v1.11.0
[4ec0a83e] + Unicode v1.11.0
[e66e0078] + CompilerSupportLibraries_jll v1.1.1+0
[deac9b47] + LibCURL_jll v8.6.0+0
[e37daf67] + LibGit2_jll v1.7.2+0
[29816b5a] + LibSSH2_jll v1.11.0+1
[c8ffd9c3] + MbedTLS_jll v2.28.6+0
[14a3606d] + MozillaCACerts_jll v2023.12.12
[4536629a] + OpenBLAS_jll v0.3.27+1
[05823500] + OpenLibm_jll v0.8.5+0
[bea87d4a] + SuiteSparse_jll v7.7.0+0
[83775a58] + Zlib_jll v1.2.13+1
[8e850b90] + libblastrampoline_jll v5.11.0+0
[8e850ede] + nghttp2_jll v1.59.0+0
[3f19e933] + p7zip_jll v17.4.0+2
Info Packages marked with ⌅ have new versions available but compatibility constraints restrict them from upgrading. To see why use `status --outdated -m`
Precompiling project...
595.0 ms ✓ TensorMarket
803.2 ms ✓ AutoHashEquals
1152.2 ms ✓ OrderedCollections
446.6 ms ✓ DataValueInterfaces
694.4 ms ✓ InverseFunctions
646.8 ms ✓ Reexport
1688.8 ms ✓ FillArrays
760.5 ms ✓ Statistics
1051.9 ms ✓ AbstractTrees
1265.1 ms ✓ DocStringExtensions
617.7 ms ✓ UnsafePointers
656.4 ms ✓ ConstructionBase
737.4 ms ✓ CommonSolve
2058.8 ms ✓ IrrationalConstants
627.5 ms ✓ Adapt
684.3 ms ✓ IteratorInterfaceExtensions
569.8 ms ✓ DataAPI
598.5 ms ✓ ArgCheck
652.9 ms ✓ StatsAPI
490.3 ms ✓ CompositionsBase 1117.5 ms ✓ IterTools
635.8 ms ✓ SyntaxInterface
3779.6 ms ✓ UnsafeAtomics
1492.9 ms ✓ Gamma
682.0 ms ✓ PtrArrays
585.0 ms ✓ StaticArraysCore
865.3 ms ✓ Requires
1176.2 ms ✓ ZipFile
716.9 ms ✓ Scratch 1399.1 ms ✓ StructUtils
960.4 ms ✓ SuiteSparse
787.7 ms ✓ Pidfile
5830.2 ms ✓ MacroTools
922.9 ms ✓ Compat
1325.3 ms ✓ Preferences
842.1 ms ✓ InverseFunctions → InverseFunctionsDatesExt
1159.5 ms ✓ InverseFunctions → InverseFunctionsTestExt
951.8 ms ✓ FillArrays → FillArraysSparseArraysExt
735.7 ms ✓ FillArrays → FillArraysStatisticsExt 1016.8 ms ✓ Statistics → SparseArraysExt 3513.2 ms ✓ DataStructures
777.9 ms ✓ ConstructionBase → ConstructionBaseLinearAlgebraExt
1032.2 ms ✓ LogExpFunctions 1021.5 ms ✓ Adapt → AdaptSparseArraysExt
794.8 ms ✓ GPUArraysCore
512.2 ms ✓ TableTraits
764.3 ms ✓ Missings
764.9 ms ✓ CompositionsBase → CompositionsBaseInverseFunctionsExt
872.6 ms ✓ RewriteTools
1008.3 ms ✓ Atomix
845.9 ms ✓ AliasTables
626.6 ms ✓ StructUtils → StructUtilsStaticArraysCoreExt
1861.3 ms ✓ HypergeometricFunctions
566.7 ms ✓ Compat → CompatLinearAlgebraExt
1490.5 ms ✓ PDMats
1119.6 ms ✓ MPIPreferences
691.5 ms ✓ PrecompileTools
1194.6 ms ✓ JLLWrappers 1049.1 ms ✓ SortingAlgorithms
632.7 ms ✓ LogExpFunctions → LogExpFunctionsInverseFunctionsExt
1570.9 ms ✓ QuadGK
1676.3 ms ✓ Tables
1209.2 ms ✓ FillArrays → FillArraysPDMatsExt
4870.0 ms ✓ Accessors 10762.9 ms ✓ FileIO
1020.0 ms ✓ OpenSSL_jll
1191.2 ms ✓ Rmath_jll
842.0 ms ✓ MicrosoftMPI_jll
835.2 ms ✓ dlfcn_win32_jll
970.9 ms ✓ aws_c_common_jll
1136.1 ms ✓ Libiconv_jll
2407.8 ms ✓ MPItrampoline_jll
2471.2 ms ✓ micromamba_jll
1002.9 ms ✓ Xorg_libpciaccess_jll
2223.4 ms ✓ pixi_jll
17566.0 ms ✓ StaticArrays
1084.9 ms ✓ OpenSpecFun_jll
1002.1 ms ✓ libaec_jll
1002.9 ms ✓ s2n_tls_jll
679.4 ms ✓ StructUtils → StructUtilsTablesExt
846.7 ms ✓ Accessors → LinearAlgebraExt
1038.0 ms ✓ Accessors → TestExt
19632.6 ms ✓ Parsers
4561.6 ms ✓ StatsBase
1505.5 ms ✓ Rmath
1063.6 ms ✓ aws_checksums_jll
2871.9 ms ✓ NPZ
979.8 ms ✓ aws_c_cal_jll
1080.3 ms ✓ aws_c_sdkutils_jll
1121.7 ms ✓ aws_c_compression_jll
1134.9 ms ✓ XML2_jll
1206.7 ms ✓ StaticArrays → StaticArraysStatisticsExt
1169.2 ms ✓ FillArrays → FillArraysStaticArraysExt
974.0 ms ✓ ConstructionBase → ConstructionBaseStaticArraysExt
1085.9 ms ✓ Adapt → AdaptStaticArraysExt
1210.3 ms ✓ Accessors → StaticArraysExt
4934.9 ms ✓ MicroMamba
5194.3 ms ✓ SpecialFunctions
1168.3 ms ✓ PDMats → StatsBaseExt
6210.6 ms ✓ Roots
1009.8 ms ✓ aws_c_io_jll
1264.7 ms ✓ Hwloc_jll
2385.7 ms ✓ StatsFuns
1157.5 ms ✓ aws_c_http_jll
10542.8 ms ✓ JSON
2309.4 ms ✓ MPIABI_jll
2491.4 ms ✓ OpenMPI_jll
1241.5 ms ✓ MPICH_jll
906.5 ms ✓ StatsFuns → StatsFunsInverseFunctionsExt
8995.8 ms ✓ KernelAbstractions
1228.1 ms ✓ aws_c_auth_jll
2005.2 ms ✓ mpif_jll
1572.6 ms ✓ KernelAbstractions → SparseArraysExt
1094.6 ms ✓ KernelAbstractions → LinearAlgebraExt
1117.8 ms ✓ aws_c_s3_jll
9207.7 ms ✓ Distributions 10085.0 ms ✓ CondaPkg
4139.6 ms ✓ AcceleratedKernels
2386.4 ms ✓ Distributions → DistributionsTestExt 2501.5 ms ✓ HDF5_jll
17143.9 ms ✓ HDF5
31519.5 ms ✓ Finch
34752.0 ms ✓ PythonCall
3268.7 ms ✓ Finch → SparseArraysExt
2883.6 ms ✓ Finch → HDF5Ext
4688.6 ms ✓ Finch → NPZExt
1916.1 ms ✓ Finch → TensorMarketExt 127 dependencies successfully precompiled in 120 seconds. 32 already precompiled. 2 dependencies had output during precompilation: ┌ CondaPkg │ Downloading artifact: pixi └ ┌ MicroMamba │ Downloading artifact: micromamba └
No Changes to `~/checkouts/readthedocs.org/user_builds/sparse-nd/envs/latest/julia_env/Project.toml` No Changes to `~/checkouts/readthedocs.org/user_builds/sparse-nd/envs/latest/julia_env/Manifest.toml`
Detected IPython. Loading juliacall extension. See https://juliapy.github.io/PythonCall.jl/stable/compat/#IPython
Perform Operations¶
Let's create two arrays.
In [2]:
Copied!
rng = np.random.default_rng(42) # Seed for reproducibility
a = sparse.random((3, 3), density=1 / 6, random_state=rng)
b = sparse.random((3, 3), density=1 / 6, random_state=rng)
rng = np.random.default_rng(42) # Seed for reproducibility
a = sparse.random((3, 3), density=1 / 6, random_state=rng)
b = sparse.random((3, 3), density=1 / 6, random_state=rng)
Now let's matrix multiply them.
In [3]:
Copied!
c = a @ b
c = a @ b
And view the result as a (dense) NumPy array.
In [4]:
Copied!
c_dense = c.todense()
c_dense = c.todense()
Now let's do the same for other formats, and compare the results.
In [5]:
Copied!
for format in ["coo", "csr", "csc", "dense"]:
af = sparse.asarray(a, format=format)
bf = sparse.asarray(b, format=format)
cf = af @ bf
np.testing.assert_array_equal(c_dense, cf.todense())
for format in ["coo", "csr", "csc", "dense"]:
af = sparse.asarray(a, format=format)
bf = sparse.asarray(b, format=format)
cf = af @ bf
np.testing.assert_array_equal(c_dense, cf.todense())