# Contributing to Geostatex

Thank you for helping. Bug reports, fixes, new methods and documentation are all welcome.

## Before you start

Open an issue for anything larger than a fix, so the approach is agreed before you write it.

## Setup

You need Elixir 1.17 or newer and Rust 1.91 or newer (`.tool-versions` has the versions used in
development). A checkout always builds the NIF from source.

```sh
mix deps.get
mix test
cargo test --workspace
```

Before opening a pull request, run what CI runs:

```sh
mix format --check-formatted
mix compile --warnings-as-errors
mix credo --strict
mix docs --warnings-as-errors
cargo fmt --all --check
cargo clippy --workspace --all-targets -- -D warnings
```

## How the code is verified

Geostatex reproduces the results of reference libraries. Every numerical result is checked
against a fixture under `test/reference/fixtures`, generated by the scripts under
`test/reference` (Python and R, needed only to regenerate fixtures; see
[test/reference/README.md](test/reference/README.md)).

- Write the test first, against a fixture or a value you can justify, then the implementation.
- Every deviation from a reference library is documented in [docs/parity.md](docs/parity.md).
- Every random step takes a `seed` and is reproducible.
- Options are a trailing keyword list; unknown keys raise.

## Licences of the code you study

Geostatex is LGPL-3.0-only (see [NOTICE](NOTICE)). What you read while writing a contribution
decides whether it can be accepted:

- Code under the MIT, BSD or Apache licences, and LGPL-3.0 code such as GSTools, may be studied
  and ported. Name the source in the pull request so that `NOTICE` stays accurate.
- **Do not read GPL-licensed source code** (R gstat, R sp, GSLIB derivatives under the GPL) to
  write a contribution, and do not copy from books whose code is not freely licensed (Numerical
  Recipes). Work from the published papers, the documentation and the outputs of the program:
  running a GPL program to produce reference numbers is fine.
- Data sets need a stated licence and source next to them.

By contributing you agree that your contribution is licensed under the LGPL-3.0-only.

## Commits and pull requests

Use [Conventional Commits](https://www.conventionalcommits.org) (`feat:`, `fix:`, `docs:`, ...).
Keep a pull request to one change, with its tests and documentation.
