Skip to content

Commit bfbe503

Browse files
committed
Run "make format" to format docstrings
1 parent b8479d0 commit bfbe503

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+607
-1127
lines changed

doc/conf.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
"""
3-
Sphinx documentation configuration file.
4-
"""
2+
"""Sphinx documentation configuration file."""
53
# pylint: disable=invalid-name
64

75
import datetime

pygmt/__init__.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@
3535

3636

3737
def print_clib_info():
38-
"""
39-
Print information about the GMT shared library that we can find.
38+
"""Print information about the GMT shared library that we can find.
4039
4140
Includes the GMT version, default values for parameters, the path to the
4241
``libgmt`` shared library, and GMT directories.
@@ -51,9 +50,8 @@ def print_clib_info():
5150

5251

5352
def show_versions():
54-
"""
55-
Prints various dependency versions useful when submitting bug reports. This
56-
includes information about:
53+
"""Prints various dependency versions useful when submitting bug reports.
54+
This includes information about:
5755
5856
- PyGMT itself
5957
- System information (Python version, Operating System)
@@ -136,8 +134,7 @@ def _get_gmt_version():
136134

137135

138136
def test(doctest=True, verbose=True, coverage=False, figures=True):
139-
"""
140-
Run the test suite.
137+
"""Run the test suite.
141138
142139
Uses `pytest <http://pytest.org/>`__ to discover and run the tests. If you
143140
haven't already, you can install it with `conda
@@ -164,7 +161,6 @@ def test(doctest=True, verbose=True, coverage=False, figures=True):
164161
AssertionError
165162
If pytest returns a non-zero error code indicating that some tests have
166163
failed.
167-
168164
"""
169165
import pytest
170166

pygmt/base_plotting.py

Lines changed: 19 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
"""
2-
Base class with plot generating commands.
1+
"""Base class with plot generating commands.
2+
33
Does not define any special non-GMT methods (savefig, show, etc).
44
"""
55
import contextlib
@@ -19,16 +19,14 @@
1919

2020

2121
class BasePlotting:
22-
"""
23-
Base class for Figure and Subplot.
22+
"""Base class for Figure and Subplot.
2423
2524
Defines the plot generating methods and a hook for subclasses to insert
2625
special arguments (the _preprocess method).
2726
"""
2827

2928
def _preprocess(self, **kwargs): # pylint: disable=no-self-use
30-
"""
31-
Make any changes to kwargs or required actions before plotting.
29+
"""Make any changes to kwargs or required actions before plotting.
3230
3331
This method is run before all plotting commands and can be used to
3432
insert special arguments into the kwargs or make any actions that are
@@ -50,7 +48,6 @@ def _preprocess(self, **kwargs): # pylint: disable=no-self-use
5048
>>> base = BasePlotting()
5149
>>> base._preprocess(resolution="low")
5250
{'resolution': 'low'}
53-
5451
"""
5552
return kwargs
5653

