Skip to content

TST: improve coverage of array.jl #10261

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

Closed
wants to merge 1 commit into from
Closed

TST: improve coverage of array.jl #10261

wants to merge 1 commit into from

Conversation

catawbasam
Copy link
Contributor

No description provided.

@catawbasam
Copy link
Contributor Author

For type-related tests, I think you want someone more comfortable with the logic of the type system (see #10255).
Shall I close this PR?

@nalimilan
Copy link
Member

No, don't worry, you'll probably get this right, and people can help you if you hesitate. Also, tests are mostly meant to catch regressions: you can start assuming that the types of the current outputs are correct.

@catawbasam
Copy link
Contributor Author

Ok, I'm hesitating and would appreciate some advice.

'===' uses pointer equality for mutable objects like arrays and strings. Given that, these results make sense:

julia> ca = complex([0,0,0],0)
3-element Array{Complex{Int64},1}:
 0+0im
 0+0im
 0+0im

julia> ca2=Complex{Int64}[0+0im, 0+0im, 0+0im]
3-element Array{Complex{Int64},1}:
 0+0im
 0+0im
 0+0im

julia> ca == ca2
true
julia> ca === ca2
false

But what is the right type check here? typeof()?

julia> ca==ca2 && typeof(ca)==typeof(ca2)
true

`

@jiahao
Copy link
Member

jiahao commented Feb 21, 2015

That was what I had in mind.

@jakebolewski
Copy link
Member

I would do all(map(is, ca, ca2)).

@catawbasam
Copy link
Contributor Author

So

julia> ca3 = Complex[0+0im, 0+0im, 0+0im]
3-element Array{Complex{T<:Real},1}:
 0+0im
 0+0im
 0+0im

julia> all(map(is, ca, ca3))
true

Implying this test would pass even if the return type of complex([0,0,0],0) changed to Array{Complex{T<:Real},1} at some point.

Or do we need ca==ca2 && typeof(ca)==typeof(ca2) && all(map(is, ca, ca2))?

EDIT: Maybe better all(map(is, ca, ca2)) && typeof(ca)==typeof(ca2)

@catawbasam
Copy link
Contributor Author

Is there an existing function that does the equivalent of all(map(is, ca, ca2)) && typeof(ca)==typeof(ca2)?
If not, maybe there should be.

@vtjnash
Copy link
Member

vtjnash commented Feb 22, 2015

i would check the arrayops.jl tests, i know there's usage of @test_approx_eq with a eps=0

@catawbasam catawbasam closed this Mar 13, 2015
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.

5 participants