Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e0f874d

Browse files
committed
add test directory variable
1 parent f559d43 commit e0f874d

File tree

2 files changed

+35
-25
lines changed

2 files changed

+35
-25
lines changed

‎test/color_test.f90‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,26 @@ program color_test
77
use pyplot_module, only : pyplot, wp => pyplot_wp
88

99
implicit none
10-
10+
1111
type(pyplot) :: plt !! pytplot handler
1212
integer :: istat
13-
real(wp), parameter :: F(3) = [0.4510d0, 0.3098d0, 0.5882d0] ! Fortran-lang color
13+
real(wp), parameter :: F(3) = [0.4510d0, 0.3098d0, 0.5882d0] ! Fortran-lang color
1414
real(wp), parameter :: Y(3) = [0.9608d0, 0.8157d0, 0.0118d0] ! Yellow
15-
15+
1616
real(wp),dimension(3),parameter :: Ax = [1,2,3]
1717
real(wp),dimension(3),parameter :: Ay = [1,2,3]
1818
real(wp),dimension(3),parameter :: Bx = [1,2,3]
1919
real(wp),dimension(3),parameter :: By = [4,5,6]
2020

21+
character(len=*), parameter :: testdir = "test/"
22+
2123
call plt%initialize(figsize=[20,10],title='color test')
2224

2325
call plt%add_plot(Ax,Ay,label='',linestyle='o',markersize=5,color=F)
2426
call plt%add_plot(Bx,By,label='',linestyle='o',markersize=5,color=Y)
2527

26-
call plt%savefig('color_test.png', pyfile='color_test.py',istat=istat)
28+
call plt%savefig(testdir//'color_test.png',&
29+
pyfile=testdir//'color_test.py',istat=istat)
2730

2831
end program color_test
2932
!*****************************************************************************************

‎test/test.f90‎

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ program test
1515

1616
real(wp), dimension(:),allocatable :: x !! x values
1717
real(wp), dimension(:),allocatable :: y !! y values
18-
real(wp), dimension(:),allocatable :: xerr !! error values
18+
real(wp), dimension(:),allocatable :: xerr !! error values
1919
real(wp), dimension(:),allocatable :: yerr !! error values for bar chart
2020
real(wp), dimension(:),allocatable :: sx !! sin(x) values
2121
real(wp), dimension(:),allocatable :: cx !! cos(x) values
@@ -32,16 +32,18 @@ program test
3232
real(wp),parameter :: pi = acos(-1.0_wp)
3333
real(wp),parameter :: deg2rad = pi/180.0_wp
3434

35+
character(len=*), parameter :: testdir = "test/"
36+
3537
! size arrays:
36-
allocate(x(n))
37-
allocate(y(n))
38+
allocate(x(n))
39+
allocate(y(n))
3840
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))
41+
allocate(sx(n))
42+
allocate(cx(n))
43+
allocate(zx(n))
44+
allocate(tx(n))
45+
allocate(z(n,n))
46+
allocate(mat(n,n))
4547

4648
!generate some data:
4749
x = [(real(i,wp), i=0,size(x)-1)]/5.0_wp
@@ -64,7 +66,8 @@ program test
6466
call plt%add_plot(x,sx,label='$\sin (x)$',linestyle='b-o',markersize=5,linewidth=2,istat=istat)
6567
call plt%add_plot(x,cx,label='$\cos (x)$',linestyle='r-o',markersize=5,linewidth=2,istat=istat)
6668
call plt%add_plot(x,tx,label='$\sin (x) \cos (x)$',linestyle='g-o',markersize=2,linewidth=1,istat=istat)
67-
call plt%savefig('plottest.png', pyfile='plottest.py',istat=istat)
69+
call plt%savefig(testdir//'plottest.png', pyfile=testdir//'plottest.py',&
70+
istat=istat)
6871

6972
!bar chart:
7073
tx = 0.1_wp !for bar width
@@ -77,7 +80,8 @@ program test
7780
legend_fontsize = 20, raw_strings=.true. )
7881
call plt%add_bar(x=x,height=sx,width=tx,label='$\sin (x)$',&
7982
color='r',yerr=yerr,xlim=[0.0_wp, 20.0_wp],align='center',istat=istat)
80-
call plt%savefig('bartest.png', pyfile='bartest.py',istat=istat)
83+
call plt%savefig(testdir//'bartest.png', pyfile=testdir//'bartest.py',&
84+
istat=istat)
8185

