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

DM-22234: Remove python 2 remnants #20

Merged
merged 5 commits into from
Nov 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
sudo: false
language: python
matrix:
include:
- python: '3.7'
install:
- pip install flake8
script: flake8
33 changes: 15 additions & 18 deletions misc/makeHilbertLuts.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" &
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY
Expand All @@ -28,10 +28,7 @@
functions in `lsst/sphgeom/curve.h`.
"""

from __future__ import absolute_import, division, print_function

import math
from builtins import range

import numpy as np

Expand Down Expand Up @@ -145,13 +142,13 @@ def TR_algo2(p, M):
for i in range(M-1, -1, -1):
# the cell label is constructed in two steps
# 1. extract the relevant bits from p
l = [bit_component(px, i) for px in p]
ll = [bit_component(px, i) for px in p]
# 2. construct a integer whose bits are given by l
l = sum([lx*2**j for j, lx in enumerate(l)])
ll = sum([lx*2**j for j, lx in enumerate(ll)])
# transform l into the current subcube
l = T(ve, vd, l)
ll = T(ve, vd, ll)
# obtain the gray code ordering from the label l
w = inverse_gc(l)
w = inverse_gc(ll)
# compose (see [TR] lemma 2.13) the transform of ve and vd
# with the data of the subcube
ve = ve ^ (rotate_left(e(w), vd+1))
Expand All @@ -169,10 +166,10 @@ def TR_algo3(h, M):
for i in range(M-1, -1, -1):
w = [bit_component(h, i*N + ii) for ii in range(N)]
w = sum([wx*2**j for j, wx in enumerate(w)])
l = gc(w)
l = T_inv(ve, vd, l)
ll = gc(w)
ll = T_inv(ve, vd, ll)
for j in range(N):
p[j] += bit_component(l, j) << i
p[j] += bit_component(ll, j) << i
ve = ve ^ rotate_left(e(w), vd+1)
vd = (vd + d(w) + 1) % N
return p
Expand Down Expand Up @@ -201,13 +198,13 @@ def make_TR_algo2_lut(M):
for i in range(M-1, -1, -1):
# the cell label is constructed in two steps
# 1. extract the relevant bits from p
l = [bit_component(px, i) for px in p]
ll = [bit_component(px, i) for px in p]
# 2. construct a integer whose bits are given by l
l = sum([lx*2**j for j, lx in enumerate(l)])
ll = sum([lx*2**j for j, lx in enumerate(ll)])
# transform l into the current subcube
l = T(ve, vd, l)
ll = T(ve, vd, ll)
# obtain the gray code ordering from the label l
w = inverse_gc(l)
w = inverse_gc(ll)
# compose (see [TR] lemma 2.13) the transform of ve and vd
# with the data of the subcube
ve = ve ^ (rotate_left(e(w), vd+1))
Expand All @@ -232,11 +229,11 @@ def make_TR_algo3_lut(M):
for i in range(M-1, -1, -1):
w = [bit_component(h, i*N+ii) for ii in range(N)]
w = sum([wx*2**j for j, wx in enumerate(w)])
l = gc(w)
l = T_inv(ve, vd, l)
ll = gc(w)
ll = T_inv(ve, vd, ll)
ve = ve ^ rotate_left(e(w), vd+1)
vd = (vd + d(w) + 1) % N
z = (z << N) | l
z = (z << N) | ll
lut.append(z | (vd << 2*M) | ((ve % 2) << (2*M + 1)))
return lut

Expand Down
1 change: 0 additions & 1 deletion python/lsst/sphgeom/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

"""lsst.sphgeom
"""
from __future__ import absolute_import

from .region import *
from .pixelization import *
Expand Down
9 changes: 9 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[flake8]
max-line-length = 110
max-doc-length = 79
ignore = E133, E226, E228, N802, N803, N806, N812, N815, N816, W504
exclude = __init__.py

[tool:pytest]
addopts = --flake8
flake8-ignore = E133 E226 E228 N802 N803 N806 N812 N815 N816 W504
2 changes: 1 addition & 1 deletion tests/SConscript
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from lsst.sconsUtils import scripts
scripts.BasicSConscript.tests()
scripts.BasicSConscript.tests(pyList=[])
1 change: 0 additions & 1 deletion tests/test_Angle.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
# the GNU General Public License along with this program. If not,
# see <https://www.lsstcorp.org/LegalNotices/>.
#
from __future__ import absolute_import, division, print_function

import pickle
import unittest
Expand Down
4 changes: 1 addition & 3 deletions tests/test_AngleIntervals.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,16 @@
# the GNU General Public License along with this program. If not,
# see <https://www.lsstcorp.org/LegalNotices/>.
#
from __future__ import absolute_import, division, print_function

import pickle
import unittest
from builtins import object

from lsst.sphgeom import (Angle, AngleInterval,
CONTAINS, DISJOINT,
NormalizedAngle, NormalizedAngleInterval)


class IntervalTests(object):
class IntervalTests:

def testConstruction(self):
i = self.Interval(self.Scalar(1))
Expand Down
6 changes: 1 addition & 5 deletions tests/test_Box.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,8 @@
# the GNU General Public License along with this program. If not,
# see <https://www.lsstcorp.org/LegalNotices/>.
#
from __future__ import absolute_import, division, print_function

try:
import cPickle as pickle # Use cPickle on Python 2.7
except ImportError:
import pickle
import pickle

import math
import unittest
Expand Down
1 change: 0 additions & 1 deletion tests/test_Box3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
# the GNU General Public License along with this program. If not,
# see <https://www.lsstcorp.org/LegalNotices/>.
#
from __future__ import absolute_import, division, print_function

import pickle
import unittest
Expand Down
1 change: 0 additions & 1 deletion tests/test_Chunker.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
# the GNU General Public License along with this program. If not,
# see <https://www.lsstcorp.org/LegalNotices/>.
#
from __future__ import absolute_import, division, print_function

import pickle
import unittest
Expand Down
6 changes: 1 addition & 5 deletions tests/test_Circle.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,8 @@
# the GNU General Public License along with this program. If not,
# see <https://www.lsstcorp.org/LegalNotices/>.
#
from __future__ import absolute_import, division, print_function

try:
import cPickle as pickle # Use cPickle on Python 2.7
except ImportError:
import pickle
import pickle

import math
import unittest
Expand Down
6 changes: 1 addition & 5 deletions tests/test_ConvexPolygon.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,8 @@
# the GNU General Public License along with this program. If not,
# see <https://www.lsstcorp.org/LegalNotices/>.
#
from __future__ import absolute_import, division, print_function

try:
import cPickle as pickle # Use cPickle on Python 2.7
except ImportError:
import pickle
import pickle

import unittest

Expand Down
6 changes: 1 addition & 5 deletions tests/test_Ellipse.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,8 @@
# the GNU General Public License along with this program. If not,
# see <https://www.lsstcorp.org/LegalNotices/>.
#
from __future__ import absolute_import, division, print_function

try:
import cPickle as pickle # Use cPickle on Python 2.7
except ImportError:
import pickle
import pickle

import math
import unittest
Expand Down
2 changes: 0 additions & 2 deletions tests/test_HtmPixelization.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@
# the GNU General Public License along with this program. If not,
# see <https://www.lsstcorp.org/LegalNotices/>.
#
from __future__ import absolute_import, division, print_function

import pickle
import unittest
from builtins import range

from lsst.sphgeom import Angle, Circle, HtmPixelization, RangeSet, UnitVector3d, ConvexPolygon

Expand Down
1 change: 0 additions & 1 deletion tests/test_Interval1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
# the GNU General Public License along with this program. If not,
# see <https://www.lsstcorp.org/LegalNotices/>.
#
from __future__ import absolute_import, division, print_function

import pickle
import unittest
Expand Down
1 change: 0 additions & 1 deletion tests/test_LonLat.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
# the GNU General Public License along with this program. If not,
# see <https://www.lsstcorp.org/LegalNotices/>.
#
from __future__ import absolute_import, division, print_function

import pickle
import unittest
Expand Down
1 change: 0 additions & 1 deletion tests/test_Matrix3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
# the GNU General Public License along with this program. If not,
# see <https://www.lsstcorp.org/LegalNotices/>.
#
from __future__ import absolute_import, division, print_function

import pickle
import unittest
Expand Down
2 changes: 0 additions & 2 deletions tests/test_Mq3cPixelization.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@
# the GNU General Public License along with this program. If not,
# see <https://www.lsstcorp.org/LegalNotices/>.
#
from __future__ import absolute_import, division, print_function

import pickle
import unittest
from builtins import range

from lsst.sphgeom import (Angle, Circle, Mq3cPixelization, RangeSet,
UnitVector3d)
Expand Down
1 change: 0 additions & 1 deletion tests/test_NormalizedAngle.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
# the GNU General Public License along with this program. If not,
# see <https://www.lsstcorp.org/LegalNotices/>.
#
from __future__ import absolute_import, division, print_function

import pickle
import unittest
Expand Down
2 changes: 0 additions & 2 deletions tests/test_Q3cPixelization.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@
# the GNU General Public License along with this program. If not,
# see <https://www.lsstcorp.org/LegalNotices/>.
#
from __future__ import absolute_import, division, print_function

import pickle
import unittest
from builtins import range

from lsst.sphgeom import Angle, Circle, Q3cPixelization, RangeSet, UnitVector3d

Expand Down
1 change: 0 additions & 1 deletion tests/test_RangeSet.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
# the GNU General Public License along with this program. If not,
# see <https://www.lsstcorp.org/LegalNotices/>.
#
from __future__ import absolute_import, division, print_function

import pickle
import sys
Expand Down
6 changes: 1 addition & 5 deletions tests/test_UnitVector3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,8 @@
# the GNU General Public License along with this program. If not,
# see <https://www.lsstcorp.org/LegalNotices/>.
#
from __future__ import absolute_import, division, print_function

try:
import cPickle as pickle # Use cPickle on Python 2.7
except ImportError:
import pickle
import pickle

import math
import unittest
Expand Down
1 change: 0 additions & 1 deletion tests/test_Vector3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
# the GNU General Public License along with this program. If not,
# see <https://www.lsstcorp.org/LegalNotices/>.
#
from __future__ import absolute_import, division, print_function

import math
import pickle
Expand Down