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

introduce function collect_as for construction from an iterator #48

Merged
merged 8 commits into from
May 1, 2024
Merged

introduce function collect_as for construction from an iterator #48

merged 8 commits into from
May 1, 2024

Conversation

nsajko
Copy link
Collaborator

@nsajko nsajko commented Apr 29, 2024

Makes constructing FixedSizeArrays more convenient!

Inspired by
JuliaLang/julia#36288

This currently ignores Base.IteratorElType, xref https://discourse.julialang.org/t/i-dont-get-base-iteratoreltype/113604

The allocations in some code paths are probably excessive/could be optimized. But I guess this is good for a start.

Fixes #20

Copy link

codecov bot commented Apr 29, 2024

Codecov Report

Attention: Patch coverage is 97.80220% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 98.36%. Comparing base (11ec2b2) to head (480cb96).

Files Patch % Lines
src/FixedSizeArrays.jl 97.80% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #48      +/-   ##
==========================================
- Coverage   98.91%   98.36%   -0.56%     
==========================================
  Files           1        1              
  Lines          92      183      +91     
==========================================
+ Hits           91      180      +89     
- Misses          1        3       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Makes constructing `FixedSizeArray`s more convenient!

Inspired by
JuliaLang/julia#36288

This currently ignores `Base.IteratorElType`, xref
https://discourse.julialang.org/t/i-dont-get-base-iteratoreltype/113604

The allocations in some code paths are probably excessive/could be
optimized. But I guess this is good for a start.

Fixes #20
Copy link
Collaborator

@giordano giordano left a comment

Choose a reason for hiding this comment

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

Since this is a new user-facing function, maybe it should be documented at least in the README? We can also set up proper docs

src/FixedSizeArrays.jl Show resolved Hide resolved
@nsajko nsajko requested a review from giordano April 30, 2024 20:30
nsajko added 3 commits May 1, 2024 06:35
One of these wasn't being recorded by code coverage (another Julia
coverage bug, I guess).
@@ -94,6 +96,41 @@ end

# helper functions

dimension_count_of(::Base.SizeUnknown) = 1
dimension_count_of(::Base.HasLength) = 1
Copy link
Collaborator

Choose a reason for hiding this comment

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

Last line still not covered (unless it's another coverage bug?)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, it's JuliaLang/julia#54214 again. I guess this form is buggy:

f(::SingletonType) = isbits_literal

Copy link
Collaborator

Choose a reason for hiding this comment

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

So it isn't just empty tuple but any singleton?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I guess 🤷

Copy link
Collaborator Author

@nsajko nsajko May 1, 2024

Choose a reason for hiding this comment

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

I did check that these lines are in actuality covered by the tests, by replacing 1 with error().

@nsajko nsajko merged commit c102065 into JuliaArrays:main May 1, 2024
6 of 8 checks passed
@nsajko nsajko deleted the collect_as branch May 1, 2024 14:45
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.

constructing a FixedSizeArray from a generator
2 participants