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

Correct and consistent usage of 'function, 'method', and 'class' #2043

Merged
merged 44 commits into from
Aug 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
8734dbe
Replace 'function' by 'method' in 'subplots.py'
yvonnefroehlich Aug 6, 2022
ef169ec
Replace 'function' by 'class' in 'figure.py' ('psconvert')
yvonnefroehlich Aug 10, 2022
b313a67
Replace 'module' by 'function' in 'api/index.rst'
yvonnefroehlich Aug 11, 2022
0b13099
Replace 'method' by 'function' in 'colorbars_multiple.py'
yvonnefroehlich Aug 11, 2022
80339eb
Replace 'method' by 'function' in 'points_categorical.py'
yvonnefroehlich Aug 11, 2022
1c62054
Replace 'function' by 'method' in 'regions.py'
yvonnefroehlich Aug 19, 2022
b8c851f
Replace 'function' by 'method' in 'insets.py'
yvonnefroehlich Aug 19, 2022
0f1adbc
Replace 'function' by 'method' in 'gird_equalization.py'
yvonnefroehlich Aug 19, 2022
f69b105
Replace 'function' by 'method' in 'inset.py' (embellishments)
yvonnefroehlich Aug 19, 2022
9bdf46e
Replace 'function' by 'method' in 'inset_rectangle_region.py'
yvonnefroehlich Aug 19, 2022
24fb9e0
Replace 'method' by 'function' in 'great_circles.py'
yvonnefroehlich Aug 19, 2022
d10f292
Replace 'method' by 'function' in 'grdlandmask.py'
yvonnefroehlich Aug 19, 2022
a83038a
Replace 'method' by 'function' in 'blockm.py'
yvonnefroehlich Aug 19, 2022
e12619f
Replace 'method' by 'function' in 'grdgradient.py'
yvonnefroehlich Aug 19, 2022
6139c8f
Replace 'method' by 'function' in 'grdclip.py'
yvonnefroehlich Aug 19, 2022
876324a
Replace 'method' by 'function' in 'earth_relief.py'
yvonnefroehlich Aug 19, 2022
c90cf8e
Merge branch 'main' into correct-usage-function-method
yvonnefroehlich Aug 20, 2022
03e8151
Replace 'meth' by 'class' in 'configuration.py'
yvonnefroehlich Aug 21, 2022
1a782f2
Replace 'meth' by 'func' in 'date_time_charts.py'
yvonnefroehlich Aug 21, 2022
f6698f1
Replace 'meth' by 'func' in 'earth_relief.py'
yvonnefroehlich Aug 21, 2022
f1ffb5d
Replace 'meth' by 'func' in 'grid_equalization.py'
yvonnefroehlich Aug 21, 2022
3e9a801
Replace 'meth' by 'class' in 'vectors.py'
yvonnefroehlich Aug 21, 2022
1fea362
Replace 'func' by 'meth' in 'plot.py'
yvonnefroehlich Aug 21, 2022
3e2b595
Replace 'meth' by 'func' in 'scatter3d.py'
yvonnefroehlich Aug 21, 2022
7f3a50f
Replace 'function' by 'method' in 'inset.py' (pygmt/src)
yvonnefroehlich Aug 21, 2022
426cbab
Replace 'function' by 'method' in 'subplot.py'
yvonnefroehlich Aug 21, 2022
cef17c3
Replace 'method' by 'function' in 'grd2cpt.py'
yvonnefroehlich Aug 21, 2022
b14d8ac
Replace 'meth' by 'class' in 'grdhisteq.py'
yvonnefroehlich Aug 21, 2022
3ec33fb
Replace 'meth' by 'func' in 'grdhisteq.py'
yvonnefroehlich Aug 21, 2022
7b78e25
Replace 'meth' by 'func' in 'x2sys_init.py'
yvonnefroehlich Aug 21, 2022
5bb6be5
Replace 'meth' by 'func' in 'x2sys_cross.py'
yvonnefroehlich Aug 21, 2022
edff42f
Replace 'method' by 'function' in 'grdimage.py'
yvonnefroehlich Aug 21, 2022
8342fa5
Merge branch 'main' into correct-usage-function-method
yvonnefroehlich Aug 22, 2022
b920c61
Merge branch 'main' into correct-usage-function-method
yvonnefroehlich Aug 23, 2022
3e91e11
Remove 'modules' in 'first_figure.py'
yvonnefroehlich Aug 23, 2022
3db83c8
Improve formulation in 'first_figure.py'
yvonnefroehlich Aug 23, 2022
77ea1ea
Replace 'method' by 'function' in 'makecpt.py'
yvonnefroehlich Aug 24, 2022
e7d1446
Replace 'function' by 'method' in 'contributing.md'
yvonnefroehlich Aug 25, 2022
0855dfe
Replace 'method' by 'function' in 'grdview.py'
yvonnefroehlich Aug 25, 2022
c798e36
Merge branch 'main' into correct-usage-function-method
yvonnefroehlich Aug 25, 2022
ab844db
Remove reStructuredText syntax in 'contributing.md' (own)
yvonnefroehlich Aug 26, 2022
46b7986
Merge branch 'main' into correct-usage-function-method
yvonnefroehlich Aug 27, 2022
8613bbd
Replace 'meth' by 'func' in 'grdinfo.py'
yvonnefroehlich Aug 27, 2022
ec12259
Replace 'meth' by 'func' in 'grdcut.py'
yvonnefroehlich Aug 27, 2022
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
4 changes: 2 additions & 2 deletions doc/api/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Saving and displaying the figure
Configuring the display settings
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The following module is provided directly through the :mod:`pygmt` top level
The following function is provided directly through the :mod:`pygmt` top level
package.

