Esempio n. 1
0
    def testMath(self):
        self.subtitle(karney, 'Math')

        # compare geomath.Math.AngDiff with mimicked _diff182
        _diff = karney._diff182
        n = '%s(%%d, %%d)' % (_diff.__name__, )
        for a in range(-180, 181, 90):
            for b in range(-180, 181, 90):
                d, _ = _diff(a, b)
                x, _ = _diff(b, a)
                self.test(n % (a, b), d, -x, known=d in (0, 180))

        # compare geomath.Math.AngNormalize with mimicked _norm180
        _norm180 = karney._norm180
        n = '%s(%%s)' % (_norm180.__name__, )
        for a, x in zip(
            (-361, -360, -180, -90, -0, 0, 90, 180, 360, 361),
            (-1.0, -0.0, 180.0, -90.0, 0.0, 0.0, 90.0, 180.0, 0.0, 1.0)):
            w = _norm180(a)
            self.test(n % (a), float(w), float(x), known=w in (0, -180))
            w = wrap180(a)
            self.test(' wrap180(%s)' % (a),
                      float(w),
                      float(x),
                      known=w in (0, -180))

        # compare geomath.Math.sum with mimicked _sum2
        _fsum2_ = karney._fsum2_
        n = _fsum2_.__name__
        s, t = _fsum2_(7, 1e100, -7, -1e100, 9e-20, -8e-20)
        self.test(n, s, '1.0e-20', fmt='%.1e')
        self.test(n, t, 0.0, known=t in (NEG0, 0.0))
        # however, summation fails after some shuffling ...
        s, _ = _fsum2_(7, 1e100, 9e-20, -7, -1e100, -8e-20)
        self.test(n, s, '1.0e-20', fmt='%.1e', known=True)
        # ... but works after some other shuffling
        s, _ = _fsum2_(7, 1e100, -7, 9e-20, -1e100, -8e-20)
        self.test(n, s, '1.0e-20', fmt='%.1e', known=True)

        # Knuth/Kulisch, TAOCP, vol 2, p 245, sec 4.2.2, item 31, see also .testFmath.py
        # <https://SeriousComputerist.Atariverse.com/media/pdf/book/
        #          Art%20of%20Computer%20Programming%20-%20Volume%202%20(Seminumerical%20Algorithms).pdf>
        x = 408855776.0
        y = 708158977.0
        s, t = _fsum2_(2 * y**2, 9 * x**4, -(y**4))
        self.test(n, s, 1.0, known=True)  # -3.589050987400773e+19
        self.test(n, t, 0.0, known=t in (NEG0, 0.0))

        _unroll2 = karney._unroll2
        for lon in range(0, 361, 30):
            lon = float(lon)
            _t = _unroll2(-30.0, lon, wrap=True)
            t = unroll180(-30.0, lon, wrap=True)
            self.test('unroll', _t, t)
Esempio n. 2
0
    def testUtils(self):

        self.test('antipode1', antipode(89, 179), (-89, -1))
        self.test('antipode2', antipode(-89, -179), (89, 1))

        self.test('isantipode1', isantipode(89, 179, -89, -1), True)
        self.test('isantipode2', isantipode(-89, -179, 89, 1), True)
        self.test('isantipode3', isantipode(-89, -179, -89, -1), False)

        self.test('heightof0', heightOf(0, R_M), 2638958.23912, fmt='%.5f')
        self.test('heightof45', heightOf(45, R_M), 5401080.43931, fmt='%.5f')
        self.test('heightof90', heightOf(90, R_M), R_M)
        self.test('heightof135', heightOf(135, R_M), 5401080.43931, fmt='%.5f')

        self.test('horizon0', horizon(0), 0.0)
        self.test('horizon10Km', horizon(10000), '357099.672', fmt='%.3f')
        self.test('horizon30Kft',
                  horizon(10000, refraction=True),
                  '392310.704',
                  fmt='%.3f')
        self.test('horizon10Kft',
                  horizon(3000, refraction=True),
                  '214877.422',
                  fmt='%.3f')

        self.test('unroll180', fStr(unroll180(-90, 110, wrap=True)),
                  '-160.0, -250.0')
        self.test('unroll180', fStr(unroll180(-90, 110, wrap=False)),
                  '200.0, 110.0')

        self.test('unroll180', fStr(unroll180(-90, 830, wrap=True)),
                  '-160.0, -250.0')
        self.test('unroll180', fStr(unroll180(-90, 830, wrap=False)),
                  '920.0, 830.0')

        self.test('unroll180', fStr(unroll180(-110, 90, wrap=True)),
                  '-160.0, -270.0')
        self.test('unroll180', fStr(unroll180(-110, 90, wrap=False)),
                  '200.0, 90.0')

        self.test('unroll180', fStr(unroll180(-830, 90, wrap=True)),
                  '-160.0, -990.0')
        self.test('unroll180', fStr(unroll180(-830, 90, wrap=False)),
                  '920.0, 90.0')
