Skip to content

Commit 990acdd

Browse files
authoredMar 8, 2021
Merge pull request #29 from jacobwilliams/26-raw-strings
26 raw strings
2 parents 4c4a6e0 + a9b307e commit 990acdd

File tree

6 files changed

+242
-202
lines changed

6 files changed

+242
-202
lines changed
 

‎.github/workflows/CI.yml

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: CI
2+
on: [push]
3+
jobs:
4+
5+
Build:
6+
runs-on: ${{ matrix.os }}
7+
strategy:
8+
fail-fast: false
9+
matrix:
10+
os: [ubuntu-latest]
11+
gcc_v: [9] # Version of GFortran we want to use.
12+
env:
13+
FC: gfortran-${{ matrix.gcc_v }}
14+
GCC_V: ${{ matrix.gcc_v }}
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v1
19+
20+
- name: Set up Python 3.x
21+
uses: actions/setup-python@v1 # Use pip to install latest CMake, & FORD/Jin2For, etc.
22+
with:
23+
python-version: 3.x
24+
25+
- name: Install other tools
26+
if: contains( matrix.os, 'ubuntu')
27+
run: |
28+
sudo apt-get install graphviz
29+
sudo -H pip install numpy
30+
sudo -H pip install ford && ford --version
31+
sudo -H pip install matplotlib
32+
33+
- name: Install GFortran Linux
34+
if: contains( matrix.os, 'ubuntu')
35+
run: |
36+
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
37+
sudo apt-get update
38+
sudo apt-get install -y gcc-${GCC_V} gfortran-${GCC_V}
39+
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${GCC_V} 100 \
40+
--slave /usr/bin/gfortran gfortran /usr/bin/gfortran-${GCC_V} \
41+
--slave /usr/bingcov gcov /usr/bin/gcov-${GCC_V}
42+
43+
- name: Compile
44+
run: |
45+
mkdir bin
46+
gfortran -O2 ./src/pyplot_module.f90 ./src/tests/test.f90 -o ./bin/test
47+
48+
- name: Run test
49+
run: ./bin/test
50+
51+
- name: Build documentation
52+
run: ford ./pyplot-fortran.md
53+
54+
- name: Deploy Documentation
55+
if: github.ref == 'refs/heads/master'
56+
uses: JamesIves/github-pages-deploy-action@4.1.0
57+
with:
58+
branch: gh-pages # The branch the action should deploy to.
59+
folder: doc # The folder the action should deploy.

‎.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,6 @@ doc/
3030
*.exe
3131
*.out
3232
*.app
33+
34+
# misc
35+
.DS_Store

‎.travis.yml

-39
This file was deleted.

‎README.md

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Supported plot types
2222
* ```matplotlib.pyplot.contourf``` -- filled contour plot
2323
* ```matplotlib.pyplot.imshow``` -- image plot
2424
* ```matplotlib.pyplot.hist``` -- histogram plot
25+
* ```matplotlib.pyplot.errorbar``` -- errorbar plot
2526

2627
Example
2728
---------------

‎src/pyplot_module.f90

+154-149
Large diffs are not rendered by default.

‎src/tests/test.f90

+25-14
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,35 @@ program test
1414

1515
integer,parameter :: n = 100
1616

17-
real(wp), dimension(n) :: x !! x values
18-
real(wp), dimension(n) :: y !! y values
19-
real(wp), dimension(n) :: yerr !! error values for bar chart
20-
real(wp), dimension(n) :: sx !! sin(x) values
21-
real(wp), dimension(n) :: cx !! cos(x) values
22-
real(wp), dimension(n) :: zx !!
23-
real(wp), dimension(n) :: tx !! sin(x)*cos(x) values
24-
real(wp), dimension(n,n) :: z !! z matrix for contour plot
17+
real(wp), dimension(:),allocatable :: x !! x values
18+
real(wp), dimension(:),allocatable :: y !! y values
19+
real(wp), dimension(:),allocatable :: yerr !! error values for bar chart
20+
real(wp), dimension(:),allocatable :: sx !! sin(x) values
21+
real(wp), dimension(:),allocatable :: cx !! cos(x) values
22+
real(wp), dimension(:),allocatable :: zx !!
23+
real(wp), dimension(:),allocatable :: tx !! sin(x)*cos(x) values
24+
real(wp), dimension(:,:),allocatable :: z !! z matrix for contour plot
25+
real(wp), dimension(:,:),allocatable :: mat !! image values
2526
type(pyplot) :: plt !! pytplot handler
2627
integer :: i !! counter
2728
integer :: j !! counter
2829
real(wp) :: r2 !! temp variable
29-
real(wp), dimension(n,n) :: mat !! image values
3030
integer :: istat !! status code
3131

3232
real(wp),parameter :: pi = acos(-1.0_wp)
3333
real(wp),parameter :: deg2rad = pi/180.0_wp
3434

35+
! size arrays:
36+
allocate(x(n))
37+
allocate(y(n))
38+
allocate(yerr(n))
39+
allocate(sx(n))
40+
allocate(cx(n))
41+
allocate(zx(n))
42+
allocate(tx(n))
43+
allocate(z(n,n))
44+
allocate(mat(n,n))
45+
3546
!generate some data:
3647
x = [(real(i,wp), i=0,size(x)-1)]/5.0_wp
3748
sx = sin(x)
@@ -63,7 +74,7 @@ program test
6374
axes_labelsize = 20,&
6475
xtick_labelsize = 20,&
6576
ytick_labelsize = 20,&
66-
legend_fontsize = 20 )
77+
legend_fontsize = 20, raw_strings=.true. )
6778
call plt%add_bar(x=x,height=sx,width=tx,label='$\sin (x)$',&
6879
color='r',yerr=yerr,xlim=[0.0_wp, 20.0_wp],align='center',istat=istat)
6980
call plt%savefig('bartest.png', pyfile='bartest.py',istat=istat)
@@ -81,8 +92,8 @@ program test
8192
ylabel='y angle (rad)',figsize=[10,10],&
8293
title='Contour plot test', real_fmt='*',&
8394
axisbelow=.false.)
84-
call plt%add_contour(x, y, z, label='contour', linestyle='-', &
85-
linewidth=2, filled=.true., cmap='bone', colorbar=.true.,&
95+
call plt%add_contour(x, y, z, linestyle='-', &
96+
filled=.true., cmap='bone', colorbar=.true.,&
8697
istat=istat)
8798
call plt%savefig('contour.png',pyfile='contour.py',istat=istat)
8899

@@ -114,7 +125,7 @@ program test
114125
ytick_labelsize = 20,&
115126
legend_fontsize = 20 )
116127

117-
call plt%add_hist(x=x, label='x', normed=.true.,istat=istat)
128+
call plt%add_hist(x=x, label='x',istat=istat)
118129
call plt%savefig('histtest1.png', pyfile='histtest1.py',istat=istat)
119130

120131
call plt%initialize(grid=.true.,xlabel='x',&
@@ -138,7 +149,7 @@ program test
138149
title='Orbit',&
139150
axis_equal=.true.,&
140151
mplot3d=.true.,&
141-
figsize=[20,10])
152+
figsize=[20,10] )
142153

143154
x = [(real(i,wp), i=0,size(x)-1)]/5.0_wp
144155
sx = 7000.0_wp * cos(x * deg2rad)

0 commit comments

Comments
 (0)
Please sign in to comment.