.. autosummary::
Expand All @@ -95,7 +95,7 @@ package.
Color palette table generation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The following modules are provided directly through the :mod:`pygmt` top level
The following functions are provided directly through the :mod:`pygmt` top level
package.

.. autosummary::
Expand Down
6 changes: 3 additions & 3 deletions doc/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ Guidelines for a good tutorial:
concise examples while the tutorials are detailed and full of text.
* SI units should be used in the example code for tutorial plots.

Note that the `Figure.show()` function needs to be called for a plot to be inserted into
Note that the `Figure.show()` method needs to be called for a plot to be inserted into
the documentation.

### Editing the API Documentation
Expand Down Expand Up @@ -576,7 +576,7 @@ returning the `pygmt.Figure` object:
```python
@pytest.mark.mpl_image_compare
def test_my_plotting_case():
"Test that my plotting function works"
"Test that my plotting method works"
fig = Figure()
fig.basemap(region=[0, 360, -90, 90], projection='W7i', frame=True)
return fig
Expand Down Expand Up @@ -682,7 +682,7 @@ Here's an example:
```python
@check_figures_equal()
def test_my_plotting_case():
"Test that my plotting function works"
"Test that my plotting method works"
fig_ref, fig_test = Figure(), Figure()
fig_ref.grdimage("@earth_relief_01d_g", projection="W120/15c", cmap="geo")
fig_test.grdimage(grid, projection="W120/15c", cmap="geo")
Expand Down
2 changes: 1 addition & 1 deletion examples/gallery/3d_plots/scatter3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
can be visualized using a perspective 3D plot. The ``region``
parameter has to include the :math:`x`, :math:`y`, :math:`z` axis limits in the
form of (xmin, xmax, ymin, ymax, zmin, zmax), which can be done automatically
using :meth:`pygmt.info`. To plot the z-axis frame, set ``frame`` as a
using :func:`pygmt.info`. To plot the z-axis frame, set ``frame`` as a
minimum to something like ``frame=["WsNeZ", "zaf"]``. Use ``perspective`` to
control the azimuth and elevation angle of the view, and ``zscale`` to adjust
the vertical exaggeration factor.
Expand Down
4 changes: 2 additions & 2 deletions examples/gallery/embellishments/colorbars_multiple.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@
nrows=1, ncols=2, figsize=("15c", "8c"), autolabel=True, margins="0.5c"
):
# Activate the first panel so that the colormap created by the makecpt
# method is a panel-level CPT
# function is a panel-level CPT
with fig.set_panel(panel=0):
pygmt.makecpt(cmap="geo", series=[-8000, 8000])
# "R?" means Winkel Tripel projection with map width automatically
# determined from the subplot width.
fig.grdimage(grid=grid_globe, projection="R?", region="g", frame="a")
fig.colorbar(frame=["a4000f2000", "x+lElevation", "y+lm"])
# Activate the second panel so that the colormap created by the makecpt
# method is a panel-level CPT
# function is a panel-level CPT
with fig.set_panel(panel=1):
pygmt.makecpt(cmap="globe", series=[-6000, 3000])
# "M?" means Mercator projection with map width also automatically
Expand Down
2 changes: 1 addition & 1 deletion examples/gallery/embellishments/inset.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
-----