@@ -75,8 +72,7 @@ def _preprocess(self, **kwargs): # pylint: disable=no-self-use
7572
)
7673
@kwargs_to_strings(R="sequence", p="sequence")
7774
def coast(self, **kwargs):
78-
"""
79-
Plot continents, shorelines, rivers, and borders on maps
75+
"""Plot continents, shorelines, rivers, and borders on maps.
8076
8177
Plots grayshaded, colored, or textured land-masses [or water-masses] on
8278
maps and [optionally] draws coastlines, rivers, and political
@@ -135,7 +131,6 @@ def coast(self, **kwargs):
135131
{XY}
136132
{p}
137133
{t}
138-
139134
"""
140135
kwargs = self._preprocess(**kwargs)
141136
with Session() as lib:
@@ -158,8 +153,7 @@ def coast(self, **kwargs):
158153
)
159154
@kwargs_to_strings(R="sequence", G="sequence", p="sequence")
160155
def colorbar(self, **kwargs):
161-
"""
162-
Plot a gray or color scale-bar on maps.
156+
"""Plot a gray or color scale-bar on maps.
163157
164158
Both horizontal and vertical scales are supported. For CPTs with
165159
gradational colors (i.e., the lower and upper boundary of an interval
@@ -219,7 +213,6 @@ def colorbar(self, **kwargs):
219213
{XY}
220214
{p}
221215
{t}
222-
223216
"""
224217
kwargs = self._preprocess(**kwargs)
225218
with Session() as lib:
@@ -246,8 +239,7 @@ def colorbar(self, **kwargs):
246239
)
247240
@kwargs_to_strings(R="sequence", L="sequence", A="sequence_plus", p="sequence")
248241
def grdcontour(self, grid, **kwargs):
249-
"""
250-
Convert grids or images to contours and plot them on maps
242+
"""Convert grids or images to contours and plot them on maps.
251243
252244
Takes a grid file name or an xarray.DataArray object as input.
253245
@@ -341,8 +333,7 @@ def grdcontour(self, grid, **kwargs):
341333
)
342334
@kwargs_to_strings(R="sequence", p="sequence")
343335
def grdimage(self, grid, **kwargs):
344-
"""
345-
Project and plot grids or images.
336+
"""Project and plot grids or images.
346337
347338
Reads a 2-D grid file and produces a gray-shaded (or colored) map by
348339
building a rectangular image and assigning pixels a gray-shade (or
@@ -458,7 +449,6 @@ def grdimage(self, grid, **kwargs):
458449
{p}
459450
{t}
460451
{x}
461-
462452
"""
463453
kwargs = self._preprocess(**kwargs)
464454
kind = data_kind(grid, None, None)
@@ -495,8 +485,7 @@ def grdimage(self, grid, **kwargs):
495485
)
496486
@kwargs_to_strings(R="sequence", p="sequence")
497487
def grdview(self, grid, **kwargs):
498-
"""
499-
Create 3-D perspective image or surface mesh from a grid.
488+
"""Create 3-D perspective image or surface mesh from a grid.
500489
501490
Reads a 2-D grid file and produces a 3-D perspective plot by drawing a
502491
mesh, painting a colored/gray-shaded surface made up of polygons, or by
@@ -567,7 +556,6 @@ def grdview(self, grid, **kwargs):
567556
{XY}
568557
{p}
569558
{t}
570-
571559
"""
572560
kwargs = self._preprocess(**kwargs)
573561
kind = data_kind(grid, None, None)
@@ -614,8 +602,7 @@ def grdview(self, grid, **kwargs):
614602
)
615603
@kwargs_to_strings(R="sequence", i="sequence_comma", p="sequence")
616604
def plot(self, x=None, y=None, data=None, sizes=None, direction=None, **kwargs):
617-
"""
618-
Plot lines, polygons, and symbols on maps.
605+
"""Plot lines, polygons, and symbols on maps.
619606
620607
Used to be psxy.
621608
@@ -740,8 +727,7 @@ def plot(self, x=None, y=None, data=None, sizes=None, direction=None, **kwargs):
740727
)
741728
@kwargs_to_strings(R="sequence", i="sequence_comma", p="sequence")
742729
def contour(self, x=None, y=None, z=None, data=None, **kwargs):
743-
"""
744-
Contour table data by direct triangulation.
730+
"""Contour table data by direct triangulation.
745731
746732
Takes a matrix, (x,y,z) pairs, or a file name as input and plots lines,
747733
polygons, or symbols at those locations on a map.
@@ -797,7 +783,6 @@ def contour(self, x=None, y=None, z=None, data=None, **kwargs):
797783
{XY}
798784
{p}
799785
{t}
800-
801786
"""
802787
kwargs = self._preprocess(**kwargs)
803788

@@ -834,8 +819,7 @@ def contour(self, x=None, y=None, z=None, data=None, **kwargs):
834819
)
835820
@kwargs_to_strings(R="sequence", p="sequence")
836821
def basemap(self, **kwargs):
837-
"""
838-
Produce a basemap for the figure.
822+
"""Produce a basemap for the figure.
839823
840824
Several map projections are available, and the user may specify
841825
separate tick-mark intervals for boundary annotation, ticking, and
@@ -867,7 +851,6 @@ def basemap(self, **kwargs):
867851
{XY}
868852
{p}
869853
{t}
870-
871854
"""
872855
kwargs = self._preprocess(**kwargs)
873856
if not ("B" in kwargs or "L" in kwargs or "T" in kwargs):
@@ -889,8 +872,7 @@ def basemap(self, **kwargs):
889872
)
890873
@kwargs_to_strings(R="sequence", p="sequence")
891874
def logo(self, **kwargs):
892-
"""
893-
Place the GMT graphics logo on a map.
875+
"""Place the GMT graphics logo on a map.
894876
895877
By default, the GMT logo is 2 inches wide and 1 inch high and
896878
will be positioned relative to the current plot origin.
@@ -915,7 +897,6 @@ def logo(self, **kwargs):
915897
{XY}
916898
{p}
917899
{t}
918-
919900
"""
920901
kwargs = self._preprocess(**kwargs)
921902
if "D" not in kwargs:
@@ -937,8 +918,7 @@ def logo(self, **kwargs):
937918
)
938919
@kwargs_to_strings(R="sequence", p="sequence")
939920
def image(self, imagefile, **kwargs):
940-
"""
941-
Place images or EPS files on maps.
921+
"""Place images or EPS files on maps.
942922
943923
Reads an Encapsulated PostScript file or a raster image file and plots
944924
it on a map.
@@ -990,8 +970,7 @@ def image(self, imagefile, **kwargs):
990970
)
991971
@kwargs_to_strings(R="sequence", p="sequence")
992972
def legend(self, spec=None, position="JTR+jTR+o0.2c", box="+gwhite+p1p", **kwargs):
993-
"""
994-
Plot legends on maps.
973+
"""Plot legends on maps.
995974
996975
Makes legends that can be overlaid on maps. Reads specific
997976
legend-related information from an input file, or automatically creates
@@ -1078,8 +1057,7 @@ def text(
10781057
justify=None,
10791058
**kwargs,
10801059
):
1081-
"""
1082-
Plot or typeset text strings of variable size, font type, and
1060+
"""Plot or typeset text strings of variable size, font type, and
10831061
orientation.
10841062
10851063
Must provide at least one of the following combinations as input:
@@ -1239,8 +1217,7 @@ def meca(
12391217
plot_latitude=None,
12401218
**kwargs,
12411219
):
1242-
"""
1243-
Plot focal mechanisms.
1220+
"""Plot focal mechanisms.
12441221
12451222
Full option list at :gmt-docs:`supplements/seis/meca.html`
12461223
@@ -1342,8 +1319,8 @@ def set_pointer(data_pointers, spec):
13421319

13431320
def update_pointers(data_pointers):
13441321
"""Updates variables based on the location of data, as the
1345-
following data can be passed as parameters or it can be
1346-
contained in `spec`."""
1322+
following data can be passed as parameters or it can be contained
1323+
in `spec`."""
13471324
# update all pointers
13481325
longitude = data_pointers["longitude"]
13491326
latitude = data_pointers["latitude"]

