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

Set up and apply isort #1530

Closed
wants to merge 1 commit into from
Closed
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
1 change: 0 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

import metpy


# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
Expand Down
1 change: 0 additions & 1 deletion docs/override_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import os
import sys


modules_to_skip = ['metpy.xarray']


Expand Down
2 changes: 1 addition & 1 deletion examples/Advanced_Sounding.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import metpy.calc as mpcalc
from metpy.cbook import get_test_data
from metpy.plots import add_metpy_logo, SkewT
from metpy.plots import SkewT, add_metpy_logo
from metpy.units import units

###########################################
Expand Down
2 changes: 1 addition & 1 deletion examples/gridding/Natural_Neighbor_Verification.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
# 8. Repeat steps 4 through 7 for each grid cell.
import matplotlib.pyplot as plt
import numpy as np
from scipy.spatial import ConvexHull, Delaunay, delaunay_plot_2d, Voronoi, voronoi_plot_2d
from scipy.spatial import ConvexHull, Delaunay, Voronoi, delaunay_plot_2d, voronoi_plot_2d
from scipy.spatial.distance import euclidean

from metpy.interpolate import geometry
Expand Down
7 changes: 5 additions & 2 deletions examples/gridding/Point_Interpolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@
import numpy as np

from metpy.cbook import get_test_data
from metpy.interpolate import (interpolate_to_grid, remove_nan_observations,
remove_repeat_coordinates)
from metpy.interpolate import (
interpolate_to_grid,
remove_nan_observations,
remove_repeat_coordinates,
)
from metpy.plots import add_metpy_logo


Expand Down
2 changes: 1 addition & 1 deletion examples/plots/Hodograph_Inset.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import metpy.calc as mpcalc
from metpy.cbook import get_test_data
from metpy.plots import add_metpy_logo, Hodograph, SkewT
from metpy.plots import Hodograph, SkewT, add_metpy_logo
from metpy.units import units

###########################################
Expand Down
2 changes: 1 addition & 1 deletion examples/plots/Mesonet_Stationplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import metpy.calc as mpcalc
from metpy.cbook import get_test_data
from metpy.plots import add_metpy_logo, StationPlot
from metpy.plots import StationPlot, add_metpy_logo
from metpy.units import units

###########################################
Expand Down
3 changes: 1 addition & 2 deletions examples/plots/Simple_Sounding.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@

import metpy.calc as mpcalc
from metpy.cbook import get_test_data
from metpy.plots import add_metpy_logo, SkewT
from metpy.plots import SkewT, add_metpy_logo
from metpy.units import units


###########################################

# Change default to be better for skew-T
Expand Down
2 changes: 1 addition & 1 deletion examples/plots/Skew-T_Layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import metpy.calc as mpcalc
from metpy.cbook import get_test_data
from metpy.plots import add_metpy_logo, Hodograph, SkewT
from metpy.plots import Hodograph, SkewT, add_metpy_logo
from metpy.units import units

###########################################
Expand Down
2 changes: 1 addition & 1 deletion examples/plots/Station_Plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from metpy.calc import reduce_point_density
from metpy.cbook import get_test_data
from metpy.io import metar
from metpy.plots import add_metpy_logo, current_weather, sky_cover, StationPlot
from metpy.plots import StationPlot, add_metpy_logo, current_weather, sky_cover

###########################################
# The setup
Expand Down
9 changes: 7 additions & 2 deletions examples/plots/Station_Plot_with_Layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,13 @@

from metpy.calc import wind_components
from metpy.cbook import get_test_data
from metpy.plots import (add_metpy_logo, simple_layout, StationPlot,
StationPlotLayout, wx_code_map)
from metpy.plots import (
StationPlot,
StationPlotLayout,
add_metpy_logo,
simple_layout,
wx_code_map,
)
from metpy.units import units

###########################################
Expand Down
1 change: 0 additions & 1 deletion examples/plots/upperair_declarative.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import metpy.plots as mpplots
from metpy.units import units


########################################
# **Getting the data**
#
Expand Down
11 changes: 11 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,14 @@ max-line-length = 95
match = (?!(test_|setup)).*\.py
match-dir = (?!(build|docs|examples|tutorials|_nexrad_msgs))[^.].*
convention = numpy

[isort]
multi_line_output = 3
include_trailing_comma = True
force_grid_wrap = 0
use_parentheses = True
ensure_newline_before_comments = True
line_length = 95
known_first_party = ["metpy"]
force_sort_within_sections = true
src_paths=src,ci,docs,examples,tests,tools,tutorials
1 change: 1 addition & 0 deletions src/metpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@

from ._version import get_version # noqa: E402
from .xarray import * # noqa: F401, F403, E402

__version__ = get_version()
del get_version
4 changes: 2 additions & 2 deletions src/metpy/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ def get_version():
version_scheme='post-release', local_scheme='dirty-tag')
except (ImportError, LookupError):
try:
from importlib.metadata import version, PackageNotFoundError
from importlib.metadata import PackageNotFoundError, version
except ImportError: # Can remove when we require Python > 3.7
from importlib_metadata import version, PackageNotFoundError
from importlib_metadata import PackageNotFoundError, version

try:
return version(__package__)
Expand Down
4 changes: 2 additions & 2 deletions src/metpy/calc/cross_sections.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
import numpy as np
import xarray as xr

from .basic import coriolis_parameter
from .tools import first_derivative
from ..package_tools import Exporter
from ..units import units
from ..xarray import check_axis, check_matching_coordinates
from .basic import coriolis_parameter
from .tools import first_derivative

exporter = Exporter(globals())

Expand Down
4 changes: 2 additions & 2 deletions src/metpy/calc/indices.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
"""Contains calculation of various derived indices."""
import numpy as np

from .thermo import mixing_ratio, saturation_vapor_pressure
from .tools import _remove_nans, get_layer
from .. import constants as mpconsts
from ..package_tools import Exporter
from ..units import check_units, concatenate, units
from ..xarray import preprocess_and_wrap
from .thermo import mixing_ratio, saturation_vapor_pressure
from .tools import _remove_nans, get_layer

exporter = Exporter(globals())

Expand Down
2 changes: 1 addition & 1 deletion src/metpy/calc/kinematics.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
import numpy as np

from . import coriolis_parameter
from .tools import first_derivative, get_layer_heights, gradient
from .. import constants as mpconsts
from ..package_tools import Exporter
from ..units import check_units, units
from ..xarray import add_grid_arguments_from_xarray, preprocess_and_wrap
from .tools import first_derivative, get_layer_heights, gradient

exporter = Exporter(globals())

Expand Down
11 changes: 9 additions & 2 deletions src/metpy/calc/thermo.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,21 @@
import scipy.optimize as so
import xarray as xr

from .tools import (_greater_or_close, _less_or_close, _remove_nans, find_bounding_indices,
find_intersections, first_derivative, get_layer)
from .. import constants as mpconsts
from ..cbook import broadcast_indices
from ..interpolate.one_dimension import interpolate_1d
from ..package_tools import Exporter
from ..units import check_units, concatenate, units
from ..xarray import add_vertical_dim_from_xarray, preprocess_and_wrap
from .tools import (
_greater_or_close,
_less_or_close,
_remove_nans,
find_bounding_indices,
find_intersections,
first_derivative,
get_layer,
)

exporter = Exporter(globals())

Expand Down
1 change: 1 addition & 0 deletions src/metpy/calc/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ def _get_bound_pressure_height(pressure, bound, height=None, interpolate=True):
"""
# avoid circular import if basic.py ever imports something from tools.py
from .basic import height_to_pressure_std, pressure_to_height_std

# Make sure pressure is monotonically decreasing
sort_inds = np.argsort(pressure)[::-1]
pressure = pressure[sort_inds]
Expand Down
2 changes: 1 addition & 1 deletion src/metpy/calc/turbulence.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

import numpy as np

from .tools import make_take
from ..package_tools import Exporter
from ..xarray import preprocess_and_wrap
from .tools import make_take

exporter = Exporter(globals())

Expand Down
8 changes: 6 additions & 2 deletions src/metpy/interpolate/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@

import numpy as np

from .points import (interpolate_to_points, inverse_distance_to_points,
natural_neighbor_to_points)
from ..package_tools import Exporter
from ..pandas import preprocess_pandas
from .points import (
interpolate_to_points,
inverse_distance_to_points,
natural_neighbor_to_points,
)

exporter = Exporter(globals())

Expand Down Expand Up @@ -342,6 +345,7 @@ def interpolate_to_isosurface(level_var, interp_var, level, bottom_up_search=Tru

"""
from ..calc import find_bounding_indices

# Find index values above and below desired interpolated surface value
above, below, good = find_bounding_indices(level_var, [level], axis=0,
from_below=bottom_up_search)
Expand Down
4 changes: 2 additions & 2 deletions src/metpy/interpolate/points.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import logging

import numpy as np
from scipy.interpolate import griddata, Rbf
from scipy.spatial import cKDTree, ConvexHull, Delaunay, qhull
from scipy.interpolate import Rbf, griddata
from scipy.spatial import ConvexHull, Delaunay, cKDTree, qhull

from . import geometry, tools
from ..package_tools import Exporter
Expand Down
2 changes: 1 addition & 1 deletion src/metpy/io/gini.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
from xarray.backends.common import AbstractDataStore
from xarray.core.utils import FrozenDict

from ._tools import Bits, IOBuffer, NamedStruct, open_as_needed, zlib_decompress_all_frames
from ..package_tools import Exporter
from ._tools import Bits, IOBuffer, NamedStruct, open_as_needed, zlib_decompress_all_frames

exporter = Exporter(globals())
log = logging.getLogger(__name__)
Expand Down
6 changes: 3 additions & 3 deletions src/metpy/io/metar.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
import numpy as np
import pandas as pd

from ._tools import open_as_needed
from .metar_parser import parse, ParseError
from .station_data import station_info
from ..calc import altimeter_to_sea_level_pressure, wind_components
from ..package_tools import Exporter
from ..plots.wx_symbols import wx_code_map
from ..units import units
from ._tools import open_as_needed
from .metar_parser import ParseError, parse
from .station_data import station_info

exporter = Exporter(globals())

Expand Down
15 changes: 12 additions & 3 deletions src/metpy/io/nexrad.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""Support reading information from various NEXRAD formats."""

import bz2
from collections import defaultdict, namedtuple, OrderedDict
from collections import OrderedDict, defaultdict, namedtuple
import contextlib
import datetime
import logging
Expand All @@ -17,9 +17,18 @@
import numpy as np
from scipy.constants import day, milli

from ._tools import (Array, BitField, Bits, DictStruct, Enum, IOBuffer, NamedStruct,
open_as_needed, zlib_decompress_all_frames)
from ..package_tools import Exporter
from ._tools import (
Array,
BitField,
Bits,
DictStruct,
Enum,
IOBuffer,
NamedStruct,
open_as_needed,
zlib_decompress_all_frames,
)

exporter = Exporter(globals())

Expand Down
8 changes: 6 additions & 2 deletions src/metpy/plots/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@

# Trigger matplotlib wrappers
from . import _mpl # noqa: F401
from ._util import (add_metpy_logo, add_timestamp, add_unidata_logo, # noqa: F401
convert_gempak_color)
from ._util import ( # noqa: F401
add_metpy_logo,
add_timestamp,
add_unidata_logo,
convert_gempak_color,
)
from .ctables import * # noqa: F403
from .declarative import * # noqa: F403
from .skewt import * # noqa: F403
Expand Down
9 changes: 5 additions & 4 deletions src/metpy/plots/_mpl.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@
# SPDX-License-Identifier: BSD-3-Clause
"""Functionality that we have upstreamed or will upstream into matplotlib."""

# See if we need to patch in our own scattertext implementation
from matplotlib.axes import Axes # noqa: E402, I100, I202

# See if we should monkey-patch Barbs for better pivot
import matplotlib.transforms as transforms
import numpy as np

# See if we need to patch in our own scattertext implementation
from matplotlib.axes import Axes # noqa: E402, I100, I202
if not hasattr(Axes, 'scattertext'):
import matplotlib.cbook as cbook
import matplotlib.transforms as mtransforms
from matplotlib import rcParams
from matplotlib.artist import allow_rasterization
import matplotlib.cbook as cbook
from matplotlib.text import Text
import matplotlib.transforms as mtransforms

def scattertext(self, x, y, texts, loc=(0, 0), **kw):
"""Add text to the axes.
Expand Down
1 change: 1 addition & 0 deletions src/metpy/plots/cartopy_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def __init__(self, name, scale, **kwargs):
def geometries(self):
"""Return an iterator of (shapely) geometries for this feature."""
import cartopy.io.shapereader as shapereader

# Ensure that the associated files are in the cache
fname = f'{self.name}_{self.scaler.scale}'
for extension in ['.dbf', '.shx']:
Expand Down
Loading