From dc11bb6d1b0e4aebae40e9f15607f8a7d3b9475e Mon Sep 17 00:00:00 2001 From: yohaimagen Date: Wed, 1 Sep 2021 08:37:23 +0300 Subject: [PATCH 01/23] add required_z parameters, and if statement to handle missing z vector --- pygmt/helpers/utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pygmt/helpers/utils.py b/pygmt/helpers/utils.py index 177e3d23f62..bb5c6ce5a41 100644 --- a/pygmt/helpers/utils.py +++ b/pygmt/helpers/utils.py @@ -14,7 +14,7 @@ from pygmt.exceptions import GMTInvalidInput -def data_kind(data, x=None, y=None, z=None): +def data_kind(data, x=None, y=None, z=None, required_z=False): """ Check what kind of data is provided to a module. @@ -65,6 +65,8 @@ def data_kind(data, x=None, y=None, z=None): raise GMTInvalidInput("Too much data. Use either data or x and y.") if data is None and (x is None or y is None): raise GMTInvalidInput("Must provided both x and y.") + if data is None and required_z and (x is None or y is None or z is None): + raise GMTInvalidInput("Must provided both x, y, and z.") if isinstance(data, str): kind = "file" From df1b0d5d3d449366096b06ee67e8555fc7706edd Mon Sep 17 00:00:00 2001 From: yohaimagen Date: Wed, 1 Sep 2021 08:38:51 +0300 Subject: [PATCH 02/23] add required_z parameters and pass it to data_kind --- pygmt/clib/session.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pygmt/clib/session.py b/pygmt/clib/session.py index 89026a71b94..378c6f5cbce 100644 --- a/pygmt/clib/session.py +++ b/pygmt/clib/session.py @@ -1362,7 +1362,14 @@ def virtualfile_from_grid(self, grid): @fmt_docstring def virtualfile_from_data( - self, check_kind=None, data=None, x=None, y=None, z=None, extra_arrays=None + self, + check_kind=None, + data=None, + x=None, + y=None, + z=None, + extra_arrays=None, + required_z=False, ): """ Store any data inside a virtual file. @@ -1414,7 +1421,7 @@ def virtualfile_from_data( ... : N = 3 <7/9> <4/6> <1/3> """ - kind = data_kind(data, x, y, z) + kind = data_kind(data, x, y, z, required_z=required_z) if check_kind == "raster" and kind not in ("file", "grid"): raise GMTInvalidInput(f"Unrecognized data type for grid: {type(data)}") From 1b7a8a6135b7fb51c9176fc3054079f50bb82dfe Mon Sep 17 00:00:00 2001 From: yohaimagen Date: Thu, 2 Sep 2021 09:15:59 +0300 Subject: [PATCH 03/23] test requierd_z --- pygmt/tests/test_clib.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pygmt/tests/test_clib.py b/pygmt/tests/test_clib.py index 4f2b8f4a980..4a25342e129 100644 --- a/pygmt/tests/test_clib.py +++ b/pygmt/tests/test_clib.py @@ -410,6 +410,19 @@ def test_virtual_file_bad_direction(): print("This should have failed") +def test_virtualfile_from_data_required_z(): + """ + Test that function fails when needs and do not provide z columns. + """ + x = np.arange(5) + y = np.arange(5) + z = None + with clib.Session() as lib: + with pytest.raises(GMTInvalidInput): + with lib.virtualfile_from_data(x=x, y=y, z=z, required_z=True): + print("This should have failed") + + def test_virtualfile_from_vectors(): """ Test the automation for transforming vectors to virtual file dataset. From e471f9e4d2e0e40b374897ebc8279da7a20dca5f Mon Sep 17 00:00:00 2001 From: yohaimagen Date: Fri, 3 Sep 2021 13:20:46 +0300 Subject: [PATCH 04/23] Update pygmt/helpers/utils.py Co-authored-by: Meghan Jones --- pygmt/helpers/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/helpers/utils.py b/pygmt/helpers/utils.py index bb5c6ce5a41..bf118887038 100644 --- a/pygmt/helpers/utils.py +++ b/pygmt/helpers/utils.py @@ -66,7 +66,7 @@ def data_kind(data, x=None, y=None, z=None, required_z=False): if data is None and (x is None or y is None): raise GMTInvalidInput("Must provided both x and y.") if data is None and required_z and (x is None or y is None or z is None): - raise GMTInvalidInput("Must provided both x, y, and z.") + raise GMTInvalidInput("Must provide x, y, and z.") if isinstance(data, str): kind = "file" From 11d98ee018b7534cb3b51e82f73ae6a8194b1c4b Mon Sep 17 00:00:00 2001 From: yohaimagen Date: Fri, 3 Sep 2021 13:21:12 +0300 Subject: [PATCH 05/23] Update pygmt/helpers/utils.py Co-authored-by: Meghan Jones --- pygmt/helpers/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/helpers/utils.py b/pygmt/helpers/utils.py index bf118887038..d72fefe305c 100644 --- a/pygmt/helpers/utils.py +++ b/pygmt/helpers/utils.py @@ -64,7 +64,7 @@ def data_kind(data, x=None, y=None, z=None, required_z=False): if data is not None and (x is not None or y is not None or z is not None): raise GMTInvalidInput("Too much data. Use either data or x and y.") if data is None and (x is None or y is None): - raise GMTInvalidInput("Must provided both x and y.") + raise GMTInvalidInput("Must provide both x and y.") if data is None and required_z and (x is None or y is None or z is None): raise GMTInvalidInput("Must provide x, y, and z.") From bcfc03a9de56aa31d594a9888f917eb6d9386a79 Mon Sep 17 00:00:00 2001 From: yohaimagen Date: Fri, 3 Sep 2021 13:22:04 +0300 Subject: [PATCH 06/23] Update pygmt/helpers/utils.py Co-authored-by: Meghan Jones --- pygmt/helpers/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/helpers/utils.py b/pygmt/helpers/utils.py index d72fefe305c..6df0509c7f1 100644 --- a/pygmt/helpers/utils.py +++ b/pygmt/helpers/utils.py @@ -65,7 +65,7 @@ def data_kind(data, x=None, y=None, z=None, required_z=False): raise GMTInvalidInput("Too much data. Use either data or x and y.") if data is None and (x is None or y is None): raise GMTInvalidInput("Must provide both x and y.") - if data is None and required_z and (x is None or y is None or z is None): + if data is None and required_z and z is None: raise GMTInvalidInput("Must provide x, y, and z.") if isinstance(data, str): From ba73d5bdc796a529a66541721628794b09105cc0 Mon Sep 17 00:00:00 2001 From: yohaimagen Date: Fri, 3 Sep 2021 13:35:46 +0300 Subject: [PATCH 07/23] checks that when required z data matrix has at least 3 columns --- pygmt/helpers/utils.py | 2 ++ pygmt/tests/test_clib.py | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/pygmt/helpers/utils.py b/pygmt/helpers/utils.py index 6df0509c7f1..363cd75d430 100644 --- a/pygmt/helpers/utils.py +++ b/pygmt/helpers/utils.py @@ -75,6 +75,8 @@ def data_kind(data, x=None, y=None, z=None, required_z=False): elif hasattr(data, "__geo_interface__"): kind = "geojson" elif data is not None: + if required_z and data.shape[1] < 3: + raise GMTInvalidInput("data must provide x, y, and z columns.") kind = "matrix" else: kind = "vectors" diff --git a/pygmt/tests/test_clib.py b/pygmt/tests/test_clib.py index 4a25342e129..eda12dbf920 100644 --- a/pygmt/tests/test_clib.py +++ b/pygmt/tests/test_clib.py @@ -410,7 +410,7 @@ def test_virtual_file_bad_direction(): print("This should have failed") -def test_virtualfile_from_data_required_z(): +def test_virtualfile_from_data_required_z_vectors(): """ Test that function fails when needs and do not provide z columns. """ @@ -422,6 +422,17 @@ def test_virtualfile_from_data_required_z(): with lib.virtualfile_from_data(x=x, y=y, z=z, required_z=True): print("This should have failed") +def test_virtualfile_from_data_required_z_matrix(): + """ + Test that function fails when needs and do not provide third z columns in a matrix. + """ + + data = np.ones((5, 2)) + with clib.Session() as lib: + with pytest.raises(GMTInvalidInput): + with lib.virtualfile_from_data(data=data, required_z=True): + print("This should have failed") + def test_virtualfile_from_vectors(): """ From ed1419dee32f0c16bccc81383229894ca4de4eb3 Mon Sep 17 00:00:00 2001 From: actions-bot <58130806+actions-bot@users.noreply.github.com> Date: Fri, 3 Sep 2021 10:38:44 +0000 Subject: [PATCH 08/23] [format-command] fixes --- pygmt/tests/test_clib.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pygmt/tests/test_clib.py b/pygmt/tests/test_clib.py index eda12dbf920..a8930285c13 100644 --- a/pygmt/tests/test_clib.py +++ b/pygmt/tests/test_clib.py @@ -422,9 +422,11 @@ def test_virtualfile_from_data_required_z_vectors(): with lib.virtualfile_from_data(x=x, y=y, z=z, required_z=True): print("This should have failed") + def test_virtualfile_from_data_required_z_matrix(): """ - Test that function fails when needs and do not provide third z columns in a matrix. + Test that function fails when needs and do not provide third z columns in a + matrix. """ data = np.ones((5, 2)) From 166b439ebf1f42467692647355d15d49840df694 Mon Sep 17 00:00:00 2001 From: yohaimagen Date: Fri, 3 Sep 2021 14:16:38 +0300 Subject: [PATCH 09/23] add required_z=True to _blockm --- pygmt/src/blockm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/blockm.py b/pygmt/src/blockm.py index 22f6cbd43c5..f4326c302a0 100644 --- a/pygmt/src/blockm.py +++ b/pygmt/src/blockm.py @@ -42,7 +42,7 @@ def _blockm(block_method, table, outfile, x, y, z, **kwargs): with Session() as lib: # Choose how data will be passed into the module table_context = lib.virtualfile_from_data( - check_kind="vector", data=table, x=x, y=y, z=z + check_kind="vector", data=table, x=x, y=y, z=z, required_z=True ) # Run blockm* on data table with table_context as infile: From 767544929fac6b2ab76417762898ce2d326b94ff Mon Sep 17 00:00:00 2001 From: yohaimagen Date: Fri, 3 Sep 2021 14:17:06 +0300 Subject: [PATCH 10/23] add required_z=True to contour --- pygmt/src/contour.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pygmt/src/contour.py b/pygmt/src/contour.py index 871ad994e33..493a4b662ac 100644 --- a/pygmt/src/contour.py +++ b/pygmt/src/contour.py @@ -127,9 +127,7 @@ def contour(self, x=None, y=None, z=None, data=None, **kwargs): """ kwargs = self._preprocess(**kwargs) # pylint: disable=protected-access - kind = data_kind(data, x, y, z) - if kind == "vectors" and z is None: - raise GMTInvalidInput("Must provided both x, y, and z.") + kind = data_kind(data, x, y, z, required_z=True) with Session() as lib: # Choose how data will be passed in to the module From 09c68cd85b53748d226590c13fb7c84839f85ffd Mon Sep 17 00:00:00 2001 From: yohaimagen Date: Fri, 3 Sep 2021 14:17:28 +0300 Subject: [PATCH 11/23] add required_z=True to plot3d --- pygmt/src/plot3d.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/plot3d.py b/pygmt/src/plot3d.py index 5bcfd23ba98..9d34f9b65a3 100644 --- a/pygmt/src/plot3d.py +++ b/pygmt/src/plot3d.py @@ -223,7 +223,7 @@ def plot3d( with Session() as lib: # Choose how data will be passed in to the module file_context = lib.virtualfile_from_data( - check_kind="vector", data=data, x=x, y=y, z=z, extra_arrays=extra_arrays + check_kind="vector", data=data, x=x, y=y, z=z, extra_arrays=extra_arrays, required_z=True ) with file_context as fname: From 8b3eeb2e4d958ab7521c242ef2d26275f9a86808 Mon Sep 17 00:00:00 2001 From: yohaimagen Date: Fri, 3 Sep 2021 14:17:46 +0300 Subject: [PATCH 12/23] add required_z=True to surface --- pygmt/src/surface.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pygmt/src/surface.py b/pygmt/src/surface.py index 1d24a438595..69915f5b833 100644 --- a/pygmt/src/surface.py +++ b/pygmt/src/surface.py @@ -78,9 +78,7 @@ def surface(x=None, y=None, z=None, data=None, **kwargs): - None if ``outfile`` is set (grid output will be stored in file set by ``outfile``) """ - kind = data_kind(data, x, y, z) - if kind == "vectors" and z is None: - raise GMTInvalidInput("Must provide z with x and y.") + kind = data_kind(data, x, y, z, required_z=True) with GMTTempFile(suffix=".nc") as tmpfile: with Session() as lib: From 2a77656018e0fa2441a9ac2d344913a27b73bb69 Mon Sep 17 00:00:00 2001 From: yohaimagen Date: Fri, 3 Sep 2021 14:19:20 +0300 Subject: [PATCH 13/23] reformat --- pygmt/src/plot3d.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pygmt/src/plot3d.py b/pygmt/src/plot3d.py index 9d34f9b65a3..e934ebbd774 100644 --- a/pygmt/src/plot3d.py +++ b/pygmt/src/plot3d.py @@ -223,7 +223,13 @@ def plot3d( with Session() as lib: # Choose how data will be passed in to the module file_context = lib.virtualfile_from_data( - check_kind="vector", data=data, x=x, y=y, z=z, extra_arrays=extra_arrays, required_z=True + check_kind="vector", + data=data, + x=x, + y=y, + z=z, + extra_arrays=extra_arrays, + required_z=True, ) with file_context as fname: From e1d8248e753ff4ddf2edbab7327d49550a3a6bca Mon Sep 17 00:00:00 2001 From: yohaimagen Date: Fri, 3 Sep 2021 14:38:37 +0300 Subject: [PATCH 14/23] remove unnecessary import --- pygmt/src/contour.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pygmt/src/contour.py b/pygmt/src/contour.py index 493a4b662ac..ac5efe989ff 100644 --- a/pygmt/src/contour.py +++ b/pygmt/src/contour.py @@ -3,7 +3,6 @@ """ from pygmt.clib import Session -from pygmt.exceptions import GMTInvalidInput from pygmt.helpers import ( build_arg_string, data_kind, From 306a5c64c62d5afbbcbe94e2a582021c644b573e Mon Sep 17 00:00:00 2001 From: yohaimagen Date: Sun, 12 Sep 2021 07:50:19 +0300 Subject: [PATCH 15/23] add required_z to wiggle --- pygmt/src/wiggle.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/wiggle.py b/pygmt/src/wiggle.py index f7a24cd6dc4..e4f41be341c 100644 --- a/pygmt/src/wiggle.py +++ b/pygmt/src/wiggle.py @@ -98,7 +98,7 @@ def wiggle(self, x=None, y=None, z=None, data=None, **kwargs): with Session() as lib: # Choose how data will be passed in to the module file_context = lib.virtualfile_from_data( - check_kind="vector", data=data, x=x, y=y, z=z + check_kind="vector", data=data, x=x, y=y, z=z, required_z=True ) with file_context as fname: From 8451465836e1ab697d97248d3af7e9702d0f55b0 Mon Sep 17 00:00:00 2001 From: yohaimagen Date: Sun, 12 Sep 2021 08:22:21 +0300 Subject: [PATCH 16/23] remove insuficent data test from test_contour --- pygmt/tests/test_contour.py | 40 ------------------------------------- 1 file changed, 40 deletions(-) diff --git a/pygmt/tests/test_contour.py b/pygmt/tests/test_contour.py index 3e285de9355..73ccf515a24 100644 --- a/pygmt/tests/test_contour.py +++ b/pygmt/tests/test_contour.py @@ -30,46 +30,6 @@ def region(): return [10, 70, -5, 10] -def test_contour_fail_no_data(data): - """ - Should raise an exception if no data is given. - """ - # Contour should raise an exception if no or not sufficient data - # is given - fig = Figure() - # Test all combinations where at least one data variable - # is not given: - for variable in product([None, data[:, 0]], repeat=3): - # Filter one valid configuration: - if not any(item is None for item in variable): - continue - with pytest.raises(GMTInvalidInput): - fig.contour( - x=variable[0], - y=variable[1], - z=variable[2], - region=region, - projection="X4i", - color="red", - frame="afg", - pen="", - ) - # Should also fail if given too much data - with pytest.raises(GMTInvalidInput): - fig.contour( - x=data[:, 0], - y=data[:, 1], - z=data[:, 2], - data=data, - region=region, - projection="X10c", - style="c0.2c", - color="red", - frame="afg", - pen=True, - ) - - @pytest.mark.mpl_image_compare def test_contour_vec(region): """ From da514877fc2590f77743b8519f12ad41e406589f Mon Sep 17 00:00:00 2001 From: yohaimagen Date: Sun, 12 Sep 2021 08:22:59 +0300 Subject: [PATCH 17/23] add test for sufficent data to test_clib --- pygmt/tests/test_clib.py | 62 ++++++++++++++++++++++++++++++++-------- 1 file changed, 50 insertions(+), 12 deletions(-) diff --git a/pygmt/tests/test_clib.py b/pygmt/tests/test_clib.py index a8930285c13..3155d07c411 100644 --- a/pygmt/tests/test_clib.py +++ b/pygmt/tests/test_clib.py @@ -1,9 +1,11 @@ # pylint: disable=protected-access +# pylint: disable=redefined-outer-name """ Test the wrappers for the C API. """ import os from contextlib import contextmanager +from itertools import product import numpy as np import numpy.testing as npt @@ -23,11 +25,20 @@ from pygmt.helpers import GMTTempFile TEST_DATA_DIR = os.path.join(os.path.dirname(__file__), "data") +POINTS_DATA = os.path.join(TEST_DATA_DIR, "points.txt") with clib.Session() as _lib: gmt_version = Version(_lib.info["version"]) +@pytest.fixture(scope="module") +def data(): + """ + Load the point data from the test file. + """ + return np.loadtxt(POINTS_DATA) + + @contextmanager def mock(session, func, returns=None, mock_func=None): """ @@ -410,30 +421,57 @@ def test_virtual_file_bad_direction(): print("This should have failed") -def test_virtualfile_from_data_required_z_vectors(): +def test_virtualfile_from_data_required_z_matrix(): """ - Test that function fails when needs and do not provide z columns. + Test that function fails when needs and do not provide third z columns in a + matrix. """ - x = np.arange(5) - y = np.arange(5) - z = None + + data = np.ones((5, 2)) with clib.Session() as lib: with pytest.raises(GMTInvalidInput): - with lib.virtualfile_from_data(x=x, y=y, z=z, required_z=True): + with lib.virtualfile_from_data(data=data, required_z=True): print("This should have failed") -def test_virtualfile_from_data_required_z_matrix(): +def test_virtualfile_from_data_fail_non_valid_data(data): """ - Test that function fails when needs and do not provide third z columns in a - matrix. + Should raise an exception if to less or to match data is given. """ + # Test all combinations where at least one data variable + # is not given in the x, y case: + for variable in product([None, data[:, 0]], repeat=2): + # Filter one valid configuration: + if not any(item is None for item in variable): + continue + with clib.Session() as lib: + with pytest.raises(GMTInvalidInput): + lib.virtualfile_from_data( + x=variable[0], + y=variable[1], + ) - data = np.ones((5, 2)) + # Test all combinations where at least one data variable + # is not given in the x, y, z case: + for variable in product([None, data[:, 0]], repeat=3): + # Filter one valid configuration: + if not any(item is None for item in variable): + continue + with clib.Session() as lib: + with pytest.raises(GMTInvalidInput): + lib.virtualfile_from_data( + x=variable[0], y=variable[1], z=variable[2], required_z=True + ) + + # Should also fail if given too much data with clib.Session() as lib: with pytest.raises(GMTInvalidInput): - with lib.virtualfile_from_data(data=data, required_z=True): - print("This should have failed") + lib.virtualfile_from_data( + x=data[:, 0], + y=data[:, 1], + z=data[:, 2], + data=data, + ) def test_virtualfile_from_vectors(): From 45592840c14febcec7d7e3894801a07384243fd5 Mon Sep 17 00:00:00 2001 From: yohaimagen Date: Sun, 12 Sep 2021 08:25:07 +0300 Subject: [PATCH 18/23] remove test for sufficent data test_plot3d --- pygmt/tests/test_plot3d.py | 42 -------------------------------------- 1 file changed, 42 deletions(-) diff --git a/pygmt/tests/test_plot3d.py b/pygmt/tests/test_plot3d.py index 3eb39e3f2af..302edd23fcd 100644 --- a/pygmt/tests/test_plot3d.py +++ b/pygmt/tests/test_plot3d.py @@ -68,48 +68,6 @@ def test_plot3d_red_circles_zsize(data, region): return fig -def test_plot3d_fail_no_data(data, region): - """ - Plot should raise an exception if no data is given. - """ - fig = Figure() - with pytest.raises(GMTInvalidInput): - fig.plot3d( - region=region, projection="X10c", style="c0.2c", color="red", frame="afg" - ) - with pytest.raises(GMTInvalidInput): - fig.plot3d( - x=data[:, 0], - region=region, - projection="X10c", - style="c0.2c", - color="red", - frame="afg", - ) - with pytest.raises(GMTInvalidInput): - fig.plot3d( - y=data[:, 0], - region=region, - projection="X10c", - style="c0.2c", - color="red", - frame="afg", - ) - # Should also fail if given too much data - with pytest.raises(GMTInvalidInput): - fig.plot3d( - x=data[:, 0], - y=data[:, 1], - z=data[:, 2], - data=data, - region=region, - projection="X10c", - style="c0.2c", - color="red", - frame="afg", - ) - - def test_plot3d_fail_1d_array_with_data(data, region): """ Should raise an exception if array color, size, intensity and transparency From 6a0042ecdd9b8ad295caec0dc27789dd37df94e3 Mon Sep 17 00:00:00 2001 From: yohaimagen Date: Sun, 12 Sep 2021 08:27:38 +0300 Subject: [PATCH 19/23] remove test for passing z value test_surface --- pygmt/tests/test_surface.py | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/pygmt/tests/test_surface.py b/pygmt/tests/test_surface.py index 8d9d84bc45a..050c47cc2bd 100644 --- a/pygmt/tests/test_surface.py +++ b/pygmt/tests/test_surface.py @@ -59,18 +59,6 @@ def test_surface_input_xyz(ship_data): return output -def test_surface_input_xy_no_z(ship_data): - """ - Run surface by passing in x and y, but no z. - """ - with pytest.raises(GMTInvalidInput): - surface( - x=ship_data.longitude, - y=ship_data.latitude, - spacing="5m", - region=[245, 255, 20, 30], - ) - def test_surface_wrong_kind_of_input(ship_data): """ From bb51fc58e7045fe6925586e63da2531678b8adb2 Mon Sep 17 00:00:00 2001 From: yohaimagen Date: Sun, 12 Sep 2021 08:33:12 +0300 Subject: [PATCH 20/23] reformat --- pygmt/tests/test_surface.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pygmt/tests/test_surface.py b/pygmt/tests/test_surface.py index 050c47cc2bd..b5e93d50b1a 100644 --- a/pygmt/tests/test_surface.py +++ b/pygmt/tests/test_surface.py @@ -59,7 +59,6 @@ def test_surface_input_xyz(ship_data): return output - def test_surface_wrong_kind_of_input(ship_data): """ Run surface using grid input that is not file/matrix/vectors. From 5eb4cc06d45e484ec41a603a512c070ab194c9d6 Mon Sep 17 00:00:00 2001 From: yohaimagen Date: Sun, 12 Sep 2021 08:40:02 +0300 Subject: [PATCH 21/23] remove unused imports --- pygmt/tests/test_contour.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/pygmt/tests/test_contour.py b/pygmt/tests/test_contour.py index 73ccf515a24..8c083370d9d 100644 --- a/pygmt/tests/test_contour.py +++ b/pygmt/tests/test_contour.py @@ -3,12 +3,10 @@ Tests contour. """ import os -from itertools import product import numpy as np import pytest from pygmt import Figure -from pygmt.exceptions import GMTInvalidInput TEST_DATA_DIR = os.path.join(os.path.dirname(__file__), "data") POINTS_DATA = os.path.join(TEST_DATA_DIR, "points.txt") From ba10dbb87f397f836469a9e2b4c4eaaf110b2b74 Mon Sep 17 00:00:00 2001 From: yohaimagen Date: Tue, 14 Sep 2021 08:01:17 +0300 Subject: [PATCH 22/23] Apply suggestions from code review Co-authored-by: Meghan Jones --- pygmt/tests/test_clib.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pygmt/tests/test_clib.py b/pygmt/tests/test_clib.py index 3155d07c411..84706471e5c 100644 --- a/pygmt/tests/test_clib.py +++ b/pygmt/tests/test_clib.py @@ -423,8 +423,8 @@ def test_virtual_file_bad_direction(): def test_virtualfile_from_data_required_z_matrix(): """ - Test that function fails when needs and do not provide third z columns in a - matrix. + Test that function fails when third z column in a matrix is needed but not + provided. """ data = np.ones((5, 2)) @@ -436,7 +436,7 @@ def test_virtualfile_from_data_required_z_matrix(): def test_virtualfile_from_data_fail_non_valid_data(data): """ - Should raise an exception if to less or to match data is given. + Should raise an exception if too few or too much data is given. """ # Test all combinations where at least one data variable # is not given in the x, y case: From 15075e8215d4ccc9b61b8c52575e19d7109967c9 Mon Sep 17 00:00:00 2001 From: yohaimagen Date: Tue, 14 Sep 2021 11:49:00 +0300 Subject: [PATCH 23/23] Apply suggestions from code review Co-authored-by: Dongdong Tian --- pygmt/tests/test_clib.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pygmt/tests/test_clib.py b/pygmt/tests/test_clib.py index efe7cb27327..a7cc3bfff15 100644 --- a/pygmt/tests/test_clib.py +++ b/pygmt/tests/test_clib.py @@ -426,12 +426,11 @@ def test_virtualfile_from_data_required_z_matrix(): Test that function fails when third z column in a matrix is needed but not provided. """ - data = np.ones((5, 2)) with clib.Session() as lib: with pytest.raises(GMTInvalidInput): with lib.virtualfile_from_data(data=data, required_z=True): - print("This should have failed") + pass def test_virtualfile_from_data_fail_non_valid_data(data):