Skip to content

Commit 7e46181

Browse files
committed
Remove extra_arrays
1 parent 59ccf4f commit 7e46181

File tree

4 files changed

+30
-41
lines changed

4 files changed

+30
-41
lines changed

pygmt/clib/session.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1772,7 +1772,6 @@ def virtualfile_in(
17721772
x=None,
17731773
y=None,
17741774
z=None,
1775-
extra_arrays=None,
17761775
required_z=False,
17771776
required_data=True,
17781777
):
@@ -1794,9 +1793,6 @@ def virtualfile_in(
17941793
data input.
17951794
x/y/z : 1-D arrays or None
17961795
x, y, and z columns as numpy arrays.
1797-
extra_arrays : list of 1-D arrays
1798-
Optional. A list of numpy arrays in addition to x, y, and z.
1799-
All of these arrays must be of the same size as the x/y/z arrays.
18001796
required_z : bool
18011797
State whether the 'z' column is required.
18021798
required_data : bool
@@ -1879,8 +1875,6 @@ def virtualfile_in(
18791875
_data = [x, y]
18801876
if z is not None:
18811877
_data.append(z)
1882-
if extra_arrays:
1883-
_data.extend(extra_arrays)
18841878
case "vectors":
18851879
if hasattr(data, "items") and not hasattr(data, "to_frame"):
18861880
# pandas.DataFrame or xarray.Dataset types.

pygmt/src/plot.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -232,33 +232,35 @@ def plot(
232232
kwargs = self._preprocess(**kwargs)
233233

234234
kind = data_kind(data)
235-
extra_arrays = []
236235
if kind == "empty": # Add more columns for vectors input
236+
data = {"x": x, "y": y}
237+
x, y = None, None
238+
237239
# Parameters for vector styles
238240
if (
239241
isinstance(kwargs.get("S"), str)
240242
and len(kwargs["S"]) >= 1
241243
and kwargs["S"][0] in "vV"
242244
and is_nonstr_iter(direction)
243245
):
244-
extra_arrays.extend(direction)
246+
data.update({"x2": direction[0], "y2": direction[1]})
245247
# Fill
246248
if is_nonstr_iter(kwargs.get("G")):
247-
extra_arrays.append(kwargs.get("G"))
249+
data["fill"] = kwargs["G"]
248250
del kwargs["G"]
249251
# Size
250252
if is_nonstr_iter(size):
251-
extra_arrays.append(size)
253+
data["size"] = size
252254
# Intensity and transparency
253-
for flag in ["I", "t"]:
255+
for flag, name in ["I", "intensity"], ["t", "transparency"]:
254256
if is_nonstr_iter(kwargs.get(flag)):
255-
extra_arrays.append(kwargs.get(flag))
257+
data[name] = kwargs[flag]
256258
kwargs[flag] = ""
257259
# Symbol must be at the last column
258260
if is_nonstr_iter(symbol):
259261
if "S" not in kwargs:
260262
kwargs["S"] = True
261-
extra_arrays.append(symbol)
263+
data["symbol"] = symbol
262264
else:
263265
for name, value in [
264266
("direction", direction),
@@ -277,7 +279,5 @@ def plot(
277279
kwargs["S"] = "s0.2c"
278280

279281
with Session() as lib:
280-
with lib.virtualfile_in(
281-
check_kind="vector", data=data, x=x, y=y, extra_arrays=extra_arrays
282-
) as vintbl:
282+
with lib.virtualfile_in(check_kind="vector", data=data) as vintbl:
283283
lib.call_module(module="plot", args=build_arg_list(kwargs, infile=vintbl))

pygmt/src/plot3d.py

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -210,34 +210,35 @@ def plot3d(
210210
kwargs = self._preprocess(**kwargs)
211211

212212
kind = data_kind(data)
213-
extra_arrays = []
214-
215213
if kind == "empty": # Add more columns for vectors input
214+
data = {"x": x, "y": y, "z": z}
215+
x, y, z = None, None, None
216+
216217
# Parameters for vector styles
217218
if (
218219
isinstance(kwargs.get("S"), str)
219220
and len(kwargs["S"]) >= 1
220221
and kwargs["S"][0] in "vV"
221222
and is_nonstr_iter(direction)
222223
):
223-
extra_arrays.extend(direction)
224+
data.update({"x2": direction[0], "y2": direction[1]})
224225
# Fill
225226
if is_nonstr_iter(kwargs.get("G")):
226-
extra_arrays.append(kwargs.get("G"))
227+
data["fill"] = kwargs["G"]
227228
del kwargs["G"]
228229
# Size
229230
if is_nonstr_iter(size):
230-
extra_arrays.append(size)
231+
data["size"] = size
231232
# Intensity and transparency
232-
for flag in ["I", "t"]:
233+
for flag, name in [("I", "intensity"), ("t", "transparency")]:
233234
if is_nonstr_iter(kwargs.get(flag)):
234-
extra_arrays.append(kwargs.get(flag))
235+
data[name] = kwargs[flag]
235236
kwargs[flag] = ""
236237
# Symbol must be at the last column
237238
if is_nonstr_iter(symbol):
238239
if "S" not in kwargs:
239240
kwargs["S"] = True
240-
extra_arrays.append(symbol)
241+
data["symbol"] = symbol
241242
else:
242243
for name, value in [
243244
("direction", direction),
@@ -257,12 +258,6 @@ def plot3d(
257258

258259
with Session() as lib:
259260
with lib.virtualfile_in(
260-
check_kind="vector",
261-
data=data,
262-
x=x,
263-
y=y,
264-
z=z,
265-
extra_arrays=extra_arrays,
266-
required_z=True,
261+
check_kind="vector", data=data, required_z=True
267262
) as vintbl:
268263
lib.call_module(module="plot3d", args=build_arg_list(kwargs, infile=vintbl))

pygmt/src/text.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
w="wrap",
4343
)
4444
@kwargs_to_strings(R="sequence", c="sequence_comma", p="sequence")
45-
def text_( # noqa: PLR0912
45+
def text_( # noqa: PLR0912, PLR0915
4646
self,
4747
textfiles=None,
4848
x=None,
@@ -222,22 +222,25 @@ def text_( # noqa: PLR0912
222222
elif isinstance(arg, int | float | str):
223223
kwargs["F"] += f"{flag}{arg}"
224224

225-
extra_arrays = []
226225
confdict = {}
226+
data = None
227227
if kind == "empty":
228+
data = {"x": x, "y": y}
229+
x, y = None, None
230+
228231
for arg, flag, name in array_args:
229232
if is_nonstr_iter(arg):
230233
kwargs["F"] += flag
231234
# angle is numeric type and font/justify are str type.
232235
if name == "angle":
233-
extra_arrays.append(arg)
236+
data["angle"] = arg
234237
else:
235-
extra_arrays.append(np.asarray(arg, dtype=np.str_))
238+
data[name] = np.asarray(arg, dtype=np.str_)
236239

237240
# If an array of transparency is given, GMT will read it from the last numerical
238241
# column per data record.
239242
if is_nonstr_iter(kwargs.get("t")):
240-
extra_arrays.append(kwargs["t"])
243+
data["transparency"] = kwargs["t"]
241244
kwargs["t"] = True
242245

243246
# Append text to the last column. Text must be passed in as str type.
@@ -247,7 +250,7 @@ def text_( # noqa: PLR0912
247250
text, encoding=encoding
248251
)
249252
confdict["PS_CHAR_ENCODING"] = encoding
250-
extra_arrays.append(text)
253+
data["text"] = text
251254
else:
252255
if isinstance(position, str):
253256
kwargs["F"] += f"+c{position}+t{text}"
@@ -260,10 +263,7 @@ def text_( # noqa: PLR0912
260263
with Session() as lib:
261264
with lib.virtualfile_in(
262265
check_kind="vector",
263-
data=textfiles,
264-
x=x,
265-
y=y,
266-
extra_arrays=extra_arrays,
266+
data=textfiles or data,
267267
required_data=required_data,
268268
) as vintbl:
269269
lib.call_module(

0 commit comments

Comments
 (0)