Skip to content

Commit

Permalink
All compiler '#if' checks for interpreting 'format' are replaced by '…
Browse files Browse the repository at this point in the history
…dtype' now.
  • Loading branch information
jpivarski committed Jul 15, 2020
1 parent 04279be commit 216dc41
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 33 deletions.
31 changes: 10 additions & 21 deletions src/libawkward/builder/Int64Builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,27 +48,16 @@ namespace awkward {
Int64Builder::snapshot() const {
std::vector<ssize_t> shape = { (ssize_t)buffer_.length() };
std::vector<ssize_t> strides = { (ssize_t)sizeof(int64_t) };
#if defined _MSC_VER || defined __i386__
return std::make_shared<NumpyArray>(Identities::none(),
util::Parameters(),
buffer_.ptr(),
shape,
strides,
0,
sizeof(int64_t),
"q",
util::dtype::int64);
#else
return std::make_shared<NumpyArray>(Identities::none(),
util::Parameters(),
buffer_.ptr(),
shape,
strides,
0,
sizeof(int64_t),
"l",
util::dtype::int64);
#endif
return std::make_shared<NumpyArray>(
Identities::none(),
util::Parameters(),
buffer_.ptr(),
shape,
strides,
0,
sizeof(int64_t),
util::dtype_to_format(util::dtype::int64),
util::dtype::int64);
}

bool
Expand Down
15 changes: 3 additions & 12 deletions src/python/content.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -528,20 +528,11 @@ toslice_part(ak::Slice& slice, py::object obj) {
std::string format(info.format);
format.erase(0, format.find_first_not_of("@=<>!"));
if (py::isinstance<py::array>(obj) &&
format.compare("c") != 0 &&
format.compare("b") != 0 &&
format.compare("B") != 0 &&
format.compare("h") != 0 &&
format.compare("H") != 0 &&
format.compare("i") != 0 &&
format.compare("I") != 0 &&
format.compare("l") != 0 &&
format.compare("L") != 0 &&
format.compare("q") != 0 &&
format.compare("Q") != 0 &&
!ak::util::is_integer(
ak::util::format_to_dtype(format, (int64_t)info.itemsize)) &&
flatlen != 0) {
throw std::invalid_argument(
"arrays used as an index must be integer or boolean");
"arrays used as an index must be a (native-endian) integer or boolean");
}

py::object intarray_object =
Expand Down

0 comments on commit 216dc41

Please sign in to comment.