From a0fbf1f67126f96bf518bbedb8fc14d1ff37b99a Mon Sep 17 00:00:00 2001 From: Marshall McDonnell Date: Mon, 4 Jan 2021 16:55:30 -0500 Subject: [PATCH 1/4] Fix small test filename error --- tests/test_stog.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_stog.py b/tests/test_stog.py index 0ebe74e..83c0a9d 100644 --- a/tests/test_stog.py +++ b/tests/test_stog.py @@ -73,11 +73,11 @@ def setUp(self): self.reciprocal_xtarget = 1.94 self.fourier_filter_cutoff = 1.5 - filename = self.material.reciprocal_space_filename self.kwargs_for_files = { 'Files': [ { - 'Filename': get_data_path(filename), + 'Filename': + get_data_path(self.material.reciprocal_space_filename), 'ReciprocalFunction': 'S(Q)', 'Qmin': 0.02, 'Qmax': 15.0, From f19dfc1077bbcac4aa2687ef1874368c0555ad6e Mon Sep 17 00:00:00 2001 From: Marshall McDonnell Date: Mon, 4 Jan 2021 16:56:05 -0500 Subject: [PATCH 2/4] Update REAMDE development section --- README.md | 88 ++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 65 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index fdcac68..13754a1 100644 --- a/README.md +++ b/README.md @@ -32,31 +32,12 @@ Yet, migration to the Mantid Framework is still a goal since it feeds into the [ ## Installation -Installation is available via `pip`. +Installation is available via [`pip`](https://pip.pypa.io/en/stable/). ```bash pip install pystog ``` -or for a local install -```bash -pip install pystog --user #locally installed in $HOME/.local -``` -For a development environment, you can use [`virtualenv`](https://virtualenv.pypa.io/en/latest/) to setup an isolated environemnt, namely `ENV`: - -```bash -python -m virtualenv /path/to/ENV -source /path/to/ENV/bin/activate -pip install pystog -``` - -Also, [`direnv`](https://github.com/direnv/direnv) is a useful and recommended way to manage the virtual environment. -You can simply use an `.envrc` file which contains: - -`layout python3` - -Then, once inside the development directory, just install via `pip` as described above. - ## Getting started Once installed, you can access the packages classes that perform the function manipulation. @@ -85,9 +66,70 @@ Also, a useful example reference is the [PDFFourierTransform](http://docs.mantid Finally, tutorials in the form of Jupyter Notebooks can be launched via Binder by clicking the badge here [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/neutrons/pystog/master?filepath=tutorials) or at the top of the page. -## Running the tests -From the parent directory of the module, run: +## Development + +The following are ways to setup the virtual environment, lint and test the package. +### Virtual environment setup + +#### Using pipenv (recommended) +With [pipenv](https://pipenv.pypa.io/en/latest/) installed, run the following: ```bash -python setup.py test +pipenv install --dev . ``` + +#### Using virtualenv +You can use [`virtualenv`](https://virtualenv.pypa.io/en/latest/) to setup an environment, here named `ENV`: + +```bash +python -m virtualenv /path/to/ENV +source /path/to/ENV/bin/activate +pip install pystog +``` + +#### Using direnv +Also, [`direnv`](https://github.com/direnv/direnv) is a useful and recommended way to manage the virtual environment. +You can simply use an `.envrc` file which contains: + +`layout python3` + +Then, once inside the development directory, just install via `pip` as described above. + +### Testing +[pytest](https://docs.pytest.org/en/latest/) is used to write the test suite. +[Tox](https://tox.readthedocs.io/en/latest/) is the general tool for running both linting and testing (single and multiple python version testing). +[pyenv](https://github.com/pyenv/pyenv) is the recommended tool for python version management. +From the parent directory of the module, run: + +`pytest` + +Using pipenv: +`pipenv run pytest` + +Using tox for a single python version, +where `py` is one of [py36, py37, py38, py39]: +`tox -e py` + +or with pipenv: +`pipenv run tox -e py` + +Using tox for all stages of testing (all python versions and linting), just run: +`tox` +NOTE: You must have the version of python installed to run a test suite against that verion via tox. +Recommended way to install python versions is `pyenv` + +### Linting +[Flake8](https://flake8.pycqa.org/en/latest/) is used for style guide enforcement (i.e. linting): + +From the parent directory of the module, run: + +`flake8 .` + +Using pipenv and flake8: +`pipenv run flake8 .` + +Using tox +`tox -e lint` + +Using pipenv and tox: +`pipenv run tox -e lint` From 1d3aaa9ec46028256d38cec420245b21953e729b Mon Sep 17 00:00:00 2001 From: Marshall McDonnell Date: Mon, 4 Jan 2021 16:59:26 -0500 Subject: [PATCH 3/4] Add conda install to README --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 13754a1..a086b15 100644 --- a/README.md +++ b/README.md @@ -32,11 +32,11 @@ Yet, migration to the Mantid Framework is still a goal since it feeds into the [ ## Installation -Installation is available via [`pip`](https://pip.pypa.io/en/stable/). +Installation is available via [`pip`](https://pip.pypa.io/en/stable/): +`pip install pystog` -```bash -pip install pystog -``` +And [conda](https://docs.conda.io/en/latest/): +`conda install -c neutrons pystog` ## Getting started From 1e095ecede00e7a920b140d96926d7166d75161c Mon Sep 17 00:00:00 2001 From: Marshall McDonnell Date: Mon, 4 Jan 2021 17:02:05 -0500 Subject: [PATCH 4/4] Fix lint error for test filename --- tests/test_stog.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/test_stog.py b/tests/test_stog.py index 83c0a9d..e7ac6b7 100644 --- a/tests/test_stog.py +++ b/tests/test_stog.py @@ -73,11 +73,11 @@ def setUp(self): self.reciprocal_xtarget = 1.94 self.fourier_filter_cutoff = 1.5 + filename = get_data_path(self.material.reciprocal_space_filename) self.kwargs_for_files = { 'Files': [ { - 'Filename': - get_data_path(self.material.reciprocal_space_filename), + 'Filename': filename, 'ReciprocalFunction': 'S(Q)', 'Qmin': 0.02, 'Qmax': 15.0, @@ -90,8 +90,7 @@ def setUp(self): } }, { - 'Filename': - get_data_path(self.material.reciprocal_space_filename), + 'Filename': filename, 'ReciprocalFunction': 'S(Q)', 'Qmin': 1.90, 'Qmax': 35.2,