pygmt/clib/conversion.py

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
1-
"""
2-
Functions to convert data types into ctypes friendly formats.
3-
"""
1+
"""Functions to convert data types into ctypes friendly formats."""
42
import numpy as np
53
import pandas as pd
64

75
from ..exceptions import GMTInvalidInput
86

97

108
def dataarray_to_matrix(grid):
11-
"""
12-
Transform an xarray.DataArray into a data 2D array and metadata.
9+
"""Transform an xarray.DataArray into a data 2D array and metadata.
1310
1411
Use this to extract the underlying numpy array of data and the region and
1512
increment for the grid.
@@ -80,7 +77,6 @@ def dataarray_to_matrix(grid):
8077
[-150.5, -78.5, -80.5, -48.5]
8178
>>> print(inc)
8279
[2.0, 2.0]
83-
8480
"""
8581
if len(grid.dims) != 2:
8682
raise GMTInvalidInput(
@@ -119,8 +115,7 @@ def dataarray_to_matrix(grid):
119115

120116

121117
def vectors_to_arrays(vectors):
122-
"""
123-
Convert 1d vectors (lists, arrays or pandas.Series) to C contiguous 1d
118+
"""Convert 1d vectors (lists, arrays or pandas.Series) to C contiguous 1d
124119
arrays.
125120
126121
Arrays must be in C contiguous order for us to pass their memory pointers
@@ -159,15 +154,13 @@ def vectors_to_arrays(vectors):
159154
>>> data = [[1, 2], (3, 4), range(5, 7)]
160155
>>> all(isinstance(i, np.ndarray) for i in vectors_to_arrays(data))
161156
True
162-
163157
"""
164158
arrays = [as_c_contiguous(np.asarray(i)) for i in vectors]
165159
return arrays
166160

167161

168162
def as_c_contiguous(array):
169-
"""
170-
Ensure a numpy array is C contiguous in memory.
163+
"""Ensure a numpy array is C contiguous in memory.
171164
172165
If the array is not C contiguous, a copy will be necessary.
173166
@@ -201,16 +194,14 @@ def as_c_contiguous(array):
201194
True
202195
>>> as_c_contiguous(x).flags.c_contiguous
203196
True
204-
205197
"""
206198
if not array.flags.c_contiguous:
207199
return array.copy(order="C")
208200
return array
209201

210202

211203
def kwargs_to_ctypes_array(argument, kwargs, dtype):
212-
"""
213-
Convert an iterable argument from kwargs into a ctypes array variable.
204+
"""Convert an iterable argument from kwargs into a ctypes array variable.
214205
215206
If the argument is not present in kwargs, returns ``None``.
216207
@@ -239,17 +230,15 @@ def kwargs_to_ctypes_array(argument, kwargs, dtype):
239230
... )
240231
>>> print(should_be_none)
241232
None
242-
243233
"""
244234
if argument in kwargs:
245235
return dtype(*kwargs[argument])
246236
return None
247237

248238

249239
def array_to_datetime(array):
250-
"""
251-
Convert an 1d datetime array from various types into pandas.DatetimeIndex
252-
(i.e., numpy.datetime64).
240+
"""Convert an 1d datetime array from various types into
241+
pandas.DatetimeIndex (i.e., numpy.datetime64).
253242
254243
If the input array is not in legal datetime formats, raise a "ParseError"
255244
exception.

0 commit comments

Comments
 (0)