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

remove Python2 crumbs #907

Merged
merged 1 commit into from
Oct 18, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +192,4 @@
# continue
# dtype, target = line.split(None, 1)
# target = target.strip()
# nitpick_ignore.append((dtype, six.u(target)))
# nitpick_ignore.append((dtype, str(target)))
1 change: 0 additions & 1 deletion docs/installing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ This package has the following dependencies:
* `dask <https://dask.org/>`_, used for the :class:`~spectral_cube.DaskSpectralCube` class
* `zarr <https://zarr.readthedocs.io/en/stable/>`_ and `fsspec <https://pypi.org/project/fsspec/>`_,
used for storing computations to disk when using the dask-enabled classes.
* `six <http://pypi.python.org/pypi/six/>`_
* `casa-formats-io <https://pypi.org/project/casa-formats-io>`_

Installation
Expand Down
1 change: 0 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ install_requires =
astropy
numpy>=1.8.0
radio_beam>=0.3.3
six
dask[array]
joblib
casa-formats-io
Expand Down
2 changes: 0 additions & 2 deletions spectral_cube/_moments.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import print_function, absolute_import, division

import numpy as np

from .cube_utils import iterator_strategy
Expand Down
1 change: 0 additions & 1 deletion spectral_cube/analysis_utilities.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import numpy as np

from astropy import units as u
from six.moves import zip, range
from astropy.wcs import WCS
from astropy.utils.console import ProgressBar
from astropy import log
Expand Down
1 change: 0 additions & 1 deletion spectral_cube/conftest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# this contains imports plugins that configure py.test for astropy tests.
# by importing them here in conftest.py they are discoverable by py.test
# no matter how it is invoked within the source tree.
from __future__ import print_function, absolute_import, division

import os
from astropy.units.equivalencies import pixel_scale
Expand Down
8 changes: 1 addition & 7 deletions spectral_cube/cube_utils.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
from __future__ import print_function, absolute_import, division

import contextlib
import warnings
from copy import deepcopy

try:
import builtins
except ImportError:
# python2
import __builtin__ as builtins
import builtins

import dask.array as da
import numpy as np
Expand Down
2 changes: 0 additions & 2 deletions spectral_cube/dask_spectral_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
A class to represent a 3-d position-position-velocity spectral cube.
"""

from __future__ import print_function, absolute_import, division

import uuid
import inspect
import warnings
Expand Down
1 change: 0 additions & 1 deletion spectral_cube/io/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
from __future__ import print_function, absolute_import, division
2 changes: 0 additions & 2 deletions spectral_cube/io/casa_image.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import print_function, absolute_import, division

import warnings
from astropy import units as u
from astropy.io import registry as io_registry
Expand Down
2 changes: 0 additions & 2 deletions spectral_cube/io/casa_masks.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import print_function, absolute_import, division

import numpy as np
from astropy.io import fits
import tempfile
Expand Down
7 changes: 2 additions & 5 deletions spectral_cube/io/class_lmv.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from __future__ import print_function, absolute_import, division

import six
import numpy as np
import struct
import warnings
Expand Down Expand Up @@ -252,8 +249,8 @@ def read_lmv_tofits(fileobj):
if isinstance(v, tuple) else
fits.header.Card(''.join(s for s in k if s in string.printable),
''.join(s for s in v if s in string.printable)
if isinstance(v, six.string_types) else v)
for k,v in six.iteritems(header)
if isinstance(v, str) else v)
for k,v in header.items()
if k not in bad_kws]
Header = fits.Header(cards)
hdu = fits.PrimaryHDU(data=data, header=Header)
Expand Down
2 changes: 0 additions & 2 deletions spectral_cube/io/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
# the unified I/O framework from Astropy which is used to implement this, see
# http://docs.astropy.org/en/stable/io/unified.html

from __future__ import print_function, absolute_import, division

from pathlib import PosixPath
import warnings

Expand Down
3 changes: 0 additions & 3 deletions spectral_cube/io/fits.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from __future__ import print_function, absolute_import, division

import six
import dask
import warnings

Expand Down
2 changes: 0 additions & 2 deletions spectral_cube/lower_dimensional_structures.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import print_function, absolute_import, division

import warnings

import numpy as np
Expand Down
3 changes: 0 additions & 3 deletions spectral_cube/masks.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
from __future__ import print_function, absolute_import, division

import abc
import uuid
import warnings
import tempfile

from six.moves import zip
import numpy as np
from numpy.lib.stride_tricks import as_strided

Expand Down
2 changes: 0 additions & 2 deletions spectral_cube/np_compat.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import print_function, absolute_import, division

import numpy as np

def allbadtonan(function):
Expand Down
2 changes: 0 additions & 2 deletions spectral_cube/spectral_axis.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import print_function, absolute_import, division

import numpy as np

from astropy import wcs
Expand Down
8 changes: 2 additions & 6 deletions spectral_cube/spectral_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
A class to represent a 3-d position-position-velocity spectral cube.
"""

from __future__ import print_function, absolute_import, division

import warnings
from functools import wraps
import operator
Expand All @@ -13,8 +11,6 @@
import tempfile
import textwrap
from pathlib import PosixPath
import six
from six.moves import zip, range
import dask.array as da