Esempio n. 3
0
    def testUtily(self):

        # Python 2.6.9 on Travis Ubuntu 14.04 produces -0.0

        self.test('degrees90(PI_2)', degrees90(PI_2), 90.0)
        self.test('degrees90(PI)',   degrees90(PI), -180.0)  # XXX
        self.test('degrees90(PI2)',  degrees90(PI2),   0.0)
        self.test('degrees90(-PI_2)',    degrees90(-PI_2), -90.0)
        self.test('degrees90(-PI)',      degrees90(-PI),  -180.0)  # XXX
        self.test('degrees90(-PI2)', abs(degrees90(-PI2)),   0.0)  # -0.0

        self.test('degrees180(PI_2)', degrees180(PI_2), 90.0)
        self.test('degrees180(PI)',   degrees180(PI),  180.0)  # XXX
        self.test('degrees180(PI2)',  degrees180(PI2),   0.0)
        self.test('degrees180(-PI_2)',    degrees180(-PI_2), -90.0)
        self.test('degrees180(-PI)',      degrees180(-PI),  -180.0)  # XXX
        self.test('degrees180(-PI2)', abs(degrees180(-PI2)),   0.0)  # -0.0

        self.test('degrees360(PI_2)', degrees360(PI_2), 90.0)
        self.test('degrees360(PI)',   degrees360(PI),  180.0)  # XXX
        self.test('degrees360(PI2)',  degrees360(PI2),   0.0)
        self.test('degrees360(-PI_2)',    degrees360(-PI_2), 270.0)
        self.test('degrees360(-PI)',      degrees360(-PI),   180.0)  # XXX
        self.test('degrees360(-PI2)', abs(degrees360(-PI2)),   0.0)  # -0.0

        self.test('radiansPI_2(90)',  radiansPI_2(90), PI_2)
        self.test('radiansPI_2(180)', radiansPI_2(180), -PI)
        self.test('radiansPI_2(360)', radiansPI_2(360), 0.0)
        self.test('radiansPI_2(-90)',      radiansPI_2(-90), -PI_2)
        self.test('radiansPI_2(-180)',     radiansPI_2(-180),  -PI)
        self.test('radiansPI_2(-360)', abs(radiansPI_2(-360)), 0.0)  # -0.0

        self.test('radiansPI(90)',  radiansPI(90), PI_2)
        self.test('radiansPI(180)', radiansPI(180),  PI)
        self.test('radiansPI(360)', radiansPI(360), 0.0)
        self.test('radiansPI(-90)',      radiansPI(-90), -PI_2)
        self.test('radiansPI(-180)',     radiansPI(-180),  -PI)
        self.test('radiansPI(-360)', abs(radiansPI(-360)), 0.0)  # -0.0

        self.test('radiansPI2(90)',  radiansPI2(90), PI_2)
        self.test('radiansPI2(180)', radiansPI2(180),  PI)
        self.test('radiansPI2(360)', radiansPI2(360), 0.0)
        self.test('radiansPI2(-90)',      radiansPI2(-90), PI_2+PI)
        self.test('radiansPI2(-180)',     radiansPI2(-180),     PI)
        self.test('radiansPI2(-360)', abs(radiansPI2(-360)),   0.0)  # -0.0

        self.test('wrap90(90)',   wrap90(90),    90)
        self.test('wrap90(180)',  wrap90(180), -180)
        self.test('wrap90(360)',  wrap90(360),    0)
        self.test('wrap90(-90)',  wrap90(-90),   -90)
        self.test('wrap90(-180)', wrap90(-180), -180)
        self.test('wrap90(-360)', wrap90(-360),    0)

        self.test('wrap180(90)',   wrap180(90),   90)
        self.test('wrap180(180)',  wrap180(180), 180)
        self.test('wrap180(360)',  wrap180(360),   0)
        self.test('wrap180(-90)',  wrap180(-90),   -90)
        self.test('wrap180(-180)', wrap180(-180), -180)
        self.test('wrap180(-360)', wrap180(-360),    0)

        self.test('wrap360(90)',   wrap360(90),   90)
        self.test('wrap360(180)',  wrap360(180), 180)
        self.test('wrap360(360)',  wrap360(360),   0)
        self.test('wrap360(-90)',  wrap360(-90),  270)
        self.test('wrap360(-180)', wrap360(-180), 180)
        self.test('wrap360(-360)', wrap360(-360),   0)

        self.test('wrapPI_2(PI_2)', wrapPI_2(PI_2), PI_2)
        self.test('wrapPI_2(PI)',   wrapPI_2(PI),    -PI)  # XXX
        self.test('wrapPI_2(PI2)',  wrapPI_2(PI2),   0.0)
        self.test('wrapPI_2(-PI_2)',    wrapPI_2(-PI_2), -PI_2)
        self.test('wrapPI_2(-PI)',      wrapPI_2(-PI),     -PI)  # XXX
        self.test('wrapPI_2(-PI2)', abs(wrapPI_2(-PI2)),   0.0)

        self.test('wrapPI(PI_2)', wrapPI(PI_2), PI_2)
        self.test('wrapPI(PI)',   wrapPI(PI),     PI)  # XXX
        self.test('wrapPI(PI2)',  wrapPI(PI2),   0.0)
        self.test('wrapPI(-PI_2)',    wrapPI(-PI_2), -PI_2)
        self.test('wrapPI(-PI)',      wrapPI(-PI),     -PI)  # XXX
        self.test('wrapPI(-PI2)', abs(wrapPI(-PI2)),   0.0)  # -0.0

        self.test('wrapPI2(PI_2)', wrapPI2(PI_2), PI_2)
        self.test('wrapPI2(PI)',   wrapPI2(PI),     PI)  # XXX
        self.test('wrapPI2(PI2)',  wrapPI2(PI2),   0.0)
        self.test('wrapPI2(-PI_2)',    wrapPI2(-PI_2), PI_2+PI)
        self.test('wrapPI2(-PI)',      wrapPI2(-PI),        PI)  # XXX
        self.test('wrapPI2(-PI2)', abs(wrapPI2(-PI2)),     0.0)  # -0.0

        self.test('unroll180', fStr(unroll180(-90, 110, wrap=True)), '-160.0, -250.0')
        self.test('unroll180', fStr(unroll180(-90, 110, wrap=False)), '200.0, 110.0')

        self.test('unroll180', fStr(unroll180(-90, 830, wrap=True)), '-160.0, -250.0')
        self.test('unroll180', fStr(unroll180(-90, 830, wrap=False)), '920.0, 830.0')

        self.test('unroll180', fStr(unroll180(-110, 90, wrap=True)), '-160.0, -270.0')
        self.test('unroll180', fStr(unroll180(-110, 90, wrap=False)), '200.0, 90.0')

        self.test('unroll180', fStr(unroll180(-830, 90, wrap=True)), '-160.0, -990.0')
        self.test('unroll180', fStr(unroll180(-830, 90, wrap=False)), '920.0, 90.0')

        e = d = g = f = 0
        for a in range(-1000, 1000):
            a *= 0.47
            r = radians(a)
            sr, cr = sin(r), cos(r)

            s, c = sincos2(r)
            e = max(e, abs(sr - s), abs(cr - c))

            sd, cd = sincos2d(a)
            d = max(d, abs(sr - sd), abs(cr - cd))
            if sincosd:  # compare with geographiclib
                s, c = sincosd(a)
                g = max(g, abs(sr - s), abs(cr - c))
                f = max(f, abs(sd - s), abs(cd - c))

        EPS_ = EPS * 8
        self.test('sincos2',  e, EPS, known=e < EPS_)
        self.test('sincos2d', d, EPS, known=d < EPS_)
        if sincosd:
            self.test('sincosd ', g, EPS, known=g < EPS_)
            self.test('sincos*d', f, EPS, known=f < EPS_)

        a, b = splice(range(10))  # PYCHOK false
        self.test('splice', (a, b), map1(type(a), (0, 2, 4, 6, 8), (1, 3, 5, 7, 9)))
        a, b, c = splice(range(10), n=3)  # PYCHOK false
        self.test('splice', (a, b, c), map1(type(a), (0, 3, 6, 9), (1, 4, 7), (2, 5, 8)))
        a, b, c = splice(range(10), n=3, fill=-1)  # PYCHOK false
        self.test('splice', (a, b, c), map1(type(a), (0, 3, 6, 9), (1, 4, 7, -1), (2, 5, 8, -1)))
        t = tuple(splice(range(12), n=5))  # PYCHOK false
        self.test('splice', t, map1(type(t[0]), (0, 5, 10), (1, 6, 11), (2, 7), (3, 8), (4, 9)))

        # <https://www.CivilGeo.com/when-a-foot-isnt-really-a-foot/>
        self.test('iFt2m',  ft2m(614963.91), 187441, fmt='%.0f')
        self.test('iFt2m', ft2m(2483759.84), 757050, fmt='%.0f')
        self.test('sFt2m',  ft2m(614962.68, usurvey=True), 187441, fmt='%.0f')
        self.test('sFt2m', ft2m(2483754.87, usurvey=True), 757050, fmt='%.0f')

        self.test('m2iFt',  m2ft(187441),  614963.91, fmt='%.0f')
        self.test('m2iFt',  m2ft(757050), 2483759.84, fmt='%.0f')
        self.test('m2sFt',  m2ft(187441, usurvey=True),  614962.68, fmt='%.0f')
        self.test('m2sFt',  m2ft(757050, usurvey=True), 2483754.87, fmt='%.0f')
