Skip to content

Derive numpy_num_face_vertices element type from member type instead of hardcoding unsigned int#412

Merged
syoyo merged 30 commits intoreleasefrom
copilot/sub-pr-408
Mar 3, 2026
Merged

Derive numpy_num_face_vertices element type from member type instead of hardcoding unsigned int#412
syoyo merged 30 commits intoreleasefrom
copilot/sub-pr-408

Conversation

Copy link
Contributor

Copilot AI commented Feb 24, 2026

Hardcoding unsigned int in two places in numpy_num_face_vertices risks silent type mismatches if mesh_t::num_face_vertices changes type again.

Introduces a type alias T derived directly from the container's declared element type:

using T = typename std::remove_reference<decltype(instance.num_face_vertices)>::type::value_type;
auto ret = py::array_t<T>(instance.num_face_vertices.size());
memcpy(buf.ptr, instance.num_face_vertices.data(), instance.num_face_vertices.size() * sizeof(T));

Uses std::remove_reference<>::type (C++11) rather than std::remove_reference_t<> (C++14) since setup.py sets cxx_std=11.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits February 24, 2026 03:58
…gned int

Co-authored-by: paulmelnikow <1487036+paulmelnikow@users.noreply.github.com>
Co-authored-by: paulmelnikow <1487036+paulmelnikow@users.noreply.github.com>
Copilot AI changed the title [WIP] Update PR to address feedback on numpy_num_face_vertices fix Derive numpy_num_face_vertices element type from member type instead of hardcoding unsigned int Feb 24, 2026
Base automatically changed from numpy-fixes to release March 3, 2026 17:52
@syoyo syoyo marked this pull request as ready for review March 3, 2026 18:40
Copilot AI review requested due to automatic review settings March 3, 2026 18:40
@syoyo syoyo merged commit ff228a9 into release Mar 3, 2026
32 of 33 checks passed
@syoyo syoyo deleted the copilot/sub-pr-408 branch March 3, 2026 18:41
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the Python bindings to derive the NumPy array element type for mesh_t::num_face_vertices from the actual container element type, avoiding hardcoded unsigned int and reducing the risk of silent type mismatches if the C++ API changes.

Changes:

  • Derive numpy_num_face_vertices’s NumPy dtype from mesh_t::num_face_vertices::value_type instead of hardcoding unsigned int.
  • Update the memcpy size calculation to use sizeof(T) consistently.
  • Extend .gitignore to exclude additional generated/build artifacts (CodeQL, version file, egg-info, __pycache__).

Reviewed changes

Copilot reviewed 1 out of 2 changed files in this pull request and generated 1 comment.

File Description
python/bindings.cc Switch numpy_num_face_vertices to use container-derived element type T for the NumPy array and copy size.
.gitignore Add ignores for CodeQL artifacts, generated Python version file, egg-info, and __pycache__.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +152 to +153
using T = typename std::remove_reference<decltype(instance.num_face_vertices)>::type::value_type;
auto ret = py::array_t<T>(instance.num_face_vertices.size());
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

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

typename is not allowed here because this code is not in a template context (the type is non-dependent). This will fail to compile with errors like “typename specifier refers to non-dependent type”. Remove the leading typename from the alias. Also ensure <type_traits> is included since std::remove_reference is declared there (currently only <cstring> is included explicitly).

Copilot uses AI. Check for mistakes.
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.

4 participants