Skip to content

Commit

Permalink
fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
johnkerl committed Oct 11, 2022
1 parent 0732790 commit c15db68
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion apis/python/src/tiledbsoma/soma_dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def write(self, values: pa.Table) -> None:
if name != ROWID:
attr_cols_map[name] = np.asarray(
values.column(name).to_pandas(
types_mapper=util_arrow.tiledb_type_from_arrow_type,
types_mapper=util_arrow.tiledb_type_from_arrow_type_for_write,
)
)

Expand Down
14 changes: 14 additions & 0 deletions apis/python/src/tiledbsoma/util_arrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,20 @@
}


def tiledb_type_from_arrow_type_for_write(t: pa.DataType) -> Union[type, np.dtype, str]:
"""
Same as ``tiledb_type_from_arrow_type`` except that this is used for writing to a TileDB array.
The syntax of TileDB-Py is such that when we want to create a schema with an ASCII column,
we use the string ``"ascii"`` in place of a dtype. But when we want to write data, we need to
use a dtype of ``np.str``, which is now deprecated in favor of simply ``str``.
"""
retval = tiledb_type_from_arrow_type(t)
if retval == "ascii":
return str
else:
return retval


def tiledb_type_from_arrow_type(t: pa.DataType) -> Union[type, np.dtype, str]:
"""
Given an Arrow type, return the corresponding TileDB type as a Numpy dtype.
Expand Down
2 changes: 1 addition & 1 deletion apis/python/tools/peek-exp.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def count_obs(exp: tiledbsoma.SOMAExperiment, attr_name: str) -> None:
sys.exit(1)

cfg = tiledb.Config()
cfg["py.init_buffer_bytes"] = 4 * 1024**3
cfg["py.init_buffer_bytes"] = 4 * 1024 ** 3
ctx = tiledb.Ctx(cfg)

exp = tiledbsoma.SOMAExperiment(input_path, ctx=ctx)
Expand Down
2 changes: 1 addition & 1 deletion libtiledbsoma/test/test_query_condition.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def test_query_condition_and():

def test_query_condition_and_or():
uri = os.path.join(SOMA_URI, "obs")
condition = "(percent_mito > 0.02 and n_genes > 700) or (percent_mito < 0.015 and louvain == 'B cells')"
condition = '(percent_mito > 0.02 and n_genes > 700) or (percent_mito < 0.015 and louvain == "B cells")'

pandas = pandas_query(uri, condition)

Expand Down

0 comments on commit c15db68

Please sign in to comment.