Skip to content

Commit

Permalink
ENH: Refractor and clean examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
MilanSkocic committed Jan 16, 2024
1 parent 3abdc83 commit 94072f0
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
1 change: 1 addition & 0 deletions documentation/sphinx/source/getting_started/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ Example in Python
--------------------

.. literalinclude:: ../../../../example/example_in_py.py
:lines: 4-
:language: python

9 changes: 8 additions & 1 deletion example/example_in_c.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@
#include "codata.h"

int main(void){

printf("%s\n","########## VERSION ##########");
printf("version = %s\n", codata_get_version());

printf("%s\n","########## CONSTANTS ##########");
printf("c=%f\n", SPEED_OF_LIGHT_IN_VACUUM);
printf("U(c)=%f\n", U_SPEED_OF_LIGHT_IN_VACUUM);

printf("%s\n","########## UNCERTAINTY ##########");
printf("u(c)=%f\n", U_SPEED_OF_LIGHT_IN_VACUUM);

return 0;
}
5 changes: 5 additions & 0 deletions example/example_in_f.f90
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@ program example_in_f
use codata
implicit none

print '(A)', '########## VERSION ##########'
print *, "version = ", get_version()

print '(A)', '########## CONSTANTS ##########'
print *, "c=", speed_of_light_in_vacuum

print '(A)', '########## UNCERTAINTY ##########'
print *, "u(c)=", u_speed_of_light_in_vacuum

end program
11 changes: 10 additions & 1 deletion example/example_in_py.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
r"""Example in python."""
import sys
sys.path.append("../pywrapper")
import pycodata

print("########## VERSION ##########")
print(pycodata.__version__)
print(pycodata.SPEED_OF_LIGHT_IN_VACUUM)

print("########## CONSTANTS ##########")
print(pycodata.SPEED_OF_LIGHT_IN_VACUUM)

print("########## UNCERTAINTY ##########")
print(pycodata.U_SPEED_OF_LIGHT_IN_VACUUM)

0 comments on commit 94072f0

Please sign in to comment.