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

specialize one for FillArrays #184

Merged
merged 1 commit into from
Sep 5, 2022
Merged

Conversation

jishnub
Copy link
Member

@jishnub jishnub commented Aug 31, 2022

Fixes #173.
Now

julia> one(Ones(3,3))
3×3 Eye{Float64}

julia> one(Zeros(3,3))
3×3 Eye{Float64}

julia> one(Eye(3))
3×3 Diagonal{Float64, Fill{Float64, 1, Tuple{Base.OneTo{Int64}}}}:
 1.0        
     1.0    
         1.0

@codecov
Copy link

codecov bot commented Aug 31, 2022

Codecov Report

Merging #184 (164b0c7) into master (6ed6ec5) will increase coverage by 0.02%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #184      +/-   ##
==========================================
+ Coverage   96.95%   96.97%   +0.02%     
==========================================
  Files           4        4              
  Lines         657      662       +5     
==========================================
+ Hits          637      642       +5     
  Misses         20       20              
Impacted Files Coverage Δ
src/FillArrays.jl 95.63% <100.00%> (+0.06%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@dlfivefifty
Copy link
Member

Should this be considered breaking?

I think not since it's more of a "bug fix"

@jishnub
Copy link
Member Author

jishnub commented Sep 1, 2022

Shouldn't be breaking, since the contract of one is that the result satisfies A * one(A) == one(A) * A == A, which is unchanged. The output of one is not guaranteed to be mutable, or of a specific type.

@dlfivefifty dlfivefifty merged commit 404fbb5 into JuliaArrays:master Sep 5, 2022
@cossio
Copy link

cossio commented Sep 5, 2022

Why one(Eye(3)) is not Eye(3)?

@dlfivefifty
Copy link
Member

Can you make a PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consistently specialize one, zero on args of type Zeros, Ones, Eye
3 participants