Skip to content

Add docformatter to format plain text in docstrings #642

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

Merged
merged 10 commits into from
Jan 21, 2021
13 changes: 9 additions & 4 deletions pygmt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ def show_versions():
import sys

def _get_module_version(modname):
"""Get version information of a Python module."""
"""
Get version information of a Python module.
"""
try:
if modname in sys.modules:
module = sys.modules[modname]
Expand All @@ -82,7 +84,9 @@ def _get_module_version(modname):
return None

def _get_ghostscript_version():
"""Get ghostscript version."""
"""
Get ghostscript version.
"""
os_name = sys.platform
if os_name.startswith("linux") or os_name == "darwin":
cmds = ["gs"]
Expand All @@ -102,7 +106,9 @@ def _get_ghostscript_version():
return None

def _get_gmt_version():
"""Get GMT version."""
"""
Get GMT version.
"""
try:
version = subprocess.check_output(
["gmt", "--version"], universal_newlines=True
Expand Down Expand Up @@ -164,7 +170,6 @@ def test(doctest=True, verbose=True, coverage=False, figures=True):
AssertionError
If pytest returns a non-zero error code indicating that some tests have
failed.

"""
import pytest

Expand Down
27 changes: 11 additions & 16 deletions pygmt/base_plotting.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""
Base class with plot generating commands.

Does not define any special non-GMT methods (savefig, show, etc).
"""
import contextlib
Expand Down Expand Up @@ -52,7 +53,6 @@ def _preprocess(self, **kwargs): # pylint: disable=no-self-use
>>> base = BasePlotting()
>>> base._preprocess(resolution="low")
{'resolution': 'low'}

"""
return kwargs

Expand Down Expand Up @@ -266,7 +266,6 @@ def colorbar(self, **kwargs):
{XY}
{p}
{t}

"""
kwargs = self._preprocess(**kwargs)
with Session() as lib:
Expand Down Expand Up @@ -295,7 +294,7 @@ def colorbar(self, **kwargs):
@kwargs_to_strings(R="sequence", L="sequence", A="sequence_plus", p="sequence")
def grdcontour(self, grid, **kwargs):
"""
Convert grids or images to contours and plot them on maps
Convert grids or images to contours and plot them on maps.

Takes a grid file name or an xarray.DataArray object as input.

Expand Down Expand Up @@ -511,7 +510,6 @@ def grdimage(self, grid, **kwargs):
{p}
{t}
{x}

"""
kwargs = self._preprocess(**kwargs)
kind = data_kind(grid, None, None)
Expand Down Expand Up @@ -624,7 +622,6 @@ def grdview(self, grid, **kwargs):
{XY}
{p}
{t}

"""
kwargs = self._preprocess(**kwargs)
kind = data_kind(grid, None, None)
Expand Down Expand Up @@ -827,7 +824,6 @@ def plot(self, x=None, y=None, data=None, sizes=None, direction=None, **kwargs):
{t}
*transparency* can also be a 1d array to set varying transparency
for symbols.

"""
kwargs = self._preprocess(**kwargs)

Expand Down Expand Up @@ -900,7 +896,7 @@ def plot3d(
self, x=None, y=None, z=None, data=None, sizes=None, direction=None, **kwargs
):
"""
Plot lines, polygons, and symbols in 3-D
Plot lines, polygons, and symbols in 3-D.

Takes a matrix, (x,y,z) triplets, or a file name as input and plots
lines, polygons, or symbols at those locations in 3-D.
Expand Down Expand Up @@ -1010,7 +1006,6 @@ def plot3d(
{t}
*transparency* can also be a 1d array to set varying transparency
for symbols.

"""
kwargs = self._preprocess(**kwargs)

Expand Down Expand Up @@ -1132,7 +1127,6 @@ def contour(self, x=None, y=None, z=None, data=None, **kwargs):
{XY}
{p}
{t}

"""
kwargs = self._preprocess(**kwargs)

Expand Down Expand Up @@ -1208,7 +1202,6 @@ def basemap(self, **kwargs):
{XY}
{p}
{t}

"""
kwargs = self._preprocess(**kwargs)
if not ("B" in kwargs or "L" in kwargs or "Td" in kwargs or "Tm" in kwargs):
Expand Down Expand Up @@ -1267,7 +1260,6 @@ def logo(self, **kwargs):
{V}
{XY}
{t}

"""
kwargs = self._preprocess(**kwargs)
with Session() as lib:
Expand Down Expand Up @@ -1715,17 +1707,20 @@ def meca(
# pylint: disable=too-many-statements

def set_pointer(data_pointers, spec):
"""Set optional parameter pointers based on DataFrame or dict, if
those parameters are present in the DataFrame or dict."""
"""
Set optional parameter pointers based on DataFrame or dict, if
those parameters are present in the DataFrame or dict.
"""
for param in list(data_pointers.keys()):
if param in spec:
# set pointer based on param name
data_pointers[param] = spec[param]

def update_pointers(data_pointers):
"""Updates variables based on the location of data, as the
following data can be passed as parameters or it can be
contained in `spec`."""
"""
Updates variables based on the location of data, as the following
data can be passed as parameters or it can be contained in `spec`.
"""
# update all pointers
longitude = data_pointers["longitude"]
latitude = data_pointers["latitude"]
Expand Down
4 changes: 0 additions & 4 deletions pygmt/clib/conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ def dataarray_to_matrix(grid):
[-150.5, -78.5, -80.5, -48.5]
>>> print(inc)
[2.0, 2.0]

"""
if len(grid.dims) != 2:
raise GMTInvalidInput(
Expand Down Expand Up @@ -158,7 +157,6 @@ def vectors_to_arrays(vectors):
>>> data = [[1, 2], (3, 4), range(5, 7)]
>>> all(isinstance(i, np.ndarray) for i in vectors_to_arrays(data))
True

"""
arrays = [as_c_contiguous(np.asarray(i)) for i in vectors]
return arrays
Expand Down Expand Up @@ -200,7 +198,6 @@ def as_c_contiguous(array):
True
>>> as_c_contiguous(x).flags.c_contiguous
True

"""
if not array.flags.c_contiguous:
return array.copy(order="C")
Expand Down Expand Up @@ -238,7 +235,6 @@ def kwargs_to_ctypes_array(argument, kwargs, dtype):
... )
>>> print(should_be_none)
None

"""
if argument in kwargs:
return dtype(*kwargs[argument])
Expand Down
4 changes: 0 additions & 4 deletions pygmt/clib/loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ def load_libgmt():
GMTCLibNotFoundError
If there was any problem loading the library (couldn't find it or
couldn't access the functions).

"""
lib_fullnames = clib_full_names()
error = True
Expand Down Expand Up @@ -64,7 +63,6 @@ def clib_names(os_name):
-------
libnames : list of str
List of possible names of GMT's shared library.

"""
if os_name.startswith("linux"):
libnames = ["libgmt.so"]
Expand Down Expand Up @@ -93,7 +91,6 @@ def clib_full_names(env=None):
-------
lib_fullnames: list of str
List of possible full names of GMT's shared library.

"""
if env is None:
env = os.environ
Expand Down Expand Up @@ -127,7 +124,6 @@ def check_libgmt(libgmt):
Raises
------
GMTCLibError

"""
# Check if a few of the functions we need are in the library
functions = ["Create_Session", "Get_Enum", "Call_Module", "Destroy_Session"]
Expand Down
Loading