Web-Books
im Austria-Forum
Austria-Forum
Web-Books
Informatik
Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Band Second Edition
Seite - 168 -
  • Benutzer
  • Version
    • Vollversion
    • Textversion
  • Sprache
    • Deutsch
    • English - Englisch

Seite - 168 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Band Second Edition

Bild der Seite - 168 -

Bild der Seite - 168 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Band Second Edition

Text der Seite - 168 -

168 6 ComputingIntegralsandTestingCode r = sympy.symbols(’r’) I_exact = sympy.integrate(2*sympy.pi*r*r, (r, 0, 2)) print(’Exact integral: {:g}’.format(I_exact.evalf())) x0 = -2; x1 = 2; y0 = -2; y1 = 2 n = 1000 np.random.seed(6) I_expected = 16.7970837117376384 # Computed with this seed I_computed = MonteCarlo_double( lambda x, y: np.sqrt(x**2 + y**2), g, x0, x1, y0, y1, n) print(’MC approximation, {:d} samples: {:.16f}’\ .format(n**2, I_computed)) assert abs(I_expected - I_computed) < 1E-15 (See thefileMC_double.py.) RemarkAboutVersionControlofFiles Havingasuiteof test functionsforautomaticallychecking thatyoursoftware works is considered as a fundamental requirement for reliable computing. Equally important is a system that can keep track of different versionsof the files and the tests, known as a version control system. Today’s most popular version control system is Git,a which the authors strongly recommend the reader to use for programming and writing reports. The combination of Git and cloud storage such as GitHub is a very common way of organizing scientificorengineeringwork.We havea quick introb to Git andGitHub that getsyouupandrunningwithinminutes. The typicalworkflowwithGit goesas follows. 1. Before you start working with files, make sure you have the latest versionof thembyrunninggit pull. 2. Edit files, remove or create files (new files must be registered bygit add). 3. Whenanaturalpieceofwork isdone,commit yourchangesby thegit commitcommand. 4. Implementyourchangesalso in thecloudbydoinggit push. Anice featureofGit is thatpeoplecanedit thesamefileat thesametimeand veryoftenGit will beable toautomaticallymerge the changes(!).Therefore, version control is crucial when you work with others or when you do your work on different types of computers. Another key feature is that anyone can at any time view the history of a file, see who did what when, and roll back theentirefile collection toapreviouscommit.This feature is, of course, fundamentalfor reliablework. a https://en.wikipedia.org/wiki/Git_(software). b http://hplgit.github.io/teamods/bitgit/Langtangen_bitgit-bootstrap.html.
zurück zum  Buch Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Band Second Edition"
Programming for Computations – Python A Gentle Introduction to Numerical Simulations with Python 3.6, Band Second Edition
Titel
Programming for Computations – Python
Untertitel
A Gentle Introduction to Numerical Simulations with Python 3.6
Band
Second Edition
Autoren
Svein Linge
Hans Petter Langtangen
Verlag
Springer Open
Datum
2020
Sprache
englisch
Lizenz
CC BY 4.0
ISBN
978-3-319-32428-9
Abmessungen
17.8 x 25.4 cm
Seiten
356
Schlagwörter
Programmiersprache, Informatik, programming language, functional, imperative, object-oriented, reflective
Kategorie
Informatik
Web-Books
Bibliothek
Datenschutz
Impressum
Austria-Forum
Austria-Forum
Web-Books
Programming for Computations – Python