Esempio n. 4
0
    def testUtily(self):

        # Python 2.6.9 on Travis Ubuntu 14.04 produces -0.0

        self.test('degrees90(PI_2)', degrees90(PI_2), 90.0)
        self.test('degrees90(PI)', degrees90(PI), -180.0)  # XXX
        self.test('degrees90(PI2)', degrees90(PI2), 0.0)
        self.test('degrees90(-PI_2)', degrees90(-PI_2), -90.0)
        self.test('degrees90(-PI)', degrees90(-PI), -180.0)  # XXX
        self.test('degrees90(-PI2)', abs(degrees90(-PI2)), 0.0)  # -0.0

        self.test('degrees180(PI_2)', degrees180(PI_2), 90.0)
        self.test('degrees180(PI)', degrees180(PI), 180.0)  # XXX
        self.test('degrees180(PI2)', degrees180(PI2), 0.0)
        self.test('degrees180(-PI_2)', degrees180(-PI_2), -90.0)
        self.test('degrees180(-PI)', degrees180(-PI), -180.0)  # XXX
        self.test('degrees180(-PI2)', abs(degrees180(-PI2)), 0.0)  # -0.0

        self.test('degrees360(PI_2)', degrees360(PI_2), 90.0)
        self.test('degrees360(PI)', degrees360(PI), 180.0)  # XXX
        self.test('degrees360(PI2)', degrees360(PI2), 0.0)
        self.test('degrees360(-PI_2)', degrees360(-PI_2), 270.0)
        self.test('degrees360(-PI)', degrees360(-PI), 180.0)  # XXX
        self.test('degrees360(-PI2)', abs(degrees360(-PI2)), 0.0)  # -0.0

        self.test('radiansPI_2(90)', radiansPI_2(90), PI_2)
        self.test('radiansPI_2(180)', radiansPI_2(180), -PI)
        self.test('radiansPI_2(360)', radiansPI_2(360), 0.0)
        self.test('radiansPI_2(-90)', radiansPI_2(-90), -PI_2)
        self.test('radiansPI_2(-180)', radiansPI_2(-180), -PI)
        self.test('radiansPI_2(-360)', abs(radiansPI_2(-360)), 0.0)  # -0.0

        self.test('radiansPI(90)', radiansPI(90), PI_2)
        self.test('radiansPI(180)', radiansPI(180), PI)
        self.test('radiansPI(360)', radiansPI(360), 0.0)
        self.test('radiansPI(-90)', radiansPI(-90), -PI_2)
        self.test('radiansPI(-180)', radiansPI(-180), -PI)
        self.test('radiansPI(-360)', abs(radiansPI(-360)), 0.0)  # -0.0

        self.test('radiansPI2(90)', radiansPI2(90), PI_2)
        self.test('radiansPI2(180)', radiansPI2(180), PI)
        self.test('radiansPI2(360)', radiansPI2(360), 0.0)
        self.test('radiansPI2(-90)', radiansPI2(-90), PI_2 + PI)
        self.test('radiansPI2(-180)', radiansPI2(-180), PI)
        self.test('radiansPI2(-360)', abs(radiansPI2(-360)), 0.0)  # -0.0

        self.test('wrap90(90)', wrap90(90), 90)
        self.test('wrap90(180)', wrap90(180), -180)
        self.test('wrap90(360)', wrap90(360), 0)
        self.test('wrap90(-90)', wrap90(-90), -90)
        self.test('wrap90(-180)', wrap90(-180), -180)
        self.test('wrap90(-360)', wrap90(-360), 0)

        self.test('wrap180(90)', wrap180(90), 90)
        self.test('wrap180(180)', wrap180(180), 180)
        self.test('wrap180(360)', wrap180(360), 0)
        self.test('wrap180(-90)', wrap180(-90), -90)
        self.test('wrap180(-180)', wrap180(-180), -180)
        self.test('wrap180(-360)', wrap180(-360), 0)

        self.test('wrap360(90)', wrap360(90), 90)
        self.test('wrap360(180)', wrap360(180), 180)
        self.test('wrap360(360)', wrap360(360), 0)
        self.test('wrap360(-90)', wrap360(-90), 270)
        self.test('wrap360(-180)', wrap360(-180), 180)
        self.test('wrap360(-360)', wrap360(-360), 0)

        self.test('wrapPI_2(PI_2)', wrapPI_2(PI_2), PI_2)
        self.test('wrapPI_2(PI)', wrapPI_2(PI), -PI)  # XXX
        self.test('wrapPI_2(PI2)', wrapPI_2(PI2), 0.0)
        self.test('wrapPI_2(-PI_2)', wrapPI_2(-PI_2), -PI_2)
        self.test('wrapPI_2(-PI)', wrapPI_2(-PI), -PI)  # XXX
        self.test('wrapPI_2(-PI2)', abs(wrapPI_2(-PI2)), 0.0)

        self.test('wrapPI(PI_2)', wrapPI(PI_2), PI_2)
        self.test('wrapPI(PI)', wrapPI(PI), PI)  # XXX
        self.test('wrapPI(PI2)', wrapPI(PI2), 0.0)
        self.test('wrapPI(-PI_2)', wrapPI(-PI_2), -PI_2)
        self.test('wrapPI(-PI)', wrapPI(-PI), -PI)  # XXX
        self.test('wrapPI(-PI2)', abs(wrapPI(-PI2)), 0.0)  # -0.0

        self.test('wrapPI2(PI_2)', wrapPI2(PI_2), PI_2)
        self.test('wrapPI2(PI)', wrapPI2(PI), PI)  # XXX
        self.test('wrapPI2(PI2)', wrapPI2(PI2), 0.0)
        self.test('wrapPI2(-PI_2)', wrapPI2(-PI_2), PI_2 + PI)
        self.test('wrapPI2(-PI)', wrapPI2(-PI), PI)  # XXX
        self.test('wrapPI2(-PI2)', abs(wrapPI2(-PI2)), 0.0)  # -0.0

        self.test('unroll180', fstr(unroll180(-90, 110, wrap=True)),
                  '-160.0, -250.0')
        self.test('unroll180', fstr(unroll180(-90, 110, wrap=False)),
                  '200.0, 110.0')

        self.test('unroll180', fstr(unroll180(-90, 830, wrap=True)),
                  '-160.0, -250.0')
        self.test('unroll180', fstr(unroll180(-90, 830, wrap=False)),
                  '920.0, 830.0')

        self.test('unroll180', fstr(unroll180(-110, 90, wrap=True)),
                  '-160.0, -270.0')
        self.test('unroll180', fstr(unroll180(-110, 90, wrap=False)),
                  '200.0, 90.0')

        self.test('unroll180', fstr(unroll180(-830, 90, wrap=True)),
                  '-160.0, -990.0')
        self.test('unroll180', fstr(unroll180(-830, 90, wrap=False)),
                  '920.0, 90.0')

        e = d = g = f = 0
        for a in range(-1000, 1000):
            a *= 0.47
            r = radians(a)
            sr, cr = sin(r), cos(r)

            s, c = sincos2(r)
            e = max(e, abs(sr - s), abs(cr - c))

            sd, cd = sincos2d(a)
            d = max(d, abs(sr - sd), abs(cr - cd))
            if sincosd:  # compare with geographiclib
                s, c = sincosd(a)
                g = max(g, abs(sr - s), abs(cr - c))
                f = max(f, abs(sd - s), abs(cd - c))

        EPS_ = EPS * 8
        self.test('sincos2', e, EPS, known=e < EPS_)
        self.test('sincos2d', d, EPS, known=d < EPS_)
        if sincosd:
            self.test('sincosd ', g, EPS, known=g < EPS_)
            self.test('sincos*d', f, EPS, known=f < EPS_)

        # <https://www.CivilGeo.com/when-a-foot-isnt-really-a-foot/>
        self.test('iFt2m', ft2m(614963.91), 187441, fmt='%.0f')
        self.test('iFt2m', ft2m(2483759.84), 757050, fmt='%.0f')
        self.test('sFt2m', ft2m(614962.68, usurvey=True), 187441, fmt='%.0f')
        self.test('sFt2m', ft2m(2483754.87, usurvey=True), 757050, fmt='%.0f')

        self.test('m2iFt', m2ft(187441), 614963.91, fmt='%.0f')
        self.test('m2iFt', m2ft(757050), 2483759.84, fmt='%.0f')
        self.test('m2sFt', m2ft(187441, usurvey=True), 614962.68, fmt='%.0f')
        self.test('m2sFt', m2ft(757050, usurvey=True), 2483754.87, fmt='%.0f')

        self.test('degrees2m', fstr(degrees2m(90), prec=4), '10007557.1761')
        self.test('degrees2m', fstr(degrees2m(90, lat=30), prec=4),
                  '8666798.7443')
        self.test('m2degrees', fstr(m2degrees(degrees2m(90)), prec=1), '90.0')

        self.test('degrees2m', fstr(degrees2m(180), prec=4), '20015114.3522')
        self.test('degrees2m', fstr(degrees2m(180, lat=3 - 0), prec=4),
                  '19987684.3336')
        self.test('m2degrees', fstr(m2degrees(degrees2m(180)), prec=1),
                  '180.0')

        for a in range(0, 90, 7):
            d = m2degrees(degrees2m(45, lat=a), lat=a)
            self.test('m2-degrees-2m(%s, lat=%s)' % (45, a),
                      d,
                      '45.00',
                      fmt='%.2f')

        self.test('isPoints2', isPoints2(None), False)