The :meth:`pygmt.Figure.inset` method adds an inset figure inside a larger
figure. The function is called using a ``with`` statement, and its
figure. The method is called using a ``with`` statement, and its
``position``, ``box``, ``offset``, and ``margin`` parameters are set. Plotting
methods called within the ``with`` statement are applied to the inset figure.
"""
Expand Down
2 changes: 1 addition & 1 deletion examples/gallery/embellishments/inset_rectangle_region.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
--------------------------------------

The :meth:`pygmt.Figure.inset` method adds an inset figure inside a larger
figure. The function is called using a ``with`` statement, and its
figure. The method is called using a ``with`` statement, and its
``position``, ``box``, ``offset``, and ``margin`` can be customized. Plotting
methods called within the ``with`` statement plot into the inset figure.
"""
Expand Down
2 changes: 1 addition & 1 deletion examples/gallery/histograms/blockm.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
Blockmean
---------
The :meth:`pygmt.blockmean` method calculates different quantities
The :func:`pygmt.blockmean` function calculates different quantities
inside blocks/bins whose dimensions are defined via the ``spacing`` parameter.
The following examples show how to calculate the averages of the given values
inside each bin and how to report the number of points inside each bin.
Expand Down
8 changes: 4 additions & 4 deletions examples/gallery/images/grdclip.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""
Clipping grid values
--------------------
The :meth:`pygmt.grdclip` method allows to clip defined ranges of grid values.
In the example shown below we set all elevation values (grid points) smaller
than 0 m (in general the bathymetric part of the grid) to a common value of
-2000 m via the ``below`` parameter.
The :func:`pygmt.grdclip` function allows to clip defined ranges of grid
values. In the example shown below we set all elevation values (grid points)
smaller than 0 m (in general the bathymetric part of the grid) to a common
value of -2000 m via the ``below`` parameter.
"""

import pygmt
Expand Down
4 changes: 2 additions & 2 deletions examples/gallery/images/grdgradient.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""
Calculating grid gradient and radiance
--------------------------------------
The :meth:`pygmt.grdgradient` method calculates the gradient of a grid file.
The :func:`pygmt.grdgradient` function calculates the gradient of a grid file.
In the example shown below we will see how to calculate a hillshade map based
on a Data Elevation Model (DEM). As input :meth:`pygmt.grdgradient` gets
on a Data Elevation Model (DEM). As input :func:`pygmt.grdgradient` gets
a :class:`xarray.DataArray` object or a path string to a grid file, calculates
the respective gradient and returns it as an :class:`xarray.DataArray` object.
We will use the ``radiance`` parameter in order to set the illumination source
Expand Down
2 changes: 1 addition & 1 deletion examples/gallery/images/grdlandmask.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
Create 'wet-dry' mask grid
--------------------------
The :meth:`pygmt.grdlandmask` method allows setting
The :func:`pygmt.grdlandmask` function allows setting
all nodes on land or water to a specified value using
the ``maskvalues`` parameter.
"""
Expand Down
2 changes: 1 addition & 1 deletion examples/gallery/lines/great_circles.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Generate points along great circles
-----------------------------------

The :meth:`pygmt.project` method can generate points along a great circle
The :func:`pygmt.project` function can generate points along a great circle
whose center and end points can be defined via the ``center`` and ``endpoint``
parameters, respectively. Using the ``generate`` parameter allows to generate
(*r*, *s*, *p*) points every *dist* units of *p* along a profile as
Expand Down
4 changes: 2 additions & 2 deletions examples/gallery/symbols/points_categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
can be visualized. Here, we can pass the individual categories included in
the "species" column directly to the ``color`` parameter via
``color=df.species.cat.codes.astype(int)``. Additionally, we have to set
``cmap=True``. A desired colormap can be selected via the :meth:`pygmt.makecpt`
method.
``cmap=True``. A desired colormap can be selected via the :func:`pygmt.makecpt`
function.
"""

import pandas as pd
Expand Down
6 changes: 3 additions & 3 deletions examples/get-started/first_figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@
fig = pygmt.Figure()

###############################################################################
# To add to a plot object (``fig`` in this example), the PyGMT module is used
# as a method on the class. This example will use the
# To add elements to the figure instance or object (``fig`` in this example)
# different methods can be called on it. This example will use the
# :meth:`pygmt.Figure.coast` method, which can be used to create a map without
# any other methods, modules or external data. The :meth:`pygmt.Figure.coast`
# any other methods or external data. The :meth:`pygmt.Figure.coast`
# method plots the coastlines, borders, and bodies of water using a database
# that is included in GMT.
#
Expand Down
4 changes: 2 additions & 2 deletions examples/tutorials/advanced/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
# ----------------------------------
#
# Users can override default parameters either temporarily (locally) or
# permanently (globally) using :meth:`pygmt.config`. The full list of default
# permanently (globally) using :class:`pygmt.config`. The full list of default
# parameters that can be changed can be found at :gmt-docs:`gmt.conf.html`.
#
# We demonstrate the usage of :meth:`pygmt.config` by configuring a map plot.
# We demonstrate the usage of :class:`pygmt.config` by configuring a map plot.

# Start with a basic figure with the default style
fig = pygmt.Figure()
Expand Down
2 changes: 1 addition & 1 deletion examples/tutorials/advanced/date_time_charts.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@
#
# Another way of creating charts involving datetime data can be done
# by automatically generating the region of the plot. This can be done
# by passing the dataframe to :meth:`pygmt.info`, which will find
# by passing the dataframe to :func:`pygmt.info`, which will find
# maximum and minimum values for each column and create a list
# that could be passed as region. Additionally, the ``spacing`` argument
# can be passed to increase the range past the maximum and minimum
Expand Down
6 changes: 3 additions & 3 deletions examples/tutorials/advanced/earth_relief.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
=====================

Plotting a map of Earth relief can use the data accessed by the
:meth:`pygmt.datasets.load_earth_relief` method. The data can then be plotted
using the :meth:`pygmt.Figure.grdimage` method.
:func:`pygmt.datasets.load_earth_relief` function. The data can then be
plotted using the :meth:`pygmt.Figure.grdimage` method.
"""
# sphinx_gallery_thumbnail_number = 5

Expand Down Expand Up @@ -86,7 +86,7 @@
# -------------------
#
# In addition to providing global data, the ``region`` parameter for
# :meth:`pygmt.datasets.load_earth_relief` can be used to provide data for a
# :func:`pygmt.datasets.load_earth_relief` can be used to provide data for a
# specific area. The ``region`` parameter is required for resolutions at 5 arc
# minutes or higher, and accepts a list (as in the example below) or a string.
# The geographic ranges are passed as *xmin*/*xmax*/*ymin*/*ymax*.
Expand Down
4 changes: 2 additions & 2 deletions examples/tutorials/advanced/grid_equalization.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
Performing grid histogram equalization
======================================
The :meth:`pygmt.grdhisteq.equalize_grid` function creates a grid using
The :meth:`pygmt.grdhisteq.equalize_grid` method creates a grid using
statistics based on a cumulative distribution function.
"""
# sphinx_gallery_thumbnail_number = 3
Expand All @@ -12,7 +12,7 @@
# Load sample data
# ----------------
# Load the sample Earth relief data for a region around Yosemite valley
# and use :meth:`pygmt.grd2xyz` to create a :class:`pandas.Series` with the
# and use :func:`pygmt.grd2xyz` to create a :class:`pandas.Series` with the
# z-values.

grid = pygmt.datasets.load_earth_relief(
Expand Down
6 changes: 3 additions & 3 deletions examples/tutorials/advanced/insets.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
frame="a",
)
with fig.inset(position="jBL+w3c", box="+pblack+glightred"):
# pass is used to exit the with statement as no plotting functions are
# pass is used to exit the with statement as no plotting methods are
# called
pass
fig.show()
Expand Down Expand Up @@ -81,7 +81,7 @@

###############################################################################
#
# Standard plotting functions can be called from within the ``inset`` context
# Standard plotting methods can be called from within the ``inset`` context
# manager. The example below uses :meth:`pygmt.Figure.coast` to plot a zoomed
# out map that selectively paints the state of Massachusetts to shows its
# location relative to other states.
Expand All @@ -105,7 +105,7 @@
region=[-80, -65, 35, 50],
projection="M3c",
):
# Use a plotting function to create a figure inside the inset.
# Use a plotting method to create a figure inside the inset.
fig.coast(
land="gray",
borders=[1, 2],
Expand Down
8 changes: 4 additions & 4 deletions examples/tutorials/advanced/subplots.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
# Define subplot layout
# ---------------------
#
# The :meth:`pygmt.Figure.subplot` function is used to set up the layout, size,
# The :meth:`pygmt.Figure.subplot` method is used to set up the layout, size,
# and other attributes of the figure. It divides the whole canvas into regular
# grid areas with *n* rows and *m* columns. Each grid area can contain an
# individual subplot. For example:
Expand Down Expand Up @@ -62,8 +62,8 @@
fig.show()

###############################################################################
# The :meth:`pygmt.Figure.set_panel` function activates a specified subplot,
# and all subsequent plotting functions will take place in that subplot panel.
# The :meth:`pygmt.Figure.set_panel` method activates a specified subplot,
# and all subsequent plotting methods will take place in that subplot panel.
# This is similar to matplotlib's ``plt.sca`` method. In order to specify a
# subplot, you will need to provide the identifier for that subplot via the
# ``panel`` parameter. Pass in either the *index* number, or a tuple/list like
Expand Down Expand Up @@ -145,7 +145,7 @@
###############################################################################
# .. note::
#
# All plotting functions (e.g. :meth:`pygmt.Figure.coast`,
# All plotting methods (e.g. :meth:`pygmt.Figure.coast`,
# :meth:`pygmt.Figure.text`, etc) are able to use ``panel`` parameter when
# in subplot mode. Once a panel is activated using ``panel`` or
# :meth:`pygmt.Figure.set_panel`, subsequent plotting commands that don't
Expand Down
2 changes: 1 addition & 1 deletion examples/tutorials/advanced/vectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
# The angle is measured in degrees and moves counter-clockwise from the
# horizontal.
# The length of the vector uses centimeters by default but
# could be changed using :meth:`pygmt.config`
# could be changed using :class:`pygmt.config`
# (Check the next examples for unit changes).
#
# Notice that the ``v`` in the ``style`` parameter stands for
Expand Down
2 changes: 1 addition & 1 deletion examples/tutorials/basics/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
# even use the new matplotlib colormap "viridis". Here, we first create a
# continuous colormap ranging from the minimum depth to the maximum depth of
# the earthquakes using :func:`pygmt.makecpt`, then set ``cmap=True`` in
# :func:`pygmt.Figure.plot` to use the colormap. At the end of the plot, we
# :meth:`pygmt.Figure.plot` to use the colormap. At the end of the plot, we
# also plot a colorbar showing the colormap used in the plot.
#

Expand Down
2 changes: 1 addition & 1 deletion examples/tutorials/basics/regions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Setting the region
==================

Many of the plotting functions take the ``region`` parameter, which sets the
Many of the plotting methods take the ``region`` parameter, which sets the
area that will be shown in the figure. This tutorial covers the different types
of inputs that it can accept.
"""
Expand Down
2 changes: 1 addition & 1 deletion pygmt/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def psconvert(self, icc_gray=False, **kwargs):
PDF, PNG, PPM, SVG, TIFF) using Ghostscript.

