Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] seqan3::views::chunk #2975

Merged
merged 17 commits into from
May 31, 2022
Merged

[FEATURE] seqan3::views::chunk #2975

merged 17 commits into from
May 31, 2022

Conversation

smehringer
Copy link
Member

@smehringer smehringer commented May 9, 2022

Implemetation should work. Doc still has to be done.

@vercel
Copy link

vercel bot commented May 9, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
seqan3 ✅ Ready (Inspect) Visit Preview May 31, 2022 at 0:36AM (UTC)

@codecov
Copy link

codecov bot commented May 9, 2022

Codecov Report

Merging #2975 (c1f75ef) into master (7e96df4) will increase coverage by 0.01%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #2975      +/-   ##
==========================================
+ Coverage   98.17%   98.19%   +0.01%     
==========================================
  Files         272      273       +1     
  Lines       11991    12119     +128     
==========================================
+ Hits        11772    11900     +128     
  Misses        219      219              
Impacted Files Coverage Δ
include/seqan3/utility/views/chunk.hpp 100.00% <100.00%> (ø)
include/seqan3/utility/views/repeat.hpp 100.00% <0.00%> (ø)
include/seqan3/utility/views/single_pass_input.hpp 100.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7e96df4...c1f75ef. Read the comment docs.

Copy link
Member

@eseiler eseiler left a comment

Choose a reason for hiding this comment

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

Could you use https://en.cppreference.com/w/cpp/ranges/view_counted for this?
But it's more or less a take_view without bounds checking, and take_view didn't work?

include/seqan3/utility/views/chunk.hpp Outdated Show resolved Hide resolved
include/seqan3/utility/views/chunk.hpp Outdated Show resolved Hide resolved
include/seqan3/utility/views/chunk.hpp Outdated Show resolved Hide resolved
include/seqan3/utility/views/chunk.hpp Outdated Show resolved Hide resolved
//!\cond
requires (!std::same_as<std::remove_cvref_t<rng_t>, chunk_view>) &&
std::ranges::viewable_range<rng_t> &&
std::constructible_from<urng_t, std::ranges::ref_view<std::remove_reference_t<rng_t>>>
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
std::constructible_from<urng_t, std::ranges::ref_view<std::remove_reference_t<rng_t>>>
std::constructible_from<urng_t, std::views::all_t<std::remove_reference_t<rng_t>>

I think?
And you don't really need it for overload resolution anyway?

Copy link
Member Author

Choose a reason for hiding this comment

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

This was copied from the kmer_hash view. I thought I don't need it for overload resolution but for checking wether the ctor is valid with the given rng_t

Copy link
Member

Choose a reason for hiding this comment

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

I see, I wonder why we have that kind of ctor. It's non-standard 😆

Copy link
Member

Choose a reason for hiding this comment

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

Do we really have a need for this ctor? It kinda seems smelly....

include/seqan3/utility/views/chunk.hpp Outdated Show resolved Hide resolved
include/seqan3/utility/views/chunk.hpp Outdated Show resolved Hide resolved
{
private:
//!\brief The iterator type of the underlying range.
using urng_it_t = maybe_const_iterator_t<const_range, urng_t>;
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
using urng_it_t = maybe_const_iterator_t<const_range, urng_t>;
using it_t = maybe_const_iterator_t<const_range, urng_t>;

It's kinda what I'd expect of it_t and you call the sentinel sentinel_t, not urng_sentinel_t.

Copy link
Contributor

Choose a reason for hiding this comment

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

still open?

include/seqan3/utility/views/chunk.hpp Outdated Show resolved Hide resolved
include/seqan3/utility/views/chunk.hpp Outdated Show resolved Hide resolved
@smehringer
Copy link
Member Author

smehringer commented May 16, 2022

Could you use https://en.cppreference.com/w/cpp/ranges/view_counted for this?
But it's more or less a take_view without bounds checking, and take_view didn't work?

Yes it's what the take_view returns anyway and it did not work because

  1. When storing a subrange{rng_begin, rng_end} | std::take(chunk_size) as value type I don't know whether the chunk was completely consumed. Calling begin on this value_type refreshes the take every time so I will consume too much. Caching the iterator on this subrange | take in another subrange was a little hacky and somehow did not work either
  2. Using a counted iterator directly would not work because I need the bound checking for the last chunk.

Copy link
Contributor

@MitraDarja MitraDarja left a comment

Choose a reason for hiding this comment

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

LGTM, but add Enrico's suggestions. :)

test/unit/utility/views/chunk_test.cpp Outdated Show resolved Hide resolved
@seqan-actions seqan-actions added lint [INTERNAL] signal for linting and removed lint [INTERNAL] signal for linting labels May 31, 2022
@seqan-actions seqan-actions added lint [INTERNAL] signal for linting and removed lint [INTERNAL] signal for linting labels May 31, 2022
@seqan-actions seqan-actions added lint [INTERNAL] signal for linting and removed lint [INTERNAL] signal for linting labels May 31, 2022
@seqan-actions seqan-actions added lint [INTERNAL] signal for linting and removed lint [INTERNAL] signal for linting labels May 31, 2022
@seqan-actions seqan-actions added lint [INTERNAL] signal for linting and removed lint [INTERNAL] signal for linting labels May 31, 2022
@smehringer smehringer merged commit 385bf6b into seqan:master May 31, 2022
@smehringer smehringer deleted the chunk_view branch October 6, 2022 10:23
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.

None yet

5 participants