Skip to content

Commit 04cbfb3

Browse files
committed
tuplesize<0 works with single points
i.e. I can do this: gp.plot( np.array((3,40)), tuplesize = -2 ) This patch adds the feature and a test
1 parent 41cc120 commit 04cbfb3

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

demo.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/python
22

33
import numpy as np
4+
import numpysane as nps
45
import time
56
import sys
67

@@ -52,6 +53,18 @@ def check_expected_error(what, f):
5253
# first, some very basic stuff. Testing implicit domains, multiple curves in
5354
# arguments, packed broadcastable data, etc
5455
gp.plot(x**2, wait=1)
56+
gp.plot(( np.transpose(nps.cat(x,x**2)),
57+
dict(_with='linespoints pt 4 ps 2'),
58+
),
59+
( 5,60,
60+
dict(tuplesize=2,
61+
_with='linespoints pt 5 ps 2'),
62+
),
63+
( np.array((3,40)),
64+
dict(_with='linespoints pt 6 ps 2'),
65+
),
66+
tuplesize = -2,
67+
wait=1)
5568
gp.plot(-x, x**3, wait=1)
5669
gp.plot((x**2), wait=1)
5770
gp.plot((-x, x**3, {'with': 'lines'}), (x**2,), wait=1)

gnuplotlib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1885,7 +1885,7 @@ def reformat(curve):
18851885
if len(curve) != 1:
18861886
raise GnuplotlibError("tuplesize<0 means that only a single numpy array of data should be given: all data is in this array")
18871887
d['tuplesize'] = -d['tuplesize']
1888-
d['_data'] = list(nps.mv(curve[0], -1, 0))
1888+
d['_data'] = list(nps.mv(nps.atleast_dims(curve[0],-2), -1, 0))
18891889
else:
18901890
d['_data'] = list(curve)
18911891
return d

0 commit comments

Comments
 (0)