If no input files are given, will convert the current active figure
(see :func:`pygmt.Figure`). In this case, an output name must be given
(see :class:`pygmt.Figure`). In this case, an output name must be given
using parameter *prefix*.

Full option list at :gmt-docs:`psconvert.html`
Expand Down
4 changes: 2 additions & 2 deletions pygmt/src/grd2cpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def grd2cpt(grid, **kwargs):
r"""
Make GMT color palette tables from a grid file.

This is a method that will help you make static color palette tables
This is a function that will help you make static color palette tables
(CPTs). By default, the CPT will simply be saved to the current session,
but you can use ``output`` to save it to a file. The CPT is based on an
existing dynamic master CPT of your choice, and the mapping from data value
Expand Down Expand Up @@ -61,7 +61,7 @@ def grd2cpt(grid, **kwargs):
``overrule_bg`` or ``no_bg``.

The color model (RGB, HSV or CMYK) of the palette created by
:meth:`pygmt.grd2cpt` will be the same as specified in the header of the
:func:`pygmt.grd2cpt` will be the same as specified in the header of the
master CPT. When there is no :gmt-term:`COLOR_MODEL` entry in the master
CPT, the :gmt-term:`COLOR_MODEL` specified in the
:gmt-docs:`gmt.conf <gmt.conf>` file or the ``color_model`` option will be
Expand Down
2 changes: 1 addition & 1 deletion pygmt/src/grdcut.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def grdcut(grid, **kwargs):
Produce a new ``outgrid`` file which is a subregion of ``grid``. The
subregion is specified with ``region``; the specified range must not exceed
the range of ``grid`` (but see ``extend``). If in doubt, run
:meth:`pygmt.grdinfo` to check range. Alternatively, define the subregion
:func:`pygmt.grdinfo` to check range. Alternatively, define the subregion
indirectly via a range check on the node values or via distances from a
given point. Finally, you can give ``projection`` for oblique projections
to determine the corresponding rectangular ``region`` that will give a grid
Expand Down
Loading