Repository navigation
Conversation
Several functions declared noexcept can throw an exception that xtensor raises on purpose, so the caller gets std::terminate instead of an exception it can catch: - in1d asserts that its arguments are 1D. - allclose, has_shape, transpose, imag of a real expression, meshgrid and filter read the shape of their argument. For an xfunction, the shape is computed on first use and throws broadcast_error when the operand shapes are incompatible. - begin, end and the other iterator functions of xconst_iterable and xiterable read the shape the same way. xcontiguous_iterable is now noexcept only for the layout that uses the linear iterators. - The norm functions on expressions check the reduction axes. - xgenerator::assign_to resizes the destination, and a fixed-size container asserts when the shape differs. - xscalar::operator() runs XTENSOR_CHECK_DIMENSION when dimension checks are enabled. - The xkeep_slice and xdrop_slice conversions allocate. Functions that only forward to another expression are now noexcept when the forwarded call is: xshared_expression iterators, xfunctor_applier_base::size and shape, and xconst_accessible::dimension. The xfunction constructor is noexcept when building its operands and functor cannot throw, and the converting constructor, which copies them, is no longer noexcept. The xfunction shape cache is value-initialized instead of going through make_sequence. isin captured an rvalue test container by copy. It is now moved into the lambda.
Contributor
Merging this PR will regress 1 benchmark1 warning
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist
Description
Several functions are
noexceptbut can throw an exception xtensor raises on purpose, so the caller getsstd::terminate. Most cases fail withoutXTENSOR_ENABLE_ASSERT:noexceptis removed where an exception can escape:xfunction:xconst_iterable/xiterableiterators,allclose,has_shape,transpose,imag,meshgrid,filterin1d, norms on expressions,xgenerator::assign_to,xscalar::operator()(dimension checks)xkeep_slice/xdrop_sliceconversionsForwarding functions (
xshared_expressioniterators,xfunctor_applier_base::size/shape,xconst_accessible::dimension, thexfunctionconstructor) are nownoexceptonly when the forwarded call is.isinnow moves an rvalue test container instead of copying it.Functions whose only failure is
std::bad_allocon shape-sized buffers (iterators, steppers, view constructors) keepnoexcept, following C++ Core Guidelines E.12.The new tests terminate on master and pass with the fix.