Skip to content

Commit

Permalink
refactor: tests package imports for test modules and rm relative paths
Browse files Browse the repository at this point in the history
  • Loading branch information
Aidan Griffiths committed Oct 19, 2023
1 parent 7614b23 commit 8e4da52
Show file tree
Hide file tree
Showing 23 changed files with 16 additions and 20 deletions.
Empty file added tests/__init__.py
Empty file.
File renamed without changes.
Empty file added tests/categorical/__init__.py
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
Contains unit tests for scores.categorical
"""
import dask
import multicategorical_test_data as mtd
import numpy as np
import pytest
import xarray as xr

from scores.categorical import firm
from scores.categorical.multicategorical_impl import _single_category_score
from scores.utils import DimensionError
from tests.categorical import multicategorical_test_data as mtd


def test_dummy_test():
Expand Down
Empty file.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
"""Tests for murphy metrics and thetas generation code."""
import pathlib
import re
from datetime import datetime
from unittest.mock import Mock, patch

import dask
import numpy as np
import pytest
import xarray as xr
import dask

from scores.continuous import murphy_score, murphy_thetas
from scores.continuous.murphy_impl import _expectile_thetas, _huber_thetas, _quantile_thetas
from scores.continuous import murphy_impl as murphy
from scores.continuous import murphy_score, murphy_thetas
from scores.continuous.murphy_impl import (
_expectile_thetas,
_huber_thetas,
_quantile_thetas,
)

FCST = xr.DataArray(
dims=("lead_day", "station_number", "valid_15z_date"),
Expand Down Expand Up @@ -97,7 +102,7 @@ def patch_scoring_func(monkeypatch, score_function, thetas):
return mock_rel_fc_func


thetas_nc = xr.open_dataarray("tests/scores/continuous/test_data/thetas.nc")
thetas_nc = xr.open_dataarray(pathlib.Path(__file__).parent / "test_data/thetas.nc")
thetas_list = [0.0, 2.0, 10.0]


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ def test_rmse_xarray_1d(forecast, observations, expected, request_kwargs, reques
if isinstance(observations, str):
observations = request.getfixturevalue(observations)
result = scores.continuous.rmse(forecast, observations, **request_kwargs)
print(result)
assert (result.round(PRECISION) == expected).all()


Expand Down
Empty file added tests/probabilty/__init__.py
Empty file.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,9 @@
"""
Contains unit tests for scores.probability.crps
"""

from typing import Iterable, Optional # pylint: disable=unused-import

import crps_test_data # pylint: disable=import-error
import dask
import numpy as np
import pytest
from assertions import assert_dataarray_equal # pylint: disable=import-error
from assertions import assert_dataset_equal # pylint: disable=import-error

from scores.probability import (
adjust_fcst_for_crps,
Expand All @@ -23,6 +17,8 @@
crps_cdf_trapz,
crps_step_threshold_weight,
)
from tests.assertions import assert_dataarray_equal, assert_dataset_equal
from tests.probabilty import crps_test_data


@pytest.mark.parametrize(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
"""
This module contains unit tests for scores.probability.functions
"""

import assertions # pylint: disable=import-error
import cdf_test_data # pylint: disable=import-error
import crps_test_data # pylint: disable=import-error
import numpy as np
import pytest
import xarray as xr

import scores.probability.functions

### TESTS ###
from tests import assertions
from tests.probabilty import cdf_test_data, crps_test_data


def test_round_values_exception():
Expand Down
Empty file added tests/stats/__init__.py
Empty file.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""Tests for processing"""
import numpy as np
import pytest
import test_processing_data as xtd
import xarray as xr

from scores.processing import broadcast_and_match_nan
from tests import test_processing_data as xtd


@pytest.mark.parametrize(
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/scores/test_utils.py → tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
"""

import pytest
import utils_test_data # pylint: disable=import-error

from scores import utils
from scores.utils import DimensionError
from scores.utils import gather_dimensions as gd
from tests import utils_test_data


@pytest.mark.parametrize(
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 8e4da52

Please sign in to comment.