Skip to content

Commit 410e46a

Browse files
authored
Merge pull request #24 from Anselmoo/ranges
Ranges
2 parents eb4cbf7 + e57881c commit 410e46a

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

bashplot/bashplot.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,13 @@ def plot(data, args, label):
151151
if args["y_limits"]:
152152
fig.set_y_limits(min_=args["y_limits"][0], max_=args["y_limits"][1])
153153
else:
154-
fig.set_y_limits(min_=np.min(data[:, 1]), max_=np.max(data[:, 1]))
155-
154+
try:
155+
fig.set_y_limits(min_=np.min(data[:, 1:]), max_=np.max(data[:, 1:]))
156+
except ValueError:
157+
min_max = np.mean(data[:, 1:])
158+
fig.set_y_limits(
159+
min_=min_max - min_max * 0.1, max_=min_max + min_max * 0.1
160+
)
156161
if args["color"]:
157162
fig.color_mode = "rgb"
158163

test/sample_generator.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,8 @@ def generate(fname="test_data"):
4646
y = np.random.normal(mu, sigma, 50)
4747
data = np.array([x, y]).T
4848
np.savetxt(Path(f"./{fname}_random_gaussian.txt"), data)
49+
50+
np.savetxt(
51+
Path(f"./{fname}_equaldata.out"),
52+
np.array([[-1.0, 2.0], [0.0, 2.0], [1.0, 2.0]]),
53+
)

test/test_bashplot.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
test_txt = list(Path.cwd().glob("test*.txt"))
1616
test_dat = list(Path.cwd().glob("test*.dat"))
17+
test_out = list(Path.cwd().glob("test*.out"))
1718

1819
args_1 = {
1920
"infile": test_txt,
@@ -61,6 +62,21 @@
6162
"legend": True,
6263
"version": True,
6364
}
65+
args_4 = {
66+
"infile": test_out,
67+
"comments": None,
68+
"delimiter": None,
69+
"skip_header": 0,
70+
"skip_footer": 0,
71+
"usecols": (0, 1),
72+
"size": [30, 20],
73+
"x_limits": None,
74+
"y_limits": None,
75+
"scatter": False,
76+
"color": False,
77+
"legend": True,
78+
"version": False,
79+
}
6480

6581

6682
def test_fnames():
@@ -136,6 +152,11 @@ def test_customize_run_2():
136152
assert True
137153

138154

155+
def test_customize_run_3():
156+
bashplot.bashplot(fnames=test_out, args=args_4)
157+
assert True
158+
159+
139160
@mock.patch("bashplot.bashplot.command_line_runner")
140161
def test_command_line_mock(command_line_runner):
141162
bashplot.command_line_runner()

0 commit comments

Comments
 (0)