Skip to content

Commit

Permalink
Fix signed/unsigned compare warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderKalistratov committed Nov 28, 2024
1 parent 6fc7166 commit fbc94d0
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions dpnp/backend/extensions/statistics/validation_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,34 +138,37 @@ void check_num_dims(const array_ptr &arr,
const size_t ndim,
const array_names &names)
{
if (arr != nullptr && arr->get_ndim() != ndim) {
size_t arr_n_dim = arr != nullptr ? arr->get_ndim() : 0;
if (arr != nullptr && arr_n_dim != ndim) {
throw py::value_error("Array " + name_of(arr, names) + " must be " +
std::to_string(ndim) + "D, but got " +
std::to_string(arr->get_ndim()) + "D.");
std::to_string(arr_n_dim) + "D.");
}
}

void check_max_dims(const array_ptr &arr,
const size_t max_ndim,
const array_names &names)
{
if (arr != nullptr && arr->get_ndim() > max_ndim) {
size_t arr_n_dim = arr != nullptr ? arr->get_ndim() : 0;
if (arr != nullptr && arr_n_dim > max_ndim) {
throw py::value_error(
"Array " + name_of(arr, names) + " must have no more than " +
std::to_string(max_ndim) + " dimensions, but got " +
std::to_string(arr->get_ndim()) + " dimensions.");
std::to_string(arr_n_dim) + " dimensions.");
}
}

void check_size_at_least(const array_ptr &arr,
const size_t size,
const array_names &names)
{
if (arr != nullptr && arr->get_size() < size) {
size_t arr_size = arr != nullptr ? arr->get_size() : 0;
if (arr != nullptr && arr_size < size) {
throw py::value_error("Array " + name_of(arr, names) +
" must have at least " + std::to_string(size) +
" elements, but got " +
std::to_string(arr->get_size()) + " elements.");
" elements, but got " + std::to_string(arr_size) +
" elements.");
}
}

Expand Down

0 comments on commit fbc94d0

Please sign in to comment.