Skip to content

Commit 015d9a1

Browse files
authored
Update minor enhancement (#102)
* Bump versions * [Minor]: Update bashplot * Updae pyproject * Update poetry * Float 2 Str * Update bashplot * Extend by 3.10
1 parent 68db1b7 commit 015d9a1

File tree

8 files changed

+144
-149
lines changed

8 files changed

+144
-149
lines changed

.github/workflows/pypi_publish.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@ on:
77

88
jobs:
99
build:
10-
1110
runs-on: ubuntu-latest
1211
strategy:
1312
matrix:
14-
python-version: [3.6, 3.7, 3.8, 3.9]
13+
python-version: [3.6, 3.7, 3.8, 3.9, 3.10]
1514

1615
steps:
1716
- uses: actions/checkout@v3

.github/workflows/python-package.yml

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,43 +5,42 @@ name: Python Package
55

66
on:
77
push:
8-
branches: [ master ]
8+
branches: [master]
99
pull_request:
10-
branches: [ master ]
10+
branches: [master]
1111

1212
jobs:
1313
build:
14-
1514
runs-on: ubuntu-latest
1615
strategy:
1716
matrix:
18-
python-version: [3.6, 3.7, 3.8, 3.9]
17+
python-version: [3.6, 3.7, 3.8, 3.9, "3.10"]
1918

2019
steps:
21-
- uses: actions/checkout@v3
22-
- name: Set up Python ${{ matrix.python-version }}
23-
uses: actions/setup-python@v3
24-
with:
25-
python-version: ${{ matrix.python-version }}
26-
- name: Install dependencies
27-
run: |
28-
python -m pip install --upgrade pip
29-
pip install poetry
30-
poetry install
31-
- name: Lint with flake8, black, isort, pydocstyle
32-
run: |
33-
poetry run flake8 bashplot/ --count --statistic
34-
poetry run black . --check -v
35-
poetry run isort . --check -v
36-
poetry run flake8 . --count --exit-zero --max-complexity=10 --statistics
37-
poetry run pydocstyle --convention=numpy -e bashplot/bashplot.py
38-
- name: Test with pytest and coverage
39-
run: |
40-
poetry run coverage run -m pytest -vv
41-
poetry run coverage report -m
42-
poetry run coverage xml
43-
- name: Codecov
44-
uses: codecov/[email protected]
45-
with:
46-
token: ${{ secrets.CODECOV_TOKEN }}
47-
env_vars: OS,PYTHON
20+
- uses: actions/checkout@v3
21+
- name: Set up Python ${{ matrix.python-version }}
22+
uses: actions/setup-python@v3
23+
with:
24+
python-version: ${{ matrix.python-version }}
25+
- name: Install dependencies
26+
run: |
27+
python -m pip install --upgrade pip
28+
pip install poetry
29+
poetry install
30+
- name: Lint with flake8, black, isort, pydocstyle
31+
run: |
32+
poetry run flake8 bashplot/ --count --statistic
33+
poetry run black . --check -v
34+
poetry run isort . --check -v
35+
poetry run flake8 . --count --exit-zero --max-complexity=10 --statistics
36+
poetry run pydocstyle --convention=numpy -e bashplot/bashplot.py
37+
- name: Test with pytest and coverage
38+
run: |
39+
poetry run coverage run -m pytest -vv
40+
poetry run coverage report -m
41+
poetry run coverage xml
42+
- name: Codecov
43+
uses: codecov/[email protected]
44+
with:
45+
token: ${{ secrets.CODECOV_TOKEN }}
46+
env_vars: OS,PYTHON

azure-pipelines.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ strategy:
1818
python.version: "3.8"
1919
Python39:
2020
python.version: "3.9"
21+
Python310:
22+
python.version: "3.10"
2123

2224
steps:
2325
- task: UsePythonVersion@0

bashplot/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
"""Bashplot: Instant data plotting from the terminal into the terminal."""
2-
__version__ = "1.1.1"
2+
__version__ = "1.1.2"

bashplot/bashplot.py

Lines changed: 40 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def load_data(fname: str, args: dict) -> np.ndarray:
6464
)
6565

6666

