Skip to content

perf: "two-pass" seurat hvg via scanpy.get.aggregate#4013

Draft
ilan-gold wants to merge 30 commits into
mainfrom
ig/two_pass_hvg_v3
Draft

perf: "two-pass" seurat hvg via scanpy.get.aggregate#4013
ilan-gold wants to merge 30 commits into
mainfrom
ig/two_pass_hvg_v3

Conversation

@ilan-gold

@ilan-gold ilan-gold commented Mar 26, 2026

Copy link
Copy Markdown
Contributor

An idea that popped into my head for disk-bound datasets but likely also normal ones. This should, in theory, greatly improve on-disk access and produce speed ups for disk bound data by reducing the amount of i/o in the worst case, unordered scenario (while, I would guess, leaving in-memory datasets untocuhed or maybe improved thanks to memory access + more efficient mean/var).

Dependent on #4143

  • Closes #
  • Tests included or not required because:

@ilan-gold ilan-gold added this to the 1.12.1 milestone Mar 26, 2026
@ilan-gold ilan-gold changed the title perf: "two-pass" seurat hvg3 via scanpy.get.aggregate perf: "two-pass" seurat hvg via scanpy.get.aggregate Mar 26, 2026
@codecov

codecov Bot commented Mar 26, 2026

Copy link
Copy Markdown

❌ 8 Tests Failed:

