@@ -17,6 +17,28 @@ You can modify the list of models by adding a new file, `models/{model_name}.jl`
17
17
Ideally, ` model_name ` would be self-explanatory, i.e. it would serve to illustrate exactly one feature and the name would indicate this.
18
18
However, if necessary, you can add further explanatory comments inside the model definition file.
19
19
20
+ The basic structure of this file should look like this, where ` model_name ` is replaced accordingly:
21
+
22
+ ``` julia
23
+ #=
24
+ You can add any explanatory comments here if necessary
25
+ =#
26
+
27
+ # Imports if necessary
28
+ using MyOtherPackage: some_function
29
+
30
+ # Define data if necessary
31
+ data = ...
32
+
33
+ @model function model_name (data, ... )
34
+ # Define your model here
35
+ ...
36
+ end
37
+
38
+ # Instantiate the model
39
+ model = model_name (data, ... )
40
+ ```
41
+
20
42
** Dependencies**
21
43
22
44
Inside this file, you do not need to call ` using Turing ` or any of the AD backends.
@@ -29,27 +51,29 @@ However, you will have to make sure to import any other packages that your model
29
51
30
52
Each file in ` models/ ` is evaluated within its own module, so you can declare data variables, etc. without worrying about name clashes.
31
53
32
- Once you have defined your model as ` @model function model_name(...) ` , you will need to create a model object.
33
- As the final line in the file, the creation of the Turing model object using ` model = model_name(...) ` .
54
+ Models can be defined as usual with ` @model function model_name(...) ` .
55
+
56
+ The last line in the file should be the creation of the Turing model object using ` model = model_name(...) ` .
34
57
(It is mandatory for the model object to be called ` model ` .)
35
58
36
59
** Inclusion in ` main.jl ` **
37
60
38
- Finally, inside ` main.jl ` , call ` @include_model category_heading model_name ` .
39
- Both ` category_heading ` and ` model_name ` should be strings.
40
-
41
- ` category_heading ` is a string that is used to determine which table the model appears under on the website.
61
+ Finally, inside ` main.jl ` , add a call to ` @include_model category_heading model_name ` .
62
+ ** Both ` category_heading ` and ` model_name ` should be strings.**
42
63
43
- Note that for CI to run properly, ` model_name ` ** must** be consistent between the following:
64
+ ` category_heading ` is used to determine which table the model appears under on the website.
65
+ This should be self-explanatory if you look at the [ current website] ( https://turinglang.org/ADTests ) .
44
66
45
- - The name of the model itself i.e. ` @model function model_name(...) `
46
- - The filename i.e. ` models/model_name.jl `
47
- - The name of the model in ` main.jl ` i.e. ` @include_model "Category Heading" "model_name" `
67
+ > [ !IMPORTANT]
68
+ > Note that for CI to run properly, ` model_name ` ** must** be consistent between the following:
69
+ >
70
+ > - The name of the model itself i.e. ` @model function model_name(...) `
71
+ > - The filename i.e. ` models/model_name.jl `
72
+ > - The name of the model in ` main.jl ` i.e. ` @include_model "Category Heading" "model_name" `
48
73
49
- > [ !NOTE]
50
- > This setup does admittedly feel a bit complicated.
51
- > Unfortunately I could not find a simpler way to get all the components (Julia, Python, web app) to work together in an automated fashion.
52
- > Hopefully it is a small price to pay for the ability to just add a new model and have it be automatically included on the website.
74
+ (This setup does admittedly feel a bit complicated.
75
+ Unfortunately I could not find a simpler way to get all the components (Julia, Python, web app) to work together in an automated fashion.
76
+ Hopefully it is a small price to pay for the ability to just add a new model and have it be automatically included on the website.)
53
77
54
78
## I want to edit the website!
55
79
0 commit comments