Comments (7)
julia> sintau(convert(Int,1.0)) === zero(Int)
true
julia> sintau(convert(Float64,1.0)) === zero(Float64)
true
julia> sintau(convert(Complex,1.0)) === zero(Complex)
false
from tau.jl.
Note: this may be helped by JuliaLang/julia#20268
from tau.jl.
I don't think this is an issue:
julia> show(Base.return_types(sintau, Tuple{Complex{Float64}}))
Any[Complex{Float64}]
In addition, in PR #19 I used @inferred
in new tests, that takes care of testing type stability of the result.
from tau.jl.
Before going further, I'd like to make sure you're aware of the context of my role in this package. I am currently maintaining it due to my interest in both Julia and tau, and the original author's lack of availability to maintain the package. However, my experience programming Julia is rather superficial, so I probably won't be able to communicate with you via code snippets alone :) -- and I'll likely ask some silly questions, so bear with me.
With that said, I must say I don't completely follow what you mean with your comment above. I'd appreciate if you could expand a bit.
from tau.jl.
Ok, don't worry ;-)
I don't know exactly what Base.return_types
is supposed to do, it isn't documented, I can only guess based on its name. I simply showed that using Complex{Float64}
as input type (that is, a Complex
object with the parameter explicitly specified), the test is fine (and I added such test at https://github.com/JuliaMath/Tau.jl/pull/19/files#diff-fce720c43af3c52c862fd7451c7374b8R53). Instead, you were using Complex
without specifying the parameter, that is the collection of all Complex
types, and you can't infer a single returned type for all these input types.
In addition, in the same PR I used everywhere @inferred
, which is very useful to test type stability of the given expression. If the function wrapped by @inferred
isn't type-stable, an error is raised.
In the end, I believe this issue can be closed, as it isn't an issue at all ;-)
from tau.jl.
Thanks for the details! I had never really studied how Complex works at sufficient detail, which caused my confusion. I assumed it was a straightforward concrete type like Int
, while indeed it is more of a container type (like an array of numbers, I suppose).
To confirm that I got this right: the correct form of the Complex test in the second above would be
julia> sintau(convert(Complex,1.0)) === zero(Complex{Float64})
true
right?
In any case, yes, let's close this.
from tau.jl.
Exact! Indeed
julia> zero(Complex)
0 + 0im
julia> typeof(ans)
Complex{Int64}
julia> sintau(one(Complex))
0.0 + 0.0im
julia> typeof(ans)
Complex{Float64}
Thus, sintau(one(Complex))
and zero(Complex)
have different types, and ===
(which tests perfect equality) necessarily returns false
.
from tau.jl.
Related Issues (15)
- Add sintau, costau, modtau HOT 4
- Add examples HOT 2
- [PkgEval] Tau may have a testing issue on Julia 0.2 (2014-07-08)
- [PkgEval] Tau may have a testing issue on Julia 0.4 (2015-01-30)
- Compatibility with Julia 0.4 HOT 6
- (re)implement equality with 2pi HOT 14
- Create a script to help conversion of 2pi HOT 2
- Tests failing in julia nightly HOT 7
- Package compatibility caps HOT 8
- Missing `sincostau`
- TagBot trigger issue HOT 29
- Missing `cistau`
- Document the functions
- `sinΟ` etc. should be removed HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tau.jl.