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

construct_seeds for types where typeof(one(T)) !=T is broken #651

Open
longemen3000 opened this issue Jun 7, 2023 · 1 comment · May be fixed by #665 or #664
Open

construct_seeds for types where typeof(one(T)) !=T is broken #651

longemen3000 opened this issue Jun 7, 2023 · 1 comment · May be fixed by #665 or #664

Comments

@longemen3000
Copy link

longemen3000 commented Jun 7, 2023

as far as i understand, the type of one(T) is not necessarily T (JuliaPhysics/Measurements.jl#134 for example). but construct_seeds uses this:

@generated function single_seed(::Type{Partials{N,V}}, ::Val{i}) where {N,V,i}
ex = Expr(:tuple, [ifelse(i === j, :(one(V)), :(zero(V))) for j in 1:N]...)
return :(Partials($(ex)))
end

Maybe using oneunit there is more correct?

@stevengj
Copy link
Contributor

stevengj commented Sep 18, 2023

If you want to get something of the same type, you should use oneunit, that's what it's for.

(e.g. for a dimensionful type, one must be dimensionless, i.e. of a different type, as otherwise it will not be a multiplicative identity.)

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