Skip to content

Conversation

dyashuni
Copy link
Contributor

Introduced new functions get_input_array_shapes and get_input_ids_and_check_shapes to remove code duplication
Small refactoring: added spaces

@dyashuni dyashuni force-pushed the code_duplication_bindings branch from 39e97e0 to 00b434f Compare September 18, 2022 10:43
@yurymalkov
Copy link
Member

Thanks! Proposed few cosmetic changes

Copy link
Member

@yurymalkov yurymalkov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops. Forgot to send the review



inline void get_input_array_shapes(const py::buffer_info& buffer, size_t* rows, size_t* features) {
if (buffer.ndim != 2 && buffer.ndim != 1) throw std::runtime_error("data must be a 1d/2d array");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (buffer.ndim != 2 && buffer.ndim != 1) throw std::runtime_error("data must be a 1d/2d array");
if (buffer.ndim != 2 && buffer.ndim != 1) throw std::runtime_error("Input vector data wrong shape. Data must be a 1D or 2D array");

Copy link
Contributor Author

@dyashuni dyashuni Sep 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also added logging of actual number of dimensions in the error message

@dyashuni dyashuni force-pushed the code_duplication_bindings branch from 41a77e4 to 9921073 Compare September 19, 2022 17:41
@dyashuni dyashuni force-pushed the code_duplication_bindings branch from 9921073 to 97e7009 Compare September 19, 2022 17:44
Copy link
Member

@yurymalkov yurymalkov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@dyashuni dyashuni merged commit 4ab1d61 into nmslib:develop Sep 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants