From da97204be4450ed0fa68646710f9830dfcb23a0b Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Fri, 1 Mar 2024 10:22:13 +0800 Subject: [PATCH 1/2] Bump to ruff 0.3.0 --- environment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/environment.yml b/environment.yml index d6702d6c3ce..b893373b96f 100644 --- a/environment.yml +++ b/environment.yml @@ -24,7 +24,7 @@ dependencies: - pip # Dev dependencies (style checks) - codespell - - ruff>=0.2.0 + - ruff>=0.3.0 # Dev dependencies (unit testing) - matplotlib - pytest-cov From 57103417d2f07b365fae749b4b266c6cc0f046f9 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Fri, 1 Mar 2024 10:22:32 +0800 Subject: [PATCH 2/2] Format with ruff v0.3.0 --- doc/conf.py | 1 + pygmt/__init__.py | 1 + pygmt/accessors.py | 1 + pygmt/clib/conversion.py | 1 + pygmt/clib/loading.py | 1 + pygmt/clib/session.py | 1 + pygmt/datasets/earth_age.py | 1 + pygmt/datasets/earth_free_air_anomaly.py | 1 + pygmt/datasets/earth_geoid.py | 1 + pygmt/datasets/earth_magnetic_anomaly.py | 1 + pygmt/datasets/earth_mask.py | 1 + pygmt/datasets/earth_relief.py | 1 + pygmt/datasets/earth_vertical_gravity_gradient.py | 1 + pygmt/datasets/load_remote_dataset.py | 1 + pygmt/datasets/mars_relief.py | 1 + pygmt/datasets/mercury_relief.py | 1 + pygmt/datasets/moon_relief.py | 1 + pygmt/datasets/pluto_relief.py | 1 + pygmt/datasets/samples.py | 1 + pygmt/datasets/tile_map.py | 1 + pygmt/datasets/venus_relief.py | 1 + pygmt/datatypes/__init__.py | 1 + pygmt/datatypes/dataset.py | 1 + pygmt/datatypes/grid.py | 1 + pygmt/figure.py | 1 + pygmt/helpers/__init__.py | 1 + pygmt/helpers/caching.py | 1 + pygmt/helpers/decorators.py | 7 ++++--- pygmt/helpers/tempfile.py | 1 + pygmt/helpers/testing.py | 1 + pygmt/helpers/utils.py | 1 + pygmt/helpers/validators.py | 1 + pygmt/io.py | 1 + pygmt/session_management.py | 1 + pygmt/src/__init__.py | 1 + pygmt/src/binstats.py | 1 + pygmt/src/blockm.py | 1 + pygmt/src/config.py | 1 + pygmt/src/grdcontour.py | 1 + pygmt/src/grdimage.py | 12 +++++++----- pygmt/src/grdinfo.py | 1 + pygmt/src/grdlandmask.py | 1 + pygmt/src/grdproject.py | 1 + pygmt/src/grdtrack.py | 12 +++++++----- pygmt/src/grdview.py | 12 +++++++----- pygmt/src/grdvolume.py | 1 + pygmt/src/histogram.py | 1 + pygmt/src/image.py | 1 + pygmt/src/info.py | 1 + pygmt/src/inset.py | 1 + pygmt/src/makecpt.py | 1 + pygmt/src/meca.py | 1 + pygmt/src/plot.py | 1 + pygmt/src/plot3d.py | 1 + pygmt/src/project.py | 1 + pygmt/src/select.py | 1 + pygmt/src/shift_origin.py | 1 + pygmt/src/solar.py | 1 + pygmt/src/sph2grd.py | 1 + pygmt/src/sphdistance.py | 1 + pygmt/src/sphinterpolate.py | 1 + pygmt/src/subplot.py | 1 + pygmt/src/surface.py | 1 + pygmt/src/ternary.py | 1 + pygmt/src/text.py | 1 + pygmt/src/tilemap.py | 1 + pygmt/src/timestamp.py | 1 + pygmt/src/velo.py | 1 + pygmt/src/which.py | 1 + pygmt/src/x2sys_cross.py | 1 + pygmt/src/x2sys_init.py | 1 + pygmt/src/xyz2grd.py | 1 + pygmt/tests/test_accessor.py | 1 + pygmt/tests/test_basemap.py | 1 + pygmt/tests/test_binstats.py | 1 + pygmt/tests/test_blockm.py | 1 + pygmt/tests/test_blockmedian.py | 1 + pygmt/tests/test_clib.py | 1 + pygmt/tests/test_clib_loading.py | 1 + pygmt/tests/test_clib_put_matrix.py | 1 + pygmt/tests/test_clib_put_strings.py | 1 + pygmt/tests/test_clib_put_vector.py | 1 + pygmt/tests/test_clib_virtualfiles.py | 7 +++++-- pygmt/tests/test_coast.py | 1 + pygmt/tests/test_colorbar.py | 1 + pygmt/tests/test_config.py | 1 + pygmt/tests/test_contour.py | 1 + pygmt/tests/test_datasets_earth_age.py | 1 + pygmt/tests/test_datasets_earth_free_air_anomaly.py | 1 + pygmt/tests/test_datasets_earth_geoid.py | 1 + pygmt/tests/test_datasets_earth_magnetic_anomaly.py | 1 + pygmt/tests/test_datasets_earth_mask.py | 1 + pygmt/tests/test_datasets_earth_relief.py | 1 + .../test_datasets_earth_vertical_gravity_gradient.py | 1 + pygmt/tests/test_datasets_load_remote_datasets.py | 1 + pygmt/tests/test_datasets_mars_relief.py | 1 + pygmt/tests/test_datasets_mercury_relief.py | 1 + pygmt/tests/test_datasets_moon_relief.py | 1 + pygmt/tests/test_datasets_pluto_relief.py | 1 + pygmt/tests/test_datasets_samples.py | 1 + pygmt/tests/test_datasets_venus_relief.py | 1 + pygmt/tests/test_dimfilter.py | 1 + pygmt/tests/test_figure.py | 1 + pygmt/tests/test_filter1d.py | 1 + pygmt/tests/test_geopandas.py | 1 + pygmt/tests/test_grd2cpt.py | 1 + pygmt/tests/test_grd2xyz.py | 1 + pygmt/tests/test_grdclip.py | 1 + pygmt/tests/test_grdcontour.py | 1 + pygmt/tests/test_grdcut.py | 1 + pygmt/tests/test_grdfill.py | 1 + pygmt/tests/test_grdfilter.py | 1 + pygmt/tests/test_grdgradient.py | 1 + pygmt/tests/test_grdhisteq.py | 1 + pygmt/tests/test_grdimage.py | 1 + pygmt/tests/test_grdimage_image.py | 1 + pygmt/tests/test_grdinfo.py | 1 + pygmt/tests/test_grdlandmask.py | 1 + pygmt/tests/test_grdproject.py | 1 + pygmt/tests/test_grdsample.py | 1 + pygmt/tests/test_grdtrack.py | 1 + pygmt/tests/test_grdview.py | 1 + pygmt/tests/test_grdvolume.py | 1 + pygmt/tests/test_helpers.py | 1 + pygmt/tests/test_histogram.py | 1 + pygmt/tests/test_image.py | 1 + pygmt/tests/test_info.py | 1 + pygmt/tests/test_init.py | 1 + pygmt/tests/test_inset.py | 1 + pygmt/tests/test_io.py | 1 + pygmt/tests/test_legend.py | 1 + pygmt/tests/test_logo.py | 1 + pygmt/tests/test_makecpt.py | 1 + pygmt/tests/test_meca.py | 1 + pygmt/tests/test_nearneighbor.py | 1 + pygmt/tests/test_plot.py | 1 + pygmt/tests/test_plot3d.py | 1 + pygmt/tests/test_project.py | 1 + pygmt/tests/test_psconvert.py | 1 + pygmt/tests/test_rose.py | 1 + pygmt/tests/test_select.py | 1 + pygmt/tests/test_session_management.py | 1 + pygmt/tests/test_solar.py | 1 + pygmt/tests/test_sph2grd.py | 1 + pygmt/tests/test_sphdistance.py | 1 + pygmt/tests/test_sphinterpolate.py | 1 + pygmt/tests/test_sphinx_gallery.py | 1 + pygmt/tests/test_subplot.py | 1 + pygmt/tests/test_surface.py | 1 + pygmt/tests/test_ternary.py | 1 + pygmt/tests/test_text.py | 1 + pygmt/tests/test_tilemap.py | 1 + pygmt/tests/test_timestamp.py | 1 + pygmt/tests/test_triangulate.py | 1 + pygmt/tests/test_velo.py | 1 + pygmt/tests/test_which.py | 1 + pygmt/tests/test_wiggle.py | 1 + pygmt/tests/test_x2sys_cross.py | 1 + pygmt/tests/test_x2sys_init.py | 1 + pygmt/tests/test_xyz2grd.py | 1 + 160 files changed, 185 insertions(+), 20 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index 2b3e1adb209..b8a6c6ce4fc 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -1,6 +1,7 @@ """ Sphinx documentation configuration file. """ + import datetime from importlib.metadata import metadata diff --git a/pygmt/__init__.py b/pygmt/__init__.py index 0d22a6047b4..917aab0ac62 100644 --- a/pygmt/__init__.py +++ b/pygmt/__init__.py @@ -17,6 +17,7 @@ lines, vectors, polygons, and symbols (pre-defined and customized). - Generating publication-quality illustrations and making animations. """ + import atexit as _atexit import sys from importlib.metadata import version diff --git a/pygmt/accessors.py b/pygmt/accessors.py index e03ed28c03a..6d661a6dbc4 100644 --- a/pygmt/accessors.py +++ b/pygmt/accessors.py @@ -1,6 +1,7 @@ """ GMT accessor for :class:`xarray.DataArray`. """ + from pathlib import Path import xarray as xr diff --git a/pygmt/clib/conversion.py b/pygmt/clib/conversion.py index b3530926bb2..27cda9f971c 100644 --- a/pygmt/clib/conversion.py +++ b/pygmt/clib/conversion.py @@ -1,6 +1,7 @@ """ Functions to convert data types into ctypes friendly formats. """ + import warnings import numpy as np diff --git a/pygmt/clib/loading.py b/pygmt/clib/loading.py index 54208ffee44..2cc05a6ae6b 100644 --- a/pygmt/clib/loading.py +++ b/pygmt/clib/loading.py @@ -4,6 +4,7 @@ The path to the shared library can be found automatically by ctypes or set through the GMT_LIBRARY_PATH environment variable. """ + import ctypes import os import shutil diff --git a/pygmt/clib/session.py b/pygmt/clib/session.py index d8544a7937b..b2fd760dcd2 100644 --- a/pygmt/clib/session.py +++ b/pygmt/clib/session.py @@ -4,6 +4,7 @@ Uses ctypes to wrap most of the core functions from the C API. """ + import contextlib import ctypes as ctp import pathlib diff --git a/pygmt/datasets/earth_age.py b/pygmt/datasets/earth_age.py index d6b91d1ef0f..702129826c8 100644 --- a/pygmt/datasets/earth_age.py +++ b/pygmt/datasets/earth_age.py @@ -4,6 +4,7 @@ The grids are available in various resolutions. """ + from typing import Literal from pygmt.datasets.load_remote_dataset import _load_remote_dataset diff --git a/pygmt/datasets/earth_free_air_anomaly.py b/pygmt/datasets/earth_free_air_anomaly.py index ef9a9d61947..00abae85122 100644 --- a/pygmt/datasets/earth_free_air_anomaly.py +++ b/pygmt/datasets/earth_free_air_anomaly.py @@ -4,6 +4,7 @@ The grids are available in various resolutions. """ + from typing import Literal from pygmt.datasets.load_remote_dataset import _load_remote_dataset diff --git a/pygmt/datasets/earth_geoid.py b/pygmt/datasets/earth_geoid.py index 46c44661c4f..e62fb20bdf3 100644 --- a/pygmt/datasets/earth_geoid.py +++ b/pygmt/datasets/earth_geoid.py @@ -4,6 +4,7 @@ The grids are available in various resolutions. """ + from typing import Literal from pygmt.datasets.load_remote_dataset import _load_remote_dataset diff --git a/pygmt/datasets/earth_magnetic_anomaly.py b/pygmt/datasets/earth_magnetic_anomaly.py index c36b9a673b2..7eb1552bbc8 100644 --- a/pygmt/datasets/earth_magnetic_anomaly.py +++ b/pygmt/datasets/earth_magnetic_anomaly.py @@ -4,6 +4,7 @@ The grids are available in various resolutions. """ + from typing import Literal from pygmt.datasets.load_remote_dataset import _load_remote_dataset diff --git a/pygmt/datasets/earth_mask.py b/pygmt/datasets/earth_mask.py index e49c451ca70..cd38b5bc5c2 100644 --- a/pygmt/datasets/earth_mask.py +++ b/pygmt/datasets/earth_mask.py @@ -4,6 +4,7 @@ The grids are available in various resolutions. """ + from typing import Literal from pygmt.datasets.load_remote_dataset import _load_remote_dataset diff --git a/pygmt/datasets/earth_relief.py b/pygmt/datasets/earth_relief.py index ee1059a21b9..e87f2b403fe 100644 --- a/pygmt/datasets/earth_relief.py +++ b/pygmt/datasets/earth_relief.py @@ -4,6 +4,7 @@ The grids are available in various resolutions. """ + from typing import Literal from pygmt.datasets.load_remote_dataset import _load_remote_dataset diff --git a/pygmt/datasets/earth_vertical_gravity_gradient.py b/pygmt/datasets/earth_vertical_gravity_gradient.py index 5f46da77a01..da5fc880766 100644 --- a/pygmt/datasets/earth_vertical_gravity_gradient.py +++ b/pygmt/datasets/earth_vertical_gravity_gradient.py @@ -4,6 +4,7 @@ The grids are available in various resolutions. """ + from typing import Literal from pygmt.datasets.load_remote_dataset import _load_remote_dataset diff --git a/pygmt/datasets/load_remote_dataset.py b/pygmt/datasets/load_remote_dataset.py index 73c7d46dcf7..0907d35dccf 100644 --- a/pygmt/datasets/load_remote_dataset.py +++ b/pygmt/datasets/load_remote_dataset.py @@ -1,6 +1,7 @@ """ Internal function to load GMT remote datasets. """ + from __future__ import annotations from typing import TYPE_CHECKING, ClassVar, NamedTuple diff --git a/pygmt/datasets/mars_relief.py b/pygmt/datasets/mars_relief.py index 1d4ae06ee4d..a8106513a79 100644 --- a/pygmt/datasets/mars_relief.py +++ b/pygmt/datasets/mars_relief.py @@ -4,6 +4,7 @@ The grids are available in various resolutions. """ + from typing import Literal from pygmt.datasets.load_remote_dataset import _load_remote_dataset diff --git a/pygmt/datasets/mercury_relief.py b/pygmt/datasets/mercury_relief.py index 52a8d8787db..956a41ed145 100644 --- a/pygmt/datasets/mercury_relief.py +++ b/pygmt/datasets/mercury_relief.py @@ -4,6 +4,7 @@ The grids are available in various resolutions. """ + from typing import Literal from pygmt.datasets.load_remote_dataset import _load_remote_dataset diff --git a/pygmt/datasets/moon_relief.py b/pygmt/datasets/moon_relief.py index 1045aef519c..5681fb7becb 100644 --- a/pygmt/datasets/moon_relief.py +++ b/pygmt/datasets/moon_relief.py @@ -4,6 +4,7 @@ The grids are available in various resolutions. """ + from typing import Literal from pygmt.datasets.load_remote_dataset import _load_remote_dataset diff --git a/pygmt/datasets/pluto_relief.py b/pygmt/datasets/pluto_relief.py index dbc74a23f03..72de0c9c593 100644 --- a/pygmt/datasets/pluto_relief.py +++ b/pygmt/datasets/pluto_relief.py @@ -4,6 +4,7 @@ The grids are available in various resolutions. """ + from typing import Literal from pygmt.datasets.load_remote_dataset import _load_remote_dataset diff --git a/pygmt/datasets/samples.py b/pygmt/datasets/samples.py index e3182df54b8..297d1ce14fd 100644 --- a/pygmt/datasets/samples.py +++ b/pygmt/datasets/samples.py @@ -1,6 +1,7 @@ """ Functions to load sample data. """ + from collections.abc import Callable from typing import Literal, NamedTuple diff --git a/pygmt/datasets/tile_map.py b/pygmt/datasets/tile_map.py index 7e690dfb65e..1f30aa1ff51 100644 --- a/pygmt/datasets/tile_map.py +++ b/pygmt/datasets/tile_map.py @@ -2,6 +2,7 @@ Function to load raster tile maps from XYZ tile providers, and load as :class:`xarray.DataArray`. """ + from __future__ import annotations from packaging.version import Version diff --git a/pygmt/datasets/venus_relief.py b/pygmt/datasets/venus_relief.py index fea98a68a00..0bf52f7b611 100644 --- a/pygmt/datasets/venus_relief.py +++ b/pygmt/datasets/venus_relief.py @@ -4,6 +4,7 @@ The grids are available in various resolutions. """ + from typing import Literal from pygmt.datasets.load_remote_dataset import _load_remote_dataset diff --git a/pygmt/datatypes/__init__.py b/pygmt/datatypes/__init__.py index a257f73c489..237a050a9f7 100644 --- a/pygmt/datatypes/__init__.py +++ b/pygmt/datatypes/__init__.py @@ -1,5 +1,6 @@ """ Wrappers for GMT data types. """ + from pygmt.datatypes.dataset import _GMT_DATASET from pygmt.datatypes.grid import _GMT_GRID diff --git a/pygmt/datatypes/dataset.py b/pygmt/datatypes/dataset.py index cc1f29041ee..32b7397dbba 100644 --- a/pygmt/datatypes/dataset.py +++ b/pygmt/datatypes/dataset.py @@ -1,6 +1,7 @@ """ Wrapper for the GMT_DATASET data type. """ + import ctypes as ctp diff --git a/pygmt/datatypes/grid.py b/pygmt/datatypes/grid.py index b1801d6e0fc..e67f44ebef5 100644 --- a/pygmt/datatypes/grid.py +++ b/pygmt/datatypes/grid.py @@ -1,6 +1,7 @@ """ Wrapper for the GMT_GRID data type. """ + import ctypes as ctp diff --git a/pygmt/figure.py b/pygmt/figure.py index 0986c6c87be..98f06291c6b 100644 --- a/pygmt/figure.py +++ b/pygmt/figure.py @@ -1,6 +1,7 @@ """ Define the Figure class that handles all plotting. """ + import base64 import os from pathlib import Path diff --git a/pygmt/helpers/__init__.py b/pygmt/helpers/__init__.py index 8b8891cb63f..d0356798d97 100644 --- a/pygmt/helpers/__init__.py +++ b/pygmt/helpers/__init__.py @@ -1,6 +1,7 @@ """ Functions, classes, decorators, and context managers to help wrap GMT modules. """ + from pygmt.helpers.decorators import ( deprecate_parameter, fmt_docstring, diff --git a/pygmt/helpers/caching.py b/pygmt/helpers/caching.py index c944e20acf5..44d9f6f05d1 100644 --- a/pygmt/helpers/caching.py +++ b/pygmt/helpers/caching.py @@ -1,6 +1,7 @@ """ Functions for downloading remote data files to cache. """ + from pygmt.src import which diff --git a/pygmt/helpers/decorators.py b/pygmt/helpers/decorators.py index 253fdc2b0d5..046cffa5514 100644 --- a/pygmt/helpers/decorators.py +++ b/pygmt/helpers/decorators.py @@ -5,6 +5,7 @@ arguments, insert common text into docstrings, transform arguments to strings, etc. """ + import functools import textwrap import warnings @@ -455,9 +456,9 @@ def fmt_docstring(module_func): aliases.append(f"- {arg} = {alias}") filler_text["aliases"] = "\n".join(aliases) - filler_text[ - "table-like" - ] = "numpy.ndarray, pandas.DataFrame, xarray.Dataset, or geopandas.GeoDataFrame" + filler_text["table-like"] = ( + "numpy.ndarray, pandas.DataFrame, xarray.Dataset, or geopandas.GeoDataFrame" + ) filler_text["table-classes"] = ( ":class:`numpy.ndarray`, a :class:`pandas.DataFrame`, an\n" " :class:`xarray.Dataset` made up of 1-D :class:`xarray.DataArray`\n" diff --git a/pygmt/helpers/tempfile.py b/pygmt/helpers/tempfile.py index 5545d2b3695..62a3daf5447 100644 --- a/pygmt/helpers/tempfile.py +++ b/pygmt/helpers/tempfile.py @@ -1,6 +1,7 @@ """ Utilities for dealing with temporary file management. """ + import os import uuid from contextlib import contextmanager diff --git a/pygmt/helpers/testing.py b/pygmt/helpers/testing.py index 81ffc2ff5cf..1a1c72cb334 100644 --- a/pygmt/helpers/testing.py +++ b/pygmt/helpers/testing.py @@ -1,6 +1,7 @@ """ Helper functions for testing. """ + import importlib import inspect import os diff --git a/pygmt/helpers/utils.py b/pygmt/helpers/utils.py index f1649a68a74..75514d2077d 100644 --- a/pygmt/helpers/utils.py +++ b/pygmt/helpers/utils.py @@ -1,6 +1,7 @@ """ Utilities and common tasks for wrapping the GMT modules. """ + # ruff: noqa: RUF001 import os import pathlib diff --git a/pygmt/helpers/validators.py b/pygmt/helpers/validators.py index c400163fee8..a91205809da 100644 --- a/pygmt/helpers/validators.py +++ b/pygmt/helpers/validators.py @@ -1,6 +1,7 @@ """ Functions to check if given arguments are valid. """ + import warnings from pygmt.exceptions import GMTInvalidInput diff --git a/pygmt/io.py b/pygmt/io.py index 9c27e7b08b5..33f3bfdbb12 100644 --- a/pygmt/io.py +++ b/pygmt/io.py @@ -1,6 +1,7 @@ """ PyGMT input/output (I/O) utilities. """ + import xarray as xr diff --git a/pygmt/session_management.py b/pygmt/session_management.py index 750157679d4..9b598c72d73 100644 --- a/pygmt/session_management.py +++ b/pygmt/session_management.py @@ -1,6 +1,7 @@ """ Modern mode session management modules. """ + import os import sys diff --git a/pygmt/src/__init__.py b/pygmt/src/__init__.py index 7f7d9f93674..1d113e5dd30 100644 --- a/pygmt/src/__init__.py +++ b/pygmt/src/__init__.py @@ -1,6 +1,7 @@ """ Source code for PyGMT methods. """ + from pygmt.src.basemap import basemap from pygmt.src.binstats import binstats from pygmt.src.blockm import blockmean, blockmedian, blockmode diff --git a/pygmt/src/binstats.py b/pygmt/src/binstats.py index 5e5188915b4..3304ee9ea54 100644 --- a/pygmt/src/binstats.py +++ b/pygmt/src/binstats.py @@ -1,6 +1,7 @@ """ binstats - Bin spatial data and determine statistics per bin """ + from pygmt.clib import Session from pygmt.helpers import ( GMTTempFile, diff --git a/pygmt/src/blockm.py b/pygmt/src/blockm.py index 8f0bde7f6f6..038066cacac 100644 --- a/pygmt/src/blockm.py +++ b/pygmt/src/blockm.py @@ -2,6 +2,7 @@ blockm - Block average (x, y, z) data tables by mean, median, or mode estimation. """ + import pandas as pd from pygmt.clib import Session from pygmt.helpers import ( diff --git a/pygmt/src/config.py b/pygmt/src/config.py index dd0854a296b..9d647ff83d1 100644 --- a/pygmt/src/config.py +++ b/pygmt/src/config.py @@ -1,6 +1,7 @@ """ config - set GMT defaults globally or locally. """ + from inspect import Parameter, Signature from typing import ClassVar diff --git a/pygmt/src/grdcontour.py b/pygmt/src/grdcontour.py index 6c3707d3e93..4bedea245bd 100644 --- a/pygmt/src/grdcontour.py +++ b/pygmt/src/grdcontour.py @@ -1,6 +1,7 @@ """ grdcontour - Plot a contour figure. """ + from pygmt.clib import Session from pygmt.helpers import build_arg_string, fmt_docstring, kwargs_to_strings, use_alias diff --git a/pygmt/src/grdimage.py b/pygmt/src/grdimage.py index 1c9e3319ea2..d670ba1ebaf 100644 --- a/pygmt/src/grdimage.py +++ b/pygmt/src/grdimage.py @@ -1,6 +1,7 @@ """ grdimage - Plot grids or images. """ + from pygmt.clib import Session from pygmt.exceptions import GMTInvalidInput from pygmt.helpers import ( @@ -163,11 +164,12 @@ def grdimage(self, grid, **kwargs): ) with Session() as lib: - with lib.virtualfile_in( - check_kind="raster", data=grid - ) as fname, lib.virtualfile_in( - check_kind="raster", data=kwargs.get("I"), required_data=False - ) as shadegrid: + with ( + lib.virtualfile_in(check_kind="raster", data=grid) as fname, + lib.virtualfile_in( + check_kind="raster", data=kwargs.get("I"), required_data=False + ) as shadegrid, + ): kwargs["I"] = shadegrid lib.call_module( module="grdimage", args=build_arg_string(kwargs, infile=fname) diff --git a/pygmt/src/grdinfo.py b/pygmt/src/grdinfo.py index 651e403eac7..a0b18795133 100644 --- a/pygmt/src/grdinfo.py +++ b/pygmt/src/grdinfo.py @@ -1,6 +1,7 @@ """ grdinfo - Retrieve info about grid file. """ + from pygmt.clib import Session from pygmt.helpers import ( GMTTempFile, diff --git a/pygmt/src/grdlandmask.py b/pygmt/src/grdlandmask.py index beb06450959..29bfef73fd6 100644 --- a/pygmt/src/grdlandmask.py +++ b/pygmt/src/grdlandmask.py @@ -1,6 +1,7 @@ """ grdlandmask - Create a "wet-dry" mask grid from shoreline data base """ + from pygmt.clib import Session from pygmt.exceptions import GMTInvalidInput from pygmt.helpers import ( diff --git a/pygmt/src/grdproject.py b/pygmt/src/grdproject.py index 3add55e421b..4c4b06f361d 100644 --- a/pygmt/src/grdproject.py +++ b/pygmt/src/grdproject.py @@ -1,6 +1,7 @@ """ grdproject - Forward and inverse map transformation of grids. """ + from pygmt.clib import Session from pygmt.exceptions import GMTInvalidInput from pygmt.helpers import ( diff --git a/pygmt/src/grdtrack.py b/pygmt/src/grdtrack.py index 8859e642fdb..fe13bb02b2d 100644 --- a/pygmt/src/grdtrack.py +++ b/pygmt/src/grdtrack.py @@ -1,6 +1,7 @@ """ grdtrack - Sample grids at specified (x,y) locations. """ + import pandas as pd from pygmt.clib import Session from pygmt.exceptions import GMTInvalidInput @@ -292,11 +293,12 @@ def grdtrack(grid, points=None, newcolname=None, outfile=None, **kwargs): with GMTTempFile(suffix=".csv") as tmpfile: with Session() as lib: - with lib.virtualfile_in( - check_kind="raster", data=grid - ) as grdfile, lib.virtualfile_in( - check_kind="vector", data=points, required_data=False - ) as csvfile: + with ( + lib.virtualfile_in(check_kind="raster", data=grid) as grdfile, + lib.virtualfile_in( + check_kind="vector", data=points, required_data=False + ) as csvfile, + ): kwargs["G"] = grdfile if outfile is None: # Output to tmpfile if outfile is not set outfile = tmpfile.name diff --git a/pygmt/src/grdview.py b/pygmt/src/grdview.py index 7ff4a5f7599..601648b13d7 100644 --- a/pygmt/src/grdview.py +++ b/pygmt/src/grdview.py @@ -1,6 +1,7 @@ """ grdview - Create a three-dimensional plot from a grid. """ + from pygmt.clib import Session from pygmt.helpers import build_arg_string, fmt_docstring, kwargs_to_strings, use_alias @@ -144,11 +145,12 @@ def grdview(self, grid, **kwargs): """ kwargs = self._preprocess(**kwargs) with Session() as lib: - with lib.virtualfile_in( - check_kind="raster", data=grid - ) as fname, lib.virtualfile_in( - check_kind="raster", data=kwargs.get("G"), required_data=False - ) as drapegrid: + with ( + lib.virtualfile_in(check_kind="raster", data=grid) as fname, + lib.virtualfile_in( + check_kind="raster", data=kwargs.get("G"), required_data=False + ) as drapegrid, + ): kwargs["G"] = drapegrid lib.call_module( module="grdview", args=build_arg_string(kwargs, infile=fname) diff --git a/pygmt/src/grdvolume.py b/pygmt/src/grdvolume.py index d64b7eb70e0..d5c6515ee1e 100644 --- a/pygmt/src/grdvolume.py +++ b/pygmt/src/grdvolume.py @@ -1,6 +1,7 @@ """ grdvolume - Calculate grid volume and area constrained by a contour. """ + import pandas as pd from pygmt.clib import Session from pygmt.helpers import ( diff --git a/pygmt/src/histogram.py b/pygmt/src/histogram.py index c059cf631eb..50ae0a71fa2 100644 --- a/pygmt/src/histogram.py +++ b/pygmt/src/histogram.py @@ -1,6 +1,7 @@ """ Histogram - Create a histogram """ + from pygmt.clib import Session from pygmt.helpers import build_arg_string, fmt_docstring, kwargs_to_strings, use_alias diff --git a/pygmt/src/image.py b/pygmt/src/image.py index 951033af255..80bc7552b0c 100644 --- a/pygmt/src/image.py +++ b/pygmt/src/image.py @@ -1,6 +1,7 @@ """ image - Plot an image. """ + from pygmt.clib import Session from pygmt.helpers import build_arg_string, fmt_docstring, kwargs_to_strings, use_alias diff --git a/pygmt/src/info.py b/pygmt/src/info.py index abf5c4ebd5f..ee0e98c676a 100644 --- a/pygmt/src/info.py +++ b/pygmt/src/info.py @@ -1,6 +1,7 @@ """ info - Get information about data tables. """ + import numpy as np from pygmt.clib import Session from pygmt.helpers import ( diff --git a/pygmt/src/inset.py b/pygmt/src/inset.py index 6e31649da9f..97b9825c1d1 100644 --- a/pygmt/src/inset.py +++ b/pygmt/src/inset.py @@ -1,6 +1,7 @@ """ inset - Create inset figures. """ + import contextlib from pygmt.clib import Session diff --git a/pygmt/src/makecpt.py b/pygmt/src/makecpt.py index 0d87268e97f..9e8a07e6f95 100644 --- a/pygmt/src/makecpt.py +++ b/pygmt/src/makecpt.py @@ -1,6 +1,7 @@ """ makecpt - Make GMT color palette tables. """ + from pygmt.clib import Session from pygmt.exceptions import GMTInvalidInput from pygmt.helpers import build_arg_string, fmt_docstring, kwargs_to_strings, use_alias diff --git a/pygmt/src/meca.py b/pygmt/src/meca.py index b66a9529858..e4a64c933ee 100644 --- a/pygmt/src/meca.py +++ b/pygmt/src/meca.py @@ -1,6 +1,7 @@ """ meca - Plot focal mechanisms. """ + import numpy as np import pandas as pd from pygmt.clib import Session diff --git a/pygmt/src/plot.py b/pygmt/src/plot.py index 0c28b81b5a6..aa9171d033e 100644 --- a/pygmt/src/plot.py +++ b/pygmt/src/plot.py @@ -1,6 +1,7 @@ """ plot - Plot in two dimensions. """ + from pygmt.clib import Session from pygmt.exceptions import GMTInvalidInput from pygmt.helpers import ( diff --git a/pygmt/src/plot3d.py b/pygmt/src/plot3d.py index b783aba0d22..c22e2270e4a 100644 --- a/pygmt/src/plot3d.py +++ b/pygmt/src/plot3d.py @@ -1,6 +1,7 @@ """ plot3d - Plot in three dimensions. """ + from pygmt.clib import Session from pygmt.exceptions import GMTInvalidInput from pygmt.helpers import ( diff --git a/pygmt/src/project.py b/pygmt/src/project.py index bde40f150ed..f20cb4a97e6 100644 --- a/pygmt/src/project.py +++ b/pygmt/src/project.py @@ -1,6 +1,7 @@ """ project - Project data onto lines or great circles, or generate tracks. """ + import pandas as pd from pygmt.clib import Session from pygmt.exceptions import GMTInvalidInput diff --git a/pygmt/src/select.py b/pygmt/src/select.py index d819cadac73..653b005da01 100644 --- a/pygmt/src/select.py +++ b/pygmt/src/select.py @@ -1,6 +1,7 @@ """ select - Select data table subsets based on multiple spatial criteria. """ + import pandas as pd from pygmt.clib import Session from pygmt.helpers import ( diff --git a/pygmt/src/shift_origin.py b/pygmt/src/shift_origin.py index d877a89d62b..ed789231799 100644 --- a/pygmt/src/shift_origin.py +++ b/pygmt/src/shift_origin.py @@ -1,6 +1,7 @@ """ shift_origin - Shift plot origin in x and/or y directions. """ + from __future__ import annotations from pygmt.clib import Session diff --git a/pygmt/src/solar.py b/pygmt/src/solar.py index 3413214cbd6..ffc086e8267 100644 --- a/pygmt/src/solar.py +++ b/pygmt/src/solar.py @@ -1,6 +1,7 @@ """ solar - Plot day-night terminators and twilight. """ + from __future__ import annotations from typing import Literal diff --git a/pygmt/src/sph2grd.py b/pygmt/src/sph2grd.py index 9cf5bcf1fdc..582167e5313 100644 --- a/pygmt/src/sph2grd.py +++ b/pygmt/src/sph2grd.py @@ -1,6 +1,7 @@ """ sph2grd - Compute grid from spherical harmonic coefficients """ + from pygmt.clib import Session from pygmt.helpers import ( GMTTempFile, diff --git a/pygmt/src/sphdistance.py b/pygmt/src/sphdistance.py index c57431f935e..118e4733e75 100644 --- a/pygmt/src/sphdistance.py +++ b/pygmt/src/sphdistance.py @@ -2,6 +2,7 @@ sphdistance - Create Voronoi distance, node, or natural nearest-neighbor grid on a sphere """ + from pygmt.clib import Session from pygmt.exceptions import GMTInvalidInput from pygmt.helpers import ( diff --git a/pygmt/src/sphinterpolate.py b/pygmt/src/sphinterpolate.py index 7be24a8523e..461cdff31f0 100644 --- a/pygmt/src/sphinterpolate.py +++ b/pygmt/src/sphinterpolate.py @@ -1,6 +1,7 @@ """ sphinterpolate - Spherical gridding in tension of data on a sphere """ + from pygmt.clib import Session from pygmt.helpers import ( GMTTempFile, diff --git a/pygmt/src/subplot.py b/pygmt/src/subplot.py index 563bd655a96..0b913472022 100644 --- a/pygmt/src/subplot.py +++ b/pygmt/src/subplot.py @@ -1,6 +1,7 @@ """ subplot - Manage modern mode figure subplot configuration and selection. """ + import contextlib from pygmt.clib import Session diff --git a/pygmt/src/surface.py b/pygmt/src/surface.py index 37487ca5fdd..4e218ad209c 100644 --- a/pygmt/src/surface.py +++ b/pygmt/src/surface.py @@ -2,6 +2,7 @@ surface - Grid table data using adjustable tension continuous curvature splines. """ + from pygmt.clib import Session from pygmt.helpers import ( GMTTempFile, diff --git a/pygmt/src/ternary.py b/pygmt/src/ternary.py index bf3434c639b..fb984457c82 100644 --- a/pygmt/src/ternary.py +++ b/pygmt/src/ternary.py @@ -1,6 +1,7 @@ """ ternary - Plot data on ternary diagrams. """ + import pandas as pd from packaging.version import Version from pygmt.clib import Session, __gmt_version__ diff --git a/pygmt/src/text.py b/pygmt/src/text.py index 16d409136a6..5087e9b2186 100644 --- a/pygmt/src/text.py +++ b/pygmt/src/text.py @@ -1,6 +1,7 @@ """ text - Plot text on a figure. """ + import numpy as np from pygmt.clib import Session from pygmt.exceptions import GMTInvalidInput diff --git a/pygmt/src/tilemap.py b/pygmt/src/tilemap.py index d2aeaad04d9..7e94b29b7ff 100644 --- a/pygmt/src/tilemap.py +++ b/pygmt/src/tilemap.py @@ -1,6 +1,7 @@ """ tilemap - Plot XYZ tile maps. """ + from __future__ import annotations from pygmt.clib import Session diff --git a/pygmt/src/timestamp.py b/pygmt/src/timestamp.py index 84937a08a2f..c7cc18574cf 100644 --- a/pygmt/src/timestamp.py +++ b/pygmt/src/timestamp.py @@ -1,6 +1,7 @@ """ timestamp - Plot the GMT timestamp logo. """ + from __future__ import annotations import warnings diff --git a/pygmt/src/velo.py b/pygmt/src/velo.py index 1a81a66b10e..3f0d485df68 100644 --- a/pygmt/src/velo.py +++ b/pygmt/src/velo.py @@ -1,6 +1,7 @@ """ velo - Plot velocity vectors, crosses, anisotropy bars, and wedges. """ + import numpy as np import pandas as pd from pygmt.clib import Session diff --git a/pygmt/src/which.py b/pygmt/src/which.py index d20059f0492..1cfd7df0c39 100644 --- a/pygmt/src/which.py +++ b/pygmt/src/which.py @@ -1,6 +1,7 @@ """ which - Find the full path to specified files. """ + from pygmt.clib import Session from pygmt.helpers import ( GMTTempFile, diff --git a/pygmt/src/x2sys_cross.py b/pygmt/src/x2sys_cross.py index dec6f041e34..a8988a00af8 100644 --- a/pygmt/src/x2sys_cross.py +++ b/pygmt/src/x2sys_cross.py @@ -1,6 +1,7 @@ """ x2sys_cross - Calculate crossovers between track data files. """ + import contextlib import os from pathlib import Path diff --git a/pygmt/src/x2sys_init.py b/pygmt/src/x2sys_init.py index 3387d24797e..f4107e6f0b6 100644 --- a/pygmt/src/x2sys_init.py +++ b/pygmt/src/x2sys_init.py @@ -1,6 +1,7 @@ """ x2sys_init - Initialize a new x2sys track database. """ + from pygmt.clib import Session from pygmt.helpers import build_arg_string, fmt_docstring, kwargs_to_strings, use_alias diff --git a/pygmt/src/xyz2grd.py b/pygmt/src/xyz2grd.py index fed9b82ed7f..3cd26181608 100644 --- a/pygmt/src/xyz2grd.py +++ b/pygmt/src/xyz2grd.py @@ -1,6 +1,7 @@ """ xyz2grd - Convert data table to a grid. """ + from pygmt.clib import Session from pygmt.exceptions import GMTInvalidInput from pygmt.helpers import ( diff --git a/pygmt/tests/test_accessor.py b/pygmt/tests/test_accessor.py index 6ba6c58b122..a12c01e9265 100644 --- a/pygmt/tests/test_accessor.py +++ b/pygmt/tests/test_accessor.py @@ -1,6 +1,7 @@ """ Test the behaviour of the GMTDataArrayAccessor class. """ + import os import sys from pathlib import Path diff --git a/pygmt/tests/test_basemap.py b/pygmt/tests/test_basemap.py index 7a77d8bc99b..c75459c99ca 100644 --- a/pygmt/tests/test_basemap.py +++ b/pygmt/tests/test_basemap.py @@ -1,6 +1,7 @@ """ Test Figure.basemap. """ + import pytest from pygmt import Figure diff --git a/pygmt/tests/test_binstats.py b/pygmt/tests/test_binstats.py index 4815b9e6d5c..b8a1a39e8ad 100644 --- a/pygmt/tests/test_binstats.py +++ b/pygmt/tests/test_binstats.py @@ -1,6 +1,7 @@ """ Test pygmt.binstats. """ + from pathlib import Path import numpy.testing as npt diff --git a/pygmt/tests/test_blockm.py b/pygmt/tests/test_blockm.py index f8bea4ac1f5..9af3264e3b0 100644 --- a/pygmt/tests/test_blockm.py +++ b/pygmt/tests/test_blockm.py @@ -1,6 +1,7 @@ """ Test pygmt.blockmean and pygmt.blockmode. """ + from pathlib import Path import numpy as np diff --git a/pygmt/tests/test_blockmedian.py b/pygmt/tests/test_blockmedian.py index c46770db077..a1111664065 100644 --- a/pygmt/tests/test_blockmedian.py +++ b/pygmt/tests/test_blockmedian.py @@ -1,6 +1,7 @@ """ Test pygmt.blockmedian. """ + from pathlib import Path import numpy.testing as npt diff --git a/pygmt/tests/test_clib.py b/pygmt/tests/test_clib.py index ffb7a6bde41..78121b13cda 100644 --- a/pygmt/tests/test_clib.py +++ b/pygmt/tests/test_clib.py @@ -1,6 +1,7 @@ """ Test the wrappers for the C API. """ + import os from contextlib import contextmanager from pathlib import Path diff --git a/pygmt/tests/test_clib_loading.py b/pygmt/tests/test_clib_loading.py index 288fc067727..bc4c154553d 100644 --- a/pygmt/tests/test_clib_loading.py +++ b/pygmt/tests/test_clib_loading.py @@ -1,6 +1,7 @@ """ Test the functions that load libgmt. """ + import ctypes import os import shutil diff --git a/pygmt/tests/test_clib_put_matrix.py b/pygmt/tests/test_clib_put_matrix.py index dd50050edb9..2b5572799e2 100644 --- a/pygmt/tests/test_clib_put_matrix.py +++ b/pygmt/tests/test_clib_put_matrix.py @@ -1,6 +1,7 @@ """ Test the functions that put matrix data into GMT. """ + import numpy as np import numpy.testing as npt import pytest diff --git a/pygmt/tests/test_clib_put_strings.py b/pygmt/tests/test_clib_put_strings.py index 8aad6abbffd..92287be3e29 100644 --- a/pygmt/tests/test_clib_put_strings.py +++ b/pygmt/tests/test_clib_put_strings.py @@ -1,6 +1,7 @@ """ Test the functions that put string data into GMT. """ + import numpy as np import numpy.testing as npt import pytest diff --git a/pygmt/tests/test_clib_put_vector.py b/pygmt/tests/test_clib_put_vector.py index 40fed52ea27..de3da3f3b43 100644 --- a/pygmt/tests/test_clib_put_vector.py +++ b/pygmt/tests/test_clib_put_vector.py @@ -1,6 +1,7 @@ """ Test the functions that put vector data into GMT. """ + import datetime import itertools diff --git a/pygmt/tests/test_clib_virtualfiles.py b/pygmt/tests/test_clib_virtualfiles.py index 8b4ae0ad957..ce71553fc24 100644 --- a/pygmt/tests/test_clib_virtualfiles.py +++ b/pygmt/tests/test_clib_virtualfiles.py @@ -1,6 +1,7 @@ """ Test the C API functions related to virtual files. """ + import os from importlib.util import find_spec from itertools import product @@ -99,8 +100,10 @@ def test_virtual_file_fails(): # Test the status check when closing the virtual file # Mock the opening to return 0 (success) so that we don't open a file that # we won't close later. - with clib.Session() as lib, mock(lib, "GMT_Open_VirtualFile", returns=0), mock( - lib, "GMT_Close_VirtualFile", returns=1 + with ( + clib.Session() as lib, + mock(lib, "GMT_Open_VirtualFile", returns=0), + mock(lib, "GMT_Close_VirtualFile", returns=1), ): with pytest.raises(GMTCLibError): with lib.open_virtualfile(*vfargs): diff --git a/pygmt/tests/test_coast.py b/pygmt/tests/test_coast.py index cc7fb092b13..780ec63cace 100644 --- a/pygmt/tests/test_coast.py +++ b/pygmt/tests/test_coast.py @@ -1,6 +1,7 @@ """ Test Figure.coast. """ + import pytest from pygmt import Figure from pygmt.exceptions import GMTInvalidInput diff --git a/pygmt/tests/test_colorbar.py b/pygmt/tests/test_colorbar.py index 1377a626bed..3b132a5d64f 100644 --- a/pygmt/tests/test_colorbar.py +++ b/pygmt/tests/test_colorbar.py @@ -1,6 +1,7 @@ """ Test Figure.colorbar. """ + import pytest from pygmt import Figure diff --git a/pygmt/tests/test_config.py b/pygmt/tests/test_config.py index b9341f5b0bf..1468d7d7ae7 100644 --- a/pygmt/tests/test_config.py +++ b/pygmt/tests/test_config.py @@ -1,6 +1,7 @@ """ Test pygmt.config. """ + import pytest from pygmt import Figure, config diff --git a/pygmt/tests/test_contour.py b/pygmt/tests/test_contour.py index 58aa0d56a31..416ad5c8a3e 100644 --- a/pygmt/tests/test_contour.py +++ b/pygmt/tests/test_contour.py @@ -1,6 +1,7 @@ """ Test Figure.contour. """ + import os import numpy as np diff --git a/pygmt/tests/test_datasets_earth_age.py b/pygmt/tests/test_datasets_earth_age.py index 0288d333656..854821bad25 100644 --- a/pygmt/tests/test_datasets_earth_age.py +++ b/pygmt/tests/test_datasets_earth_age.py @@ -1,6 +1,7 @@ """ Test basic functionality for loading Earth seafloor crust age datasets. """ + import numpy as np import numpy.testing as npt from pygmt.datasets import load_earth_age diff --git a/pygmt/tests/test_datasets_earth_free_air_anomaly.py b/pygmt/tests/test_datasets_earth_free_air_anomaly.py index f8bb13b6c53..3bf3b32fa47 100644 --- a/pygmt/tests/test_datasets_earth_free_air_anomaly.py +++ b/pygmt/tests/test_datasets_earth_free_air_anomaly.py @@ -1,6 +1,7 @@ """ Test basic functionality for loading Earth free air anomaly datasets. """ + import numpy as np import numpy.testing as npt from pygmt.datasets import load_earth_free_air_anomaly diff --git a/pygmt/tests/test_datasets_earth_geoid.py b/pygmt/tests/test_datasets_earth_geoid.py index 1dbab676407..3ea2916792c 100644 --- a/pygmt/tests/test_datasets_earth_geoid.py +++ b/pygmt/tests/test_datasets_earth_geoid.py @@ -1,6 +1,7 @@ """ Test basic functionality for loading Earth geoid datasets. """ + import numpy as np import numpy.testing as npt from pygmt.datasets import load_earth_geoid diff --git a/pygmt/tests/test_datasets_earth_magnetic_anomaly.py b/pygmt/tests/test_datasets_earth_magnetic_anomaly.py index f84cd44c006..aa81ad5e1a4 100644 --- a/pygmt/tests/test_datasets_earth_magnetic_anomaly.py +++ b/pygmt/tests/test_datasets_earth_magnetic_anomaly.py @@ -1,6 +1,7 @@ """ Test basic functionality for loading Earth magnetic anomaly datasets. """ + import numpy as np import numpy.testing as npt import pytest diff --git a/pygmt/tests/test_datasets_earth_mask.py b/pygmt/tests/test_datasets_earth_mask.py index 0ecb7697488..d46bfd3353f 100644 --- a/pygmt/tests/test_datasets_earth_mask.py +++ b/pygmt/tests/test_datasets_earth_mask.py @@ -1,6 +1,7 @@ """ Test basic functionality for loading Earth mask datasets. """ + import numpy as np import numpy.testing as npt from pygmt.datasets import load_earth_mask diff --git a/pygmt/tests/test_datasets_earth_relief.py b/pygmt/tests/test_datasets_earth_relief.py index c8c63050a63..13339ab0bb8 100644 --- a/pygmt/tests/test_datasets_earth_relief.py +++ b/pygmt/tests/test_datasets_earth_relief.py @@ -1,6 +1,7 @@ """ Test basic functionality for loading Earth relief datasets. """ + import numpy as np import numpy.testing as npt import pytest diff --git a/pygmt/tests/test_datasets_earth_vertical_gravity_gradient.py b/pygmt/tests/test_datasets_earth_vertical_gravity_gradient.py index ad142f15a23..7e1ab6a2c88 100644 --- a/pygmt/tests/test_datasets_earth_vertical_gravity_gradient.py +++ b/pygmt/tests/test_datasets_earth_vertical_gravity_gradient.py @@ -1,6 +1,7 @@ """ Test basic functionality for loading Earth vertical gravity gradient datasets. """ + import numpy as np import numpy.testing as npt from pygmt.datasets import load_earth_vertical_gravity_gradient diff --git a/pygmt/tests/test_datasets_load_remote_datasets.py b/pygmt/tests/test_datasets_load_remote_datasets.py index 3d68518f18d..6b6b472281e 100644 --- a/pygmt/tests/test_datasets_load_remote_datasets.py +++ b/pygmt/tests/test_datasets_load_remote_datasets.py @@ -1,6 +1,7 @@ """ Test the _load_remote_dataset function. """ + import pytest from packaging.version import Version from pygmt.clib import __gmt_version__ diff --git a/pygmt/tests/test_datasets_mars_relief.py b/pygmt/tests/test_datasets_mars_relief.py index 4857c695cce..7a8ed0993b1 100644 --- a/pygmt/tests/test_datasets_mars_relief.py +++ b/pygmt/tests/test_datasets_mars_relief.py @@ -1,6 +1,7 @@ """ Test basic functionality for loading Mars relief datasets. """ + import numpy as np import numpy.testing as npt from pygmt.datasets import load_mars_relief diff --git a/pygmt/tests/test_datasets_mercury_relief.py b/pygmt/tests/test_datasets_mercury_relief.py index a6548ff58e1..e51ef7c0dc1 100644 --- a/pygmt/tests/test_datasets_mercury_relief.py +++ b/pygmt/tests/test_datasets_mercury_relief.py @@ -1,6 +1,7 @@ """ Test basic functionality for loading Mercury relief datasets. """ + import numpy as np import numpy.testing as npt from pygmt.datasets import load_mercury_relief diff --git a/pygmt/tests/test_datasets_moon_relief.py b/pygmt/tests/test_datasets_moon_relief.py index d9f157950c2..5aa801d792d 100644 --- a/pygmt/tests/test_datasets_moon_relief.py +++ b/pygmt/tests/test_datasets_moon_relief.py @@ -1,6 +1,7 @@ """ Test basic functionality for loading Moon relief datasets. """ + import numpy as np import numpy.testing as npt from pygmt.datasets import load_moon_relief diff --git a/pygmt/tests/test_datasets_pluto_relief.py b/pygmt/tests/test_datasets_pluto_relief.py index 096a9e2cd3f..ad5a046d528 100644 --- a/pygmt/tests/test_datasets_pluto_relief.py +++ b/pygmt/tests/test_datasets_pluto_relief.py @@ -1,6 +1,7 @@ """ Test basic functionality for loading Pluto relief datasets. """ + import numpy as np import numpy.testing as npt from pygmt.datasets import load_pluto_relief diff --git a/pygmt/tests/test_datasets_samples.py b/pygmt/tests/test_datasets_samples.py index 3c05cbec790..77228863641 100644 --- a/pygmt/tests/test_datasets_samples.py +++ b/pygmt/tests/test_datasets_samples.py @@ -1,6 +1,7 @@ """ Test basic functionality for loading sample datasets. """ + import numpy.testing as npt import pandas as pd import pytest diff --git a/pygmt/tests/test_datasets_venus_relief.py b/pygmt/tests/test_datasets_venus_relief.py index bd9a959139d..f411ff2069c 100644 --- a/pygmt/tests/test_datasets_venus_relief.py +++ b/pygmt/tests/test_datasets_venus_relief.py @@ -1,6 +1,7 @@ """ Test basic functionality for loading Venus relief datasets. """ + import numpy as np import numpy.testing as npt from pygmt.datasets import load_venus_relief diff --git a/pygmt/tests/test_dimfilter.py b/pygmt/tests/test_dimfilter.py index 4bc53d34e7b..9e998ac9980 100644 --- a/pygmt/tests/test_dimfilter.py +++ b/pygmt/tests/test_dimfilter.py @@ -1,6 +1,7 @@ """ Test pygmt.dimfilter. """ + from pathlib import Path import pytest diff --git a/pygmt/tests/test_figure.py b/pygmt/tests/test_figure.py index 586973fe6ad..d33be107eda 100644 --- a/pygmt/tests/test_figure.py +++ b/pygmt/tests/test_figure.py @@ -3,6 +3,7 @@ Doesn't include the plotting commands which have their own test files. """ + import importlib import os from pathlib import Path diff --git a/pygmt/tests/test_filter1d.py b/pygmt/tests/test_filter1d.py index f9f7f37bf9f..c98c39f7ac4 100644 --- a/pygmt/tests/test_filter1d.py +++ b/pygmt/tests/test_filter1d.py @@ -1,6 +1,7 @@ """ Test pygmt.filter1d. """ + from pathlib import Path import numpy as np diff --git a/pygmt/tests/test_geopandas.py b/pygmt/tests/test_geopandas.py index 50d85675730..af40cc8e6d4 100644 --- a/pygmt/tests/test_geopandas.py +++ b/pygmt/tests/test_geopandas.py @@ -1,6 +1,7 @@ """ Test integration with geopandas. """ + import numpy.testing as npt import pandas as pd import pytest diff --git a/pygmt/tests/test_grd2cpt.py b/pygmt/tests/test_grd2cpt.py index decdbbf7041..76d19905259 100644 --- a/pygmt/tests/test_grd2cpt.py +++ b/pygmt/tests/test_grd2cpt.py @@ -1,6 +1,7 @@ """ Test pygmt.grd2cpt. """ + import os import pytest diff --git a/pygmt/tests/test_grd2xyz.py b/pygmt/tests/test_grd2xyz.py index 6f7339f0af8..b6f8e92c1ea 100644 --- a/pygmt/tests/test_grd2xyz.py +++ b/pygmt/tests/test_grd2xyz.py @@ -1,6 +1,7 @@ """ Test pygmt.grd2xyz. """ + from pathlib import Path import numpy as np diff --git a/pygmt/tests/test_grdclip.py b/pygmt/tests/test_grdclip.py index 997a789ee8b..a0f2e4a8d7c 100644 --- a/pygmt/tests/test_grdclip.py +++ b/pygmt/tests/test_grdclip.py @@ -1,6 +1,7 @@ """ Test pygmt.grdclip. """ + from pathlib import Path import pytest diff --git a/pygmt/tests/test_grdcontour.py b/pygmt/tests/test_grdcontour.py index af24e24214d..c40439bdc7b 100644 --- a/pygmt/tests/test_grdcontour.py +++ b/pygmt/tests/test_grdcontour.py @@ -1,6 +1,7 @@ """ Test Figure.grdcontour. """ + import os import numpy as np diff --git a/pygmt/tests/test_grdcut.py b/pygmt/tests/test_grdcut.py index c71ef7c4d1e..dbf5dd21f49 100644 --- a/pygmt/tests/test_grdcut.py +++ b/pygmt/tests/test_grdcut.py @@ -1,6 +1,7 @@ """ Test pygmt.grdcut. """ + import numpy as np import pytest import xarray as xr diff --git a/pygmt/tests/test_grdfill.py b/pygmt/tests/test_grdfill.py index e0bd1e924a3..35be47ebef4 100644 --- a/pygmt/tests/test_grdfill.py +++ b/pygmt/tests/test_grdfill.py @@ -1,6 +1,7 @@ """ Test pygmt.grdfill. """ + from pathlib import Path import numpy as np diff --git a/pygmt/tests/test_grdfilter.py b/pygmt/tests/test_grdfilter.py index d86add635f0..5cbe3574767 100644 --- a/pygmt/tests/test_grdfilter.py +++ b/pygmt/tests/test_grdfilter.py @@ -1,6 +1,7 @@ """ Test pygmt.grdfilter. """ + from pathlib import Path import numpy as np diff --git a/pygmt/tests/test_grdgradient.py b/pygmt/tests/test_grdgradient.py index 879be7fb6bc..dc082d50d90 100644 --- a/pygmt/tests/test_grdgradient.py +++ b/pygmt/tests/test_grdgradient.py @@ -1,6 +1,7 @@ """ Test pygmt.grdgradient. """ + from pathlib import Path import pytest diff --git a/pygmt/tests/test_grdhisteq.py b/pygmt/tests/test_grdhisteq.py index a0a55d01d83..76892905269 100644 --- a/pygmt/tests/test_grdhisteq.py +++ b/pygmt/tests/test_grdhisteq.py @@ -1,6 +1,7 @@ """ Test pygmt.grdhisteq. """ + from pathlib import Path import numpy as np diff --git a/pygmt/tests/test_grdimage.py b/pygmt/tests/test_grdimage.py index fee33de1b65..8f0e538d270 100644 --- a/pygmt/tests/test_grdimage.py +++ b/pygmt/tests/test_grdimage.py @@ -1,6 +1,7 @@ """ Test Figure.grdimage. """ + import numpy as np import pytest import xarray as xr diff --git a/pygmt/tests/test_grdimage_image.py b/pygmt/tests/test_grdimage_image.py index c713957dc91..c7d74b206ed 100644 --- a/pygmt/tests/test_grdimage_image.py +++ b/pygmt/tests/test_grdimage_image.py @@ -1,6 +1,7 @@ """ Test Figure.grdimage on 3-band RGB images. """ + import pytest from pygmt import Figure, which diff --git a/pygmt/tests/test_grdinfo.py b/pygmt/tests/test_grdinfo.py index 2825b96d4be..f993e4b73db 100644 --- a/pygmt/tests/test_grdinfo.py +++ b/pygmt/tests/test_grdinfo.py @@ -1,6 +1,7 @@ """ Test pygmt.grdinfo. """ + import numpy as np import pytest from pygmt import grdinfo diff --git a/pygmt/tests/test_grdlandmask.py b/pygmt/tests/test_grdlandmask.py index 5340c4269fe..ae51ba2eda4 100644 --- a/pygmt/tests/test_grdlandmask.py +++ b/pygmt/tests/test_grdlandmask.py @@ -1,6 +1,7 @@ """ Test pygmt.grdlandmask. """ + from pathlib import Path import pytest diff --git a/pygmt/tests/test_grdproject.py b/pygmt/tests/test_grdproject.py index 1d76647f75a..644ac311c54 100644 --- a/pygmt/tests/test_grdproject.py +++ b/pygmt/tests/test_grdproject.py @@ -1,6 +1,7 @@ """ Test pygmt.grdproject. """ + from pathlib import Path import pytest diff --git a/pygmt/tests/test_grdsample.py b/pygmt/tests/test_grdsample.py index a30a6a248e4..4c9e64139c3 100644 --- a/pygmt/tests/test_grdsample.py +++ b/pygmt/tests/test_grdsample.py @@ -1,6 +1,7 @@ """ Test pygmt.grdsample. """ + from pathlib import Path import pytest diff --git a/pygmt/tests/test_grdtrack.py b/pygmt/tests/test_grdtrack.py index bfd53884725..fdb25d9e5f7 100644 --- a/pygmt/tests/test_grdtrack.py +++ b/pygmt/tests/test_grdtrack.py @@ -1,6 +1,7 @@ """ Test pygmt.grdtrack. """ + import os from pathlib import Path diff --git a/pygmt/tests/test_grdview.py b/pygmt/tests/test_grdview.py index 37eef04c970..b8f597b2bf0 100644 --- a/pygmt/tests/test_grdview.py +++ b/pygmt/tests/test_grdview.py @@ -1,6 +1,7 @@ """ Test Figure.grdview. """ + import pytest from pygmt import Figure, grdcut from pygmt.exceptions import GMTInvalidInput diff --git a/pygmt/tests/test_grdvolume.py b/pygmt/tests/test_grdvolume.py index 6860ff0fe3a..b56e76b1f19 100644 --- a/pygmt/tests/test_grdvolume.py +++ b/pygmt/tests/test_grdvolume.py @@ -1,6 +1,7 @@ """ Test pygmt.grdvolume. """ + from pathlib import Path import numpy as np diff --git a/pygmt/tests/test_helpers.py b/pygmt/tests/test_helpers.py index 8208d98cdfb..29cc61fe8b7 100644 --- a/pygmt/tests/test_helpers.py +++ b/pygmt/tests/test_helpers.py @@ -1,6 +1,7 @@ """ Test the helper functions/classes/etc used in wrapping GMT. """ + import os import numpy as np diff --git a/pygmt/tests/test_histogram.py b/pygmt/tests/test_histogram.py index 1c5f56a329f..8a85ffd4666 100644 --- a/pygmt/tests/test_histogram.py +++ b/pygmt/tests/test_histogram.py @@ -1,6 +1,7 @@ """ Test Figure.histogram. """ + import pandas as pd import pytest from pygmt import Figure diff --git a/pygmt/tests/test_image.py b/pygmt/tests/test_image.py index 768937fe211..5bcc8c28145 100644 --- a/pygmt/tests/test_image.py +++ b/pygmt/tests/test_image.py @@ -1,6 +1,7 @@ """ Test Figure.image. """ + import pytest from pygmt import Figure diff --git a/pygmt/tests/test_info.py b/pygmt/tests/test_info.py index ddd5b805def..b812e1457ce 100644 --- a/pygmt/tests/test_info.py +++ b/pygmt/tests/test_info.py @@ -1,6 +1,7 @@ """ Test pygmt.info. """ + import os import pathlib import sys diff --git a/pygmt/tests/test_init.py b/pygmt/tests/test_init.py index e2dc735d103..27527aa71d7 100644 --- a/pygmt/tests/test_init.py +++ b/pygmt/tests/test_init.py @@ -1,6 +1,7 @@ """ Test functions in __init__. """ + import io import pygmt diff --git a/pygmt/tests/test_inset.py b/pygmt/tests/test_inset.py index 4fab4cef62e..992ba9e48c0 100644 --- a/pygmt/tests/test_inset.py +++ b/pygmt/tests/test_inset.py @@ -1,6 +1,7 @@ """ Test Figure.inset. """ + import pytest from pygmt import Figure diff --git a/pygmt/tests/test_io.py b/pygmt/tests/test_io.py index 4818d55d795..90ae4f2df83 100644 --- a/pygmt/tests/test_io.py +++ b/pygmt/tests/test_io.py @@ -1,6 +1,7 @@ """ Test input/output (I/O) utilities. """ + import numpy as np import pytest import xarray as xr diff --git a/pygmt/tests/test_legend.py b/pygmt/tests/test_legend.py index 290b6bf1a6e..9c4936d9984 100644 --- a/pygmt/tests/test_legend.py +++ b/pygmt/tests/test_legend.py @@ -1,6 +1,7 @@ """ Test Figure.legend. """ + import pytest from pygmt import Figure from pygmt.exceptions import GMTInvalidInput diff --git a/pygmt/tests/test_logo.py b/pygmt/tests/test_logo.py index 7a405289202..62bddf4eb24 100644 --- a/pygmt/tests/test_logo.py +++ b/pygmt/tests/test_logo.py @@ -1,6 +1,7 @@ """ Test Figure.logo. """ + import pytest from pygmt import Figure diff --git a/pygmt/tests/test_makecpt.py b/pygmt/tests/test_makecpt.py index 13b379ec500..eaba2589f04 100644 --- a/pygmt/tests/test_makecpt.py +++ b/pygmt/tests/test_makecpt.py @@ -1,6 +1,7 @@ """ Test pygmt.makecpt. """ + import os from pathlib import Path diff --git a/pygmt/tests/test_meca.py b/pygmt/tests/test_meca.py index 12d0a0328e3..bcf69f059f3 100644 --- a/pygmt/tests/test_meca.py +++ b/pygmt/tests/test_meca.py @@ -1,6 +1,7 @@ """ Test Figure.meca. """ + import numpy as np import pandas as pd import pytest diff --git a/pygmt/tests/test_nearneighbor.py b/pygmt/tests/test_nearneighbor.py index 3dad7a7c471..f37365fbdb4 100644 --- a/pygmt/tests/test_nearneighbor.py +++ b/pygmt/tests/test_nearneighbor.py @@ -1,6 +1,7 @@ """ Test pygmt.nearneighbor. """ + from pathlib import Path import numpy as np diff --git a/pygmt/tests/test_plot.py b/pygmt/tests/test_plot.py index be6d25161cc..83bc356692f 100644 --- a/pygmt/tests/test_plot.py +++ b/pygmt/tests/test_plot.py @@ -1,6 +1,7 @@ """ Test Figure.plot. """ + import datetime import os from pathlib import Path diff --git a/pygmt/tests/test_plot3d.py b/pygmt/tests/test_plot3d.py index 6074c64b98e..ad91f06f8fa 100644 --- a/pygmt/tests/test_plot3d.py +++ b/pygmt/tests/test_plot3d.py @@ -1,6 +1,7 @@ """ Test Figure.plot3d. """ + import os from pathlib import Path diff --git a/pygmt/tests/test_project.py b/pygmt/tests/test_project.py index 631dc8ac3b0..29aa6b531dc 100644 --- a/pygmt/tests/test_project.py +++ b/pygmt/tests/test_project.py @@ -1,6 +1,7 @@ """ Test pygmt.project. """ + from pathlib import Path import numpy as np diff --git a/pygmt/tests/test_psconvert.py b/pygmt/tests/test_psconvert.py index 025a5d46f75..6cc82cc50e9 100644 --- a/pygmt/tests/test_psconvert.py +++ b/pygmt/tests/test_psconvert.py @@ -1,6 +1,7 @@ """ Test Figure.psconvert. """ + import os import pytest diff --git a/pygmt/tests/test_rose.py b/pygmt/tests/test_rose.py index 8f0b01ebb41..9e68bc08d4f 100644 --- a/pygmt/tests/test_rose.py +++ b/pygmt/tests/test_rose.py @@ -1,6 +1,7 @@ """ Test Figure.rose. """ + import numpy as np import pytest from pygmt import Figure diff --git a/pygmt/tests/test_select.py b/pygmt/tests/test_select.py index 1d554aa43c1..f4cc72e0259 100644 --- a/pygmt/tests/test_select.py +++ b/pygmt/tests/test_select.py @@ -1,6 +1,7 @@ """ Test pygmt.select. """ + from pathlib import Path import numpy.testing as npt diff --git a/pygmt/tests/test_session_management.py b/pygmt/tests/test_session_management.py index 544c5f037de..0fbe6f8e45b 100644 --- a/pygmt/tests/test_session_management.py +++ b/pygmt/tests/test_session_management.py @@ -1,6 +1,7 @@ """ Test the session management modules. """ + import multiprocessing as mp import os from importlib import reload diff --git a/pygmt/tests/test_solar.py b/pygmt/tests/test_solar.py index d2da38880be..b72fcf400a6 100644 --- a/pygmt/tests/test_solar.py +++ b/pygmt/tests/test_solar.py @@ -1,6 +1,7 @@ """ Test Figure.solar. """ + import datetime import pytest diff --git a/pygmt/tests/test_sph2grd.py b/pygmt/tests/test_sph2grd.py index aed75d1c155..89b4abeff25 100644 --- a/pygmt/tests/test_sph2grd.py +++ b/pygmt/tests/test_sph2grd.py @@ -1,6 +1,7 @@ """ Test pygmt.sph2grd. """ + from pathlib import Path import numpy.testing as npt diff --git a/pygmt/tests/test_sphdistance.py b/pygmt/tests/test_sphdistance.py index 038068c3f7f..be8cbd1a066 100644 --- a/pygmt/tests/test_sphdistance.py +++ b/pygmt/tests/test_sphdistance.py @@ -1,6 +1,7 @@ """ Test pygmt.sphdistance. """ + from pathlib import Path import numpy as np diff --git a/pygmt/tests/test_sphinterpolate.py b/pygmt/tests/test_sphinterpolate.py index 9de868968a8..d7e24eba780 100644 --- a/pygmt/tests/test_sphinterpolate.py +++ b/pygmt/tests/test_sphinterpolate.py @@ -1,6 +1,7 @@ """ Test pygmt.sphinterpolate. """ + from pathlib import Path import numpy.testing as npt diff --git a/pygmt/tests/test_sphinx_gallery.py b/pygmt/tests/test_sphinx_gallery.py index 825c3f025b9..205f0f3e3e5 100644 --- a/pygmt/tests/test_sphinx_gallery.py +++ b/pygmt/tests/test_sphinx_gallery.py @@ -1,6 +1,7 @@ """ Test the sphinx-gallery scraper and code required to make it work. """ + import os from tempfile import TemporaryDirectory diff --git a/pygmt/tests/test_subplot.py b/pygmt/tests/test_subplot.py index bad0adcca49..c6b2109d0fe 100644 --- a/pygmt/tests/test_subplot.py +++ b/pygmt/tests/test_subplot.py @@ -1,6 +1,7 @@ """ Test Figure.subplot. """ + import pytest from pygmt import Figure from pygmt.exceptions import GMTInvalidInput diff --git a/pygmt/tests/test_surface.py b/pygmt/tests/test_surface.py index 877652ff048..39860dd2069 100644 --- a/pygmt/tests/test_surface.py +++ b/pygmt/tests/test_surface.py @@ -1,6 +1,7 @@ """ Test pygmt.surface. """ + from pathlib import Path import pandas as pd diff --git a/pygmt/tests/test_ternary.py b/pygmt/tests/test_ternary.py index 7f6116e6092..ba0fbe4ddcc 100644 --- a/pygmt/tests/test_ternary.py +++ b/pygmt/tests/test_ternary.py @@ -1,6 +1,7 @@ """ Test Figure.ternary. """ + import numpy as np import pytest from pygmt import Figure diff --git a/pygmt/tests/test_text.py b/pygmt/tests/test_text.py index 31ab7f3c83b..7ef50224c38 100644 --- a/pygmt/tests/test_text.py +++ b/pygmt/tests/test_text.py @@ -1,6 +1,7 @@ """ Test Figure.text. """ + import os import numpy as np diff --git a/pygmt/tests/test_tilemap.py b/pygmt/tests/test_tilemap.py index f6c6d2bcab1..704a96093af 100644 --- a/pygmt/tests/test_tilemap.py +++ b/pygmt/tests/test_tilemap.py @@ -1,6 +1,7 @@ """ Test Figure.tilemap. """ + import pytest from pygmt import Figure diff --git a/pygmt/tests/test_timestamp.py b/pygmt/tests/test_timestamp.py index 0d7f42493c2..0bf292e231c 100644 --- a/pygmt/tests/test_timestamp.py +++ b/pygmt/tests/test_timestamp.py @@ -1,6 +1,7 @@ """ Test Figure.timestamp. """ + import pytest from pygmt import Figure from pygmt.exceptions import GMTInvalidInput diff --git a/pygmt/tests/test_triangulate.py b/pygmt/tests/test_triangulate.py index b7cf950a7be..154bc82b09f 100644 --- a/pygmt/tests/test_triangulate.py +++ b/pygmt/tests/test_triangulate.py @@ -1,6 +1,7 @@ """ Test pygmt.triangulate. """ + from pathlib import Path import numpy as np diff --git a/pygmt/tests/test_velo.py b/pygmt/tests/test_velo.py index 4c88f2b481d..1f363e06596 100644 --- a/pygmt/tests/test_velo.py +++ b/pygmt/tests/test_velo.py @@ -1,6 +1,7 @@ """ Test Figure.velo. """ + import pandas as pd import pytest from pygmt import Figure diff --git a/pygmt/tests/test_which.py b/pygmt/tests/test_which.py index c9b835a207a..121d6cf4a27 100644 --- a/pygmt/tests/test_which.py +++ b/pygmt/tests/test_which.py @@ -1,6 +1,7 @@ """ Test pygmt.which. """ + from pathlib import Path import pytest diff --git a/pygmt/tests/test_wiggle.py b/pygmt/tests/test_wiggle.py index 0b76abfca08..d711e066f6a 100644 --- a/pygmt/tests/test_wiggle.py +++ b/pygmt/tests/test_wiggle.py @@ -1,6 +1,7 @@ """ Test Figure.wiggle. """ + import numpy as np import pytest from pygmt import Figure diff --git a/pygmt/tests/test_x2sys_cross.py b/pygmt/tests/test_x2sys_cross.py index af9c7ac8dcd..226fbc06e6d 100644 --- a/pygmt/tests/test_x2sys_cross.py +++ b/pygmt/tests/test_x2sys_cross.py @@ -1,6 +1,7 @@ """ Test pygmt.x2sys_cross. """ + import copy import os from pathlib import Path diff --git a/pygmt/tests/test_x2sys_init.py b/pygmt/tests/test_x2sys_init.py index 368fad16463..808c3f68315 100644 --- a/pygmt/tests/test_x2sys_init.py +++ b/pygmt/tests/test_x2sys_init.py @@ -1,6 +1,7 @@ """ Test pygmt.x2sys_init. """ + import os from tempfile import TemporaryDirectory diff --git a/pygmt/tests/test_xyz2grd.py b/pygmt/tests/test_xyz2grd.py index f15d2c7dc2d..56b2d1167e2 100644 --- a/pygmt/tests/test_xyz2grd.py +++ b/pygmt/tests/test_xyz2grd.py @@ -1,6 +1,7 @@ """ Test pygmt.xyz2grd. """ + from pathlib import Path import numpy as np