Tests completed Failed Passed Skipped
2628 8 2620 150
View the top 3 failed test(s) by shortest run time
tests/test_aggregated.py::test_aggregate_obsm_labels
Stack Traces | 0.003s run time
#x1B[0m#x1B[94mdef#x1B[39;49;00m#x1B[90m #x1B[39;49;00m#x1B[92mtest_aggregate_obsm_labels#x1B[39;49;00m() -> #x1B[94mNone#x1B[39;49;00m:#x1B[90m#x1B[39;49;00m
        #x1B[94mfrom#x1B[39;49;00m#x1B[90m #x1B[39;49;00m#x1B[04m#x1B[96mitertools#x1B[39;49;00m#x1B[90m #x1B[39;49;00m#x1B[94mimport#x1B[39;49;00m chain, repeat#x1B[90m#x1B[39;49;00m
    #x1B[90m#x1B[39;49;00m
        label_counts = [(#x1B[33m"#x1B[39;49;00m#x1B[33ma#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, #x1B[94m5#x1B[39;49;00m), (#x1B[33m"#x1B[39;49;00m#x1B[33mb#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, #x1B[94m3#x1B[39;49;00m), (#x1B[33m"#x1B[39;49;00m#x1B[33mc#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, #x1B[94m4#x1B[39;49;00m)]#x1B[90m#x1B[39;49;00m
        blocks = [np.ones((n, #x1B[94m1#x1B[39;49;00m)) #x1B[94mfor#x1B[39;49;00m _, n #x1B[95min#x1B[39;49;00m label_counts]#x1B[90m#x1B[39;49;00m
        obs_names = pd.Index([#x1B[90m#x1B[39;49;00m
            #x1B[33mf#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m#x1B[33mcell_#x1B[39;49;00m#x1B[33m{#x1B[39;49;00mi#x1B[33m:#x1B[39;49;00m#x1B[33m02d#x1B[39;49;00m#x1B[33m}#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m #x1B[94mfor#x1B[39;49;00m i #x1B[95min#x1B[39;49;00m #x1B[96mrange#x1B[39;49;00m(#x1B[96msum#x1B[39;49;00m(b.shape[#x1B[94m0#x1B[39;49;00m] #x1B[94mfor#x1B[39;49;00m b #x1B[95min#x1B[39;49;00m blocks))#x1B[90m#x1B[39;49;00m
        ])#x1B[90m#x1B[39;49;00m
        entry = pd.DataFrame(#x1B[90m#x1B[39;49;00m
>           sparse.block_diag(blocks).toarray(),#x1B[90m#x1B[39;49;00m
            ^^^^^^^^^^^^^^^^^^^^^^^^^#x1B[90m#x1B[39;49;00m
            columns=[#x1B[33mf#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m#x1B[33mdim_#x1B[39;49;00m#x1B[33m{#x1B[39;49;00mi#x1B[33m}#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m #x1B[94mfor#x1B[39;49;00m i #x1B[95min#x1B[39;49;00m #x1B[96mrange#x1B[39;49;00m(#x1B[96mlen#x1B[39;49;00m(label_counts))],#x1B[90m#x1B[39;49;00m
            index=obs_names,#x1B[90m#x1B[39;49;00m
        )#x1B[90m#x1B[39;49;00m

#x1B[1m#x1B[31mtests/test_aggregated.py#x1B[0m:470: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

mats = [array([[1.],
       [1.],
       [1.],
       [1.],
       [1.]]), array([[1.],
       [1.],
       [1.]]), array([[1.],
       [1.],
       [1.],
       [1.]])]
format = None, dtype = None

    #x1B[0m#x1B[94mdef#x1B[39;49;00m#x1B[90m #x1B[39;49;00m#x1B[92mblock_diag#x1B[39;49;00m(mats, #x1B[96mformat#x1B[39;49;00m=#x1B[94mNone#x1B[39;49;00m, dtype=#x1B[94mNone#x1B[39;49;00m):#x1B[90m#x1B[39;49;00m
    #x1B[90m    #x1B[39;49;00m#x1B[33m"""#x1B[39;49;00m
    #x1B[33m    Build a block diagonal sparse matrix or array from provided matrices.#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    .. warning::#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m        `block_diag` is switching to the sparse array interface.#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m        For the case where no input arrays are sparse, this function is#x1B[39;49;00m
    #x1B[33m        switching to returning a sparse array instead of sparse matrix.#x1B[39;49;00m
    #x1B[33m        Control the sparse return class by making at least one input sparse,#x1B[39;49;00m
    #x1B[33m        e.g., ``block_diag([coo_matrix(A), B])``, or ``block_diag([coo_array(A), B])``.#x1B[39;49;00m
    #x1B[33m        That removes any deprecation warnings as well.#x1B[39;49;00m
    #x1B[33m        For more general information about sparrays, see#x1B[39;49;00m
    #x1B[33m        :ref:`Migration from spmatrix to sparray <migration_to_sparray>`.#x1B[39;49;00m
    #x1B[33m        Handling of this no sparse input case will change no earlier than v1.20.#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    Parameters#x1B[39;49;00m
    #x1B[33m    ----------#x1B[39;49;00m
    #x1B[33m    mats : sequence of matrices or arrays#x1B[39;49;00m
    #x1B[33m        Input matrices or arrays.#x1B[39;49;00m
    #x1B[33m    format : str, optional#x1B[39;49;00m
    #x1B[33m        The sparse format of the result (e.g., "csr"). If not given, the result#x1B[39;49;00m
    #x1B[33m        is returned in "coo" format.#x1B[39;49;00m
    #x1B[33m    dtype : dtype specifier, optional#x1B[39;49;00m
    #x1B[33m        The data-type of the output. If not given, the dtype is#x1B[39;49;00m
    #x1B[33m        determined from that of `blocks`.#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    Returns#x1B[39;49;00m
    #x1B[33m    -------#x1B[39;49;00m
    #x1B[33m    res : sparse matrix or array#x1B[39;49;00m
    #x1B[33m        If at least one input is a sparse array, the output is a sparse array.#x1B[39;49;00m
    #x1B[33m        Otherwise the output is a sparse matrix.#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    See Also#x1B[39;49;00m
    #x1B[33m    --------#x1B[39;49;00m
    #x1B[33m    block_array#x1B[39;49;00m
    #x1B[33m    diags_array#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    Notes#x1B[39;49;00m
    #x1B[33m    -----#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    .. versionadded:: 0.11.0#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    Examples#x1B[39;49;00m
    #x1B[33m    --------#x1B[39;49;00m
    #x1B[33m    >>> from scipy.sparse import coo_array, block_diag#x1B[39;49;00m
    #x1B[33m    >>> A = coo_array([[1, 2], [3, 4]])#x1B[39;49;00m
    #x1B[33m    >>> B = coo_array([[5], [6]])#x1B[39;49;00m
    #x1B[33m    >>> C = coo_array([[7]])#x1B[39;49;00m
    #x1B[33m    >>> block_diag((A, B, C)).toarray()#x1B[39;49;00m
    #x1B[33m    array([[1, 2, 0, 0],#x1B[39;49;00m
    #x1B[33m           [3, 4, 0, 0],#x1B[39;49;00m
    #x1B[33m           [0, 0, 5, 0],#x1B[39;49;00m
    #x1B[33m           [0, 0, 6, 0],#x1B[39;49;00m
    #x1B[33m           [0, 0, 0, 7]])#x1B[39;49;00m
    #x1B[33m    """#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
        #x1B[94mif#x1B[39;49;00m #x1B[96many#x1B[39;49;00m(#x1B[96misinstance#x1B[39;49;00m(a, sparray) #x1B[94mfor#x1B[39;49;00m a #x1B[95min#x1B[39;49;00m mats):#x1B[90m#x1B[39;49;00m
            container = coo_array#x1B[90m#x1B[39;49;00m
        #x1B[94melif#x1B[39;49;00m #x1B[96many#x1B[39;49;00m(#x1B[96misinstance#x1B[39;49;00m(a, spmatrix) #x1B[94mfor#x1B[39;49;00m a #x1B[95min#x1B[39;49;00m mats):#x1B[90m#x1B[39;49;00m
            container = coo_matrix#x1B[90m#x1B[39;49;00m
        #x1B[94melse#x1B[39;49;00m:  #x1B[90m# all dense#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
            msg = #x1B[33m"""#x1B[39;49;00m#x1B[33m`block_diag` is switching to the sparse array interface.#x1B[39;49;00m#x1B[33m#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m        For the case where input arrays are numpy arrays, this function is#x1B[39;49;00m#x1B[33m#x1B[39;49;00m
    #x1B[33m        switching to returning a sparse array instead of sparse matrix.#x1B[39;49;00m#x1B[33m#x1B[39;49;00m
    #x1B[33m        Recover the sparse matrix return value by making one input a sparse matrix.#x1B[39;49;00m#x1B[33m#x1B[39;49;00m
    #x1B[33m        For example, block_diag([coo_matrix(A), B]).#x1B[39;49;00m#x1B[33m#x1B[39;49;00m
    #x1B[33m        Avoid this message for sparse array output using block_diag([coo_array(A), B]).#x1B[39;49;00m#x1B[33m#x1B[39;49;00m
    #x1B[33m        For more information, see the spmatrix to sparray migration guide#x1B[39;49;00m#x1B[33m#x1B[39;49;00m
    #x1B[33m        https://docs.scipy..../scipy/reference/sparse.migration_to_sparray.html#x1B[39;49;00m#x1B[33m#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m        This function will be changed no earlier than v1.20.#x1B[39;49;00m#x1B[33m#x1B[39;49;00m
    #x1B[33m        #x1B[39;49;00m#x1B[33m"""#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
            prefixes = (os.path.dirname(#x1B[91m__file__#x1B[39;49;00m),)#x1B[90m#x1B[39;49;00m
>           warn(msg, category=#x1B[96mDeprecationWarning#x1B[39;49;00m, skip_file_prefixes=prefixes)#x1B[90m#x1B[39;49;00m
#x1B[1m#x1B[31mE           DeprecationWarning: `block_diag` is switching to the sparse array interface.#x1B[0m
#x1B[1m#x1B[31mE           #x1B[0m
#x1B[1m#x1B[31mE                   For the case where input arrays are numpy arrays, this function is#x1B[0m
#x1B[1m#x1B[31mE                   switching to returning a sparse array instead of sparse matrix.#x1B[0m
#x1B[1m#x1B[31mE                   Recover the sparse matrix return value by making one input a sparse matrix.#x1B[0m
#x1B[1m#x1B[31mE                   For example, block_diag([coo_matrix(A), B]).#x1B[0m
#x1B[1m#x1B[31mE                   Avoid this message for sparse array output using block_diag([coo_array(A), B]).#x1B[0m
#x1B[1m#x1B[31mE                   For more information, see the spmatrix to sparray migration guide#x1B[0m
#x1B[1m#x1B[31mE                   https://docs.scipy..../scipy/reference/sparse.migration_to_sparray.html#x1B[0m
#x1B[1m#x1B[31mE           #x1B[0m
#x1B[1m#x1B[31mE                   This function will be changed no earlier than v1.20.#x1B[0m

#x1B[1m#x1B[31m../../../..../scanpy/B9PcT7QG/hatch-test.pre/lib/python3.14.../scipy/sparse/_construct.py#x1B[0m:1485: DeprecationWarning
tests/test_read_10x.py::test_read_10x[no_prefix-1.2.0]
Stack Traces | 0.004s run time
tmp_path = PosixPath('.../pytest-0/popen-gw0/test_read_10x_no_prefix_1_2_0_0')
mtx_path = PosixPath('.../_data/10x_data/1.2.0/filtered_gene_bc_matrices/hg19_chr21')
h5_path = PosixPath('.../_data/10x_data/1.2.0/filtered_gene_bc_matrices_h5.h5')
prefix = None

    #x1B[0m#x1B[37m@pytest#x1B[39;49;00m.mark.parametrize(#x1B[90m#x1B[39;49;00m
        (#x1B[33m"#x1B[39;49;00m#x1B[33mmtx_path#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, #x1B[33m"#x1B[39;49;00m#x1B[33mh5_path#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m),#x1B[90m#x1B[39;49;00m
        [#x1B[90m#x1B[39;49;00m
            pytest.param(#x1B[90m#x1B[39;49;00m
                ROOT / #x1B[33m"#x1B[39;49;00m#x1B[33m1.2.0#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m / #x1B[33m"#x1B[39;49;00m#x1B[33mfiltered_gene_bc_matrices#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m / #x1B[33m"#x1B[39;49;00m#x1B[33mhg19_chr21#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m,#x1B[90m#x1B[39;49;00m
                ROOT / #x1B[33m"#x1B[39;49;00m#x1B[33m1.2.0#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m / #x1B[33m"#x1B[39;49;00m#x1B[33mfiltered_gene_bc_matrices_h5.h5#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m,#x1B[90m#x1B[39;49;00m
                #x1B[96mid#x1B[39;49;00m=#x1B[33m"#x1B[39;49;00m#x1B[33m1.2.0#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m,#x1B[90m#x1B[39;49;00m
            ),#x1B[90m#x1B[39;49;00m
            pytest.param(#x1B[90m#x1B[39;49;00m
                ROOT / #x1B[33m"#x1B[39;49;00m#x1B[33m3.0.0#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m / #x1B[33m"#x1B[39;49;00m#x1B[33mfiltered_feature_bc_matrix#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m,#x1B[90m#x1B[39;49;00m
                ROOT / #x1B[33m"#x1B[39;49;00m#x1B[33m3.0.0#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m / #x1B[33m"#x1B[39;49;00m#x1B[33mfiltered_feature_bc_matrix.h5#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m,#x1B[90m#x1B[39;49;00m
                #x1B[96mid#x1B[39;49;00m=#x1B[33m"#x1B[39;49;00m#x1B[33m3.0.0#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m,#x1B[90m#x1B[39;49;00m
            ),#x1B[90m#x1B[39;49;00m
        ],#x1B[90m#x1B[39;49;00m
    )#x1B[90m#x1B[39;49;00m
    #x1B[37m@pytest#x1B[39;49;00m.mark.parametrize(#x1B[33m"#x1B[39;49;00m#x1B[33mprefix#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, [#x1B[94mNone#x1B[39;49;00m, #x1B[33m"#x1B[39;49;00m#x1B[33mprefix_#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m], ids=[#x1B[33m"#x1B[39;49;00m#x1B[33mno_prefix#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, #x1B[33m"#x1B[39;49;00m#x1B[33mprefix#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m])#x1B[90m#x1B[39;49;00m
    #x1B[94mdef#x1B[39;49;00m#x1B[90m #x1B[39;49;00m#x1B[92mtest_read_10x#x1B[39;49;00m(#x1B[90m#x1B[39;49;00m
        tmp_path: Path, mtx_path: Path, h5_path: Path, prefix: #x1B[96mstr#x1B[39;49;00m | #x1B[94mNone#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
    ) -> #x1B[94mNone#x1B[39;49;00m:#x1B[90m#x1B[39;49;00m
        #x1B[94mif#x1B[39;49;00m prefix #x1B[95mis#x1B[39;49;00m #x1B[95mnot#x1B[39;49;00m #x1B[94mNone#x1B[39;49;00m:#x1B[90m#x1B[39;49;00m
            #x1B[90m# Build files named "prefix_XXX.xxx" in a temporary directory.#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
            mtx_path_orig = mtx_path#x1B[90m#x1B[39;49;00m
            mtx_path = tmp_path / #x1B[33m"#x1B[39;49;00m#x1B[33mfiltered_gene_bc_matrices_prefix#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
            mtx_path.mkdir()#x1B[90m#x1B[39;49;00m
            #x1B[94mfor#x1B[39;49;00m item #x1B[95min#x1B[39;49;00m mtx_path_orig.iterdir():#x1B[90m#x1B[39;49;00m
                #x1B[94mif#x1B[39;49;00m item.is_file():#x1B[90m#x1B[39;49;00m
                    shutil.copyfile(item, mtx_path / #x1B[33mf#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m#x1B[33m{#x1B[39;49;00mprefix#x1B[33m}#x1B[39;49;00m#x1B[33m{#x1B[39;49;00mitem.name#x1B[33m}#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m)#x1B[90m#x1B[39;49;00m
    #x1B[90m#x1B[39;49;00m
>       mtx = sc.read_10x_mtx(mtx_path, var_names=#x1B[33m"#x1B[39;49;00m#x1B[33mgene_symbols#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, prefix=prefix)#x1B[90m#x1B[39;49;00m
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^#x1B[90m#x1B[39;49;00m

#x1B[1m#x1B[31mtests/test_read_10x.py#x1B[0m:60: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31msrc/scanpy/readwrite.py#x1B[0m:580: in read_10x_mtx
    #x1B[0madata = _read_10x_mtx(#x1B[90m#x1B[39;49;00m
#x1B[1m#x1B[31msrc/scanpy/readwrite.py#x1B[0m:632: in _read_10x_mtx
    #x1B[0madata = read(#x1B[90m#x1B[39;49;00m
#x1B[1m#x1B[31msrc/scanpy/readwrite.py#x1B[0m:142: in read
    #x1B[0m#x1B[94mreturn#x1B[39;49;00m _read(#x1B[90m#x1B[39;49;00m
#x1B[1m#x1B[31msrc/scanpy/readwrite.py#x1B[0m:892: in _read
    #x1B[0madata = _read_mtx(filename, **kwargs)#x1B[90m#x1B[39;49;00m
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^#x1B[90m#x1B[39;49;00m
#x1B[1m#x1B[31msrc/scanpy/readwrite.py#x1B[0m:607: in _read_mtx
    #x1B[0mx = mmread(filename)#x1B[90m#x1B[39;49;00m
        ^^^^^^^^^^^^^^^^#x1B[90m#x1B[39;49;00m
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

source = PosixPath('.../_data/10x_data/1.2.0.../filtered_gene_bc_matrices/hg19_chr21/matrix.mtx')

    #x1B[0m#x1B[94mdef#x1B[39;49;00m#x1B[90m #x1B[39;49;00m#x1B[92mmmread#x1B[39;49;00m(source, *, spmatrix=_NoValue):#x1B[90m#x1B[39;49;00m
    #x1B[90m    #x1B[39;49;00m#x1B[33m"""#x1B[39;49;00m
    #x1B[33m    Reads the contents of a Matrix Market file-like 'source' into a matrix.#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    Parameters#x1B[39;49;00m
    #x1B[33m    ----------#x1B[39;49;00m
    #x1B[33m    source : str or file-like#x1B[39;49;00m
    #x1B[33m        Matrix Market filename (extensions .mtx, .mtz.gz)#x1B[39;49;00m
    #x1B[33m        or open file-like object.#x1B[39;49;00m
    #x1B[33m    spmatrix : bool, optional (default: True)#x1B[39;49;00m
    #x1B[33m        If ``True``, return sparse matrix. Otherwise return sparse array.#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m        .. deprecated:: 1.18.0#x1B[39;49;00m
    #x1B[33m            The default value for `spmatrix` is changing to False in v1.20.#x1B[39;49;00m
    #x1B[33m            That means the default return value will be a sparse array.#x1B[39;49;00m
    #x1B[33m            Unless you use * instead of @, ** for matrix power, or you depend#x1B[39;49;00m
    #x1B[33m            on 2D shapes from e.g. ``A.sum(axis=0)`` it may not matter to you.#x1B[39;49;00m
    #x1B[33m            See :ref:`Migration from spmatrix to sparray <migration_to_sparray>`.#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    Returns#x1B[39;49;00m
    #x1B[33m    -------#x1B[39;49;00m
    #x1B[33m    a : ndarray or coo_array#x1B[39;49;00m
    #x1B[33m        Dense or sparse array depending on the matrix format in the#x1B[39;49;00m
    #x1B[33m        Matrix Market file.#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    Notes#x1B[39;49;00m
    #x1B[33m    -----#x1B[39;49;00m
    #x1B[33m    .. versionchanged:: 1.12.0#x1B[39;49;00m
    #x1B[33m        C++ implementation.#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    Examples#x1B[39;49;00m
    #x1B[33m    --------#x1B[39;49;00m
    #x1B[33m    >>> from io import StringIO#x1B[39;49;00m
    #x1B[33m    >>> from scipy.io import mmread#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    >>> text = '''%%MatrixMarket matrix coordinate real general#x1B[39;49;00m
    #x1B[33m    ...  5 5 7#x1B[39;49;00m
    #x1B[33m    ...  2 3 1.0#x1B[39;49;00m
    #x1B[33m    ...  3 4 2.0#x1B[39;49;00m
    #x1B[33m    ...  3 5 3.0#x1B[39;49;00m
    #x1B[33m    ...  4 1 4.0#x1B[39;49;00m
    #x1B[33m    ...  4 2 5.0#x1B[39;49;00m
    #x1B[33m    ...  4 3 6.0#x1B[39;49;00m
    #x1B[33m    ...  4 4 7.0#x1B[39;49;00m
    #x1B[33m    ... '''#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    ``mmread(source)`` returns the data as sparse array in COO format.#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    >>> m = mmread(StringIO(text), spmatrix=False)#x1B[39;49;00m
    #x1B[33m    >>> m#x1B[39;49;00m
    #x1B[33m    <COOrdinate sparse array of dtype 'float64'#x1B[39;49;00m
    #x1B[33m        with 7 stored elements and shape (5, 5)>#x1B[39;49;00m
    #x1B[33m    >>> m.toarray()#x1B[39;49;00m
    #x1B[33m    array([[0., 0., 0., 0., 0.],#x1B[39;49;00m
    #x1B[33m           [0., 0., 1., 0., 0.],#x1B[39;49;00m
    #x1B[33m           [0., 0., 0., 2., 3.],#x1B[39;49;00m
    #x1B[33m           [4., 5., 6., 7., 0.],#x1B[39;49;00m
    #x1B[33m           [0., 0., 0., 0., 0.]])#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    This method is threaded.#x1B[39;49;00m
    #x1B[33m    The default number of threads is equal to the number of CPUs in the system.#x1B[39;49;00m
    #x1B[33m    Use `threadpoolctl <https://github.com/joblib/threadpoolctl>`_ to override:#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    >>> import threadpoolctl#x1B[39;49;00m
    #x1B[33m    >>>#x1B[39;49;00m
    #x1B[33m    >>> with threadpoolctl.threadpool_limits(limits=2):#x1B[39;49;00m
    #x1B[33m    ...     m = mmread(StringIO(text), spmatrix=False)#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    """#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
        cursor, stream_to_close = _get_read_cursor(source)#x1B[90m#x1B[39;49;00m
    #x1B[90m#x1B[39;49;00m
        #x1B[94mif#x1B[39;49;00m cursor.header.format == #x1B[33m"#x1B[39;49;00m#x1B[33marray#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m:#x1B[90m#x1B[39;49;00m
            mat = _read_body_array(cursor)#x1B[90m#x1B[39;49;00m
            #x1B[94mif#x1B[39;49;00m stream_to_close:#x1B[90m#x1B[39;49;00m
                stream_to_close.close()#x1B[90m#x1B[39;49;00m
            #x1B[94mreturn#x1B[39;49;00m mat#x1B[90m#x1B[39;49;00m
        #x1B[94melse#x1B[39;49;00m:#x1B[90m#x1B[39;49;00m
            triplet, shape = _read_body_coo(cursor, generalize_symmetry=#x1B[94mTrue#x1B[39;49;00m)#x1B[90m#x1B[39;49;00m
            #x1B[94mif#x1B[39;49;00m stream_to_close:#x1B[90m#x1B[39;49;00m
                stream_to_close.close()#x1B[90m#x1B[39;49;00m
    #x1B[90m#x1B[39;49;00m
            #x1B[94mif#x1B[39;49;00m spmatrix #x1B[95mis#x1B[39;49;00m _NoValue:#x1B[90m#x1B[39;49;00m
                msg = #x1B[33m"""#x1B[39;49;00m#x1B[33mThe default value for `spmatrix` is changing to `False` in v1.20.#x1B[39;49;00m#x1B[33m#x1B[39;49;00m
    #x1B[33m             That means the default return type will be a sparse array.#x1B[39;49;00m#x1B[33m#x1B[39;49;00m
    #x1B[33m             Unless you use * instead of @, ** for matrix power, or you depend#x1B[39;49;00m#x1B[33m#x1B[39;49;00m
    #x1B[33m             on 2D shapes from e.g. `A.sum(axis=0)` it may not matter to you.#x1B[39;49;00m#x1B[33m#x1B[39;49;00m
    #x1B[33m             See the spmatrix to sparray migration guide for details.#x1B[39;49;00m#x1B[33m#x1B[39;49;00m
    #x1B[33m             https://docs.scipy..../scipy/reference/sparse.migration_to_sparray.html#x1B[39;49;00m#x1B[33m#x1B[39;49;00m
    #x1B[33m             #x1B[39;49;00m#x1B[33m"""#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
                prefixes = (os.path.dirname(#x1B[91m__file__#x1B[39;49;00m),)#x1B[90m#x1B[39;49;00m
>               warn(msg, #x1B[96mDeprecationWarning#x1B[39;49;00m, skip_file_prefixes=prefixes)#x1B[90m#x1B[39;49;00m
#x1B[1m#x1B[31mE               DeprecationWarning: The default value for `spmatrix` is changing to `False` in v1.20.#x1B[0m
#x1B[1m#x1B[31mE                            That means the default return type will be a sparse array.#x1B[0m
#x1B[1m#x1B[31mE                            Unless you use * instead of @, ** for matrix power, or you depend#x1B[0m
#x1B[1m#x1B[31mE                            on 2D shapes from e.g. `A.sum(axis=0)` it may not matter to you.#x1B[0m
#x1B[1m#x1B[31mE                            See the spmatrix to sparray migration guide for details.#x1B[0m
#x1B[1m#x1B[31mE                            https://docs.scipy..../scipy/reference/sparse.migration_to_sparray.html#x1B[0m

#x1B[1m#x1B[31m../../../..../scanpy/B9PcT7QG/hatch-test.pre/lib/python3.14.../io/_fast_matrix_market/__init__.py#x1B[0m:391: DeprecationWarning
tests/test_read_10x.py::test_read_10x_mtx_int[ids]
Stack Traces | 0.004s run time
genes = 'ids', col_dtypes = {'gene_symbols': 'str'}

    #x1B[0m#x1B[37m@pytest#x1B[39;49;00m.mark.parametrize(#x1B[90m#x1B[39;49;00m
        (#x1B[33m"#x1B[39;49;00m#x1B[33mgenes#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, #x1B[33m"#x1B[39;49;00m#x1B[33mcol_dtypes#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m),#x1B[90m#x1B[39;49;00m
        [#x1B[90m#x1B[39;49;00m
            pytest.param(#x1B[33m"#x1B[39;49;00m#x1B[33msymbols#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, #x1B[96mdict#x1B[39;49;00m(gene_ids=#x1B[33m"#x1B[39;49;00m#x1B[33mint64#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m), #x1B[96mid#x1B[39;49;00m=#x1B[33m"#x1B[39;49;00m#x1B[33msymbols#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m),#x1B[90m#x1B[39;49;00m
            pytest.param(#x1B[33m"#x1B[39;49;00m#x1B[33mids#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, #x1B[96mdict#x1B[39;49;00m(gene_symbols=#x1B[33m"#x1B[39;49;00m#x1B[33mstr#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m), #x1B[96mid#x1B[39;49;00m=#x1B[33m"#x1B[39;49;00m#x1B[33mids#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m),#x1B[90m#x1B[39;49;00m
        ],#x1B[90m#x1B[39;49;00m
    )#x1B[90m#x1B[39;49;00m
    #x1B[94mdef#x1B[39;49;00m#x1B[90m #x1B[39;49;00m#x1B[92mtest_read_10x_mtx_int#x1B[39;49;00m(#x1B[90m#x1B[39;49;00m
        genes: Literal[#x1B[33m"#x1B[39;49;00m#x1B[33msymbols#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, #x1B[33m"#x1B[39;49;00m#x1B[33mids#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m], col_dtypes: #x1B[96mdict#x1B[39;49;00m[#x1B[96mstr#x1B[39;49;00m, #x1B[96mstr#x1B[39;49;00m]#x1B[90m#x1B[39;49;00m
    ) -> #x1B[94mNone#x1B[39;49;00m:#x1B[90m#x1B[39;49;00m
        str_dt = #x1B[33m"#x1B[39;49;00m#x1B[33mstr#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m #x1B[94mif#x1B[39;49;00m pd.options.future.infer_string #x1B[94melse#x1B[39;49;00m #x1B[33m"#x1B[39;49;00m#x1B[33mobject#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
        col_dtypes = {k: str_dt #x1B[94mif#x1B[39;49;00m v == #x1B[33m"#x1B[39;49;00m#x1B[33mstr#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m #x1B[94melse#x1B[39;49;00m v #x1B[94mfor#x1B[39;49;00m k, v #x1B[95min#x1B[39;49;00m col_dtypes.items()}#x1B[90m#x1B[39;49;00m
    #x1B[90m#x1B[39;49;00m
>       adata = sc.read_10x_mtx(#x1B[90m#x1B[39;49;00m
            ROOT / #x1B[33m"#x1B[39;49;00m#x1B[33mint-ids#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, var_names=#x1B[33mf#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m#x1B[33mgene_#x1B[39;49;00m#x1B[33m{#x1B[39;49;00mgenes#x1B[33m}#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, compressed=#x1B[94mFalse#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
        )#x1B[90m#x1B[39;49;00m

#x1B[1m#x1B[31mtests/test_read_10x.py#x1B[0m:96: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31msrc/scanpy/readwrite.py#x1B[0m:580: in read_10x_mtx
    #x1B[0madata = _read_10x_mtx(#x1B[90m#x1B[39;49;00m
#x1B[1m#x1B[31msrc/scanpy/readwrite.py#x1B[0m:632: in _read_10x_mtx
    #x1B[0madata = read(#x1B[90m#x1B[39;49;00m
#x1B[1m#x1B[31msrc/scanpy/readwrite.py#x1B[0m:142: in read
    #x1B[0m#x1B[94mreturn#x1B[39;49;00m _read(#x1B[90m#x1B[39;49;00m
#x1B[1m#x1B[31msrc/scanpy/readwrite.py#x1B[0m:892: in _read
    #x1B[0madata = _read_mtx(filename, **kwargs)#x1B[90m#x1B[39;49;00m
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^#x1B[90m#x1B[39;49;00m
#x1B[1m#x1B[31msrc/scanpy/readwrite.py#x1B[0m:607: in _read_mtx
    #x1B[0mx = mmread(filename)#x1B[90m#x1B[39;49;00m
        ^^^^^^^^^^^^^^^^#x1B[90m#x1B[39;49;00m
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

source = PosixPath('.../10x_data/int-ids/matrix.mtx')

    #x1B[0m#x1B[94mdef#x1B[39;49;00m#x1B[90m #x1B[39;49;00m#x1B[92mmmread#x1B[39;49;00m(source, *, spmatrix=_NoValue):#x1B[90m#x1B[39;49;00m
    #x1B[90m    #x1B[39;49;00m#x1B[33m"""#x1B[39;49;00m
    #x1B[33m    Reads the contents of a Matrix Market file-like 'source' into a matrix.#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    Parameters#x1B[39;49;00m
    #x1B[33m    ----------#x1B[39;49;00m
    #x1B[33m    source : str or file-like#x1B[39;49;00m
    #x1B[33m        Matrix Market filename (extensions .mtx, .mtz.gz)#x1B[39;49;00m
    #x1B[33m        or open file-like object.#x1B[39;49;00m
    #x1B[33m    spmatrix : bool, optional (default: True)#x1B[39;49;00m
    #x1B[33m        If ``True``, return sparse matrix. Otherwise return sparse array.#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m        .. deprecated:: 1.18.0#x1B[39;49;00m
    #x1B[33m            The default value for `spmatrix` is changing to False in v1.20.#x1B[39;49;00m
    #x1B[33m            That means the default return value will be a sparse array.#x1B[39;49;00m
    #x1B[33m            Unless you use * instead of @, ** for matrix power, or you depend#x1B[39;49;00m
    #x1B[33m            on 2D shapes from e.g. ``A.sum(axis=0)`` it may not matter to you.#x1B[39;49;00m
    #x1B[33m            See :ref:`Migration from spmatrix to sparray <migration_to_sparray>`.#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    Returns#x1B[39;49;00m
    #x1B[33m    -------#x1B[39;49;00m
    #x1B[33m    a : ndarray or coo_array#x1B[39;49;00m
    #x1B[33m        Dense or sparse array depending on the matrix format in the#x1B[39;49;00m
    #x1B[33m        Matrix Market file.#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    Notes#x1B[39;49;00m
    #x1B[33m    -----#x1B[39;49;00m
    #x1B[33m    .. versionchanged:: 1.12.0#x1B[39;49;00m
    #x1B[33m        C++ implementation.#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    Examples#x1B[39;49;00m
    #x1B[33m    --------#x1B[39;49;00m
    #x1B[33m    >>> from io import StringIO#x1B[39;49;00m
    #x1B[33m    >>> from scipy.io import mmread#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    >>> text = '''%%MatrixMarket matrix coordinate real general#x1B[39;49;00m
    #x1B[33m    ...  5 5 7#x1B[39;49;00m
    #x1B[33m    ...  2 3 1.0#x1B[39;49;00m
    #x1B[33m    ...  3 4 2.0#x1B[39;49;00m
    #x1B[33m    ...  3 5 3.0#x1B[39;49;00m
    #x1B[33m    ...  4 1 4.0#x1B[39;49;00m
    #x1B[33m    ...  4 2 5.0#x1B[39;49;00m
    #x1B[33m    ...  4 3 6.0#x1B[39;49;00m
    #x1B[33m    ...  4 4 7.0#x1B[39;49;00m
    #x1B[33m    ... '''#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    ``mmread(source)`` returns the data as sparse array in COO format.#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    >>> m = mmread(StringIO(text), spmatrix=False)#x1B[39;49;00m
    #x1B[33m    >>> m#x1B[39;49;00m
    #x1B[33m    <COOrdinate sparse array of dtype 'float64'#x1B[39;49;00m
    #x1B[33m        with 7 stored elements and shape (5, 5)>#x1B[39;49;00m
    #x1B[33m    >>> m.toarray()#x1B[39;49;00m
    #x1B[33m    array([[0., 0., 0., 0., 0.],#x1B[39;49;00m
    #x1B[33m           [0., 0., 1., 0., 0.],#x1B[39;49;00m
    #x1B[33m           [0., 0., 0., 2., 3.],#x1B[39;49;00m
    #x1B[33m           [4., 5., 6., 7., 0.],#x1B[39;49;00m
    #x1B[33m           [0., 0., 0., 0., 0.]])#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    This method is threaded.#x1B[39;49;00m
    #x1B[33m    The default number of threads is equal to the number of CPUs in the system.#x1B[39;49;00m
    #x1B[33m    Use `threadpoolctl <https://github.com/joblib/threadpoolctl>`_ to override:#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    >>> import threadpoolctl#x1B[39;49;00m
    #x1B[33m    >>>#x1B[39;49;00m
    #x1B[33m    >>> with threadpoolctl.threadpool_limits(limits=2):#x1B[39;49;00m
    #x1B[33m    ...     m = mmread(StringIO(text), spmatrix=False)#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    """#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
        cursor, stream_to_close = _get_read_cursor(source)#x1B[90m#x1B[39;49;00m
    #x1B[90m#x1B[39;49;00m
        #x1B[94mif#x1B[39;49;00m cursor.header.format == #x1B[33m"#x1B[39;49;00m#x1B[33marray#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m:#x1B[90m#x1B[39;49;00m
            mat = _read_body_array(cursor)#x1B[90m#x1B[39;49;00m
            #x1B[94mif#x1B[39;49;00m stream_to_close:#x1B[90m#x1B[39;49;00m
                stream_to_close.close()#x1B[90m#x1B[39;49;00m
            #x1B[94mreturn#x1B[39;49;00m mat#x1B[90m#x1B[39;49;00m
        #x1B[94melse#x1B[39;49;00m:#x1B[90m#x1B[39;49;00m
            triplet, shape = _read_body_coo(cursor, generalize_symmetry=#x1B[94mTrue#x1B[39;49;00m)#x1B[90m#x1B[39;49;00m
            #x1B[94mif#x1B[39;49;00m stream_to_close:#x1B[90m#x1B[39;49;00m
                stream_to_close.close()#x1B[90m#x1B[39;49;00m
    #x1B[90m#x1B[39;49;00m
            #x1B[94mif#x1B[39;49;00m spmatrix #x1B[95mis#x1B[39;49;00m _NoValue:#x1B[90m#x1B[39;49;00m
                msg = #x1B[33m"""#x1B[39;49;00m#x1B[33mThe default value for `spmatrix` is changing to `False` in v1.20.#x1B[39;49;00m#x1B[33m#x1B[39;49;00m
    #x1B[33m             That means the default return type will be a sparse array.#x1B[39;49;00m#x1B[33m#x1B[39;49;00m
    #x1B[33m             Unless you use * instead of @, ** for matrix power, or you depend#x1B[39;49;00m#x1B[33m#x1B[39;49;00m
    #x1B[33m             on 2D shapes from e.g. `A.sum(axis=0)` it may not matter to you.#x1B[39;49;00m#x1B[33m#x1B[39;49;00m
    #x1B[33m             See the spmatrix to sparray migration guide for details.#x1B[39;49;00m#x1B[33m#x1B[39;49;00m
    #x1B[33m             https://docs.scipy..../scipy/reference/sparse.migration_to_sparray.html#x1B[39;49;00m#x1B[33m#x1B[39;49;00m
    #x1B[33m             #x1B[39;49;00m#x1B[33m"""#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
                prefixes = (os.path.dirname(#x1B[91m__file__#x1B[39;49;00m),)#x1B[90m#x1B[39;49;00m
>               warn(msg, #x1B[96mDeprecationWarning#x1B[39;49;00m, skip_file_prefixes=prefixes)#x1B[90m#x1B[39;49;00m
#x1B[1m#x1B[31mE               DeprecationWarning: The default value for `spmatrix` is changing to `False` in v1.20.#x1B[0m
#x1B[1m#x1B[31mE                            That means the default return type will be a sparse array.#x1B[0m
#x1B[1m#x1B[31mE                            Unless you use * instead of @, ** for matrix power, or you depend#x1B[0m
#x1B[1m#x1B[31mE                            on 2D shapes from e.g. `A.sum(axis=0)` it may not matter to you.#x1B[0m
#x1B[1m#x1B[31mE                            See the spmatrix to sparray migration guide for details.#x1B[0m
#x1B[1m#x1B[31mE                            https://docs.scipy..../scipy/reference/sparse.migration_to_sparray.html#x1B[0m

#x1B[1m#x1B[31m../../../..../scanpy/B9PcT7QG/hatch-test.pre/lib/python3.14.../io/_fast_matrix_market/__init__.py#x1B[0m:391: DeprecationWarning
tests/test_read_10x.py::test_read_10x[prefix-1.2.0]
Stack Traces | 0.005s run time
tmp_path = PosixPath('.../pytest-0/popen-gw0/test_read_10x_prefix_1_2_0_0')
mtx_path = PosixPath('.../pytest-0/popen-gw0/test_read_10x_prefix_1_2_0_0/filtered_gene_bc_matrices_prefix')
h5_path = PosixPath('.../_data/10x_data/1.2.0/filtered_gene_bc_matrices_h5.h5')
prefix = 'prefix_'

    #x1B[0m#x1B[37m@pytest#x1B[39;49;00m.mark.parametrize(#x1B[90m#x1B[39;49;00m
        (#x1B[33m"#x1B[39;49;00m#x1B[33mmtx_path#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, #x1B[33m"#x1B[39;49;00m#x1B[33mh5_path#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m),#x1B[90m#x1B[39;49;00m
        [#x1B[90m#x1B[39;49;00m
            pytest.param(#x1B[90m#x1B[39;49;00m
                ROOT / #x1B[33m"#x1B[39;49;00m#x1B[33m1.2.0#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m / #x1B[33m"#x1B[39;49;00m#x1B[33mfiltered_gene_bc_matrices#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m / #x1B[33m"#x1B[39;49;00m#x1B[33mhg19_chr21#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m,#x1B[90m#x1B[39;49;00m
                ROOT / #x1B[33m"#x1B[39;49;00m#x1B[33m1.2.0#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m / #x1B[33m"#x1B[39;49;00m#x1B[33mfiltered_gene_bc_matrices_h5.h5#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m,#x1B[90m#x1B[39;49;00m
                #x1B[96mid#x1B[39;49;00m=#x1B[33m"#x1B[39;49;00m#x1B[33m1.2.0#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m,#x1B[90m#x1B[39;49;00m
            ),#x1B[90m#x1B[39;49;00m
            pytest.param(#x1B[90m#x1B[39;49;00m
                ROOT / #x1B[33m"#x1B[39;49;00m#x1B[33m3.0.0#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m / #x1B[33m"#x1B[39;49;00m#x1B[33mfiltered_feature_bc_matrix#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m,#x1B[90m#x1B[39;49;00m
                ROOT / #x1B[33m"#x1B[39;49;00m#x1B[33m3.0.0#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m / #x1B[33m"#x1B[39;49;00m#x1B[33mfiltered_feature_bc_matrix.h5#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m,#x1B[90m#x1B[39;49;00m
                #x1B[96mid#x1B[39;49;00m=#x1B[33m"#x1B[39;49;00m#x1B[33m3.0.0#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m,#x1B[90m#x1B[39;49;00m
            ),#x1B[90m#x1B[39;49;00m
        ],#x1B[90m#x1B[39;49;00m
    )#x1B[90m#x1B[39;49;00m
    #x1B[37m@pytest#x1B[39;49;00m.mark.parametrize(#x1B[33m"#x1B[39;49;00m#x1B[33mprefix#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, [#x1B[94mNone#x1B[39;49;00m, #x1B[33m"#x1B[39;49;00m#x1B[33mprefix_#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m], ids=[#x1B[33m"#x1B[39;49;00m#x1B[33mno_prefix#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, #x1B[33m"#x1B[39;49;00m#x1B[33mprefix#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m])#x1B[90m#x1B[39;49;00m
    #x1B[94mdef#x1B[39;49;00m#x1B[90m #x1B[39;49;00m#x1B[92mtest_read_10x#x1B[39;49;00m(#x1B[90m#x1B[39;49;00m
        tmp_path: Path, mtx_path: Path, h5_path: Path, prefix: #x1B[96mstr#x1B[39;49;00m | #x1B[94mNone#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
    ) -> #x1B[94mNone#x1B[39;49;00m:#x1B[90m#x1B[39;49;00m
        #x1B[94mif#x1B[39;49;00m prefix #x1B[95mis#x1B[39;49;00m #x1B[95mnot#x1B[39;49;00m #x1B[94mNone#x1B[39;49;00m:#x1B[90m#x1B[39;49;00m
            #x1B[90m# Build files named "prefix_XXX.xxx" in a temporary directory.#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
            mtx_path_orig = mtx_path#x1B[90m#x1B[39;49;00m
            mtx_path = tmp_path / #x1B[33m"#x1B[39;49;00m#x1B[33mfiltered_gene_bc_matrices_prefix#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
            mtx_path.mkdir()#x1B[90m#x1B[39;49;00m
            #x1B[94mfor#x1B[39;49;00m item #x1B[95min#x1B[39;49;00m mtx_path_orig.iterdir():#x1B[90m#x1B[39;49;00m
                #x1B[94mif#x1B[39;49;00m item.is_file():#x1B[90m#x1B[39;49;00m
                    shutil.copyfile(item, mtx_path / #x1B[33mf#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m#x1B[33m{#x1B[39;49;00mprefix#x1B[33m}#x1B[39;49;00m#x1B[33m{#x1B[39;49;00mitem.name#x1B[33m}#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m)#x1B[90m#x1B[39;49;00m
    #x1B[90m#x1B[39;49;00m
>       mtx = sc.read_10x_mtx(mtx_path, var_names=#x1B[33m"#x1B[39;49;00m#x1B[33mgene_symbols#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, prefix=prefix)#x1B[90m#x1B[39;49;00m
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^#x1B[90m#x1B[39;49;00m

#x1B[1m#x1B[31mtests/test_read_10x.py#x1B[0m:60: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31msrc/scanpy/readwrite.py#x1B[0m:580: in read_10x_mtx
    #x1B[0madata = _read_10x_mtx(#x1B[90m#x1B[39;49;00m
#x1B[1m#x1B[31msrc/scanpy/readwrite.py#x1B[0m:632: in _read_10x_mtx
    #x1B[0madata = read(#x1B[90m#x1B[39;49;00m
#x1B[1m#x1B[31msrc/scanpy/readwrite.py#x1B[0m:142: in read
    #x1B[0m#x1B[94mreturn#x1B[39;49;00m _read(#x1B[90m#x1B[39;49;00m
#x1B[1m#x1B[31msrc/scanpy/readwrite.py#x1B[0m:892: in _read
    #x1B[0madata = _read_mtx(filename, **kwargs)#x1B[90m#x1B[39;49;00m
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^#x1B[90m#x1B[39;49;00m
#x1B[1m#x1B[31msrc/scanpy/readwrite.py#x1B[0m:607: in _read_mtx
    #x1B[0mx = mmread(filename)#x1B[90m#x1B[39;49;00m
        ^^^^^^^^^^^^^^^^#x1B[90m#x1B[39;49;00m
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

source = PosixPath('.../pytest-0/popen-gw0/test_read_10x_prefix_1_2_0_0/filtered_gene_bc_matrices_prefix/prefix_matrix.mtx')

    #x1B[0m#x1B[94mdef#x1B[39;49;00m#x1B[90m #x1B[39;49;00m#x1B[92mmmread#x1B[39;49;00m(source, *, spmatrix=_NoValue):#x1B[90m#x1B[39;49;00m
    #x1B[90m    #x1B[39;49;00m#x1B[33m"""#x1B[39;49;00m
    #x1B[33m    Reads the contents of a Matrix Market file-like 'source' into a matrix.#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    Parameters#x1B[39;49;00m
    #x1B[33m    ----------#x1B[39;49;00m
    #x1B[33m    source : str or file-like#x1B[39;49;00m
    #x1B[33m        Matrix Market filename (extensions .mtx, .mtz.gz)#x1B[39;49;00m
    #x1B[33m        or open file-like object.#x1B[39;49;00m
    #x1B[33m    spmatrix : bool, optional (default: True)#x1B[39;49;00m
    #x1B[33m        If ``True``, return sparse matrix. Otherwise return sparse array.#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m        .. deprecated:: 1.18.0#x1B[39;49;00m
    #x1B[33m            The default value for `spmatrix` is changing to False in v1.20.#x1B[39;49;00m
    #x1B[33m            That means the default return value will be a sparse array.#x1B[39;49;00m
    #x1B[33m            Unless you use * instead of @, ** for matrix power, or you depend#x1B[39;49;00m
    #x1B[33m            on 2D shapes from e.g. ``A.sum(axis=0)`` it may not matter to you.#x1B[39;49;00m
    #x1B[33m            See :ref:`Migration from spmatrix to sparray <migration_to_sparray>`.#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    Returns#x1B[39;49;00m
    #x1B[33m    -------#x1B[39;49;00m
    #x1B[33m    a : ndarray or coo_array#x1B[39;49;00m
    #x1B[33m        Dense or sparse array depending on the matrix format in the#x1B[39;49;00m
    #x1B[33m        Matrix Market file.#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    Notes#x1B[39;49;00m
    #x1B[33m    -----#x1B[39;49;00m
    #x1B[33m    .. versionchanged:: 1.12.0#x1B[39;49;00m
    #x1B[33m        C++ implementation.#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    Examples#x1B[39;49;00m
    #x1B[33m    --------#x1B[39;49;00m
    #x1B[33m    >>> from io import StringIO#x1B[39;49;00m
    #x1B[33m    >>> from scipy.io import mmread#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    >>> text = '''%%MatrixMarket matrix coordinate real general#x1B[39;49;00m
    #x1B[33m    ...  5 5 7#x1B[39;49;00m
    #x1B[33m    ...  2 3 1.0#x1B[39;49;00m
    #x1B[33m    ...  3 4 2.0#x1B[39;49;00m
    #x1B[33m    ...  3 5 3.0#x1B[39;49;00m
    #x1B[33m    ...  4 1 4.0#x1B[39;49;00m
    #x1B[33m    ...  4 2 5.0#x1B[39;49;00m
    #x1B[33m    ...  4 3 6.0#x1B[39;49;00m
    #x1B[33m    ...  4 4 7.0#x1B[39;49;00m
    #x1B[33m    ... '''#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    ``mmread(source)`` returns the data as sparse array in COO format.#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    >>> m = mmread(StringIO(text), spmatrix=False)#x1B[39;49;00m
    #x1B[33m    >>> m#x1B[39;49;00m
    #x1B[33m    <COOrdinate sparse array of dtype 'float64'#x1B[39;49;00m
    #x1B[33m        with 7 stored elements and shape (5, 5)>#x1B[39;49;00m
    #x1B[33m    >>> m.toarray()#x1B[39;49;00m
    #x1B[33m    array([[0., 0., 0., 0., 0.],#x1B[39;49;00m
    #x1B[33m           [0., 0., 1., 0., 0.],#x1B[39;49;00m
    #x1B[33m           [0., 0., 0., 2., 3.],#x1B[39;49;00m
    #x1B[33m           [4., 5., 6., 7., 0.],#x1B[39;49;00m
    #x1B[33m           [0., 0., 0., 0., 0.]])#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    This method is threaded.#x1B[39;49;00m
    #x1B[33m    The default number of threads is equal to the number of CPUs in the system.#x1B[39;49;00m
    #x1B[33m    Use `threadpoolctl <https://github.com/joblib/threadpoolctl>`_ to override:#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    >>> import threadpoolctl#x1B[39;49;00m
    #x1B[33m    >>>#x1B[39;49;00m
    #x1B[33m    >>> with threadpoolctl.threadpool_limits(limits=2):#x1B[39;49;00m
    #x1B[33m    ...     m = mmread(StringIO(text), spmatrix=False)#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    """#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
        cursor, stream_to_close = _get_read_cursor(source)#x1B[90m#x1B[39;49;00m
    #x1B[90m#x1B[39;49;00m
        #x1B[94mif#x1B[39;49;00m cursor.header.format == #x1B[33m"#x1B[39;49;00m#x1B[33marray#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m:#x1B[90m#x1B[39;49;00m
            mat = _read_body_array(cursor)#x1B[90m#x1B[39;49;00m
            #x1B[94mif#x1B[39;49;00m stream_to_close:#x1B[90m#x1B[39;49;00m
                stream_to_close.close()#x1B[90m#x1B[39;49;00m
            #x1B[94mreturn#x1B[39;49;00m mat#x1B[90m#x1B[39;49;00m
        #x1B[94melse#x1B[39;49;00m:#x1B[90m#x1B[39;49;00m
            triplet, shape = _read_body_coo(cursor, generalize_symmetry=#x1B[94mTrue#x1B[39;49;00m)#x1B[90m#x1B[39;49;00m
            #x1B[94mif#x1B[39;49;00m stream_to_close:#x1B[90m#x1B[39;49;00m
                stream_to_close.close()#x1B[90m#x1B[39;49;00m
    #x1B[90m#x1B[39;49;00m
            #x1B[94mif#x1B[39;49;00m spmatrix #x1B[95mis#x1B[39;49;00m _NoValue:#x1B[90m#x1B[39;49;00m
                msg = #x1B[33m"""#x1B[39;49;00m#x1B[33mThe default value for `spmatrix` is changing to `False` in v1.20.#x1B[39;49;00m#x1B[33m#x1B[39;49;00m
    #x1B[33m             That means the default return type will be a sparse array.#x1B[39;49;00m#x1B[33m#x1B[39;49;00m
    #x1B[33m             Unless you use * instead of @, ** for matrix power, or you depend#x1B[39;49;00m#x1B[33m#x1B[39;49;00m
    #x1B[33m             on 2D shapes from e.g. `A.sum(axis=0)` it may not matter to you.#x1B[39;49;00m#x1B[33m#x1B[39;49;00m
    #x1B[33m             See the spmatrix to sparray migration guide for details.#x1B[39;49;00m#x1B[33m#x1B[39;49;00m
    #x1B[33m             https://docs.scipy..../scipy/reference/sparse.migration_to_sparray.html#x1B[39;49;00m#x1B[33m#x1B[39;49;00m
    #x1B[33m             #x1B[39;49;00m#x1B[33m"""#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
                prefixes = (os.path.dirname(#x1B[91m__file__#x1B[39;49;00m),)#x1B[90m#x1B[39;49;00m
>               warn(msg, #x1B[96mDeprecationWarning#x1B[39;49;00m, skip_file_prefixes=prefixes)#x1B[90m#x1B[39;49;00m
#x1B[1m#x1B[31mE               DeprecationWarning: The default value for `spmatrix` is changing to `False` in v1.20.#x1B[0m
#x1B[1m#x1B[31mE                            That means the default return type will be a sparse array.#x1B[0m
#x1B[1m#x1B[31mE                            Unless you use * instead of @, ** for matrix power, or you depend#x1B[0m
#x1B[1m#x1B[31mE                            on 2D shapes from e.g. `A.sum(axis=0)` it may not matter to you.#x1B[0m
#x1B[1m#x1B[31mE                            See the spmatrix to sparray migration guide for details.#x1B[0m
#x1B[1m#x1B[31mE                            https://docs.scipy..../scipy/reference/sparse.migration_to_sparray.html#x1B[0m

#x1B[1m#x1B[31m../../../..../scanpy/B9PcT7QG/hatch-test.pre/lib/python3.14.../io/_fast_matrix_market/__init__.py#x1B[0m:391: DeprecationWarning
tests/test_read_10x.py::test_read_10x_mtx_int[symbols]
Stack Traces | 0.006s run time
genes = 'symbols', col_dtypes = {'gene_ids': 'int64'}

    #x1B[0m#x1B[37m@pytest#x1B[39;49;00m.mark.parametrize(#x1B[90m#x1B[39;49;00m
        (#x1B[33m"#x1B[39;49;00m#x1B[33mgenes#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, #x1B[33m"#x1B[39;49;00m#x1B[33mcol_dtypes#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m),#x1B[90m#x1B[39;49;00m
        [#x1B[90m#x1B[39;49;00m
            pytest.param(#x1B[33m"#x1B[39;49;00m#x1B[33msymbols#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, #x1B[96mdict#x1B[39;49;00m(gene_ids=#x1B[33m"#x1B[39;49;00m#x1B[33mint64#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m), #x1B[96mid#x1B[39;49;00m=#x1B[33m"#x1B[39;49;00m#x1B[33msymbols#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m),#x1B[90m#x1B[39;49;00m
            pytest.param(#x1B[33m"#x1B[39;49;00m#x1B[33mids#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, #x1B[96mdict#x1B[39;49;00m(gene_symbols=#x1B[33m"#x1B[39;49;00m#x1B[33mstr#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m), #x1B[96mid#x1B[39;49;00m=#x1B[33m"#x1B[39;49;00m#x1B[33mids#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m),#x1B[90m#x1B[39;49;00m
        ],#x1B[90m#x1B[39;49;00m
    )#x1B[90m#x1B[39;49;00m
    #x1B[94mdef#x1B[39;49;00m#x1B[90m #x1B[39;49;00m#x1B[92mtest_read_10x_mtx_int#x1B[39;49;00m(#x1B[90m#x1B[39;49;00m
        genes: Literal[#x1B[33m"#x1B[39;49;00m#x1B[33msymbols#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, #x1B[33m"#x1B[39;49;00m#x1B[33mids#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m], col_dtypes: #x1B[96mdict#x1B[39;49;00m[#x1B[96mstr#x1B[39;49;00m, #x1B[96mstr#x1B[39;49;00m]#x1B[90m#x1B[39;49;00m
    ) -> #x1B[94mNone#x1B[39;49;00m:#x1B[90m#x1B[39;49;00m
        str_dt = #x1B[33m"#x1B[39;49;00m#x1B[33mstr#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m #x1B[94mif#x1B[39;49;00m pd.options.future.infer_string #x1B[94melse#x1B[39;49;00m #x1B[33m"#x1B[39;49;00m#x1B[33mobject#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
        col_dtypes = {k: str_dt #x1B[94mif#x1B[39;49;00m v == #x1B[33m"#x1B[39;49;00m#x1B[33mstr#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m #x1B[94melse#x1B[39;49;00m v #x1B[94mfor#x1B[39;49;00m k, v #x1B[95min#x1B[39;49;00m col_dtypes.items()}#x1B[90m#x1B[39;49;00m
    #x1B[90m#x1B[39;49;00m
>       adata = sc.read_10x_mtx(#x1B[90m#x1B[39;49;00m
            ROOT / #x1B[33m"#x1B[39;49;00m#x1B[33mint-ids#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, var_names=#x1B[33mf#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m#x1B[33mgene_#x1B[39;49;00m#x1B[33m{#x1B[39;49;00mgenes#x1B[33m}#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, compressed=#x1B[94mFalse#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
        )#x1B[90m#x1B[39;49;00m

#x1B[1m#x1B[31mtests/test_read_10x.py#x1B[0m:96: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31msrc/scanpy/readwrite.py#x1B[0m:580: in read_10x_mtx
    #x1B[0madata = _read_10x_mtx(#x1B[90m#x1B[39;49;00m
#x1B[1m#x1B[31msrc/scanpy/readwrite.py#x1B[0m:632: in _read_10x_mtx
    #x1B[0madata = read(#x1B[90m#x1B[39;49;00m
#x1B[1m#x1B[31msrc/scanpy/readwrite.py#x1B[0m:142: in read
    #x1B[0m#x1B[94mreturn#x1B[39;49;00m _read(#x1B[90m#x1B[39;49;00m
#x1B[1m#x1B[31msrc/scanpy/readwrite.py#x1B[0m:892: in _read
    #x1B[0madata = _read_mtx(filename, **kwargs)#x1B[90m#x1B[39;49;00m
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^#x1B[90m#x1B[39;49;00m
#x1B[1m#x1B[31msrc/scanpy/readwrite.py#x1B[0m:607: in _read_mtx
    #x1B[0mx = mmread(filename)#x1B[90m#x1B[39;49;00m
        ^^^^^^^^^^^^^^^^#x1B[90m#x1B[39;49;00m
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

source = PosixPath('.../10x_data/int-ids/matrix.mtx')

    #x1B[0m#x1B[94mdef#x1B[39;49;00m#x1B[90m #x1B[39;49;00m#x1B[92mmmread#x1B[39;49;00m(source, *, spmatrix=_NoValue):#x1B[90m#x1B[39;49;00m
    #x1B[90m    #x1B[39;49;00m#x1B[33m"""#x1B[39;49;00m
    #x1B[33m    Reads the contents of a Matrix Market file-like 'source' into a matrix.#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    Parameters#x1B[39;49;00m
    #x1B[33m    ----------#x1B[39;49;00m
    #x1B[33m    source : str or file-like#x1B[39;49;00m
    #x1B[33m        Matrix Market filename (extensions .mtx, .mtz.gz)#x1B[39;49;00m
    #x1B[33m        or open file-like object.#x1B[39;49;00m
    #x1B[33m    spmatrix : bool, optional (default: True)#x1B[39;49;00m
    #x1B[33m        If ``True``, return sparse matrix. Otherwise return sparse array.#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m        .. deprecated:: 1.18.0#x1B[39;49;00m
    #x1B[33m            The default value for `spmatrix` is changing to False in v1.20.#x1B[39;49;00m
    #x1B[33m            That means the default return value will be a sparse array.#x1B[39;49;00m
    #x1B[33m            Unless you use * instead of @, ** for matrix power, or you depend#x1B[39;49;00m
    #x1B[33m            on 2D shapes from e.g. ``A.sum(axis=0)`` it may not matter to you.#x1B[39;49;00m
    #x1B[33m            See :ref:`Migration from spmatrix to sparray <migration_to_sparray>`.#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    Returns#x1B[39;49;00m
    #x1B[33m    -------#x1B[39;49;00m
    #x1B[33m    a : ndarray or coo_array#x1B[39;49;00m
    #x1B[33m        Dense or sparse array depending on the matrix format in the#x1B[39;49;00m
    #x1B[33m        Matrix Market file.#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    Notes#x1B[39;49;00m
    #x1B[33m    -----#x1B[39;49;00m
    #x1B[33m    .. versionchanged:: 1.12.0#x1B[39;49;00m
    #x1B[33m        C++ implementation.#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    Examples#x1B[39;49;00m
    #x1B[33m    --------#x1B[39;49;00m
    #x1B[33m    >>> from io import StringIO#x1B[39;49;00m
    #x1B[33m    >>> from scipy.io import mmread#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    >>> text = '''%%MatrixMarket matrix coordinate real general#x1B[39;49;00m
    #x1B[33m    ...  5 5 7#x1B[39;49;00m
    #x1B[33m    ...  2 3 1.0#x1B[39;49;00m
    #x1B[33m    ...  3 4 2.0#x1B[39;49;00m
    #x1B[33m    ...  3 5 3.0#x1B[39;49;00m
    #x1B[33m    ...  4 1 4.0#x1B[39;49;00m
    #x1B[33m    ...  4 2 5.0#x1B[39;49;00m
    #x1B[33m    ...  4 3 6.0#x1B[39;49;00m
    #x1B[33m    ...  4 4 7.0#x1B[39;49;00m
    #x1B[33m    ... '''#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    ``mmread(source)`` returns the data as sparse array in COO format.#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    >>> m = mmread(StringIO(text), spmatrix=False)#x1B[39;49;00m
    #x1B[33m    >>> m#x1B[39;49;00m
    #x1B[33m    <COOrdinate sparse array of dtype 'float64'#x1B[39;49;00m
    #x1B[33m        with 7 stored elements and shape (5, 5)>#x1B[39;49;00m
    #x1B[33m    >>> m.toarray()#x1B[39;49;00m
    #x1B[33m    array([[0., 0., 0., 0., 0.],#x1B[39;49;00m
    #x1B[33m           [0., 0., 1., 0., 0.],#x1B[39;49;00m
    #x1B[33m           [0., 0., 0., 2., 3.],#x1B[39;49;00m
    #x1B[33m           [4., 5., 6., 7., 0.],#x1B[39;49;00m
    #x1B[33m           [0., 0., 0., 0., 0.]])#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    This method is threaded.#x1B[39;49;00m
    #x1B[33m    The default number of threads is equal to the number of CPUs in the system.#x1B[39;49;00m
    #x1B[33m    Use `threadpoolctl <https://github.com/joblib/threadpoolctl>`_ to override:#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    >>> import threadpoolctl#x1B[39;49;00m
    #x1B[33m    >>>#x1B[39;49;00m
    #x1B[33m    >>> with threadpoolctl.threadpool_limits(limits=2):#x1B[39;49;00m
    #x1B[33m    ...     m = mmread(StringIO(text), spmatrix=False)#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    """#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
        cursor, stream_to_close = _get_read_cursor(source)#x1B[90m#x1B[39;49;00m
    #x1B[90m#x1B[39;49;00m
        #x1B[94mif#x1B[39;49;00m cursor.header.format == #x1B[33m"#x1B[39;49;00m#x1B[33marray#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m:#x1B[90m#x1B[39;49;00m
            mat = _read_body_array(cursor)#x1B[90m#x1B[39;49;00m
            #x1B[94mif#x1B[39;49;00m stream_to_close:#x1B[90m#x1B[39;49;00m
                stream_to_close.close()#x1B[90m#x1B[39;49;00m
            #x1B[94mreturn#x1B[39;49;00m mat#x1B[90m#x1B[39;49;00m
        #x1B[94melse#x1B[39;49;00m:#x1B[90m#x1B[39;49;00m
            triplet, shape = _read_body_coo(cursor, generalize_symmetry=#x1B[94mTrue#x1B[39;49;00m)#x1B[90m#x1B[39;49;00m
            #x1B[94mif#x1B[39;49;00m stream_to_close:#x1B[90m#x1B[39;49;00m
                stream_to_close.close()#x1B[90m#x1B[39;49;00m
    #x1B[90m#x1B[39;49;00m
            #x1B[94mif#x1B[39;49;00m spmatrix #x1B[95mis#x1B[39;49;00m _NoValue:#x1B[90m#x1B[39;49;00m
                msg = #x1B[33m"""#x1B[39;49;00m#x1B[33mThe default value for `spmatrix` is changing to `False` in v1.20.#x1B[39;49;00m#x1B[33m#x1B[39;49;00m
    #x1B[33m             That means the default return type will be a sparse array.#x1B[39;49;00m#x1B[33m#x1B[39;49;00m
    #x1B[33m             Unless you use * instead of @, ** for matrix power, or you depend#x1B[39;49;00m#x1B[33m#x1B[39;49;00m
    #x1B[33m             on 2D shapes from e.g. `A.sum(axis=0)` it may not matter to you.#x1B[39;49;00m#x1B[33m#x1B[39;49;00m
    #x1B[33m             See the spmatrix to sparray migration guide for details.#x1B[39;49;00m#x1B[33m#x1B[39;49;00m
    #x1B[33m             https://docs.scipy..../scipy/reference/sparse.migration_to_sparray.html#x1B[39;49;00m#x1B[33m#x1B[39;49;00m
    #x1B[33m             #x1B[39;49;00m#x1B[33m"""#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
                prefixes = (os.path.dirname(#x1B[91m__file__#x1B[39;49;00m),)#x1B[90m#x1B[39;49;00m
>               warn(msg, #x1B[96mDeprecationWarning#x1B[39;49;00m, skip_file_prefixes=prefixes)#x1B[90m#x1B[39;49;00m
#x1B[1m#x1B[31mE               DeprecationWarning: The default value for `spmatrix` is changing to `False` in v1.20.#x1B[0m
#x1B[1m#x1B[31mE                            That means the default return type will be a sparse array.#x1B[0m
#x1B[1m#x1B[31mE                            Unless you use * instead of @, ** for matrix power, or you depend#x1B[0m
#x1B[1m#x1B[31mE                            on 2D shapes from e.g. `A.sum(axis=0)` it may not matter to you.#x1B[0m
#x1B[1m#x1B[31mE                            See the spmatrix to sparray migration guide for details.#x1B[0m
#x1B[1m#x1B[31mE                            https://docs.scipy..../scipy/reference/sparse.migration_to_sparray.html#x1B[0m

#x1B[1m#x1B[31m../../../..../scanpy/B9PcT7QG/hatch-test.pre/lib/python3.14.../io/_fast_matrix_market/__init__.py#x1B[0m:391: DeprecationWarning
tests/test_read_10x.py::test_read_10x[no_prefix-3.0.0]
Stack Traces | 0.008s run time
tmp_path = PosixPath('.../pytest-0/popen-gw0/test_read_10x_no_prefix_3_0_0_0')
mtx_path = PosixPath('.../_data/10x_data/3.0.0/filtered_feature_bc_matrix')
h5_path = PosixPath('.../_data/10x_data/3.0.0/filtered_feature_bc_matrix.h5')
prefix = None

    #x1B[0m#x1B[37m@pytest#x1B[39;49;00m.mark.parametrize(#x1B[90m#x1B[39;49;00m
        (#x1B[33m"#x1B[39;49;00m#x1B[33mmtx_path#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, #x1B[33m"#x1B[39;49;00m#x1B[33mh5_path#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m),#x1B[90m#x1B[39;49;00m
        [#x1B[90m#x1B[39;49;00m
            pytest.param(#x1B[90m#x1B[39;49;00m
                ROOT / #x1B[33m"#x1B[39;49;00m#x1B[33m1.2.0#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m / #x1B[33m"#x1B[39;49;00m#x1B[33mfiltered_gene_bc_matrices#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m / #x1B[33m"#x1B[39;49;00m#x1B[33mhg19_chr21#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m,#x1B[90m#x1B[39;49;00m
                ROOT / #x1B[33m"#x1B[39;49;00m#x1B[33m1.2.0#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m / #x1B[33m"#x1B[39;49;00m#x1B[33mfiltered_gene_bc_matrices_h5.h5#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m,#x1B[90m#x1B[39;49;00m
                #x1B[96mid#x1B[39;49;00m=#x1B[33m"#x1B[39;49;00m#x1B[33m1.2.0#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m,#x1B[90m#x1B[39;49;00m
            ),#x1B[90m#x1B[39;49;00m
            pytest.param(#x1B[90m#x1B[39;49;00m
                ROOT / #x1B[33m"#x1B[39;49;00m#x1B[33m3.0.0#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m / #x1B[33m"#x1B[39;49;00m#x1B[33mfiltered_feature_bc_matrix#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m,#x1B[90m#x1B[39;49;00m
                ROOT / #x1B[33m"#x1B[39;49;00m#x1B[33m3.0.0#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m / #x1B[33m"#x1B[39;49;00m#x1B[33mfiltered_feature_bc_matrix.h5#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m,#x1B[90m#x1B[39;49;00m
                #x1B[96mid#x1B[39;49;00m=#x1B[33m"#x1B[39;49;00m#x1B[33m3.0.0#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m,#x1B[90m#x1B[39;49;00m
            ),#x1B[90m#x1B[39;49;00m
        ],#x1B[90m#x1B[39;49;00m
    )#x1B[90m#x1B[39;49;00m
    #x1B[37m@pytest#x1B[39;49;00m.mark.parametrize(#x1B[33m"#x1B[39;49;00m#x1B[33mprefix#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, [#x1B[94mNone#x1B[39;49;00m, #x1B[33m"#x1B[39;49;00m#x1B[33mprefix_#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m], ids=[#x1B[33m"#x1B[39;49;00m#x1B[33mno_prefix#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, #x1B[33m"#x1B[39;49;00m#x1B[33mprefix#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m])#x1B[90m#x1B[39;49;00m
    #x1B[94mdef#x1B[39;49;00m#x1B[90m #x1B[39;49;00m#x1B[92mtest_read_10x#x1B[39;49;00m(#x1B[90m#x1B[39;49;00m
        tmp_path: Path, mtx_path: Path, h5_path: Path, prefix: #x1B[96mstr#x1B[39;49;00m | #x1B[94mNone#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
    ) -> #x1B[94mNone#x1B[39;49;00m:#x1B[90m#x1B[39;49;00m
        #x1B[94mif#x1B[39;49;00m prefix #x1B[95mis#x1B[39;49;00m #x1B[95mnot#x1B[39;49;00m #x1B[94mNone#x1B[39;49;00m:#x1B[90m#x1B[39;49;00m
            #x1B[90m# Build files named "prefix_XXX.xxx" in a temporary directory.#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
            mtx_path_orig = mtx_path#x1B[90m#x1B[39;49;00m
            mtx_path = tmp_path / #x1B[33m"#x1B[39;49;00m#x1B[33mfiltered_gene_bc_matrices_prefix#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
            mtx_path.mkdir()#x1B[90m#x1B[39;49;00m
            #x1B[94mfor#x1B[39;49;00m item #x1B[95min#x1B[39;49;00m mtx_path_orig.iterdir():#x1B[90m#x1B[39;49;00m
                #x1B[94mif#x1B[39;49;00m item.is_file():#x1B[90m#x1B[39;49;00m
                    shutil.copyfile(item, mtx_path / #x1B[33mf#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m#x1B[33m{#x1B[39;49;00mprefix#x1B[33m}#x1B[39;49;00m#x1B[33m{#x1B[39;49;00mitem.name#x1B[33m}#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m)#x1B[90m#x1B[39;49;00m
    #x1B[90m#x1B[39;49;00m
>       mtx = sc.read_10x_mtx(mtx_path, var_names=#x1B[33m"#x1B[39;49;00m#x1B[33mgene_symbols#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, prefix=prefix)#x1B[90m#x1B[39;49;00m
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^#x1B[90m#x1B[39;49;00m

#x1B[1m#x1B[31mtests/test_read_10x.py#x1B[0m:60: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31msrc/scanpy/readwrite.py#x1B[0m:580: in read_10x_mtx
    #x1B[0madata = _read_10x_mtx(#x1B[90m#x1B[39;49;00m
#x1B[1m#x1B[31msrc/scanpy/readwrite.py#x1B[0m:632: in _read_10x_mtx
    #x1B[0madata = read(#x1B[90m#x1B[39;49;00m
#x1B[1m#x1B[31msrc/scanpy/readwrite.py#x1B[0m:142: in read
    #x1B[0m#x1B[94mreturn#x1B[39;49;00m _read(#x1B[90m#x1B[39;49;00m
#x1B[1m#x1B[31msrc/scanpy/readwrite.py#x1B[0m:892: in _read
    #x1B[0madata = _read_mtx(filename, **kwargs)#x1B[90m#x1B[39;49;00m
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^#x1B[90m#x1B[39;49;00m
#x1B[1m#x1B[31msrc/scanpy/readwrite.py#x1B[0m:607: in _read_mtx
    #x1B[0mx = mmread(filename)#x1B[90m#x1B[39;49;00m
        ^^^^^^^^^^^^^^^^#x1B[90m#x1B[39;49;00m
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

source = PosixPath('.../_data/10x_data/3.0.0/filtered_feature_bc_matrix/matrix.mtx.gz')

    #x1B[0m#x1B[94mdef#x1B[39;49;00m#x1B[90m #x1B[39;49;00m#x1B[92mmmread#x1B[39;49;00m(source, *, spmatrix=_NoValue):#x1B[90m#x1B[39;49;00m
    #x1B[90m    #x1B[39;49;00m#x1B[33m"""#x1B[39;49;00m
    #x1B[33m    Reads the contents of a Matrix Market file-like 'source' into a matrix.#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    Parameters#x1B[39;49;00m
    #x1B[33m    ----------#x1B[39;49;00m
    #x1B[33m    source : str or file-like#x1B[39;49;00m
    #x1B[33m        Matrix Market filename (extensions .mtx, .mtz.gz)#x1B[39;49;00m
    #x1B[33m        or open file-like object.#x1B[39;49;00m
    #x1B[33m    spmatrix : bool, optional (default: True)#x1B[39;49;00m
    #x1B[33m        If ``True``, return sparse matrix. Otherwise return sparse array.#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m        .. deprecated:: 1.18.0#x1B[39;49;00m
    #x1B[33m            The default value for `spmatrix` is changing to False in v1.20.#x1B[39;49;00m
    #x1B[33m            That means the default return value will be a sparse array.#x1B[39;49;00m
    #x1B[33m            Unless you use * instead of @, ** for matrix power, or you depend#x1B[39;49;00m
    #x1B[33m            on 2D shapes from e.g. ``A.sum(axis=0)`` it may not matter to you.#x1B[39;49;00m
    #x1B[33m            See :ref:`Migration from spmatrix to sparray <migration_to_sparray>`.#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    Returns#x1B[39;49;00m
    #x1B[33m    -------#x1B[39;49;00m
    #x1B[33m    a : ndarray or coo_array#x1B[39;49;00m
    #x1B[33m        Dense or sparse array depending on the matrix format in the#x1B[39;49;00m
    #x1B[33m        Matrix Market file.#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    Notes#x1B[39;49;00m
    #x1B[33m    -----#x1B[39;49;00m
    #x1B[33m    .. versionchanged:: 1.12.0#x1B[39;49;00m
    #x1B[33m        C++ implementation.#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    Examples#x1B[39;49;00m
    #x1B[33m    --------#x1B[39;49;00m
    #x1B[33m    >>> from io import StringIO#x1B[39;49;00m
    #x1B[33m    >>> from scipy.io import mmread#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    >>> text = '''%%MatrixMarket matrix coordinate real general#x1B[39;49;00m
    #x1B[33m    ...  5 5 7#x1B[39;49;00m
    #x1B[33m    ...  2 3 1.0#x1B[39;49;00m
    #x1B[33m    ...  3 4 2.0#x1B[39;49;00m
    #x1B[33m    ...  3 5 3.0#x1B[39;49;00m
    #x1B[33m    ...  4 1 4.0#x1B[39;49;00m
    #x1B[33m    ...  4 2 5.0#x1B[39;49;00m
    #x1B[33m    ...  4 3 6.0#x1B[39;49;00m
    #x1B[33m    ...  4 4 7.0#x1B[39;49;00m
    #x1B[33m    ... '''#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    ``mmread(source)`` returns the data as sparse array in COO format.#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    >>> m = mmread(StringIO(text), spmatrix=False)#x1B[39;49;00m
    #x1B[33m    >>> m#x1B[39;49;00m
    #x1B[33m    <COOrdinate sparse array of dtype 'float64'#x1B[39;49;00m
    #x1B[33m        with 7 stored elements and shape (5, 5)>#x1B[39;49;00m
    #x1B[33m    >>> m.toarray()#x1B[39;49;00m
    #x1B[33m    array([[0., 0., 0., 0., 0.],#x1B[39;49;00m
    #x1B[33m           [0., 0., 1., 0., 0.],#x1B[39;49;00m
    #x1B[33m           [0., 0., 0., 2., 3.],#x1B[39;49;00m
    #x1B[33m           [4., 5., 6., 7., 0.],#x1B[39;49;00m
    #x1B[33m           [0., 0., 0., 0., 0.]])#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    This method is threaded.#x1B[39;49;00m
    #x1B[33m    The default number of threads is equal to the number of CPUs in the system.#x1B[39;49;00m
    #x1B[33m    Use `threadpoolctl <https://github.com/joblib/threadpoolctl>`_ to override:#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    >>> import threadpoolctl#x1B[39;49;00m
    #x1B[33m    >>>#x1B[39;49;00m
    #x1B[33m    >>> with threadpoolctl.threadpool_limits(limits=2):#x1B[39;49;00m
    #x1B[33m    ...     m = mmread(StringIO(text), spmatrix=False)#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    """#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
        cursor, stream_to_close = _get_read_cursor(source)#x1B[90m#x1B[39;49;00m
    #x1B[90m#x1B[39;49;00m
        #x1B[94mif#x1B[39;49;00m cursor.header.format == #x1B[33m"#x1B[39;49;00m#x1B[33marray#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m:#x1B[90m#x1B[39;49;00m
            mat = _read_body_array(cursor)#x1B[90m#x1B[39;49;00m
            #x1B[94mif#x1B[39;49;00m stream_to_close:#x1B[90m#x1B[39;49;00m
                stream_to_close.close()#x1B[90m#x1B[39;49;00m
            #x1B[94mreturn#x1B[39;49;00m mat#x1B[90m#x1B[39;49;00m
        #x1B[94melse#x1B[39;49;00m:#x1B[90m#x1B[39;49;00m
            triplet, shape = _read_body_coo(cursor, generalize_symmetry=#x1B[94mTrue#x1B[39;49;00m)#x1B[90m#x1B[39;49;00m
            #x1B[94mif#x1B[39;49;00m stream_to_close:#x1B[90m#x1B[39;49;00m
                stream_to_close.close()#x1B[90m#x1B[39;49;00m
    #x1B[90m#x1B[39;49;00m
            #x1B[94mif#x1B[39;49;00m spmatrix #x1B[95mis#x1B[39;49;00m _NoValue:#x1B[90m#x1B[39;49;00m
                msg = #x1B[33m"""#x1B[39;49;00m#x1B[33mThe default value for `spmatrix` is changing to `False` in v1.20.#x1B[39;49;00m#x1B[33m#x1B[39;49;00m
    #x1B[33m             That means the default return type will be a sparse array.#x1B[39;49;00m#x1B[33m#x1B[39;49;00m
    #x1B[33m             Unless you use * instead of @, ** for matrix power, or you depend#x1B[39;49;00m#x1B[33m#x1B[39;49;00m
    #x1B[33m             on 2D shapes from e.g. `A.sum(axis=0)` it may not matter to you.#x1B[39;49;00m#x1B[33m#x1B[39;49;00m
    #x1B[33m             See the spmatrix to sparray migration guide for details.#x1B[39;49;00m#x1B[33m#x1B[39;49;00m
    #x1B[33m             https://docs.scipy..../scipy/reference/sparse.migration_to_sparray.html#x1B[39;49;00m#x1B[33m#x1B[39;49;00m
    #x1B[33m             #x1B[39;49;00m#x1B[33m"""#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
                prefixes = (os.path.dirname(#x1B[91m__file__#x1B[39;49;00m),)#x1B[90m#x1B[39;49;00m
>               warn(msg, #x1B[96mDeprecationWarning#x1B[39;49;00m, skip_file_prefixes=prefixes)#x1B[90m#x1B[39;49;00m
#x1B[1m#x1B[31mE               DeprecationWarning: The default value for `spmatrix` is changing to `False` in v1.20.#x1B[0m
#x1B[1m#x1B[31mE                            That means the default return type will be a sparse array.#x1B[0m
#x1B[1m#x1B[31mE                            Unless you use * instead of @, ** for matrix power, or you depend#x1B[0m
#x1B[1m#x1B[31mE                            on 2D shapes from e.g. `A.sum(axis=0)` it may not matter to you.#x1B[0m
#x1B[1m#x1B[31mE                            See the spmatrix to sparray migration guide for details.#x1B[0m
#x1B[1m#x1B[31mE                            https://docs.scipy..../scipy/reference/sparse.migration_to_sparray.html#x1B[0m

#x1B[1m#x1B[31m../../../..../scanpy/B9PcT7QG/hatch-test.pre/lib/python3.14.../io/_fast_matrix_market/__init__.py#x1B[0m:391: DeprecationWarning
tests/test_read_10x.py::test_read_10x_compressed_parameter
Stack Traces | 0.008s run time
tmp_path = PosixPath('.../pytest-0/popen-gw0/test_read_10x_compressed_param0')

    #x1B[0m#x1B[94mdef#x1B[39;49;00m#x1B[90m #x1B[39;49;00m#x1B[92mtest_read_10x_compressed_parameter#x1B[39;49;00m(tmp_path):#x1B[90m#x1B[39;49;00m
    #x1B[90m    #x1B[39;49;00m#x1B[33m"""Test that the compressed parameter works correctly."""#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
        #x1B[90m# Copy test data to temp directory#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
        mtx_path_v3 = ROOT / #x1B[33m"#x1B[39;49;00m#x1B[33m3.0.0#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m / #x1B[33m"#x1B[39;49;00m#x1B[33mfiltered_feature_bc_matrix#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
        test_path = tmp_path / #x1B[33m"#x1B[39;49;00m#x1B[33mtest_compressed#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
        test_path.mkdir()#x1B[90m#x1B[39;49;00m
    #x1B[90m#x1B[39;49;00m
        #x1B[90m# Create uncompressed copies of the compressed files#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
        #x1B[94mfor#x1B[39;49;00m file #x1B[95min#x1B[39;49;00m mtx_path_v3.glob(#x1B[33m"#x1B[39;49;00m#x1B[33m*.gz#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m):#x1B[90m#x1B[39;49;00m
            #x1B[94mimport#x1B[39;49;00m#x1B[90m #x1B[39;49;00m#x1B[04m#x1B[96mgzip#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
    #x1B[90m#x1B[39;49;00m
            #x1B[94mwith#x1B[39;49;00m gzip.open(file, #x1B[33m"#x1B[39;49;00m#x1B[33mrb#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m) #x1B[94mas#x1B[39;49;00m f_in:#x1B[90m#x1B[39;49;00m
                content = f_in.read()#x1B[90m#x1B[39;49;00m
                dest_file = test_path / file.name[:-#x1B[94m3#x1B[39;49;00m]  #x1B[90m# Removes .gz extension#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
                #x1B[94mwith#x1B[39;49;00m dest_file.open(#x1B[33m"#x1B[39;49;00m#x1B[33mwb#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m) #x1B[94mas#x1B[39;49;00m f_out:#x1B[90m#x1B[39;49;00m
                    f_out.write(content)#x1B[90m#x1B[39;49;00m
    #x1B[90m#x1B[39;49;00m
        #x1B[90m# Read the uncompressed data#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
>       adata_uncompressed = sc.read_10x_mtx(test_path, compressed=#x1B[94mFalse#x1B[39;49;00m)#x1B[90m#x1B[39;49;00m
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^#x1B[90m#x1B[39;49;00m

#x1B[1m#x1B[31mtests/test_read_10x.py#x1B[0m:233: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31msrc/scanpy/readwrite.py#x1B[0m:580: in read_10x_mtx
    #x1B[0madata = _read_10x_mtx(#x1B[90m#x1B[39;49;00m
#x1B[1m#x1B[31msrc/scanpy/readwrite.py#x1B[0m:632: in _read_10x_mtx
    #x1B[0madata = read(#x1B[90m#x1B[39;49;00m
#x1B[1m#x1B[31msrc/scanpy/readwrite.py#x1B[0m:142: in read
    #x1B[0m#x1B[94mreturn#x1B[39;49;00m _read(#x1B[90m#x1B[39;49;00m
#x1B[1m#x1B[31msrc/scanpy/readwrite.py#x1B[0m:892: in _read
    #x1B[0madata = _read_mtx(filename, **kwargs)#x1B[90m#x1B[39;49;00m
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^#x1B[90m#x1B[39;49;00m
#x1B[1m#x1B[31msrc/scanpy/readwrite.py#x1B[0m:607: in _read_mtx
    #x1B[0mx = mmread(filename)#x1B[90m#x1B[39;49;00m
        ^^^^^^^^^^^^^^^^#x1B[90m#x1B[39;49;00m
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

source = PosixPath('.../pytest-0/popen-gw0/test_read_10x_compressed_param0/test_compressed/matrix.mtx')

    #x1B[0m#x1B[94mdef#x1B[39;49;00m#x1B[90m #x1B[39;49;00m#x1B[92mmmread#x1B[39;49;00m(source, *, spmatrix=_NoValue):#x1B[90m#x1B[39;49;00m
    #x1B[90m    #x1B[39;49;00m#x1B[33m"""#x1B[39;49;00m
    #x1B[33m    Reads the contents of a Matrix Market file-like 'source' into a matrix.#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    Parameters#x1B[39;49;00m
    #x1B[33m    ----------#x1B[39;49;00m
    #x1B[33m    source : str or file-like#x1B[39;49;00m
    #x1B[33m        Matrix Market filename (extensions .mtx, .mtz.gz)#x1B[39;49;00m
    #x1B[33m        or open file-like object.#x1B[39;49;00m
    #x1B[33m    spmatrix : bool, optional (default: True)#x1B[39;49;00m
    #x1B[33m        If ``True``, return sparse matrix. Otherwise return sparse array.#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m        .. deprecated:: 1.18.0#x1B[39;49;00m
    #x1B[33m            The default value for `spmatrix` is changing to False in v1.20.#x1B[39;49;00m
    #x1B[33m            That means the default return value will be a sparse array.#x1B[39;49;00m
    #x1B[33m            Unless you use * instead of @, ** for matrix power, or you depend#x1B[39;49;00m
    #x1B[33m            on 2D shapes from e.g. ``A.sum(axis=0)`` it may not matter to you.#x1B[39;49;00m
    #x1B[33m            See :ref:`Migration from spmatrix to sparray <migration_to_sparray>`.#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    Returns#x1B[39;49;00m
    #x1B[33m    -------#x1B[39;49;00m
    #x1B[33m    a : ndarray or coo_array#x1B[39;49;00m
    #x1B[33m        Dense or sparse array depending on the matrix format in the#x1B[39;49;00m
    #x1B[33m        Matrix Market file.#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    Notes#x1B[39;49;00m
    #x1B[33m    -----#x1B[39;49;00m
    #x1B[33m    .. versionchanged:: 1.12.0#x1B[39;49;00m
    #x1B[33m        C++ implementation.#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    Examples#x1B[39;49;00m
    #x1B[33m    --------#x1B[39;49;00m
    #x1B[33m    >>> from io import StringIO#x1B[39;49;00m
    #x1B[33m    >>> from scipy.io import mmread#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    >>> text = '''%%MatrixMarket matrix coordinate real general#x1B[39;49;00m
    #x1B[33m    ...  5 5 7#x1B[39;49;00m
    #x1B[33m    ...  2 3 1.0#x1B[39;49;00m
    #x1B[33m    ...  3 4 2.0#x1B[39;49;00m
    #x1B[33m    ...  3 5 3.0#x1B[39;49;00m
    #x1B[33m    ...  4 1 4.0#x1B[39;49;00m
    #x1B[33m    ...  4 2 5.0#x1B[39;49;00m
    #x1B[33m    ...  4 3 6.0#x1B[39;49;00m
    #x1B[33m    ...  4 4 7.0#x1B[39;49;00m
    #x1B[33m    ... '''#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    ``mmread(source)`` returns the data as sparse array in COO format.#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    >>> m = mmread(StringIO(text), spmatrix=False)#x1B[39;49;00m
    #x1B[33m    >>> m#x1B[39;49;00m
    #x1B[33m    <COOrdinate sparse array of dtype 'float64'#x1B[39;49;00m
    #x1B[33m        with 7 stored elements and shape (5, 5)>#x1B[39;49;00m
    #x1B[33m    >>> m.toarray()#x1B[39;49;00m
    #x1B[33m    array([[0., 0., 0., 0., 0.],#x1B[39;49;00m
    #x1B[33m           [0., 0., 1., 0., 0.],#x1B[39;49;00m
    #x1B[33m           [0., 0., 0., 2., 3.],#x1B[39;49;00m
    #x1B[33m           [4., 5., 6., 7., 0.],#x1B[39;49;00m
    #x1B[33m           [0., 0., 0., 0., 0.]])#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    This method is threaded.#x1B[39;49;00m
    #x1B[33m    The default number of threads is equal to the number of CPUs in the system.#x1B[39;49;00m
    #x1B[33m    Use `threadpoolctl <https://github.com/joblib/threadpoolctl>`_ to override:#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    >>> import threadpoolctl#x1B[39;49;00m
    #x1B[33m    >>>#x1B[39;49;00m
    #x1B[33m    >>> with threadpoolctl.threadpool_limits(limits=2):#x1B[39;49;00m
    #x1B[33m    ...     m = mmread(StringIO(text), spmatrix=False)#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    """#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
        cursor, stream_to_close = _get_read_cursor(source)#x1B[90m#x1B[39;49;00m
    #x1B[90m#x1B[39;49;00m
        #x1B[94mif#x1B[39;49;00m cursor.header.format == #x1B[33m"#x1B[39;49;00m#x1B[33marray#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m:#x1B[90m#x1B[39;49;00m
            mat = _read_body_array(cursor)#x1B[90m#x1B[39;49;00m
            #x1B[94mif#x1B[39;49;00m stream_to_close:#x1B[90m#x1B[39;49;00m
                stream_to_close.close()#x1B[90m#x1B[39;49;00m
            #x1B[94mreturn#x1B[39;49;00m mat#x1B[90m#x1B[39;49;00m
        #x1B[94melse#x1B[39;49;00m:#x1B[90m#x1B[39;49;00m
            triplet, shape = _read_body_coo(cursor, generalize_symmetry=#x1B[94mTrue#x1B[39;49;00m)#x1B[90m#x1B[39;49;00m
            #x1B[94mif#x1B[39;49;00m stream_to_close:#x1B[90m#x1B[39;49;00m
                stream_to_close.close()#x1B[90m#x1B[39;49;00m
    #x1B[90m#x1B[39;49;00m
            #x1B[94mif#x1B[39;49;00m spmatrix #x1B[95mis#x1B[39;49;00m _NoValue:#x1B[90m#x1B[39;49;00m
                msg = #x1B[33m"""#x1B[39;49;00m#x1B[33mThe default value for `spmatrix` is changing to `False` in v1.20.#x1B[39;49;00m#x1B[33m#x1B[39;49;00m
    #x1B[33m             That means the default return type will be a sparse array.#x1B[39;49;00m#x1B[33m#x1B[39;49;00m
    #x1B[33m             Unless you use * instead of @, ** for matrix power, or you depend#x1B[39;49;00m#x1B[33m#x1B[39;49;00m
    #x1B[33m             on 2D shapes from e.g. `A.sum(axis=0)` it may not matter to you.#x1B[39;49;00m#x1B[33m#x1B[39;49;00m
    #x1B[33m             See the spmatrix to sparray migration guide for details.#x1B[39;49;00m#x1B[33m#x1B[39;49;00m
    #x1B[33m             https://docs.scipy..../scipy/reference/sparse.migration_to_sparray.html#x1B[39;49;00m#x1B[33m#x1B[39;49;00m
    #x1B[33m             #x1B[39;49;00m#x1B[33m"""#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
                prefixes = (os.path.dirname(#x1B[91m__file__#x1B[39;49;00m),)#x1B[90m#x1B[39;49;00m
>               warn(msg, #x1B[96mDeprecationWarning#x1B[39;49;00m, skip_file_prefixes=prefixes)#x1B[90m#x1B[39;49;00m
#x1B[1m#x1B[31mE               DeprecationWarning: The default value for `spmatrix` is changing to `False` in v1.20.#x1B[0m
#x1B[1m#x1B[31mE                            That means the default return type will be a sparse array.#x1B[0m
#x1B[1m#x1B[31mE                            Unless you use * instead of @, ** for matrix power, or you depend#x1B[0m
#x1B[1m#x1B[31mE                            on 2D shapes from e.g. `A.sum(axis=0)` it may not matter to you.#x1B[0m
#x1B[1m#x1B[31mE                            See the spmatrix to sparray migration guide for details.#x1B[0m
#x1B[1m#x1B[31mE                            https://docs.scipy..../scipy/reference/sparse.migration_to_sparray.html#x1B[0m

#x1B[1m#x1B[31m../../../..../scanpy/B9PcT7QG/hatch-test.pre/lib/python3.14.../io/_fast_matrix_market/__init__.py#x1B[0m:391: DeprecationWarning
tests/test_read_10x.py::test_read_10x[prefix-3.0.0]
Stack Traces | 0.009s run time
tmp_path = PosixPath('.../pytest-0/popen-gw0/test_read_10x_prefix_3_0_0_0')
mtx_path = PosixPath('.../pytest-0/popen-gw0/test_read_10x_prefix_3_0_0_0/filtered_gene_bc_matrices_prefix')
h5_path = PosixPath('.../_data/10x_data/3.0.0/filtered_feature_bc_matrix.h5')
prefix = 'prefix_'

    #x1B[0m#x1B[37m@pytest#x1B[39;49;00m.mark.parametrize(#x1B[90m#x1B[39;49;00m
        (#x1B[33m"#x1B[39;49;00m#x1B[33mmtx_path#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, #x1B[33m"#x1B[39;49;00m#x1B[33mh5_path#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m),#x1B[90m#x1B[39;49;00m
        [#x1B[90m#x1B[39;49;00m
            pytest.param(#x1B[90m#x1B[39;49;00m
                ROOT / #x1B[33m"#x1B[39;49;00m#x1B[33m1.2.0#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m / #x1B[33m"#x1B[39;49;00m#x1B[33mfiltered_gene_bc_matrices#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m / #x1B[33m"#x1B[39;49;00m#x1B[33mhg19_chr21#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m,#x1B[90m#x1B[39;49;00m
                ROOT / #x1B[33m"#x1B[39;49;00m#x1B[33m1.2.0#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m / #x1B[33m"#x1B[39;49;00m#x1B[33mfiltered_gene_bc_matrices_h5.h5#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m,#x1B[90m#x1B[39;49;00m
                #x1B[96mid#x1B[39;49;00m=#x1B[33m"#x1B[39;49;00m#x1B[33m1.2.0#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m,#x1B[90m#x1B[39;49;00m
            ),#x1B[90m#x1B[39;49;00m
            pytest.param(#x1B[90m#x1B[39;49;00m
                ROOT / #x1B[33m"#x1B[39;49;00m#x1B[33m3.0.0#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m / #x1B[33m"#x1B[39;49;00m#x1B[33mfiltered_feature_bc_matrix#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m,#x1B[90m#x1B[39;49;00m
                ROOT / #x1B[33m"#x1B[39;49;00m#x1B[33m3.0.0#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m / #x1B[33m"#x1B[39;49;00m#x1B[33mfiltered_feature_bc_matrix.h5#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m,#x1B[90m#x1B[39;49;00m
                #x1B[96mid#x1B[39;49;00m=#x1B[33m"#x1B[39;49;00m#x1B[33m3.0.0#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m,#x1B[90m#x1B[39;49;00m
            ),#x1B[90m#x1B[39;49;00m
        ],#x1B[90m#x1B[39;49;00m
    )#x1B[90m#x1B[39;49;00m
    #x1B[37m@pytest#x1B[39;49;00m.mark.parametrize(#x1B[33m"#x1B[39;49;00m#x1B[33mprefix#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, [#x1B[94mNone#x1B[39;49;00m, #x1B[33m"#x1B[39;49;00m#x1B[33mprefix_#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m], ids=[#x1B[33m"#x1B[39;49;00m#x1B[33mno_prefix#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, #x1B[33m"#x1B[39;49;00m#x1B[33mprefix#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m])#x1B[90m#x1B[39;49;00m
    #x1B[94mdef#x1B[39;49;00m#x1B[90m #x1B[39;49;00m#x1B[92mtest_read_10x#x1B[39;49;00m(#x1B[90m#x1B[39;49;00m
        tmp_path: Path, mtx_path: Path, h5_path: Path, prefix: #x1B[96mstr#x1B[39;49;00m | #x1B[94mNone#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
    ) -> #x1B[94mNone#x1B[39;49;00m:#x1B[90m#x1B[39;49;00m
        #x1B[94mif#x1B[39;49;00m prefix #x1B[95mis#x1B[39;49;00m #x1B[95mnot#x1B[39;49;00m #x1B[94mNone#x1B[39;49;00m:#x1B[90m#x1B[39;49;00m
            #x1B[90m# Build files named "prefix_XXX.xxx" in a temporary directory.#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
            mtx_path_orig = mtx_path#x1B[90m#x1B[39;49;00m
            mtx_path = tmp_path / #x1B[33m"#x1B[39;49;00m#x1B[33mfiltered_gene_bc_matrices_prefix#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
            mtx_path.mkdir()#x1B[90m#x1B[39;49;00m
            #x1B[94mfor#x1B[39;49;00m item #x1B[95min#x1B[39;49;00m mtx_path_orig.iterdir():#x1B[90m#x1B[39;49;00m
                #x1B[94mif#x1B[39;49;00m item.is_file():#x1B[90m#x1B[39;49;00m
                    shutil.copyfile(item, mtx_path / #x1B[33mf#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m#x1B[33m{#x1B[39;49;00mprefix#x1B[33m}#x1B[39;49;00m#x1B[33m{#x1B[39;49;00mitem.name#x1B[33m}#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m)#x1B[90m#x1B[39;49;00m
    #x1B[90m#x1B[39;49;00m
>       mtx = sc.read_10x_mtx(mtx_path, var_names=#x1B[33m"#x1B[39;49;00m#x1B[33mgene_symbols#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, prefix=prefix)#x1B[90m#x1B[39;49;00m
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^#x1B[90m#x1B[39;49;00m

#x1B[1m#x1B[31mtests/test_read_10x.py#x1B[0m:60: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31msrc/scanpy/readwrite.py#x1B[0m:580: in read_10x_mtx
    #x1B[0madata = _read_10x_mtx(#x1B[90m#x1B[39;49;00m
#x1B[1m#x1B[31msrc/scanpy/readwrite.py#x1B[0m:632: in _read_10x_mtx
    #x1B[0madata = read(#x1B[90m#x1B[39;49;00m
#x1B[1m#x1B[31msrc/scanpy/readwrite.py#x1B[0m:142: in read
    #x1B[0m#x1B[94mreturn#x1B[39;49;00m _read(#x1B[90m#x1B[39;49;00m
#x1B[1m#x1B[31msrc/scanpy/readwrite.py#x1B[0m:892: in _read
    #x1B[0madata = _read_mtx(filename, **kwargs)#x1B[90m#x1B[39;49;00m
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^#x1B[90m#x1B[39;49;00m
#x1B[1m#x1B[31msrc/scanpy/readwrite.py#x1B[0m:607: in _read_mtx
    #x1B[0mx = mmread(filename)#x1B[90m#x1B[39;49;00m
        ^^^^^^^^^^^^^^^^#x1B[90m#x1B[39;49;00m
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

source = PosixPath('.../pytest-0/popen-gw0/test_read_10x_prefix_3_0_0_0/filtered_gene_bc_matrices_prefix/prefix_matrix.mtx.gz')

    #x1B[0m#x1B[94mdef#x1B[39;49;00m#x1B[90m #x1B[39;49;00m#x1B[92mmmread#x1B[39;49;00m(source, *, spmatrix=_NoValue):#x1B[90m#x1B[39;49;00m
    #x1B[90m    #x1B[39;49;00m#x1B[33m"""#x1B[39;49;00m
    #x1B[33m    Reads the contents of a Matrix Market file-like 'source' into a matrix.#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    Parameters#x1B[39;49;00m
    #x1B[33m    ----------#x1B[39;49;00m
    #x1B[33m    source : str or file-like#x1B[39;49;00m
    #x1B[33m        Matrix Market filename (extensions .mtx, .mtz.gz)#x1B[39;49;00m
    #x1B[33m        or open file-like object.#x1B[39;49;00m
    #x1B[33m    spmatrix : bool, optional (default: True)#x1B[39;49;00m
    #x1B[33m        If ``True``, return sparse matrix. Otherwise return sparse array.#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m        .. deprecated:: 1.18.0#x1B[39;49;00m
    #x1B[33m            The default value for `spmatrix` is changing to False in v1.20.#x1B[39;49;00m
    #x1B[33m            That means the default return value will be a sparse array.#x1B[39;49;00m
    #x1B[33m            Unless you use * instead of @, ** for matrix power, or you depend#x1B[39;49;00m
    #x1B[33m            on 2D shapes from e.g. ``A.sum(axis=0)`` it may not matter to you.#x1B[39;49;00m
    #x1B[33m            See :ref:`Migration from spmatrix to sparray <migration_to_sparray>`.#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    Returns#x1B[39;49;00m
    #x1B[33m    -------#x1B[39;49;00m
    #x1B[33m    a : ndarray or coo_array#x1B[39;49;00m
    #x1B[33m        Dense or sparse array depending on the matrix format in the#x1B[39;49;00m
    #x1B[33m        Matrix Market file.#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    Notes#x1B[39;49;00m
    #x1B[33m    -----#x1B[39;49;00m
    #x1B[33m    .. versionchanged:: 1.12.0#x1B[39;49;00m
    #x1B[33m        C++ implementation.#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    Examples#x1B[39;49;00m
    #x1B[33m    --------#x1B[39;49;00m
    #x1B[33m    >>> from io import StringIO#x1B[39;49;00m
    #x1B[33m    >>> from scipy.io import mmread#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    >>> text = '''%%MatrixMarket matrix coordinate real general#x1B[39;49;00m
    #x1B[33m    ...  5 5 7#x1B[39;49;00m
    #x1B[33m    ...  2 3 1.0#x1B[39;49;00m
    #x1B[33m    ...  3 4 2.0#x1B[39;49;00m
    #x1B[33m    ...  3 5 3.0#x1B[39;49;00m
    #x1B[33m    ...  4 1 4.0#x1B[39;49;00m
    #x1B[33m    ...  4 2 5.0#x1B[39;49;00m
    #x1B[33m    ...  4 3 6.0#x1B[39;49;00m
    #x1B[33m    ...  4 4 7.0#x1B[39;49;00m
    #x1B[33m    ... '''#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    ``mmread(source)`` returns the data as sparse array in COO format.#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    >>> m = mmread(StringIO(text), spmatrix=False)#x1B[39;49;00m
    #x1B[33m    >>> m#x1B[39;49;00m
    #x1B[33m    <COOrdinate sparse array of dtype 'float64'#x1B[39;49;00m
    #x1B[33m        with 7 stored elements and shape (5, 5)>#x1B[39;49;00m
    #x1B[33m    >>> m.toarray()#x1B[39;49;00m
    #x1B[33m    array([[0., 0., 0., 0., 0.],#x1B[39;49;00m
    #x1B[33m           [0., 0., 1., 0., 0.],#x1B[39;49;00m
    #x1B[33m           [0., 0., 0., 2., 3.],#x1B[39;49;00m
    #x1B[33m           [4., 5., 6., 7., 0.],#x1B[39;49;00m
    #x1B[33m           [0., 0., 0., 0., 0.]])#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    This method is threaded.#x1B[39;49;00m
    #x1B[33m    The default number of threads is equal to the number of CPUs in the system.#x1B[39;49;00m
    #x1B[33m    Use `threadpoolctl <https://github.com/joblib/threadpoolctl>`_ to override:#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    >>> import threadpoolctl#x1B[39;49;00m
    #x1B[33m    >>>#x1B[39;49;00m
    #x1B[33m    >>> with threadpoolctl.threadpool_limits(limits=2):#x1B[39;49;00m
    #x1B[33m    ...     m = mmread(StringIO(text), spmatrix=False)#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    """#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
        cursor, stream_to_close = _get_read_cursor(source)#x1B[90m#x1B[39;49;00m
    #x1B[90m#x1B[39;49;00m
        #x1B[94mif#x1B[39;49;00m cursor.header.format == #x1B[33m"#x1B[39;49;00m#x1B[33marray#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m:#x1B[90m#x1B[39;49;00m
            mat = _read_body_array(cursor)#x1B[90m#x1B[39;49;00m
            #x1B[94mif#x1B[39;49;00m stream_to_close:#x1B[90m#x1B[39;49;00m
                stream_to_close.close()#x1B[90m#x1B[39;49;00m
            #x1B[94mreturn#x1B[39;49;00m mat#x1B[90m#x1B[39;49;00m
        #x1B[94melse#x1B[39;49;00m:#x1B[90m#x1B[39;49;00m
            triplet, shape = _read_body_coo(cursor, generalize_symmetry=#x1B[94mTrue#x1B[39;49;00m)#x1B[90m#x1B[39;49;00m
            #x1B[94mif#x1B[39;49;00m stream_to_close:#x1B[90m#x1B[39;49;00m
                stream_to_close.close()#x1B[90m#x1B[39;49;00m
    #x1B[90m#x1B[39;49;00m
            #x1B[94mif#x1B[39;49;00m spmatrix #x1B[95mis#x1B[39;49;00m _NoValue:#x1B[90m#x1B[39;49;00m
                msg = #x1B[33m"""#x1B[39;49;00m#x1B[33mThe default value for `spmatrix` is changing to `False` in v1.20.#x1B[39;49;00m#x1B[33m#x1B[39;49;00m
    #x1B[33m             That means the default return type will be a sparse array.#x1B[39;49;00m#x1B[33m#x1B[39;49;00m
    #x1B[33m             Unless you use * instead of @, ** for matrix power, or you depend#x1B[39;49;00m#x1B[33m#x1B[39;49;00m
    #x1B[33m             on 2D shapes from e.g. `A.sum(axis=0)` it may not matter to you.#x1B[39;49;00m#x1B[33m#x1B[39;49;00m
    #x1B[33m             See the spmatrix to sparray migration guide for details.#x1B[39;49;00m#x1B[33m#x1B[39;49;00m
    #x1B[33m             https://docs.scipy..../scipy/reference/sparse.migration_to_sparray.html#x1B[39;49;00m#x1B[33m#x1B[39;49;00m
    #x1B[33m             #x1B[39;49;00m#x1B[33m"""#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
                prefixes = (os.path.dirname(#x1B[91m__file__#x1B[39;49;00m),)#x1B[90m#x1B[39;49;00m
>               warn(msg, #x1B[96mDeprecationWarning#x1B[39;49;00m, skip_file_prefixes=prefixes)#x1B[90m#x1B[39;49;00m
#x1B[1m#x1B[31mE               DeprecationWarning: The default value for `spmatrix` is changing to `False` in v1.20.#x1B[0m
#x1B[1m#x1B[31mE                            That means the default return type will be a sparse array.#x1B[0m
#x1B[1m#x1B[31mE                            Unless you use * instead of @, ** for matrix power, or you depend#x1B[0m
#x1B[1m#x1B[31mE                            on 2D shapes from e.g. `A.sum(axis=0)` it may not matter to you.#x1B[0m
#x1B[1m#x1B[31mE                            See the spmatrix to sparray migration guide for details.#x1B[0m
#x1B[1m#x1B[31mE                            https://docs.scipy..../scipy/reference/sparse.migration_to_sparray.html#x1B[0m

#x1B[1m#x1B[31m../../../..../scanpy/B9PcT7QG/hatch-test.pre/lib/python3.14.../io/_fast_matrix_market/__init__.py#x1B[0m:391: DeprecationWarning

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@scverse-benchmark

scverse-benchmark Bot commented Mar 26, 2026

Copy link
Copy Markdown

Benchmark changes

Change Before [4ba31e4] After [44606f0] Ratio Benchmark (Parameter)
- 2.54G 384M 0.15 preprocessing_counts.Agg.peakmem_agg('var', True)
- 2.59±0.02s 21.9±0.2ms 0.01 preprocessing_counts.Agg.time_agg('var', True)

Warning

Some benchmarks failed

Comparison: https://github.com/scverse/scanpy/compare/4ba31e4e9e53918ba74570e8754bd6f172b85a36..44606f0741e6fb6d35cfd103be4dd11e5d870354
Last changed: Fri, 5 Jun 2026 17:18:27 +0000

More details: https://github.com/scverse/scanpy/pull/4013/checks?check_run_id=79755393721

@flying-sheep flying-sheep modified the milestones: 1.12.1, 1.12.2 Apr 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants