-
Notifications
You must be signed in to change notification settings - Fork 1
Sourcery refactored master branch #103
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -92,21 +92,19 @@ def _get_ghostscript_version(): | |
|
|
||
| for gs_cmd in cmds: | ||
| try: | ||
| version = subprocess.check_output( | ||
| return subprocess.check_output( | ||
| [gs_cmd, "--version"], universal_newlines=True | ||
| ).strip() | ||
| return version | ||
| except FileNotFoundError: | ||
| continue | ||
| return None | ||
|
|
||
| def _get_gmt_version(): | ||
| """Get GMT version.""" | ||
| try: | ||
| version = subprocess.check_output( | ||
| return subprocess.check_output( | ||
| ["gmt", "--version"], universal_newlines=True | ||
| ).strip() | ||
| return version | ||
|
Comment on lines
-106
to
-109
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| except FileNotFoundError: | ||
| return None | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,8 +26,7 @@ def get_keywords(): | |
| git_refnames = "$Format:%d$" | ||
| git_full = "$Format:%H$" | ||
| git_date = "$Format:%ci$" | ||
| keywords = {"refnames": git_refnames, "full": git_full, "date": git_date} | ||
| return keywords | ||
| return {"refnames": git_refnames, "full": git_full, "date": git_date} | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
|
|
||
| class VersioneerConfig: | ||
|
|
@@ -117,7 +116,7 @@ def versions_from_parentdir(parentdir_prefix, root, verbose): | |
| """ | ||
| rootdirs = [] | ||
|
|
||
| for i in range(3): | ||
| for _ in range(3): | ||
|
Comment on lines
-120
to
+119
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| dirname = os.path.basename(root) | ||
| if dirname.startswith(parentdir_prefix): | ||
| return { | ||
|
|
@@ -187,11 +186,11 @@ def git_versions_from_keywords(keywords, tag_prefix, verbose): | |
| if verbose: | ||
| print("keywords are unexpanded, not using") | ||
| raise NotThisMethod("unexpanded keywords, not a git-archive tarball") | ||
| refs = set([r.strip() for r in refnames.strip("()").split(",")]) | ||
| refs = {r.strip() for r in refnames.strip("()").split(",")} | ||
| # starting in git-1.8.3, tags are listed as "tag: foo-1.0" instead of | ||
| # just "foo-1.0". If we see a "tag: " prefix, prefer those. | ||
| TAG = "tag: " | ||
| tags = set([r[len(TAG) :] for r in refs if r.startswith(TAG)]) | ||
| tags = {r[len(TAG) :] for r in refs if r.startswith(TAG)} | ||
|
Comment on lines
-190
to
+193
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| if not tags: | ||
| # Either we're using git < 1.8.3, or there really are no tags. We use | ||
| # a heuristic: assume all version tags have a digit. The old git %d | ||
|
|
@@ -200,7 +199,7 @@ def git_versions_from_keywords(keywords, tag_prefix, verbose): | |
| # between branches and tags. By ignoring refnames without digits, we | ||
| # filter out many common branch names like "release" and | ||
| # "stabilization", as well as "HEAD" and "master". | ||
| tags = set([r for r in refs if re.search(r"\d", r)]) | ||
| tags = {r for r in refs if re.search(r"\d", r)} | ||
| if verbose: | ||
| print("discarding '%s', no digits" % ",".join(refs - tags)) | ||
| if verbose: | ||
|
|
@@ -352,13 +351,11 @@ def render_pep440(pieces): | |
| if pieces["distance"] or pieces["dirty"]: | ||
| rendered += plus_or_dot(pieces) | ||
| rendered += "%d.g%s" % (pieces["distance"], pieces["short"]) | ||
| if pieces["dirty"]: | ||
| rendered += ".dirty" | ||
| else: | ||
| # exception #1 | ||
| rendered = "0+untagged.%d.g%s" % (pieces["distance"], pieces["short"]) | ||
| if pieces["dirty"]: | ||
| rendered += ".dirty" | ||
| if pieces["dirty"]: | ||
| rendered += ".dirty" | ||
|
Comment on lines
-355
to
+358
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| return rendered | ||
|
|
||
|
|
||
|
|
@@ -417,13 +414,11 @@ def render_pep440_old(pieces): | |
| rendered = pieces["closest-tag"] | ||
| if pieces["distance"] or pieces["dirty"]: | ||
| rendered += ".post%d" % pieces["distance"] | ||
| if pieces["dirty"]: | ||
| rendered += ".dev0" | ||
| else: | ||
| # exception #1 | ||
| rendered = "0.post%d" % pieces["distance"] | ||
| if pieces["dirty"]: | ||
| rendered += ".dev0" | ||
| if pieces["dirty"]: | ||
| rendered += ".dev0" | ||
|
Comment on lines
-420
to
+421
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| return rendered | ||
|
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -675,7 +675,7 @@ def basemap(self, **kwargs): | |
|
|
||
| """ | ||
| kwargs = self._preprocess(**kwargs) | ||
| if not ("B" in kwargs or "L" in kwargs or "T" in kwargs): | ||
| if "B" not in kwargs and "L" not in kwargs and "T" not in kwargs: | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| raise GMTInvalidInput("At least one of B, L, or T must be specified.") | ||
| with Session() as lib: | ||
| lib.call_module("basemap", build_arg_string(kwargs)) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -104,7 +104,7 @@ def dataarray_to_matrix(grid): | |
| region.extend([coord.min(), coord.max()]) | ||
| inc.append(coord_inc) | ||
|
|
||
| if any([i < 0 for i in inc]): # Sort grid when there are negative increments | ||
| if any(i < 0 for i in inc): # Sort grid when there are negative increments | ||
|
||
| inc = [abs(i) for i in inc] | ||
| grid = grid.sortby(variables=list(grid.dims), ascending=True) | ||
|
|
||
|
|
@@ -155,8 +155,7 @@ def vectors_to_arrays(vectors): | |
| True | ||
|
|
||
| """ | ||
| arrays = [as_c_contiguous(np.asarray(i)) for i in vectors] | ||
| return arrays | ||
| return [as_c_contiguous(np.asarray(i)) for i in vectors] | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
|
|
||
| def as_c_contiguous(array): | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -605,10 +605,7 @@ def _parse_pad(self, family, kwargs): | |
| """ | ||
| pad = kwargs.get("pad", None) | ||
| if pad is None: | ||
| if "MATRIX" in family: | ||
| pad = 0 | ||
| else: | ||
| pad = self["GMT_PAD_DEFAULT"] | ||
| pad = 0 if "MATRIX" in family else self["GMT_PAD_DEFAULT"] | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| return pad | ||
|
|
||
| def _parse_constant(self, constant, valid, valid_modifiers=None): | ||
|
|
@@ -666,8 +663,7 @@ def _parse_constant(self, constant, valid, valid_modifiers=None): | |
| parts[1], str(valid_modifiers) | ||
| ) | ||
| ) | ||
| integer_value = sum(self[part] for part in parts) | ||
| return integer_value | ||
| return sum(self[part] for part in parts) | ||
|
Comment on lines
-669
to
+666
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
| def _check_dtype_and_dim(self, array, ndim): | ||
| """ | ||
|
|
@@ -1071,7 +1067,7 @@ def virtualfile_from_vectors(self, *vectors): | |
|
|
||
| columns = len(arrays) | ||
| rows = len(arrays[0]) | ||
| if not all(len(i) == rows for i in arrays): | ||
| if any(len(i) != rows for i in arrays): | ||
|
Comment on lines
-1074
to
+1070
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| raise GMTInvalidInput("All arrays must have same size.") | ||
|
|
||
| family = "GMT_IS_DATASET|GMT_VIA_VECTOR" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -101,11 +101,12 @@ def _is_valid_resolution(resolution): | |
| pygmt.exceptions.GMTInvalidInput: Invalid Earth relief resolution '01s'. | ||
|
|
||
| """ | ||
| valid_resolutions = ["01d"] | ||
| valid_resolutions.extend( | ||
| [f"{res:02d}m" for res in [60, 30, 20, 15, 10, 6, 5, 4, 3, 2, 1]] | ||
| ) | ||
| valid_resolutions.extend([f"{res:02d}s" for res in [30, 15]]) | ||
| valid_resolutions = [ | ||
| "01d", | ||
| *[f"{res:02d}m" for res in [60, 30, 20, 15, 10, 6, 5, 4, 3, 2, 1]], | ||
| *[f"{res:02d}s" for res in [30, 15]], | ||
| ] | ||
|
|
||
|
||
| if resolution not in valid_resolutions: | ||
| raise GMTInvalidInput( | ||
| "Invalid Earth relief resolution '{}'.".format(resolution) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -55,10 +55,9 @@ def load_ocean_ridge_points(): | |
| The data table. Columns are longitude and latitude. | ||
| """ | ||
| fname = which("@ridge.txt", download="c") | ||
| data = pd.read_csv( | ||
| return pd.read_csv( | ||
| fname, sep=r"\s+", names=["longitude", "latitude"], skiprows=1, comment=">" | ||
| ) | ||
| return data | ||
|
Comment on lines
-58
to
-61
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
|
|
||
| def load_sample_bathymetry(): | ||
|
|
@@ -78,10 +77,9 @@ def load_sample_bathymetry(): | |
| The data table. Columns are longitude, latitude, and bathymetry. | ||
| """ | ||
| fname = which("@tut_ship.xyz", download="c") | ||
| data = pd.read_csv( | ||
| return pd.read_csv( | ||
| fname, sep="\t", header=None, names=["longitude", "latitude", "bathymetry"] | ||
| ) | ||
| return data | ||
|
Comment on lines
-81
to
-84
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
|
|
||
| def load_usgs_quakes(): | ||
|
|
@@ -102,5 +100,4 @@ def load_usgs_quakes(): | |
|
|
||
| """ | ||
| fname = which("@usgs_quakes_22.txt", download="c") | ||
| data = pd.read_csv(fname) | ||
| return data | ||
| return pd.read_csv(fname) | ||
|
Comment on lines
-105
to
+103
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -83,9 +83,9 @@ def _activate_figure(self): | |
| :meth:`pygmt.Figure.savefig` or :meth:`pygmt.Figure.psconvert` must be | ||
| made in order to get a file. | ||
| """ | ||
| # Passing format '-' tells pygmt.end to not produce any files. | ||
| fmt = "-" | ||
| with Session() as lib: | ||
| # Passing format '-' tells pygmt.end to not produce any files. | ||
| fmt = "-" | ||
|
Comment on lines
-86
to
+88
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| lib.call_module("figure", "{} {}".format(self._name, fmt)) | ||
|
|
||
| def _preprocess(self, **kwargs): | ||
|
|
@@ -362,8 +362,7 @@ def _repr_png_(self): | |
| Show a PNG preview if the object is returned in an interactive shell. | ||
| For the Jupyter notebook or IPython Qt console. | ||
| """ | ||
| png = self._preview(fmt="png", dpi=70, anti_alias=True, as_bytes=True) | ||
| return png | ||
| return self._preview(fmt="png", dpi=70, anti_alias=True, as_bytes=True) | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
| def _repr_html_(self): | ||
| """ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -139,8 +139,7 @@ def build_arg_string(kwargs): | |
| else: | ||
| sorted_args.append("-{}{}".format(key, kwargs[key])) | ||
|
|
||
| arg_str = " ".join(sorted_args) | ||
| return arg_str | ||
| return " ".join(sorted_args) | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
|
|
||
| def is_nonstr_iter(value): | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,8 +12,8 @@ def begin(): | |
|
|
||
| Only meant to be used once for creating the global session. | ||
| """ | ||
| prefix = "pygmt-session" | ||
| with Session() as lib: | ||
| prefix = "pygmt-session" | ||
|
Comment on lines
-15
to
+16
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| lib.call_module("begin", prefix) | ||
| # pygmt relies on GMT modern mode with GMT_COMPATIBILITY at version 6 | ||
| lib.call_module("set", "GMT_COMPATIBILITY 6") | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,7 +24,7 @@ def __call__(self, block, block_vars, gallery_conf): | |
| Called by sphinx-gallery to save the figures generated after running | ||
| code. | ||
| """ | ||
| image_names = list() | ||
| image_names = [] | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| image_path_iterator = block_vars["image_path_iterator"] | ||
| figures = SHOWED_FIGURES | ||
| while figures: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -129,8 +129,8 @@ def test_destroy_session_fails(): | |
| def test_call_module(): | ||
| "Run a command to see if call_module works" | ||
| data_fname = os.path.join(TEST_DATA_DIR, "points.txt") | ||
| out_fname = "test_call_module.txt" | ||
| with clib.Session() as lib: | ||
| out_fname = "test_call_module.txt" | ||
|
Comment on lines
-132
to
+133
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function test_call_module refactored with the following changes:
Comment on lines
-132
to
+133
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| with GMTTempFile() as out_fname: | ||
| lib.call_module("info", "{} -C ->{}".format(data_fname, out_fname.name)) | ||
| assert os.path.exists(out_fname.name) | ||
|
|
@@ -321,10 +321,10 @@ def test_put_vector(): | |
| lib.put_vector(dataset, column=lib["GMT_X"], vector=x) | ||
| lib.put_vector(dataset, column=lib["GMT_Y"], vector=y) | ||
| lib.put_vector(dataset, column=lib["GMT_Z"], vector=z) | ||
| # Turns out wesn doesn't matter for Datasets | ||
| wesn = [0] * 6 | ||
| # Save the data to a file to see if it's being accessed correctly | ||
| with GMTTempFile() as tmp_file: | ||
| # Turns out wesn doesn't matter for Datasets | ||
| wesn = [0] * 6 | ||
|
||
| lib.write_data( | ||
| "GMT_IS_VECTOR", | ||
| "GMT_IS_POINT", | ||
|
|
@@ -396,10 +396,10 @@ def test_put_matrix(): | |
| ) | ||
| data = np.arange(shape[0] * shape[1], dtype=dtype).reshape(shape) | ||
| lib.put_matrix(dataset, matrix=data) | ||
| # wesn doesn't matter for Datasets | ||
| wesn = [0] * 6 | ||
| # Save the data to a file to see if it's being accessed correctly | ||
| with GMTTempFile() as tmp_file: | ||
| # wesn doesn't matter for Datasets | ||
| wesn = [0] * 6 | ||
|
||
| lib.write_data( | ||
| "GMT_IS_MATRIX", | ||
| "GMT_IS_POINT", | ||
|
|
@@ -521,13 +521,13 @@ def test_virtual_file_fails(): | |
| def test_virtual_file_bad_direction(): | ||
| "Test passing an invalid direction argument" | ||
| with clib.Session() as lib: | ||
| vfargs = ( | ||
| "GMT_IS_DATASET|GMT_VIA_MATRIX", | ||
| "GMT_IS_POINT", | ||
| "GMT_IS_GRID", # The invalid direction argument | ||
| 0, | ||
| ) | ||
| with pytest.raises(GMTInvalidInput): | ||
| vfargs = ( | ||
| "GMT_IS_DATASET|GMT_VIA_MATRIX", | ||
| "GMT_IS_POINT", | ||
| "GMT_IS_GRID", # The invalid direction argument | ||
| 0, | ||
| ) | ||
|
Comment on lines
-524
to
+530
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function test_virtual_file_bad_direction refactored with the following changes:
Comment on lines
-524
to
+530
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| with lib.open_virtual_file(*vfargs): | ||
| print("This should have failed") | ||
|
|
||
|
|
@@ -648,11 +648,11 @@ def test_virtualfile_from_vectors_pandas(): | |
|
|
||
| def test_virtualfile_from_vectors_arraylike(): | ||
| "Pass array-like vectors to a dataset" | ||
| size = 13 | ||
| x = list(range(0, size, 1)) | ||
| y = tuple(range(size, size * 2, 1)) | ||
| z = range(size * 2, size * 3, 1) | ||
| with clib.Session() as lib: | ||
| size = 13 | ||
| x = list(range(0, size, 1)) | ||
| y = tuple(range(size, size * 2, 1)) | ||
| z = range(size * 2, size * 3, 1) | ||
|
Comment on lines
-651
to
+655
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function test_virtualfile_from_vectors_arraylike refactored with the following changes:
Comment on lines
-651
to
+655
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| with lib.virtualfile_from_vectors(x, y, z) as vfile: | ||
| with GMTTempFile() as outfile: | ||
| lib.call_module("info", "{} ->{}".format(vfile, outfile.name)) | ||
|
|
@@ -834,12 +834,9 @@ def test_fails_for_wrong_version(): | |
| "Make sure the clib.Session raises an exception if GMT is too old" | ||
|
|
||
| # Mock GMT_Get_Default to return an old version | ||
| def mock_defaults(api, name, value): # pylint: disable=unused-argument | ||
| def mock_defaults(api, name, value): # pylint: disable=unused-argument | ||
| "Return an old version" | ||
| if name == b"API_VERSION": | ||
| value.value = b"5.4.3" | ||
| else: | ||
| value.value = b"bla" | ||
| value.value = b"5.4.3" if name == b"API_VERSION" else b"bla" | ||
|
Comment on lines
-837
to
+839
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function test_fails_for_wrong_version.mock_defaults refactored with the following changes:
Comment on lines
-837
to
+839
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| return 0 | ||
|
|
||
| lib = clib.Session() | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,7 +37,7 @@ def test_contour_fail_no_data(data): | |
| # 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): | ||
| if all(item is not None for item in variable): | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function test_contour_fail_no_data refactored with the following changes:
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| continue | ||
| with pytest.raises(GMTInvalidInput): | ||
| fig.contour( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -78,7 +78,10 @@ def test_legend_specfile(): | |
| Test specfile functionality. | ||
| """ | ||
|
|
||
| specfile_contents = """ | ||
| with GMTTempFile() as specfile: | ||
|
|
||
| with open(specfile.name, "w") as file: | ||
| specfile_contents = """ | ||
|
Comment on lines
-81
to
+84
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function test_legend_specfile refactored with the following changes:
Comment on lines
-81
to
+84
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| G -0.1i | ||
| H 24 Times-Roman My Map Legend | ||
| D 0.2i 1p | ||
|
|
@@ -105,9 +108,6 @@ def test_legend_specfile(): | |
| T so we may have to adjust the box height to get the right size box. | ||
| """ | ||
|
|
||
| with GMTTempFile() as specfile: | ||
|
|
||
| with open(specfile.name, "w") as file: | ||
| file.write(specfile_contents) | ||
|
|
||
| fig = Figure() | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,7 +19,7 @@ def test_pygmtscraper(): | |
| "Make sure the scraper finds the figures and removes them from the pool." | ||
|
|
||
| showed = SHOWED_FIGURES.copy() | ||
| for _ in range(len(SHOWED_FIGURES)): | ||
| for SHOWED_FIGURE in SHOWED_FIGURES: | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function test_pygmtscraper refactored with the following changes:
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| SHOWED_FIGURES.pop() | ||
| try: | ||
| fig = Figure() | ||
|
|
@@ -31,7 +31,7 @@ def test_pygmtscraper(): | |
| with TemporaryDirectory(dir=os.getcwd()) as tmpdir: | ||
| conf = {"src_dir": "meh"} | ||
| fname = os.path.join(tmpdir, "meh.png") | ||
| block_vars = {"image_path_iterator": (i for i in [fname])} | ||
| block_vars = {"image_path_iterator": iter([fname])} | ||
| assert not os.path.exists(fname) | ||
| scraper(None, block_vars, conf) | ||
| assert os.path.exists(fname) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function
show_versions._get_ghostscript_versionrefactored with the following changes:inline-immediately-returned-variable)