import astropy.wcs
Expand Down Expand Up @@ -2022,7 +2018,7 @@ def subcube_from_ds9region(self, ds9_region, allow_empty=False):
"""
import regions

if isinstance(ds9_region, six.string_types):
if isinstance(ds9_region, str):
if hasattr(regions, 'DS9Parser'):
region_list = regions.DS9Parser(ds9_region).shapes.to_regions()
else:
Expand All @@ -2046,7 +2042,7 @@ def subcube_from_crtfregion(self, crtf_region, allow_empty=False):
"""
import regions

if isinstance(crtf_region, six.string_types):
if isinstance(crtf_region, str):
region_list = regions.CRTFParser(crtf_region).shapes.to_regions()
else:
raise TypeError("{0} should be a CRTF string".format(crtf_region))
Expand Down
8 changes: 1 addition & 7 deletions spectral_cube/stokes_spectral_cube.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from __future__ import print_function, absolute_import, division

import six
import numpy as np

from astropy.io.registry import UnifiedReadWriteMethod
Expand Down Expand Up @@ -113,10 +110,7 @@ def wcs(self):
return self._wcs

def __dir__(self):
if six.PY2:
return self.components + dir(type(self)) + list(self.__dict__)
else:
return self.components + super(StokesSpectralCube, self).__dir__()
return self.components + super(StokesSpectralCube, self).__dir__()

@property
def components(self):
Expand Down
2 changes: 0 additions & 2 deletions spectral_cube/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import print_function, absolute_import, division

import os


Expand Down
2 changes: 0 additions & 2 deletions spectral_cube/tests/helpers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import print_function, absolute_import, division

from astropy import units as u

from numpy.testing import assert_allclose as assert_allclose_numpy, assert_array_equal
Expand Down
2 changes: 0 additions & 2 deletions spectral_cube/tests/setup_package.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import print_function, absolute_import, division

def get_package_data():
return {
_ASTROPY_PACKAGE_NAME_ + '.tests': ['coveragerc', 'data/*.fits', 'data/*.hdr', 'data/*.lmv', 'data/*reg']
Expand Down
2 changes: 0 additions & 2 deletions spectral_cube/tests/test_casafuncs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import print_function, absolute_import, division

import os
import shutil
from itertools import product
Expand Down
2 changes: 0 additions & 2 deletions spectral_cube/tests/test_io.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import print_function, absolute_import, division

import numpy as np
from astropy.io import fits as pyfits
from astropy import units as u
Expand Down
2 changes: 0 additions & 2 deletions spectral_cube/tests/test_masks.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import print_function, absolute_import, division

import pytest
import itertools
import operator
Expand Down
2 changes: 0 additions & 2 deletions spectral_cube/tests/test_moments.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import print_function, absolute_import, division

import warnings
from packaging.version import Version, parse

Expand Down
2 changes: 0 additions & 2 deletions spectral_cube/tests/test_performance.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
For now this is just for SpectralCube, not DaskSpectralCube.
"""

from __future__ import print_function, absolute_import, division

import numpy as np

import pytest
Expand Down
2 changes: 0 additions & 2 deletions spectral_cube/tests/test_projection.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import print_function, absolute_import, division

import warnings
import pytest
import numpy as np
Expand Down
2 changes: 0 additions & 2 deletions spectral_cube/tests/test_spectral_axis.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import print_function, absolute_import, division

from astropy import wcs
from astropy.io import fits
from astropy import units as u
Expand Down
2 changes: 0 additions & 2 deletions spectral_cube/tests/test_spectral_cube.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import print_function, absolute_import, division

import re
import copy
import operator
Expand Down
2 changes: 0 additions & 2 deletions spectral_cube/tests/test_subcubes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import print_function, absolute_import, division

import pytest
from packaging.version import Version, parse

Expand Down
2 changes: 0 additions & 2 deletions spectral_cube/tests/test_visualization.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import print_function, absolute_import, division

import pytest
from packaging.version import Version, parse

Expand Down
2 changes: 0 additions & 2 deletions spectral_cube/tests/test_wcs_utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import print_function, absolute_import, division

import pytest
import warnings

Expand Down
2 changes: 0 additions & 2 deletions spectral_cube/tests/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
Utilities for tests.
'''

from six.moves import zip

import numpy as np
import astropy.units as u
from astropy.io import fits
Expand Down
2 changes: 0 additions & 2 deletions spectral_cube/wcs_utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import print_function, absolute_import, division

import numpy as np
from astropy.wcs import WCS
import warnings
Expand Down
5 changes: 1 addition & 4 deletions spectral_cube/ytcube.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from __future__ import print_function, absolute_import, division

import six
import os
import subprocess
import numpy as np
Expand Down Expand Up @@ -214,7 +211,7 @@ def quick_isocontour(self, level='3 sigma', title='', description='',
-------
The result of the `yt.surface.export_sketchfab` function
"""
if isinstance(level, six.string_types):
if isinstance(level, str):
sigma = self.cube.std().value
level = float(level.split()[0]) * sigma

Expand Down
Loading