Esempio n. 5
0
    def testUtily(self):

        # Python 2.6.9 on Travis Ubuntu 14.04 produces -0.0

        self.test('degrees90(PI_2)', degrees90(PI_2), 90.0)
        self.test('degrees90(PI)', degrees90(PI), -180.0)  # XXX
        self.test('degrees90(PI2)', degrees90(PI2), 0.0)
        self.test('degrees90(-PI_2)', degrees90(-PI_2), -90.0)
        self.test('degrees90(-PI)', degrees90(-PI), -180.0)  # XXX
        self.test('degrees90(-PI2)', abs(degrees90(-PI2)), 0.0)  # -0.0

        self.test('degrees180(PI_2)', degrees180(PI_2), 90.0)
        self.test('degrees180(PI)', degrees180(PI), 180.0)  # XXX
        self.test('degrees180(PI2)', degrees180(PI2), 0.0)
        self.test('degrees180(-PI_2)', degrees180(-PI_2), -90.0)
        self.test('degrees180(-PI)', degrees180(-PI), -180.0)  # XXX
        self.test('degrees180(-PI2)', abs(degrees180(-PI2)), 0.0)  # -0.0

        self.test('degrees360(PI_2)', degrees360(PI_2), 90.0)
        self.test('degrees360(PI)', degrees360(PI), 180.0)  # XXX
        self.test('degrees360(PI2)', degrees360(PI2), 0.0)
        self.test('degrees360(-PI_2)', degrees360(-PI_2), 270.0)
        self.test('degrees360(-PI)', degrees360(-PI), 180.0)  # XXX
        self.test('degrees360(-PI2)', abs(degrees360(-PI2)), 0.0)  # -0.0

        self.test('radiansPI_2(90)', radiansPI_2(90), PI_2)
        self.test('radiansPI_2(180)', radiansPI_2(180), -PI)
        self.test('radiansPI_2(360)', radiansPI_2(360), 0.0)
        self.test('radiansPI_2(-90)', radiansPI_2(-90), -PI_2)
        self.test('radiansPI_2(-180)', radiansPI_2(-180), -PI)
        self.test('radiansPI_2(-360)', abs(radiansPI_2(-360)), 0.0)  # -0.0

        self.test('radiansPI(90)', radiansPI(90), PI_2)
        self.test('radiansPI(180)', radiansPI(180), PI)
        self.test('radiansPI(360)', radiansPI(360), 0.0)
        self.test('radiansPI(-90)', radiansPI(-90), -PI_2)
        self.test('radiansPI(-180)', radiansPI(-180), -PI)
        self.test('radiansPI(-360)', abs(radiansPI(-360)), 0.0)  # -0.0

        self.test('radiansPI2(90)', radiansPI2(90), PI_2)
        self.test('radiansPI2(180)', radiansPI2(180), PI)
        self.test('radiansPI2(360)', radiansPI2(360), 0.0)
        self.test('radiansPI2(-90)', radiansPI2(-90), PI_2 + PI)
        self.test('radiansPI2(-180)', radiansPI2(-180), PI)
        self.test('radiansPI2(-360)', abs(radiansPI2(-360)), 0.0)  # -0.0

        self.test('wrap90(90)', wrap90(90), 90.0)
        self.test('wrap90(180)', wrap90(180), -180.0)
        self.test('wrap90(360)', wrap90(360), 0.0)
        self.test('wrap90(-90)', wrap90(-90), -90.0)
        self.test('wrap90(-180)', wrap90(-180), -180.0)
        self.test('wrap90(-360)', wrap90(-360), 0.0)

        self.test('wrap180(90)', wrap180(90), 90.0)
        self.test('wrap180(180)', wrap180(180), 180.0)
        self.test('wrap180(360)', wrap180(360), 0.0)
        self.test('wrap180(-90)', wrap180(-90), -90.0)
        self.test('wrap180(-180)', wrap180(-180), -180.0)
        self.test('wrap180(-360)', wrap180(-360), 0.0)

        self.test('wrap360(90)', wrap360(90), 90.0)
        self.test('wrap360(180)', wrap360(180), 180.0)
        self.test('wrap360(360)', wrap360(360), 0.0)
        self.test('wrap360(-90)', wrap360(-90), 270.0)
        self.test('wrap360(-180)', wrap360(-180), 180.0)
        self.test('wrap360(-360)', wrap360(-360), 0.0)

        self.test('wrapPI_2(PI_2)', wrapPI_2(PI_2), PI_2)
        self.test('wrapPI_2(PI)', wrapPI_2(PI), -PI)  # XXX
        self.test('wrapPI_2(PI2)', wrapPI_2(PI2), 0.0)
        self.test('wrapPI_2(-PI_2)', wrapPI_2(-PI_2), -PI_2)
        self.test('wrapPI_2(-PI)', wrapPI_2(-PI), -PI)  # XXX
        self.test('wrapPI_2(-PI2)', abs(wrapPI_2(-PI2)), 0.0)

        self.test('wrapPI(PI_2)', wrapPI(PI_2), PI_2)
        self.test('wrapPI(PI)', wrapPI(PI), PI)  # XXX
        self.test('wrapPI(PI2)', wrapPI(PI2), 0.0)
        self.test('wrapPI(-PI_2)', wrapPI(-PI_2), -PI_2)
        self.test('wrapPI(-PI)', wrapPI(-PI), -PI)  # XXX
        self.test('wrapPI(-PI2)', abs(wrapPI(-PI2)), 0.0)  # -0.0

        self.test('wrapPI2(PI_2)', wrapPI2(PI_2), PI_2)
        self.test('wrapPI2(PI)', wrapPI2(PI), PI)  # XXX
        self.test('wrapPI2(PI2)', wrapPI2(PI2), 0.0)
        self.test('wrapPI2(-PI_2)', wrapPI2(-PI_2), PI_2 + PI)
        self.test('wrapPI2(-PI)', wrapPI2(-PI), PI)  # XXX
        self.test('wrapPI2(-PI2)', abs(wrapPI2(-PI2)), 0.0)  # -0.0

        self.test('unroll180', fstr(unroll180(-90, 110, wrap=True)),
                  '-160.0, -250.0')
        self.test('unroll180', fstr(unroll180(-90, 110, wrap=False)),
                  '200.0, 110.0')

        self.test('unroll180', fstr(unroll180(-90, 830, wrap=True)),
                  '-160.0, -250.0')
        self.test('unroll180', fstr(unroll180(-90, 830, wrap=False)),
                  '920.0, 830.0')

        self.test('unroll180', fstr(unroll180(-110, 90, wrap=True)),
                  '-160.0, -270.0')
        self.test('unroll180', fstr(unroll180(-110, 90, wrap=False)),
                  '200.0, 90.0')

        self.test('unroll180', fstr(unroll180(-830, 90, wrap=True)),
                  '-160.0, -990.0')
        self.test('unroll180', fstr(unroll180(-830, 90, wrap=False)),
                  '920.0, 90.0')

        e = d = g = f = t = 0
        for a in range(-1000, 1000, 2):
            a *= 0.47
            r = radians(a)
            sr, cr = sin(r), cos(r)

            s, c = sincos2(r)
            e = max(e, abs(sr - s), abs(cr - c))

            sd, cd = sincos2d(a)
            d = max(d, abs(sr - sd), abs(cr - cd))
            if Math:  # compare with geographiclib
                t = max(t, abs(atan2d(sr, cr) - atand(sr, cr)))
                s, c = sincosd(a)
                g = max(g, abs(sr - s), abs(cr - c))
                f = max(f, abs(sd - s), abs(cd - c))

        EPS_ = EPS * 8
        self.test('sincos2', e, EPS_, known=e < EPS_)
        self.test('sincos2d', d, EPS_, known=d < EPS_)
        if Math:
            self.test('atand', t, EPS, known=t < EPS)
            self.test('sincosd ', g, EPS_, known=g < EPS_)
            self.test('sincos*d', f, EPS_, known=f < EPS_)

        # <https://www.CivilGeo.com/when-a-foot-isnt-really-a-foot/>
        self.test('iFt2m', ft2m(614963.91), 187441, fmt='%.0f')
        self.test('iFt2m', ft2m(2483759.84), 757050, fmt='%.0f')
        self.test('sFt2m', ft2m(614962.68, usurvey=True), 187441, fmt='%.0f')
        self.test('sFt2m', ft2m(2483754.87, usurvey=True), 757050, fmt='%.0f')

        self.test('m2iFt', m2ft(187441), 614963.91, prec=2)
        self.test('m2iFt', m2ft(757050), 2483759.84, prec=2)
        self.test('m2sFt', m2ft(187441, usurvey=True), 614962.68, prec=2)
        self.test('m2sFt', m2ft(757050, usurvey=True), 2483754.87, prec=2)

        for f, m in ((m2yard, '1.093613'), (acre2ha, '0.404686'),
                     (acre2m2, '4046.856422'), (chain2m, '20.116800'),
                     (fathom2m, '1.828800'), (furlong2m, '201.168000'),
                     (yard2m, '0.914400')):
            self.test(f.__name__, f(1), m, prec=6)

        self.test('degrees2m', fstr(degrees2m(90), prec=4), '10007557.1761')
        self.test('degrees2m', fstr(degrees2m(90, lat=30), prec=4),
                  '8666798.7443')
        self.test('m2degrees', fstr(m2degrees(degrees2m(90)), prec=1), '90.0')

        self.test('degrees2m', fstr(degrees2m(180), prec=4), '20015114.3522')
        self.test('degrees2m', fstr(degrees2m(180, lat=3 - 0), prec=4),
                  '19987684.3336')
        self.test('m2degrees', fstr(m2degrees(degrees2m(180)), prec=1),
                  '180.0')

        t = 'm2degrees2m(%s, lat=%s)'
        for a in range(0, 90, 7):
            d = m2degrees(degrees2m(45, lat=a), lat=a)
            self.test(t % (45, a), d, '45.00', prec=2)

        self.test('isPoints2', isPoints2(None), False)