@@ -189,27 +189,27 @@ end
189189function DI. value_and_derivative (
190190 f:: F , backend:: AutoForwardDiff , x, contexts:: Vararg{DI.Context,C}
191191) where {F,C}
192- y, ty = DI. value_and_pushforward (f, backend, x, (one (x),), contexts... )
192+ y, ty = DI. value_and_pushforward (f, backend, x, (oneunit (x),), contexts... )
193193 return y, only (ty)
194194end
195195
196196function DI. value_and_derivative! (
197197 f:: F , der, backend:: AutoForwardDiff , x, contexts:: Vararg{DI.Context,C}
198198) where {F,C}
199- y, _ = DI. value_and_pushforward! (f, (der,), backend, x, (one (x),), contexts... )
199+ y, _ = DI. value_and_pushforward! (f, (der,), backend, x, (oneunit (x),), contexts... )
200200 return y, der
201201end
202202
203203function DI. derivative (
204204 f:: F , backend:: AutoForwardDiff , x, contexts:: Vararg{DI.Context,C}
205205) where {F,C}
206- return only (DI. pushforward (f, backend, x, (one (x),), contexts... ))
206+ return only (DI. pushforward (f, backend, x, (oneunit (x),), contexts... ))
207207end
208208
209209function DI. derivative! (
210210 f:: F , der, backend:: AutoForwardDiff , x, contexts:: Vararg{DI.Context,C}
211211) where {F,C}
212- DI. pushforward! (f, (der,), backend, x, (one (x),), contexts... )
212+ DI. pushforward! (f, (der,), backend, x, (oneunit (x),), contexts... )
213213 return der
214214end
215215
@@ -220,7 +220,7 @@ function DI.prepare_derivative_nokwarg(
220220) where {F,C}
221221 _sig = DI. signature (f, backend, x, contexts... ; strict)
222222 pushforward_prep = DI. prepare_pushforward_nokwarg (
223- strict, f, backend, x, (one (x),), contexts...
223+ strict, f, backend, x, (oneunit (x),), contexts...
224224 )
225225 return ForwardDiffOneArgDerivativePrep (_sig, pushforward_prep)
226226end
@@ -234,7 +234,7 @@ function DI.value_and_derivative(
234234) where {F,C}
235235 DI. check_prep (f, prep, backend, x, contexts... )
236236 y, ty = DI. value_and_pushforward (
237- f, prep. pushforward_prep, backend, x, (one (x),), contexts...
237+ f, prep. pushforward_prep, backend, x, (oneunit (x),), contexts...
238238 )
239239 return y, only (ty)
240240end
@@ -249,7 +249,7 @@ function DI.value_and_derivative!(
249249) where {F,C}
250250 DI. check_prep (f, prep, backend, x, contexts... )
251251 y, _ = DI. value_and_pushforward! (
252- f, (der,), prep. pushforward_prep, backend, x, (one (x),), contexts...
252+ f, (der,), prep. pushforward_prep, backend, x, (oneunit (x),), contexts...
253253 )
254254 return y, der
255255end
@@ -263,7 +263,7 @@ function DI.derivative(
263263) where {F,C}
264264 DI. check_prep (f, prep, backend, x, contexts... )
265265 return only (
266- DI. pushforward (f, prep. pushforward_prep, backend, x, (one (x),), contexts... )
266+ DI. pushforward (f, prep. pushforward_prep, backend, x, (oneunit (x),), contexts... )
267267 )
268268end
269269
@@ -276,7 +276,9 @@ function DI.derivative!(
276276 contexts:: Vararg{DI.Context,C} ,
277277) where {F,C}
278278 DI. check_prep (f, prep, backend, x, contexts... )
279- DI. pushforward! (f, (der,), prep. pushforward_prep, backend, x, (one (x),), contexts... )
279+ DI. pushforward! (
280+ f, (der,), prep. pushforward_prep, backend, x, (oneunit (x),), contexts...
281+ )
280282 return der
281283end
282284
@@ -638,9 +640,9 @@ function DI.second_derivative(
638640) where {F,C}
639641 DI. check_prep (f, prep, backend, x, contexts... )
640642 T = tag_type (f, backend, x)
641- xdual = make_dual (T, x, one (x))
643+ xdual = make_dual (T, x, oneunit (x))
642644 T2 = tag_type (f, backend, xdual)
643- xdual2 = make_dual (T2, xdual, one (xdual))
645+ xdual2 = make_dual (T2, xdual, oneunit (xdual))
644646 contexts_dual = translate (typeof (xdual2), contexts)
645647 ydual = f (xdual2, contexts_dual... )
646648 return myderivative (T, myderivative (T2, ydual))
@@ -656,9 +658,9 @@ function DI.second_derivative!(
656658) where {F,C}
657659 DI. check_prep (f, prep, backend, x, contexts... )
658660 T = tag_type (f, backend, x)
659- xdual = make_dual (T, x, one (x))
661+ xdual = make_dual (T, x, oneunit (x))
660662 T2 = tag_type (f, backend, xdual)
661- xdual2 = make_dual (T2, xdual, one (xdual))
663+ xdual2 = make_dual (T2, xdual, oneunit (xdual))
662664 contexts_dual = translate (typeof (xdual2), contexts)
663665 ydual = f (xdual2, contexts_dual... )
664666 return myderivative! (T, der2, myderivative (T2, ydual))
@@ -673,9 +675,9 @@ function DI.value_derivative_and_second_derivative(
673675) where {F,C}
674676 DI. check_prep (f, prep, backend, x, contexts... )
675677 T = tag_type (f, backend, x)
676- xdual = make_dual (T, x, one (x))
678+ xdual = make_dual (T, x, oneunit (x))
677679 T2 = tag_type (f, backend, xdual)
678- xdual2 = make_dual (T2, xdual, one (xdual))
680+ xdual2 = make_dual (T2, xdual, oneunit (xdual))
679681 contexts_dual = translate (typeof (xdual2), contexts)
680682 ydual = f (xdual2, contexts_dual... )
681683 y = myvalue (T, myvalue (T2, ydual))
@@ -695,9 +697,9 @@ function DI.value_derivative_and_second_derivative!(
695697) where {F,C}
696698 DI. check_prep (f, prep, backend, x, contexts... )
697699 T = tag_type (f, backend, x)
698- xdual = make_dual (T, x, one (x))
700+ xdual = make_dual (T, x, oneunit (x))
699701 T2 = tag_type (f, backend, xdual)
700- xdual2 = make_dual (T2, xdual, one (xdual))
702+ xdual2 = make_dual (T2, xdual, oneunit (xdual))
701703 contexts_dual = translate (typeof (xdual2), contexts)
702704 ydual = f (xdual2, contexts_dual... )
703705 y = myvalue (T, myvalue (T2, ydual))
@@ -756,7 +758,7 @@ function DI.value_gradient_and_hessian!(
756758 contexts isa NTuple{C,DI. GeneralizedConstant}
757759 )
758760 fc = DI. fix_tail (f, map (DI. unwrap, contexts)... )
759- result = DiffResult (one (eltype (x)), (grad, hess))
761+ result = DiffResult (oneunit (eltype (x)), (grad, hess))
760762 result = hessian! (result, fc, x)
761763 y = DR. value (result)
762764 grad === DR. gradient (result) || copyto! (grad, DR. gradient (result))
@@ -855,7 +857,7 @@ function DI.value_gradient_and_hessian!(
855857 DI. check_prep (f, prep, backend, x, contexts... )
856858 contexts_dual = translate_prepared (contexts, prep. contexts_dual)
857859 fc = DI. fix_tail (f, contexts_dual... )
858- result = DiffResult (one (eltype (x)), (grad, hess))
860+ result = DiffResult (oneunit (eltype (x)), (grad, hess))
859861 CHK = tag_type (backend) === Nothing
860862 if CHK
861863 checktag (prep. result_config, f, x)
0 commit comments