Skip to content

Commit 2dd6195

Browse files
authored
Remove top level lib directory and move tests to top level (#1108)
* Move tests to top level * Move improver to top level * Update pytest test discovery path * Bulk rewrite test imports * Move tolerance constants to improver This avoids improver code importing from tests. * Convert test imports to relative * Sort all imports Settings used: isort --recursive --atomic -w 79 -m 4 -y * Update bin scripts to remove lib directory * Remove unused import * Update paths in github actions * Fix long line lengths Rename some duplicated directory/file names to make names shorter * Update docs makefile * Fix import in metadata CLI * Rename tests to improver_tests * Update paths for change from tests to improver_tests
1 parent e85dece commit 2dd6195

File tree

378 files changed

+497
-482
lines changed

Some content is hidden

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

378 files changed

+497
-482
lines changed

.github/workflows/tests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ jobs:
1616
$CONDA/bin/conda list --export
1717
1818
- name: Pycodestyle (PEP8 conventions)
19-
run: $CONDA/bin/pycodestyle -v lib
19+
run: $CONDA/bin/pycodestyle -v improver improver_tests
2020

2121
- name: Sphinx-build (Doc test)
2222
run: cd doc; make SPHINXBUILD=$CONDA/bin/sphinx-build html
23-
23+
2424
- name: Pytest (Unit tests)
2525
run: $CONDA/bin/pytest -m "not acc"
2626

2727
- name: Pylint (More linting goodness)
28-
run: $CONDA/bin/pylint -j 0 -E --rcfile=etc/pylintrc lib
28+
run: $CONDA/bin/pylint -j 0 -E --rcfile=etc/pylintrc improver improver_tests

bin/improver

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,6 @@ fi
5858

5959
# Put our library and scripts in the paths.
6060
export PATH="$IMPROVER_DIR/bin/:$PATH"
61-
export PYTHONPATH="$IMPROVER_DIR/lib/:${PYTHONPATH:-}"
61+
export PYTHONPATH="$IMPROVER_DIR/:${PYTHONPATH:-}"
6262

6363
exec python3 -m improver.cli "$@"

bin/improver-tests

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,12 @@ function improver_test_pycodestyle {
126126

127127
function improver_test_pylint {
128128
# Pylint score generation.
129-
${PYLINT:-pylint} --rcfile=../etc/pylintrc $FILES_TO_TEST
129+
${PYLINT:-pylint} --rcfile=etc/pylintrc $FILES_TO_TEST
130130
}
131131

132132
function improver_test_pylintE {
133133
# Pylint obvious-errors-only testing.
134-
${PYLINT:-pylint} -E --rcfile=../etc/pylintrc $FILES_TO_TEST
134+
${PYLINT:-pylint} -E --rcfile=etc/pylintrc $FILES_TO_TEST
135135
echo_ok "pylint -E"
136136
}
137137

@@ -214,11 +214,10 @@ if [[ -f "${IMPROVER_SITE_INIT:=$IMPROVER_DIR/etc/site-init}" ]]; then
214214
. "$IMPROVER_SITE_INIT"
215215
fi
216216

217-
export PYTHONPATH="$IMPROVER_DIR/lib:${PYTHONPATH:-}"
217+
export PYTHONPATH="$IMPROVER_DIR/:${PYTHONPATH:-}"
218218

219219
TEST_INPUT_PWD=$(cd $PWD && pwd -P)
220-
cd $IMPROVER_DIR/lib
221-
#cd $IMPROVER_DIR
220+
cd $IMPROVER_DIR/
222221

223222
# Find cli test options and format to work with case statement
224223
shopt -s extglob
@@ -268,7 +267,7 @@ fi
268267

269268
# If cli sub test is not specified by user, do all cli tests.
270269
# Otherwise set CLISUBTEST to the sub test to run.
271-
CLISUBTEST="$IMPROVER_DIR/tests/"
270+
CLISUBTEST="$IMPROVER_DIR/improver_tests/"
272271
STRIPPED_TEST="$(echo -e "${TESTS}" | tr -d '[:space:]')"
273272
if [[ $STRIPPED_TEST == "cli" ]]; then
274273
if [[ -n "$SUBCLI" ]]; then

doc/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ clean:
3232

3333
.PHONY: apidoc
3434
apidoc:
35-
sphinx-apidoc -e -P -f -o source ../lib/improver ../lib/improver/tests
35+
sphinx-apidoc -e -P -f -o source ../improver ../improver_tests
3636

3737
.PHONY: html
3838
html:

doc/source/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252

5353
SOURCE_DIR = os.path.abspath(os.path.join(
5454
os.path.dirname(os.path.abspath(__file__)),
55-
'..', '..', 'lib'
55+
'..', '..'
5656
))
5757

5858
sys.path.insert(0, SOURCE_DIR)
@@ -416,7 +416,7 @@ def run_apidoc(_):
416416
from sphinx.ext.apidoc import main
417417

418418
output_dir = os.path.dirname(os.path.abspath(__file__))
419-
exclude_dir = os.path.join(SOURCE_DIR, 'improver', 'tests')
419+
exclude_dir = os.path.join(SOURCE_DIR, 'improver_tests')
420420
main(['-e', '-P', '-f', '-o', output_dir, SOURCE_DIR, exclude_dir])
421421

422422

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333

3434
import iris
3535
import numpy as np
36-
3736
from iris.exceptions import CoordinateNotFoundError
3837

3938
from improver import BasePlugin
File renamed without changes.

lib/improver/blending/calculate_weights_and_blend.py renamed to improver/blending/calculate_weights_and_blend.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,12 @@
3131
"""Plugin to calculate blend weights and blend data across a dimension"""
3232

3333
from improver import BasePlugin
34-
from improver.blending.spatial_weights import (
35-
SpatiallyVaryingWeightsFromMask)
34+
from improver.blending.spatial_weights import SpatiallyVaryingWeightsFromMask
3635
from improver.blending.weighted_blend import (
3736
MergeCubesForWeightedBlending, WeightedBlendAcrossWholeDimension)
3837
from improver.blending.weights import (
39-
ChooseWeightsLinear, ChooseDefaultWeightsLinear,
40-
ChooseDefaultWeightsNonLinear)
38+
ChooseDefaultWeightsLinear, ChooseDefaultWeightsNonLinear,
39+
ChooseWeightsLinear)
4140
from improver.metadata.amend import amend_attributes
4241
from improver.utilities.spatial import (
4342
check_if_grid_is_equal_area, convert_distance_into_number_of_grid_cells)

0 commit comments

Comments
 (0)