FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix and refactor partition by AntoinePrv · Pull Request #2652 · xtensor-stack/xtensor · GitHub

Repository navigation

Fix and refactor partition - #2652

Merged
JohanMabille merged 10 commits into
xtensor-stack:masterfrom
AntoinePrv:fix-partition
Mar 8, 2023
Merged

JohanMabille merged 10 commits into
xtensor-stack:masterfrom
AntoinePrv:fix-partition

Conversation

Copy link
Copy Markdown
Contributor

Checklist

  • The title and commit message(s) are descriptive.
  • Small commits made to fix your PR have been squashed to avoid history pollution.
  • Tests have been added for new features or bug fixes.
  • API of new functions and classes are documented.

Description

Fix #2651 and refactor (some) of xsort.hpp.
There was a lot of duplications between different functions in this file.
This is far from what I would like to do, but still a good improvement for now!

AntoinePrv commented Feb 15, 2023 •
edited
Loading

Copy link
Copy Markdown
Contributor Author

Cmake error in CI seems unrelated.

  Could not find a package configuration file provided by "xtl" (requested
  version 0.7.5) with any of the following names:

    xtlConfig.cmake
    xtl-config.cmake

Comment thread include/xtensor/xsort.hpp Outdated
Comment thread include/xtensor/xsort.hpp Outdated
Comment thread include/xtensor/xsort.hpp Outdated
Comment thread include/xtensor/xsort.hpp Outdated
Comment thread include/xtensor/xsort.hpp

template <class E, class C, class = std::enable_if_t<!xtl::is_integral<C>::value, int>>
inline auto partition(const xexpression<E>& e, const C& kth_container, std::ptrdiff_t axis = -1)
inline auto partition(const xexpression<E>& e, C kth_container, std::ptrdiff_t axis = -1)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This signature is not consistent with the previous overload, where C is passed by const ref. Passing it by value (to avoid the hidden copy) in the previous overload should be the way to go.

Note: the same should be applied to argpartition

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

@JohanMabille Actually a copy of the kth container needs to be made in order to sort it so perhaps better to go with a universal reference.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

My point is, if you need a copy of kth_container in the implementation of partition, let's pass this argument by value so that the copy is not hidden to the user.

JohanMabille merged commit a57a6fa into xtensor-stack:master Mar 8, 2023
AntoinePrv deleted the fix-partition branch March 8, 2023 16:24
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

wrong result with xt::quantile

2 participants


Back | FazBrowse Home | New Git URL