Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F122255990
main.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Jul 16, 22:35
Size
1 KB
Mime Type
text/x-python
Expires
Fri, Jul 18, 22:35 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
27457199
Attached To
R7571 SP4E-TB-TL-FR
main.py
View Options
################################################################
from
__future__
import
print_function
import
sys
from
compute_pi
import
ComputePi
from
compute_algebraic
import
ComputeAlgebraic
from
print_series
import
PrintSeries
from
plot_series
import
PlotSeries
################################################################
def
main
():
argc
=
len
(
sys
.
argv
)
if
argc
<
5
:
print
(
'Usage: python3 main.py series_type dumper_type maxiter freq
\n\n
'
'
\t
series_type: pi/algebraic
\n
'
'
\t
dumper_type: print/plot
\n
'
'
\t
maxiter: number of loop iteration to compute the series
\n
'
'
\t
freq: frequency at which dumps/plots are made
\n\n
'
)
sys
.
exit
(
-
1
)
series_type
=
sys
.
argv
[
1
]
dumper_type
=
sys
.
argv
[
2
]
maxiter
=
int
(
sys
.
argv
[
3
])
freq
=
int
(
sys
.
argv
[
4
])
outfile
=
""
if
argc
==
6
:
outfile
=
sys
.
argv
[
5
]
if
series_type
==
"pi"
:
serie_object
=
ComputePi
()
elif
series_type
==
"algebraic"
:
serie_object
=
ComputeAlgebraic
()
else
:
raise
RuntimeError
(
"unknown series type: "
+
series_type
)
if
dumper_type
==
"print"
:
dumper_object
=
PrintSeries
(
serie_object
,
maxiter
,
freq
)
elif
dumper_type
==
"plot"
:
dumper_object
=
PlotSeries
(
serie_object
,
maxiter
,
freq
)
else
:
print
(
"unknown dumper type: "
+
dumper_type
)
sys
.
exit
(
-
1
)
dumper_object
.
setPrecision
(
20
)
if
outfile
!=
""
:
_file
=
open
(
outfile
,
'w'
)
_file
.
write
(
str
(
dumper_object
))
else
:
print
(
dumper_object
)
main
()
Event Timeline
Log In to Comment