Skip to content

Commit

Permalink
Fix compilation warnings (#1940)
Browse files Browse the repository at this point in the history
* Fix Cython language_level not set warning
* Fix 'operator==' is deprecated warning
  • Loading branch information
kounelisagis authored Aug 6, 2024
1 parent da6e93b commit cc89e87
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 30 deletions.
6 changes: 3 additions & 3 deletions tiledb/cc/attribute.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
6 changes: 3 additions & 3 deletions tiledb/cc/common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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: " +
Expand Down Expand Up @@ -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"))) {
Expand Down
48 changes: 24 additions & 24 deletions tiledb/cc/current_domain.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint64_t>()) {
if (n_type.is(py::dtype::of<uint64_t>())) {
auto range = ndrect.range<uint64_t>(dim_name);
return py::make_tuple(range[0], range[1]);
} else if (n_type == py::dtype::of<int64_t>()) {
} else if (n_type.is(py::dtype::of<int64_t>())) {
auto range = ndrect.range<int64_t>(dim_name);
return py::make_tuple(range[0], range[1]);
} else if (n_type == py::dtype::of<uint32_t>()) {
} else if (n_type.is(py::dtype::of<uint32_t>())) {
auto range = ndrect.range<uint32_t>(dim_name);
return py::make_tuple(range[0], range[1]);
} else if (n_type == py::dtype::of<int32_t>()) {
} else if (n_type.is(py::dtype::of<int32_t>())) {
auto range = ndrect.range<int32_t>(dim_name);
return py::make_tuple(range[0], range[1]);
} else if (n_type == py::dtype::of<uint16_t>()) {
} else if (n_type.is(py::dtype::of<uint16_t>())) {
auto range = ndrect.range<uint16_t>(dim_name);
return py::make_tuple(range[0], range[1]);
} else if (n_type == py::dtype::of<int16_t>()) {
} else if (n_type.is(py::dtype::of<int16_t>())) {
auto range = ndrect.range<int16_t>(dim_name);
return py::make_tuple(range[0], range[1]);
} else if (n_type == py::dtype::of<uint8_t>()) {
} else if (n_type.is(py::dtype::of<uint8_t>())) {
auto range = ndrect.range<uint8_t>(dim_name);
return py::make_tuple(range[0], range[1]);
} else if (n_type == py::dtype::of<int8_t>()) {
} else if (n_type.is(py::dtype::of<int8_t>())) {
auto range = ndrect.range<int8_t>(dim_name);
return py::make_tuple(range[0], range[1]);
} else if (n_type == py::dtype::of<double>()) {
} else if (n_type.is(py::dtype::of<double>())) {
auto range = ndrect.range<double>(dim_name);
return py::make_tuple(range[0], range[1]);
} else if (n_type == py::dtype::of<float>()) {
} else if (n_type.is(py::dtype::of<float>())) {
auto range = ndrect.range<float>(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<std::string>(dim_name);
return py::make_tuple(range[0], range[1]);
} else {
Expand All @@ -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<uint64_t>()) {
if (n_type.is(py::dtype::of<uint64_t>())) {
auto range = ndrect.range<uint64_t>(dim_idx);
return py::make_tuple(range[0], range[1]);
} else if (n_type == py::dtype::of<int64_t>()) {
} else if (n_type.is(py::dtype::of<int64_t>())) {
auto range = ndrect.range<int64_t>(dim_idx);
return py::make_tuple(range[0], range[1]);
} else if (n_type == py::dtype::of<uint32_t>()) {
} else if (n_type.is(py::dtype::of<uint32_t>())) {
auto range = ndrect.range<uint32_t>(dim_idx);
return py::make_tuple(range[0], range[1]);
} else if (n_type == py::dtype::of<int32_t>()) {
} else if (n_type.is(py::dtype::of<int32_t>())) {
auto range = ndrect.range<int32_t>(dim_idx);
return py::make_tuple(range[0], range[1]);
} else if (n_type == py::dtype::of<uint16_t>()) {
} else if (n_type.is(py::dtype::of<uint16_t>())) {
auto range = ndrect.range<uint16_t>(dim_idx);
return py::make_tuple(range[0], range[1]);
} else if (n_type == py::dtype::of<int16_t>()) {
} else if (n_type.is(py::dtype::of<int16_t>())) {
auto range = ndrect.range<int16_t>(dim_idx);
return py::make_tuple(range[0], range[1]);
} else if (n_type == py::dtype::of<uint8_t>()) {
} else if (n_type.is(py::dtype::of<uint8_t>())) {
auto range = ndrect.range<uint8_t>(dim_idx);
return py::make_tuple(range[0], range[1]);
} else if (n_type == py::dtype::of<int8_t>()) {
} else if (n_type.is(py::dtype::of<int8_t>())) {
auto range = ndrect.range<int8_t>(dim_idx);
return py::make_tuple(range[0], range[1]);
} else if (n_type == py::dtype::of<double>()) {
} else if (n_type.is(py::dtype::of<double>())) {
auto range = ndrect.range<double>(dim_idx);
return py::make_tuple(range[0], range[1]);
} else if (n_type == py::dtype::of<float>()) {
} else if (n_type.is(py::dtype::of<float>())) {
auto range = ndrect.range<float>(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<std::string>(dim_idx);
return py::make_tuple(range[0], range[1]);
} else {
Expand Down
3 changes: 3 additions & 0 deletions tiledb/libtiledb.pxd
Original file line number Diff line number Diff line change
@@ -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"
Expand Down

0 comments on commit cc89e87

Please sign in to comment.