67-
def plot_plot(fig: Any, x: np.ndarray, Y: np.ndarray, label: str) -> Any:
67+
def plot_plot(fig: Any, x: np.ndarray, y: np.ndarray, label: str) -> Any:
6868
"""Make the plot-figures.
6969
7070
plot_plot() is generating a single- or multi-plot by recursively calling plot().
@@ -75,8 +75,8 @@ def plot_plot(fig: Any, x: np.ndarray, Y: np.ndarray, label: str) -> Any:
7575
Figure class for the terminal plot
7676
x : float-array
7777
1D-Numpy-array with the float column x-values.
78-
Y : float-array
79-
1D- or 2D-Numpy-array with the float column Y-values.
78+
y : float-array
79+
1D- or 2D-Numpy-array with the float column y-values.
8080
label : str
8181
The label of the plot(s) is the current filename.
8282
@@ -85,16 +85,16 @@ def plot_plot(fig: Any, x: np.ndarray, Y: np.ndarray, label: str) -> Any:
8585
fig : class
8686
Updated figure class for the terminal plot
8787
plot_plot() : function
88-
Returns the function itself for a smaller (n-1) float-array (Y) until it is an
88+
Returns the function itself for a smaller (n-1) float-array (y) until it is an
8989
1D-array.
9090
"""
91-
fig.plot(x, Y[:, 0], label=label)
92-
if Y.shape[1] == 1:
91+
fig.plot(x, y[:, 0], label=label)
92+
if y.shape[1] == 1:
9393
return fig
94-
return plot_plot(fig, x, Y[:, 1:], label=label)
94+
return plot_plot(fig, x, y[:, 1:], label=label)
9595

9696

97-
def plot_scatter(fig, x: np.ndarray, Y: np.ndarray, label: str):
97+
def plot_scatter(fig, x: np.ndarray, y: np.ndarray, label: str):
9898
"""Make the scatter-figures.
9999
100100
plot_scatter() is generating a single- or multi-plot by recursive calling
@@ -106,8 +106,8 @@ def plot_scatter(fig, x: np.ndarray, Y: np.ndarray, label: str):
106106
Figure class for the terminal plot
107107
x : np.ndarray
108108
1D-Numpy-array with the float column x-values.
109-
Y : np.ndarray
110-
1D- or 2D-Numpy-array with the float column Y-values.
109+
y : np.ndarray
110+
1D- or 2D-Numpy-array with the float column y-values.
111111
label : str
112112
The label of the scatter-plot(s) is the current filename.
113113
@@ -116,13 +116,34 @@ def plot_scatter(fig, x: np.ndarray, Y: np.ndarray, label: str):
116116
fig : class
117117
Updated figure class for the terminal plot
118118
plot_scatter() : function
119-
Returns the function itself for a smaller (n-1) float-array (Y) until it is an
119+
Returns the function itself for a smaller (n-1) float-array (y) until it is an
120120
1D-array.
121121
"""
122-
fig.scatter(x, Y[:, 0], label=label)
123-
if Y.shape[1] == 1:
122+
fig.scatter(x, y[:, 0], label=label)
123+
if y.shape[1] == 1:
124124
return fig
125-
return plot_plot(fig, x, Y[:, 1:], label=label)
125+
return plot_scatter(fig, x, y[:, 1:], label=label)
126+
127+
128+
def fig_size(width: float, height: float) -> Any:
129+
"""Set the figure size.
130+
131+
Parameters
132+
----------
133+
width : float
134+
Width of the terminal plot.
135+
height : float
136+
Height of the terminal plot.
137+
138+
Returns
139+
-------
140+
fig : class
141+
Figure class for the terminal plot
142+
"""
143+
fig = plt.Figure()
144+
fig.width = width
145+
fig.height = height
146+
return fig
126147

127148

128149
def plot(data: np.ndarray, args: dict, label: str) -> None:
@@ -140,9 +161,7 @@ def plot(data: np.ndarray, args: dict, label: str) -> None:
140161
label : str
141162
The label of the scatter-plot(s) is the current filename.
142163
"""
143-
fig = plt.Figure()
144-
fig.width = args["size"][0]
145-
fig.height = args["size"][1]
164+
fig = fig_size(width=args["size"][0], height=args["size"][1])
146165
try:
147166

148167
if args["x_limits"]:
@@ -167,14 +186,12 @@ def plot(data: np.ndarray, args: dict, label: str) -> None:
167186
y = data[:, 1:]
168187

169188
if args["scatter"]:
170-
fig = plot_scatter(fig, x=x, Y=y, label=label)
189+
fig = plot_scatter(fig, x=x, y=y, label=label)
171190
else:
172-
fig = plot_plot(fig, x=x, Y=y, label=label)
191+
fig = plot_plot(fig, x=x, y=y, label=label)
192+
193+
log(fig.show(legend=args["legend"]))
173194

174-
if args["legend"]:
175-
log(fig.show(legend=True))
176-
else:
177-
log(fig.show(legend=False))
178195
except IndexError:
179196
log(f"corrupted data in {label}", mode=1)
180197
sys.exit(1)
@@ -351,7 +368,3 @@ def command_line_runner() -> None:
351368

352369
fnames = args["infile"]
353370
bashplot(fnames, args)
354-
355-
356-
if __name__ == "__main__":
357-
command_line_runner()

0 commit comments

Comments
 (0)