Skip to content

Commit 535b075

Browse files
author
Shravan Goswami
committed
added docs with new file structure
1 parent f47a336 commit 535b075

File tree

97 files changed

+62506
-3
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+62506
-3
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,6 @@ Testing/
1616
/Manifest.toml
1717
/test/Manifest.toml
1818
.vscode
19+
/_freeze
20+
/.quarto/
21+
/_site

assets/favicon.ico

14.7 KB
Binary file not shown.

assets/images/turing-logo-wide.svg

Lines changed: 42 additions & 0 deletions
Loading

assets/images/turing-logo.svg

Lines changed: 28 additions & 0 deletions
Loading

docs/_metadata.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
format:
2+
html:
3+
toc-title: "Table of Contents"
4+
code-fold: false
5+
code-overflow: scroll
6+
execute:
7+
echo: true
8+
output: true
9+
error: true
10+
include-in-header:
11+
- text: |
12+
<style>
13+
a {
14+
text-decoration: none;
15+
}
16+
a:hover {
17+
text-decoration: underline;
18+
}
19+
</style>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
title: Contributing
3+
---
4+
5+
Turing is an open source project. If you feel that you have some relevant skills and are interested in contributing, then please do get in touch. You can contribute by opening issues on GitHub or implementing things yourself and making a pull request. We would also appreciate example models written using Turing.
6+
7+
Turing has a [style guide]({{< meta site-url >}}/dev/docs/contributing/style-guide). It is not strictly necessary to review it before making a pull request, but you may be asked to change portions of your code to conform with the style guide before it is merged.
8+
9+
## How to Contribute
10+
11+
### Getting Started
12+
13+
- [Fork this repository](https://github.com/TuringLang/Turing.jl#fork-destination-box).
14+
15+
- Clone your fork on your local machine: `git clone https://github.com/your_username/Turing.jl`.
16+
17+
- Add a remote corresponding to this repository:
18+
19+
`git remote add upstream https://github.com/TuringLang/Turing.jl`.
20+
21+
### What Can I Do?
22+
23+
Look at the [issues](https://github.com/TuringLang/Turing.jl/issues) page to find an outstanding issue. For instance, you could implement new features, fix bugs or write example models.
24+
25+
### Git Workflow
26+
27+
For more information on how the Git workflow typically functions, please see the [GitHub's introduction](https://guides.github.com/introduction/flow/) or [Julia's contribution guide](https://github.com/JuliaLang/julia/blob/master/CONTRIBUTING.md).
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
---
2+
title: Style Guide
3+
engine: julia
4+
---
5+
6+
Most Turing code follows the [Invenia](https://invenia.ca/labs/)'s style guide. We would like to thank them for allowing us to access and use it. Please don't let not having read it stop you from contributing to Turing! No one will be annoyed if you open a PR with style that doesn't follow these conventions; we will just help you correct it before it gets merged.
7+
8+
These conventions were originally written at Invenia, taking inspiration from a variety of sources including Python's [PEP8](http://legacy.python.org/dev/peps/pep-0008), Julia's [Notes for Contributors](https://github.com/JuliaLang/julia/blob/master/CONTRIBUTING.md), and Julia's [Style Guide](https://docs.julialang.org/en/v1/manual/style-guide/).
9+
10+
What follows is a mixture of a verbatim copy of Invenia's original guide and some of our own modifications.
11+
12+
## A Word on Consistency
13+
14+
When adhering to this style it's important to realize that these are guidelines and not rules. This is [stated best in the PEP8](http://legacy.python.org/dev/peps/pep-0008/#a-foolish-consistency-is-the-hobgoblin-of-little-minds):
15+
16+
> A style guide is about consistency. Consistency with this style guide is important. Consistency within a project is more important. Consistency within one module or function is most important.
17+
18+
> But most importantly: know when to be inconsistent – sometimes the style guide just doesn't apply. When in doubt, use your best judgment. Look at other examples and decide what looks best. And don't hesitate to ask!
19+
20+
## Synopsis
21+
22+
Attempt to follow the [Julia Contribution Guidelines](https://github.com/JuliaLang/julia/blob/master/CONTRIBUTING.md#general-formatting-guidelines-for-julia-code-contributions), the [Julia Style Guide](https://docs.julialang.org/en/v1/manual/style-guide/), and this guide. When convention guidelines conflict, this guide takes precedence (known conflicts will be noted in this guide).
23+
24+
- Use 4 spaces per indentation level, no tabs.
25+
- Try to adhere to a 92 character line length limit.
26+
- Use upper camel case convention for [modules](https://docs.julialang.org/en/v1/manual/modules/) and [types](https://docs.julialang.org/en/v1/manual/types/).
27+
- Use lower case with underscores for method names (note: Julia code likes to use lower case without underscores).
28+
- Comments are good, try to explain the intentions of the code.
29+
- Use whitespace to make the code more readable.
30+
- No whitespace at the end of a line (trailing whitespace).
31+
- Avoid padding brackets with spaces. ex. `Int64(value)` preferred over `Int64( value )`.
32+
33+
## Editor Configuration
34+
35+
### Sublime Text Settings
36+
37+
If you are a user of Sublime Text we recommend that you have the following options in your Julia syntax specific settings. To modify these settings first open any Julia file (`*.jl`) in Sublime Text. Then navigate to: `Preferences > Settings - More > Syntax Specific - User`
38+
39+
```{json}
40+
{
41+
"translate_tabs_to_spaces": true,
42+
"tab_size": 4,
43+
"trim_trailing_white_space_on_save": true,
44+
"ensure_newline_at_eof_on_save": true,
45+
"rulers": [92]
46+
}
47+
```
48+
49+
### Vim Settings
50+
51+
If you are a user of Vim we recommend that you add the following options to your `.vimrc` file.
52+
53+
```
54+
set tabstop=4 " Sets tabstops to a width of four columns.
55+
set softtabstop=4 " Determines the behaviour of TAB and BACKSPACE keys with expandtab.
56+
set shiftwidth=4 " Determines the results of >>, <<, and ==.
57+
58+
au FileType julia setlocal expandtab " Replaces tabs with spaces.
59+
au FileType julia setlocal colorcolumn=93 " Highlights column 93 to help maintain the 92 character line limit.
60+
```
61+
62+
By default, Vim seems to guess that `.jl` files are written in Lisp. To ensure that Vim recognizes Julia files you can manually have it check for the `.jl` extension, but a better solution is to install [Julia-Vim](https://github.com/JuliaLang/julia-vim), which also includes proper syntax highlighting and a few cool other features.
63+
64+
## Test Formatting
65+
66+
### Testsets
67+
68+
Julia provides [test sets](https://docs.julialang.org/en/v1/stdlib/Test/#Working-with-Test-Sets-1) which allows developers to group tests into logical groupings. Test sets can be nested and ideally packages should only have a single "root" test set. It is recommended that the "runtests.jl" file contains the root test set which contains the remainder of the tests:
69+
70+
```{julia}
71+
#| eval: false
72+
@testset "PkgExtreme" begin
73+
include("arithmetic.jl")
74+
include("utils.jl")
75+
end
76+
```
77+
78+
The file structure of the `test` folder should mirror that of the `src` folder. Every file in `src` should have a complementary file in the `test` folder, containing tests relevant to that file's contents.
79+
80+
### Comparisons
81+
82+
Most tests are written in the form `@test x == y`. Since the `==` function doesn't take types into account, tests like the following are valid: `@test 1.0 == 1`. Avoid adding visual noise into test comparisons:
83+
84+
```{julia}
85+
#| eval: false
86+
# Yes:
87+
@test value == 0
88+
89+
# No:
90+
@test value == 0.0
91+
```
92+
93+
In cases where you are checking the numerical validity of a model's parameter estimates, please use the `check_numerical` function found in `test/test_utils/numerical_tests.jl`. This function will evaluate a model's parameter estimates using tolerance levels `atol` and `rtol`. Testing will only be performed if you are running the test suite locally or if Travis is executing the "Numerical" testing stage.
94+
95+
Here is an example of usage:
96+
97+
```{julia}
98+
#| eval: false
99+
# Check that m and s are plus or minus one from 1.5 and 2.2, respectively.
100+
check_numerical(chain, [:m, :s], [1.5, 2.2]; atol=1.0)
101+
102+
# Checks the estimates for a default gdemo model using values 1.5 and 2.0.
103+
check_gdemo(chain; atol=0.1)
104+
105+
# Checks the estimates for a default MoG model.
106+
check_MoGtest_default(chain; atol=0.1)
107+
```

0 commit comments

Comments
 (0)