@@ -530,14 +530,15 @@ def wrap_0_pi(theta: ArrayLike) -> Union[float, NDArray]:
530
530
:param theta: input angle
531
531
:type theta: scalar or ndarray
532
532
:return: angle wrapped into range :math:`[0, \pi)`
533
+ :rtype: scalar or ndarray
533
534
534
535
This is used to fold angles of colatitude. If zero is the angle of the
535
536
north pole, colatitude increases to :math:`\pi` at the south pole then
536
537
decreases to :math:`0` as we head back to the north pole.
537
538
538
539
:seealso: :func:`wrap_mpi2_pi2` :func:`wrap_0_2pi` :func:`wrap_mpi_pi` :func:`angle_wrap`
539
540
"""
540
- theta = np .abs (theta )
541
+ theta = np .abs (getvector ( theta ) )
541
542
n = theta / np .pi
542
543
if isinstance (n , np .ndarray ):
543
544
n = n .astype (int )
@@ -546,7 +547,7 @@ def wrap_0_pi(theta: ArrayLike) -> Union[float, NDArray]:
546
547
547
548
y = np .where (np .bitwise_and (n , 1 ) == 0 , theta - n * np .pi , (n + 1 ) * np .pi - theta )
548
549
if isinstance (y , np .ndarray ) and y .size == 1 :
549
- return float (y )
550
+ return float (y [ 0 ] )
550
551
else :
551
552
return y
552
553
@@ -558,6 +559,7 @@ def wrap_mpi2_pi2(theta: ArrayLike) -> Union[float, NDArray]:
558
559
:param theta: input angle
559
560
:type theta: scalar or ndarray
560
561
:return: angle wrapped into range :math:`[-\pi/2, \pi/2]`
562
+ :rtype: scalar or ndarray
561
563
562
564
This is used to fold angles of latitude.
563
565
@@ -573,7 +575,7 @@ def wrap_mpi2_pi2(theta: ArrayLike) -> Union[float, NDArray]:
573
575
574
576
y = np .where (np .bitwise_and (n , 1 ) == 0 , theta - n * np .pi , n * np .pi - theta )
575
577
if isinstance (y , np .ndarray ) and len (y ) == 1 :
576
- return float (y )
578
+ return float (y [ 0 ] )
577
579
else :
578
580
return y
579
581
@@ -585,13 +587,14 @@ def wrap_0_2pi(theta: ArrayLike) -> Union[float, NDArray]:
585
587
:param theta: input angle
586
588
:type theta: scalar or ndarray
587
589
:return: angle wrapped into range :math:`[0, 2\pi)`
590
+ :rtype: scalar or ndarray
588
591
589
592
:seealso: :func:`wrap_mpi_pi` :func:`wrap_0_pi` :func:`wrap_mpi2_pi2` :func:`angle_wrap`
590
593
"""
591
594
theta = getvector (theta )
592
595
y = theta - 2.0 * math .pi * np .floor (theta / 2.0 / np .pi )
593
596
if isinstance (y , np .ndarray ) and len (y ) == 1 :
594
- return float (y )
597
+ return float (y [ 0 ] )
595
598
else :
596
599
return y
597
600
@@ -603,13 +606,14 @@ def wrap_mpi_pi(theta: ArrayLike) -> Union[float, NDArray]:
603
606
:param theta: input angle
604
607
:type theta: scalar or ndarray
605
608
:return: angle wrapped into range :math:`[-\pi, \pi)`
609
+ :rtype: scalar or ndarray
606
610
607
611
:seealso: :func:`wrap_0_2pi` :func:`wrap_0_pi` :func:`wrap_mpi2_pi2` :func:`angle_wrap`
608
612
"""
609
613
theta = getvector (theta )
610
614
y = np .mod (theta + math .pi , 2 * math .pi ) - np .pi
611
615
if isinstance (y , np .ndarray ) and len (y ) == 1 :
612
- return float (y )
616
+ return float (y [ 0 ] )
613
617
else :
614
618
return y
615
619
@@ -643,6 +647,7 @@ def angdiff(a, b=None):
643
647
- ``angdiff(a, b)`` is the difference ``a - b`` wrapped to the range
644
648
:math:`[-\pi, \pi)`. This is the operator :math:`a \circleddash b` used
645
649
in the RVC book
650
+
646
651
- If ``a`` and ``b`` are both scalars, the result is scalar
647
652
- If ``a`` is array_like, the result is a NumPy array ``a[i]-b``
648
653
- If ``a`` is array_like, the result is a NumPy array ``a-b[i]``
@@ -651,6 +656,7 @@ def angdiff(a, b=None):
651
656
652
657
- ``angdiff(a)`` is the angle or vector of angles ``a`` wrapped to the range
653
658
:math:`[-\pi, \pi)`.
659
+
654
660
- If ``a`` is a scalar, the result is scalar
655
661
- If ``a`` is array_like, the result is a NumPy array
656
662
@@ -671,7 +677,7 @@ def angdiff(a, b=None):
671
677
672
678
y = np .mod (a + math .pi , 2 * math .pi ) - math .pi
673
679
if isinstance (y , np .ndarray ) and len (y ) == 1 :
674
- return float (y )
680
+ return float (y [ 0 ] )
675
681
else :
676
682
return y
677
683
0 commit comments