Skip to content

Commit

Permalink
Merge branch 'main' into jpivarski/v2-ModuleNotFoundError-message
Browse files Browse the repository at this point in the history
  • Loading branch information
jpivarski authored Nov 2, 2022
2 parents 45839f3 + 87049ac commit c92ec80
Show file tree
Hide file tree
Showing 34 changed files with 290 additions and 316 deletions.
2 changes: 1 addition & 1 deletion include/awkward/builder/UnknownBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ namespace awkward {
const BuilderOptions&
options() const { return options_; }

const int64_t nullcount() const { return nullcount_; }
int64_t nullcount() const { return nullcount_; }

private:
const BuilderOptions options_;
Expand Down
48 changes: 25 additions & 23 deletions include/awkward/io/json.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ namespace awkward {
for (int64_t i = stringsstart; i < argument3(); i++) {
start = offsets[i];
stop = offsets[i + 1];
if (strncmp(str, &chars[start], stop - start) == 0) {
if (strncmp(str, &chars[start], (size_t)(stop - start)) == 0) {
return i - stringsstart;
}
}
Expand All @@ -142,7 +142,7 @@ namespace awkward {
stringi = instructions_.data()[i * 4 + 1];
start = offsets[stringi];
stop = offsets[stringi + 1];
if (strncmp(str, &chars[start], stop - start) == 0) {
if (strncmp(str, &chars[start], (size_t)(stop - start)) == 0) {
return instructions_.data()[i * 4 + 2];
}
}
Expand All @@ -151,42 +151,42 @@ namespace awkward {

/// @brief HERE
inline void write_int8(int64_t index, int8_t x) noexcept {
buffers_uint8_[index].append(*reinterpret_cast<uint8_t*>(&x));
buffers_uint8_[(size_t)index].append(*reinterpret_cast<uint8_t*>(&x));
}

/// @brief HERE
inline void write_uint8(int64_t index, uint8_t x) noexcept {
buffers_uint8_[index].append(x);
buffers_uint8_[(size_t)index].append(x);
}

/// @brief HERE
inline void write_many_uint8(int64_t index, int64_t num_items, const uint8_t* values) noexcept {
buffers_uint8_[index].extend(values, num_items);
buffers_uint8_[(size_t)index].extend(values, (size_t)num_items);
}

/// @brief HERE
inline void write_int64(int64_t index, int64_t x) noexcept {
buffers_int64_[index].append(x);
buffers_int64_[(size_t)index].append(x);
}

/// @brief HERE
inline void write_uint64(int64_t index, uint64_t x) noexcept {
buffers_int64_[index].append(static_cast<int64_t>(x));
buffers_int64_[(size_t)index].append(static_cast<int64_t>(x));
}

/// @brief HERE
inline void write_add_int64(int64_t index, int64_t x) noexcept {
buffers_int64_[index].append(buffers_int64_[index].last() + x);
buffers_int64_[(size_t)index].append(buffers_int64_[(size_t)index].last() + x);
}

/// @brief HERE
inline void write_float64(int64_t index, double x) noexcept {
buffers_float64_[index].append(x);
buffers_float64_[(size_t)index].append(x);
}

/// @brief HERE
inline int64_t get_and_increment(int64_t index) noexcept {
return counters_[index]++;
return counters_[(size_t)index]++;
}

/// @brief HERE
Expand All @@ -204,17 +204,17 @@ namespace awkward {

/// @brief HERE
int64_t num_outputs() const {
return output_names_.size();
return (int64_t)output_names_.size();
}

/// @brief HERE
std::string output_name(int64_t i) const {
return output_names_[i];
return output_names_[(size_t)i];
}

/// @brief HERE
std::string output_dtype(int64_t i) const {
switch (output_dtypes_[i]) {
switch (output_dtypes_[(size_t)i]) {
case util::dtype::int8:
return "int8";
case util::dtype::uint8:
Expand All @@ -230,43 +230,45 @@ namespace awkward {

/// @brief HERE
int64_t output_num_items(int64_t i) const {
switch (output_dtypes_[i]) {
switch (output_dtypes_[(size_t)i]) {
case util::dtype::int8:
return buffers_uint8_[output_which_[i]].nbytes();
return (int64_t)buffers_uint8_[(size_t)output_which_[(size_t)i]].nbytes();
case util::dtype::uint8:
return buffers_uint8_[output_which_[i]].nbytes();
return (int64_t)buffers_uint8_[(size_t)output_which_[(size_t)i]].nbytes();
case util::dtype::int64:
return buffers_int64_[output_which_[i]].nbytes() / 8;
return (int64_t)buffers_int64_[(size_t)output_which_[(size_t)i]].nbytes() / 8;
case util::dtype::float64:
return buffers_float64_[output_which_[i]].nbytes() / 8;
return (int64_t)buffers_float64_[(size_t)output_which_[(size_t)i]].nbytes() / 8;
default:
return -1;
}
}

/// @brief HERE
void output_fill(int64_t i, void* external_pointer) const {
switch (output_dtypes_[i]) {
switch (output_dtypes_[(size_t)i]) {
case util::dtype::int8:
buffers_uint8_[output_which_[i]].concatenate(
buffers_uint8_[(size_t)output_which_[(size_t)i]].concatenate(
reinterpret_cast<uint8_t*>(external_pointer)
);
break;
case util::dtype::uint8:
buffers_uint8_[output_which_[i]].concatenate(
buffers_uint8_[(size_t)output_which_[(size_t)i]].concatenate(
reinterpret_cast<uint8_t*>(external_pointer)
);
break;
case util::dtype::int64:
buffers_int64_[output_which_[i]].concatenate(
buffers_int64_[(size_t)output_which_[(size_t)i]].concatenate(
reinterpret_cast<int64_t*>(external_pointer)
);
break;
case util::dtype::float64:
buffers_float64_[output_which_[i]].concatenate(
buffers_float64_[(size_t)output_which_[(size_t)i]].concatenate(
reinterpret_cast<double*>(external_pointer)
);
break;
default:
break;
}
}

Expand Down
29 changes: 3 additions & 26 deletions include/awkward/python/content.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,39 +76,16 @@ namespace {
class EmptyBuffersContainer: public ak::BuffersContainer {
public:
void*
empty_buffer(const std::string& name, int64_t num_bytes) override {
empty_buffer(const std::string& /* name */, int64_t /* num_bytes */) override {
return nullptr;
}

void
copy_buffer(const std::string& name, const void* source, int64_t num_bytes) override { }
copy_buffer(const std::string& /* name */, const void* /* source */, int64_t /* num_bytes */) override { }

void
full_buffer(const std::string& name, int64_t length, int64_t value, const std::string& dtype) override { }
full_buffer(const std::string& /* name */, int64_t /* length */, int64_t /* value */, const std::string& /* dtype */) override { }
};

/// @brief Turns the accumulated data into a Content array.
///
/// This operation only converts Builder nodes into Content nodes; the
/// buffers holding array data are shared between the Builder and the
/// Content. Hence, taking a snapshot is a constant-time operation.
///
/// It is safe to take multiple snapshots while accumulating data. The
/// shared buffers are only appended to, which affects elements beyond
/// the limited view of old snapshots.
py::object
builder_snapshot(const ak::BuilderPtr builder) {
::NumpyBuffersContainer container;
int64_t form_key_id = 0;
std::string form = builder.get()->to_buffers(container, form_key_id);
py::dict kwargs;
kwargs[py::str("form")] = py::str(form);
kwargs[py::str("length")] = py::int_(builder.get()->length());
kwargs[py::str("container")] = container.container();
kwargs[py::str("key_format")] = py::str("{form_key}-{attribute}");
kwargs[py::str("highlevel")] = py::bool_(false);
return py::module::import("awkward").attr("from_buffers")(**kwargs);
}
}

#endif // AWKWARDPY_CONTENT_H_
2 changes: 1 addition & 1 deletion include/awkward/python/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class pyobject_deleter {
}
/// @brief Called by `std::shared_ptr` when its reference count reaches
/// zero.
void operator()(T const *p) {
void operator()(T const * /* p */) {
Py_DECREF(pyobj_);
}
private:
Expand Down
4 changes: 2 additions & 2 deletions src/awkward/cpp-headers/awkward/GrowableBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ namespace awkward {
template <typename TO_PRIMITIVE>
static GrowableBuffer<TO_PRIMITIVE>
copy_as(const GrowableBuffer<PRIMITIVE>& other) {
auto len = other.length();
int64_t len = (int64_t)other.length();
int64_t actual =
(len < other.options_.initial()) ? other.options_.initial() : len;

Expand Down Expand Up @@ -383,7 +383,7 @@ namespace awkward {
void
append(PRIMITIVE datum) {
if (ptr_->current_length() == ptr_->reserved()) {
add_panel((size_t)ceil(ptr_->reserved() * options_.resize()));
add_panel((size_t)ceil((double)ptr_->reserved() * (double)options_.resize()));
}
fill_panel(datum);
}
Expand Down
34 changes: 17 additions & 17 deletions src/awkward/cpp-headers/awkward/LayoutBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ namespace awkward {

/// @brief Checks for validity and consistency.
bool
is_valid(std::string& error) const noexcept {
is_valid(std::string& /* error */) const noexcept {
return true;
}

Expand Down Expand Up @@ -286,7 +286,7 @@ namespace awkward {
/// @brief Checks for validity and consistency.
bool
is_valid(std::string& error) const noexcept {
if (content_.length() != offsets_.last()) {
if ((int64_t)content_.length() != (int64_t)offsets_.last()) {
std::stringstream out;
out << "ListOffset node" << id_ << "has content length "
<< content_.length() << "but last offset " << offsets_.last()
Expand Down Expand Up @@ -585,7 +585,7 @@ namespace awkward {
}

void
set_id(size_t& id) noexcept {}
set_id(size_t& /* id */) noexcept {}

void
clear() noexcept {}
Expand All @@ -603,18 +603,18 @@ namespace awkward {
}

void
buffer_nbytes(std::map<std::string, size_t>& names_nbytes) const
buffer_nbytes(std::map<std::string, size_t>& /* names_nbytes */) const
noexcept {}

void
to_buffers(std::map<std::string, void*>& buffers) const noexcept {}
to_buffers(std::map<std::string, void*>& /* buffers */) const noexcept {}

/// @brief Copies and concatenates all the accumulated data in the builder
/// to a map of user-allocated buffers.
///
/// The map keys and the buffer sizes are obtained from #buffer_nbytes
void
to_char_buffers(std::map<std::string, uint8_t*>& buffers) const noexcept {}
to_char_buffers(std::map<std::string, uint8_t*>& /* buffers */) const noexcept {}

/// @brief Generates a unique description of the builder and its
/// contents in the form of a JSON-like string.
Expand Down Expand Up @@ -705,11 +705,11 @@ namespace awkward {
}

void
buffer_nbytes(std::map<std::string, size_t>& names_nbytes) const
buffer_nbytes(std::map<std::string, size_t>& /* names_nbytes */) const
noexcept {}

void
to_buffers(std::map<std::string, void*>& buffers) const noexcept {}
to_buffers(std::map<std::string, void*>& /* buffers */) const noexcept {}

/// @brief Copies and concatenates all the accumulated data in the builder
/// to a map of user-allocated buffers.
Expand Down Expand Up @@ -862,7 +862,7 @@ namespace awkward {
}

/// @brief Current number of records in first field.
const size_t
size_t
length() const noexcept {
return (std::get<0>(contents).builder.length());
}
Expand All @@ -872,13 +872,13 @@ namespace awkward {
is_valid(std::string& error) const noexcept {
auto index_sequence((std::index_sequence_for<BUILDERS...>()));

size_t length = -1;
bool result = false;
int64_t length = -1;
std::vector<size_t> lengths = field_lengths(index_sequence);
for (size_t i = 0; i < lengths.size(); i++) {
if (length == -1) {
length = lengths[i];
} else if (length != lengths[i]) {
}
else if (length != (int64_t)lengths[i]) {
std::stringstream out;
out << "Record node" << id_ << " has field \""
<< field_names().at(i) << "\" length " << lengths[i]
Expand Down Expand Up @@ -1071,7 +1071,7 @@ namespace awkward {
}

/// @brief Current number of records in the first index of the tuple.
const size_t
size_t
length() const noexcept {
return (std::get<0>(contents).builder.length());
}
Expand All @@ -1081,13 +1081,13 @@ namespace awkward {
is_valid(std::string& error) const noexcept {
auto index_sequence((std::index_sequence_for<BUILDERS...>()));

size_t length = -1;
bool result = false;
int64_t length = -1;
std::vector<size_t> lengths = content_lengths(index_sequence);
for (size_t i = 0; i < lengths.size(); i++) {
if (length == -1) {
length = lengths[i];
} else if (length != lengths[i]) {
length = (int64_t)lengths[i];
}
else if (length != (int64_t)lengths[i]) {
std::stringstream out;
out << "Record node" << id_ << " has index \"" << i << "\" length "
<< lengths[i] << " that differs from the first length "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,15 @@

ERROR awkward_IndexedArray_local_preparenext_64(
int64_t* tocarry,
const int64_t* starts,
const int64_t* /* starts */, // FIXME: this argument is not needed
const int64_t* parents,
const int64_t parentslength,
const int64_t* nextparents,
const int64_t nextlen) {
int64_t j = 0;
int64_t parent = 0;
int64_t start = 0;
for (int64_t i = 0; i < parentslength; i++) {
parent = parents[i];
start = starts[parent];
if (j < nextlen && parent == nextparents[j]) {
tocarry[i] = j;
++j;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ ERROR awkward_ListArray_getitem_next_array_advanced(
const T* fromarray,
const T* fromadvanced,
int64_t lenstarts,
int64_t lenarray,
int64_t /* lenarray */, // FIXME: this argument is not needed
int64_t lencontent) {
for (int64_t i = 0; i < lenstarts; i++) {
if (fromstops[i] < fromstarts[i]) {
Expand Down
3 changes: 1 addition & 2 deletions src/cpu-kernels/awkward_ListOffsetArray_argsort_strings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ ERROR awkward_ListOffsetArray_argsort_strings_impl(
const int64_t* stringstops) {

auto sorter =
[&stringdata, &stringstarts, &stringstops](int left, int right) -> bool {
[&stringdata, &stringstarts, &stringstops](int64_t left, int64_t right) -> bool {
size_t left_n = stringstops[left] - stringstarts[left];
size_t right_n = stringstops[right] - stringstarts[right];
const char* left_str = &stringdata[stringstarts[left]];
Expand All @@ -42,7 +42,6 @@ ERROR awkward_ListOffsetArray_argsort_strings_impl(

int64_t firstindex = 0;
int64_t lastparent = -1;
int64_t k = 0;
std::vector<int64_t> index;
for (int64_t i = 0; i < length + 1; i++) {
if (i == length || fromparents[i] != lastparent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ERROR awkward_ListOffsetArray_flatten_offsets(
const C* outeroffsets,
int64_t outeroffsetslen,
const T* inneroffsets,
int64_t inneroffsetslen) {
int64_t /* inneroffsetslen */) { // FIXME: this argument is not needed
for (int64_t i = 0; i < outeroffsetslen; i++) {
tooffsets[i] =
inneroffsets[outeroffsets[i]];
Expand Down
Loading

0 comments on commit c92ec80

Please sign in to comment.