Skip to content

Commit

Permalink
Remove unnecessary np.atleast_1d calls from Figure.text and Session.v…
Browse files Browse the repository at this point in the history
…irtualfile_in (#3498)
  • Loading branch information
seisman authored Oct 10, 2024
1 parent 7e1fa00 commit 7a51128
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions pygmt/clib/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -1809,9 +1809,9 @@ def virtualfile_in( # noqa: PLR0912
warnings.warn(message=msg, category=RuntimeWarning, stacklevel=2)
_data = (data,) if not isinstance(data, pathlib.PurePath) else (str(data),)
elif kind == "vectors":
_data = [np.atleast_1d(x), np.atleast_1d(y)]
_data = [x, y]
if z is not None:
_data.append(np.atleast_1d(z))
_data.append(z)
if extra_arrays:
_data.extend(extra_arrays)
elif kind == "matrix": # turn 2-D arrays into list of vectors
Expand Down
10 changes: 5 additions & 5 deletions pygmt/src/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,19 +223,19 @@ def text_( # noqa: PLR0912
kwargs["F"] += flag
# angle is numeric type and font/justify are str type.
if name == "angle":
extra_arrays.append(np.atleast_1d(arg))
extra_arrays.append(arg)
else:
extra_arrays.append(np.atleast_1d(np.asarray(arg, dtype=str)))
extra_arrays.append(np.asarray(arg, dtype=str))

# If an array of transparency is given, GMT will read it from the last numerical
# column per data record.
if is_nonstr_iter(kwargs.get("t")):
extra_arrays.append(np.atleast_1d(kwargs["t"]))
extra_arrays.append(kwargs["t"])
kwargs["t"] = True

# Append text to the last column. Text must be passed in as str type.
text = np.atleast_1d(np.asarray(text, dtype=str))
encoding = _check_encoding("".join(text))
text = np.asarray(text, dtype=str)
encoding = _check_encoding("".join(text.flatten()))
if encoding != "ascii":
text = np.vectorize(non_ascii_to_octal, excluded="encoding")(
text, encoding=encoding
Expand Down

0 comments on commit 7a51128

Please sign in to comment.