Skip to content

Promote hcat vcat #158

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

Merged
merged 3 commits into from
May 11, 2017
Merged

Promote hcat vcat #158

merged 3 commits into from
May 11, 2017

Conversation

andyferris
Copy link
Member

Fixes #155. (Based on #157).

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 71.286% when pulling 83c8a1f on promote_hcat_vcat into 190aa71 on master.

@andyferris
Copy link
Member Author

Test failure was on Julia 0.7, I'm tempted to ignore it.

@inline Size(::Union{RowVector{T, SA}, Type{RowVector{T, SA}}}) where {T, SA <: StaticArray} = Size(1, Size(SA)[1])
@inline Size(::Union{RowVector{T, CA}, Type{RowVector{T, CA}}} where CA <: ConjVector{<:Any, SA}) where {T, SA <: StaticArray} = Size(1, Size(SA)[1])
Copy link
Member Author

Choose a reason for hiding this comment

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

Oops. This line of code was meant for #157. I suggest we review all changes here and just merge both (or this).

Copy link
Member

Choose a reason for hiding this comment

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

I'll review it all here.

@fredrikekre
Copy link
Member

failure looks to be this: JuliaLang/julia#21684 (comment)

Copy link
Member

@c42f c42f left a comment

Choose a reason for hiding this comment

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

Looks good. Would be worth beefing up the tests just a little.

@@ -36,11 +36,13 @@ promote_matprod{T1,T2}(::Type{T1}, ::Type{T2}) = typeof(zero(T1)*zero(T2) + zero
@inline *(A::StaticMatrix, B::StaticMatrix) = _A_mul_B(Size(A), Size(B), A, B)
@inline *(A::StaticVector, B::StaticMatrix) = *(reshape(A, Size(Size(A)[1], 1)), B)
@inline *(A::StaticVector, B::RowVector{<:Any, <:StaticVector}) = _A_mul_B(Size(A), Size(B), A, B)
@inline *(A::StaticVector, B::RowVector{<:Any, CV} where CV <: ConjVector{<:Any, <:StaticVector}) = _A_mul_B(Size(A), Size(B), A, B)
Copy link
Member

Choose a reason for hiding this comment

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

Fancy. This can also be written without the where, with B::RowVector{<:Any,<:ConjVector{<:Any,<:StaticVector}}

@test v2 * v2' === zeros(SMatrix{3, 3, Int})

v3 = zeros(SVector{3, Complex{Int}})
@test v3 * v3' === zeros(SMatrix{3, 3, Complex{Int}})
Copy link
Member

@c42f c42f May 5, 2017

Choose a reason for hiding this comment

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

Worth testing this a little more specifically, I think. With zeros, the code could do all sorts of things and these tests will still pass.

Copy link
Member Author

Choose a reason for hiding this comment

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

I can - this was meant to be a dispatch test (keeping in mind that the matrix-matrix code that this relies upon is checked thoroughly elsewhere)

Copy link
Member

Choose a reason for hiding this comment

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

I was wondering whether the _A_mul_B(::Size{sa}, ::Size{sb}, a::StaticVector{<: Any, Ta}, b::RowVector{Tb, CV} where CV <: ConjVector{<:Any, <:StaticVector}) was specifically tested?

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, it was going to a base method before and now it isn't...

Should tests test for end behaviours or specific things like which method gets invoked?

Copy link
Member

Choose a reason for hiding this comment

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

In this case, I'd test the end behaviour - the tests will be less brittle that way, and the call chain from public interface to private implementation is not complicated to follow.

In general it's a tradeoff:

  • Testing the implementation details can let you write more specific tests for smaller blocks of code. When things break, isolating the problem is easier.
  • Testing the interface lets you refactor the implementation without breaking the tests. Refactoring very detailed implementation tests can be a lot of work, and isn't much fun.

Copy link
Member

Choose a reason for hiding this comment

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

So, after all that - is this version of _A_mul_B tested elsewhere? If not, we should test this (but via the public interface) to make sure we have coverage for that code path.

@inline Size(::Union{RowVector{T, SA}, Type{RowVector{T, SA}}}) where {T, SA <: StaticArray} = Size(1, Size(SA)[1])
@inline Size(::Union{RowVector{T, CA}, Type{RowVector{T, CA}}} where CA <: ConjVector{<:Any, SA}) where {T, SA <: StaticArray} = Size(1, Size(SA)[1])
Copy link
Member

Choose a reason for hiding this comment

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

I'll review it all here.

Copy link
Member

@c42f c42f left a comment

Choose a reason for hiding this comment

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

Nice, looks good now.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.07%) to 71.381% when pulling 1605fc8 on promote_hcat_vcat into 190aa71 on master.

@andyferris andyferris merged commit 31f8be1 into master May 11, 2017
@SimonDanisch SimonDanisch deleted the promote_hcat_vcat branch May 17, 2018 10:57
oschulz pushed a commit to oschulz/StaticArrays.jl that referenced this pull request Apr 4, 2023
* Set up Documenter

* more docs, add action

* more docs

* fix Documenter script

* typo

* add to LOAD_PATH

* move doctests to runtests.jl

* interpolate types into doctest strings
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.

4 participants