8286
!contour plot:
8387
x = [(real(i,wp), i=0,n-1)]/100.0_wp
@@ -95,14 +99,15 @@ program test
9599
call plt%add_contour(x, y, z, linestyle='-', &
96100
filled=.true., cmap='bone', colorbar=.true.,&
97101
istat=istat)
98-
call plt%savefig('contour.png',pyfile='contour.py',istat=istat)
102+
call plt%savefig(testdir//'contour.png',pyfile=testdir//'contour.py',istat=istat)
99103

100104
!image plot:
101105
call plt%initialize(grid=.true.,xlabel='x',ylabel='y',figsize=[20,20],&
102106
title='imshow test',&
103107
real_fmt='(F9.3)')
104108
call plt%add_imshow(mat,xlim=[0.0_wp, 100.0_wp],ylim=[0.0_wp, 100.0_wp],istat=istat)
105-
call plt%savefig('imshow.png', pyfile='imshow.py',istat=istat)
109+
call plt%savefig(testdir//'imshow.png', pyfile=testdir//'imshow.py',&
110+
istat=istat)
106111

107112
!wireframe plot:
108113
call plt%initialize(grid=.true.,xlabel='x angle (rad)',&
@@ -112,7 +117,8 @@ program test
112117
call plt%plot_wireframe(x, y, z, label='', linestyle='-', &
113118
cmap='bone', colorbar=.true.,&
114119
istat=istat)
115-
call plt%savefig('wireframe.png', pyfile='wireframe.py',istat=istat)
120+
call plt%savefig(testdir//'wireframe.png', pyfile=testdir//'wireframe.py',&
121+
istat=istat)
116122

117123
!histogram chart:
118124
x = [0.194,0.501,-1.241,1.425,-2.217,-0.342,-0.979,0.909,0.994,0.101, &
@@ -136,7 +142,8 @@ program test
136142
legend_fontsize = 20 )
137143

138144
call plt%add_hist(x=x, label='x',istat=istat)
139-
call plt%savefig('histtest1.png', pyfile='histtest1.py',istat=istat)
145+
call plt%savefig(testdir//'histtest1.png', pyfile=testdir//'histtest1.py',&
146+
istat=istat)
140147

141148
call plt%initialize(grid=.true.,xlabel='x',&
142149
title='cumulative hist test',&
@@ -148,8 +155,8 @@ program test
148155
legend_fontsize = 20 )
149156

150157
call plt%add_hist(x=x, label='x', bins=8, cumulative=.true.,istat=istat)
151-
call plt%savefig('histtest2.png', &
152-
pyfile='histtest2.py', &
158+
call plt%savefig(testdir//'histtest2.png', &
159+
pyfile=testdir//'histtest2.py', &
153160
dpi='200', &
154161
transparent=.true.,istat=istat)
155162

@@ -171,8 +178,8 @@ program test
171178
call plt%add_sphere(6378.0_wp,0.0_wp,0.0_wp,0.0_wp,&
172179
color='Blue',n_facets=500,&
173180
antialiased=.true.,istat=istat)
174-
call plt%savefig('orbit.png', &
175-
pyfile='orbit.py', &
181+
call plt%savefig(testdir//'orbit.png', &
182+
pyfile=testdir//'orbit.py', &
176183
dpi='200', &
177184
transparent=.true.,istat=istat)
178185

@@ -189,8 +196,8 @@ program test
189196

190197
call plt%add_errorbar(x, y, label='y', linestyle='.', &
191198
xerr=xerr, yerr=yerr, istat=istat)
192-
call plt%savefig('errorbar.png', &
193-
pyfile='errorbar.py', &
199+
call plt%savefig(testdir//'errorbar.png', &
200+
pyfile=testdir//'errorbar.py', &
194201
dpi='200', &
195202
transparent=.true.,istat=istat, python='python')
196203

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /