From cc89e87292eb8a3416294745cf233ab39ebdd6ca Mon Sep 17 00:00:00 2001 From: Agisilaos Kounelis <36283973+kounelisagis@users.noreply.github.com> Date: Tue, 6 Aug 2024 16:27:16 +0300 Subject: [PATCH] Fix compilation warnings (#1940) * Fix Cython language_level not set warning * Fix 'operator==' is deprecated warning --- tiledb/cc/attribute.cc | 6 ++--- tiledb/cc/common.cc | 6 ++--- tiledb/cc/current_domain.cc | 48 ++++++++++++++++++------------------- tiledb/libtiledb.pxd | 3 +++ 4 files changed, 33 insertions(+), 30 deletions(-) diff --git a/tiledb/cc/attribute.cc b/tiledb/cc/attribute.cc index 3582aaebe6..3179ea3701 100644 --- a/tiledb/cc/attribute.cc +++ b/tiledb/cc/attribute.cc @@ -47,13 +47,13 @@ py::array get_fill_value(Attribute &attr) { auto value_num = attr.cell_val_num(); auto value_type = tdb_to_np_dtype(attr.type(), value_num); - if (py::str(value_type.attr("kind")) == py::str("V")) { + if (py::getattr(value_type, "kind").is(py::str("V"))) { return py::array(value_type, 1, value); } // If this is a complex type both cell values fit in a single complex element. - if (value_type == py::dtype("complex64") || - value_type == py::dtype("complex128")) { + if (value_type.is(py::dtype("complex64")) || + value_type.is(py::dtype("complex128"))) { return py::array(value_type, 1, value); } diff --git a/tiledb/cc/common.cc b/tiledb/cc/common.cc index 1dc7e8ea8d..9a6be60cf7 100644 --- a/tiledb/cc/common.cc +++ b/tiledb/cc/common.cc @@ -153,9 +153,9 @@ tiledb_datatype_t np_to_tdb_dtype(py::dtype type) { return _np_name_to_tdb_dtype[name]; auto kind = py::str(py::getattr(type, "kind")); - if (kind == py::str("S")) + if (kind.is(py::str("S"))) return TILEDB_STRING_ASCII; - if (kind == py::str("U")) + if (kind.is(py::str("U"))) return TILEDB_STRING_UTF8; TPY_ERROR_LOC("could not handle numpy dtype: " + @@ -192,7 +192,7 @@ bool is_tdb_str(tiledb_datatype_t type) { } py::size_t get_ncells(py::dtype type) { - if (type == py::dtype("S")) + if (type.is(py::dtype("S"))) return type.itemsize() == 0 ? TILEDB_VAR_NUM : type.itemsize(); if (type.is(py::dtype("U"))) { diff --git a/tiledb/cc/current_domain.cc b/tiledb/cc/current_domain.cc index 8bf8aac940..050ca67c3b 100644 --- a/tiledb/cc/current_domain.cc +++ b/tiledb/cc/current_domain.cc @@ -119,38 +119,38 @@ void init_current_domain(py::module &m) { .def("_range", [](NDRectangle &ndrect, const std::string &dim_name, const py::dtype &n_type) -> py::tuple { - if (n_type == py::dtype::of()) { + if (n_type.is(py::dtype::of())) { auto range = ndrect.range(dim_name); return py::make_tuple(range[0], range[1]); - } else if (n_type == py::dtype::of()) { + } else if (n_type.is(py::dtype::of())) { auto range = ndrect.range(dim_name); return py::make_tuple(range[0], range[1]); - } else if (n_type == py::dtype::of()) { + } else if (n_type.is(py::dtype::of())) { auto range = ndrect.range(dim_name); return py::make_tuple(range[0], range[1]); - } else if (n_type == py::dtype::of()) { + } else if (n_type.is(py::dtype::of())) { auto range = ndrect.range(dim_name); return py::make_tuple(range[0], range[1]); - } else if (n_type == py::dtype::of()) { + } else if (n_type.is(py::dtype::of())) { auto range = ndrect.range(dim_name); return py::make_tuple(range[0], range[1]); - } else if (n_type == py::dtype::of()) { + } else if (n_type.is(py::dtype::of())) { auto range = ndrect.range(dim_name); return py::make_tuple(range[0], range[1]); - } else if (n_type == py::dtype::of()) { + } else if (n_type.is(py::dtype::of())) { auto range = ndrect.range(dim_name); return py::make_tuple(range[0], range[1]); - } else if (n_type == py::dtype::of()) { + } else if (n_type.is(py::dtype::of())) { auto range = ndrect.range(dim_name); return py::make_tuple(range[0], range[1]); - } else if (n_type == py::dtype::of()) { + } else if (n_type.is(py::dtype::of())) { auto range = ndrect.range(dim_name); return py::make_tuple(range[0], range[1]); - } else if (n_type == py::dtype::of()) { + } else if (n_type.is(py::dtype::of())) { auto range = ndrect.range(dim_name); return py::make_tuple(range[0], range[1]); - } else if (py::str(py::getattr(n_type, "kind")) == py::str("S") || - py::str(py::getattr(n_type, "kind")) == py::str("U")) { + } else if (py::getattr(n_type, "kind").is(py::str("S")) || + py::getattr(n_type, "kind").is(py::str("U"))) { auto range = ndrect.range(dim_name); return py::make_tuple(range[0], range[1]); } else { @@ -160,38 +160,38 @@ void init_current_domain(py::module &m) { .def("_range", [](NDRectangle &ndrect, unsigned dim_idx, const py::dtype &n_type) -> py::tuple { - if (n_type == py::dtype::of()) { + if (n_type.is(py::dtype::of())) { auto range = ndrect.range(dim_idx); return py::make_tuple(range[0], range[1]); - } else if (n_type == py::dtype::of()) { + } else if (n_type.is(py::dtype::of())) { auto range = ndrect.range(dim_idx); return py::make_tuple(range[0], range[1]); - } else if (n_type == py::dtype::of()) { + } else if (n_type.is(py::dtype::of())) { auto range = ndrect.range(dim_idx); return py::make_tuple(range[0], range[1]); - } else if (n_type == py::dtype::of()) { + } else if (n_type.is(py::dtype::of())) { auto range = ndrect.range(dim_idx); return py::make_tuple(range[0], range[1]); - } else if (n_type == py::dtype::of()) { + } else if (n_type.is(py::dtype::of())) { auto range = ndrect.range(dim_idx); return py::make_tuple(range[0], range[1]); - } else if (n_type == py::dtype::of()) { + } else if (n_type.is(py::dtype::of())) { auto range = ndrect.range(dim_idx); return py::make_tuple(range[0], range[1]); - } else if (n_type == py::dtype::of()) { + } else if (n_type.is(py::dtype::of())) { auto range = ndrect.range(dim_idx); return py::make_tuple(range[0], range[1]); - } else if (n_type == py::dtype::of()) { + } else if (n_type.is(py::dtype::of())) { auto range = ndrect.range(dim_idx); return py::make_tuple(range[0], range[1]); - } else if (n_type == py::dtype::of()) { + } else if (n_type.is(py::dtype::of())) { auto range = ndrect.range(dim_idx); return py::make_tuple(range[0], range[1]); - } else if (n_type == py::dtype::of()) { + } else if (n_type.is(py::dtype::of())) { auto range = ndrect.range(dim_idx); return py::make_tuple(range[0], range[1]); - } else if (py::str(py::getattr(n_type, "kind")) == py::str("S") || - py::str(py::getattr(n_type, "kind")) == py::str("U")) { + } else if (py::getattr(n_type, "kind").is(py::str("S")) || + py::getattr(n_type, "kind").is(py::str("U"))) { auto range = ndrect.range(dim_idx); return py::make_tuple(range[0], range[1]); } else { diff --git a/tiledb/libtiledb.pxd b/tiledb/libtiledb.pxd index 2361bb8e99..e5dd980276 100644 --- a/tiledb/libtiledb.pxd +++ b/tiledb/libtiledb.pxd @@ -1,3 +1,6 @@ +#!python +#cython: language_level=3 + from libc.stdint cimport uint32_t, uint64_t from libc.stdio cimport FILE include "indexing.pxd"