Metadata-Version: 2.4
Name: ifotools
Version: 1.0a6
Summary: Collection of functions useful for simulating interferometers
Author-email: Miron van der Kolk <mkolk@nikhef.nl>
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: sympy
Requires-Dist: pygments
Requires-Dist: finesse
Requires-Dist: tabulate
Provides-Extra: test
Requires-Dist: pytest; extra == "test"
Provides-Extra: lint
Requires-Dist: ruff; extra == "lint"
Provides-Extra: dev
Requires-Dist: pyyaml; extra == "dev"
Dynamic: license-file

# Ifotools

Collection of useful interferometer functions.

## Layout

The overall package is called `ifotools`, in which submodules(folders) can be
created. Every folder should have an `__init__.py` file inside (can be empty).
For now the suggestion is to put virgo related functions under
`src/ifotools/virgo`

`examples` should contain notebooks explaining how the functions can be used.
`tests` should contain pytest compatible tests (see
<https://pytest-with-eric.com/> and
<https://docs.pytest.org/en/stable/getting-started.html>)

Optimally the folder structure in all three (`src`, `tests`, `examples`) should
be identical.

## Installation

Clone the repository

```bash
git clone git@gitlab.com:ifosim/ifotools.git
cd ifotools
```

### Conda (prefered)

Install via `pip` in any conda/python environment.

```bash
conda create -n ifotools --file environment.yml
pip install -e . --no-deps --no-build-isolation
```

### Pip

```bash
pip install -e .[test,lint,dev]
```

## SSH keys

The above requires you to have an ssh key added to your gitlab account:

- <https://gitlab.nikhef.nl/-/user_settings/ssh_keys>
- <https://docs.gitlab.com/user/ssh/#what-are-ssh-keys>

Alternatively you can do

```bash
git clone https://gitlab.com/ifosim/ifotools.git
```

But you may have to enter your username and password when pushing and pulling.

To test:

```bash
python -c 'import ifotools'
```

## Updating

Just run

```bash
git pull
```

in the repo root folder and it should update.

## Where to add code

You can just add python files in `src/ifotools`. You can also add folders, as
long as they have an `__init__.py` inside.

## Imports

It would be cleanest to use absolute imports inside the package e.g.

```python
from ifotools.sympy_helpers import print_expression_eval
```

and not

```python
from .sympy_helpers import ****
```

## Formatting and linting

It is a good habit to use `ruff` (`pip install ruff`/`conda install -c
conda-forge ruff`) and run:

```bash
ruff check --fix my_file.py
ruff format my_file.py
```

This will help you spot common mistakes and format all files in the same way.

VS code can automate this by adding the following to your [workspace settings](https://code.visualstudio.com/docs/configure/settings#_workspace-settings)

```json
{
    "[python]": {
        "editor.formatOnSave": true,
        "editor.codeActionsOnSave": {
            "source.fixAll": "explicit",
            "source.organizeImports": "explicit"
        },
    },
    "notebook.formatOnSave.enabled": true,
    "notebook.codeActionsOnSave": {
        "notebook.source.fixAll": "explicit",
        "notebook.source.organizeImports": "explicit"
    },
}
```

## Dependencies

Dependencies are listed in the `pyproject.toml`. There is a conda `environment.yml` file which can be generated from the `pyproject.toml` file via `python scripts/generate_environment_files.py`. Please make sure they keep in sync.
