Skip to content

Commit 7a51128

Browse files
authored
Remove unnecessary np.atleast_1d calls from Figure.text and Session.virtualfile_in (#3498)
1 parent 7e1fa00 commit 7a51128

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

pygmt/clib/session.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1809,9 +1809,9 @@ def virtualfile_in( # noqa: PLR0912
18091809
warnings.warn(message=msg, category=RuntimeWarning, stacklevel=2)
18101810
_data = (data,) if not isinstance(data, pathlib.PurePath) else (str(data),)
18111811
elif kind == "vectors":
1812-
_data = [np.atleast_1d(x), np.atleast_1d(y)]
1812+
_data = [x, y]
18131813
if z is not None:
1814-
_data.append(np.atleast_1d(z))
1814+
_data.append(z)
18151815
if extra_arrays:
18161816
_data.extend(extra_arrays)
18171817
elif kind == "matrix": # turn 2-D arrays into list of vectors

pygmt/src/text.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,19 +223,19 @@ def text_( # noqa: PLR0912
223223
kwargs["F"] += flag
224224
# angle is numeric type and font/justify are str type.
225225
if name == "angle":
226-
extra_arrays.append(np.atleast_1d(arg))
226+
extra_arrays.append(arg)
227227
else:
228-
extra_arrays.append(np.atleast_1d(np.asarray(arg, dtype=str)))
228+
extra_arrays.append(np.asarray(arg, dtype=str))
229229

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

236236
# Append text to the last column. Text must be passed in as str type.
237-
text = np.atleast_1d(np.asarray(text, dtype=str))
238-
encoding = _check_encoding("".join(text))
237+
text = np.asarray(text, dtype=str)
238+
encoding = _check_encoding("".join(text.flatten()))
239239
if encoding != "ascii":
240240
text = np.vectorize(non_ascii_to_octal, excluded="encoding")(
241241
text, encoding=encoding

0 commit comments

Comments
 (0)