Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion esmvalcore/preprocessor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
def _get_itype(step):
"""Get the input type of a preprocessor function."""
function = globals()[step]
itype = inspect.getargspec(function).args[0]
itype = inspect.getfullargspec(function).args[0]
return itype


Expand Down
2 changes: 1 addition & 1 deletion esmvalcore/preprocessor/_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def _is_single_item(testee):
We count string types as 'single', also.
"""
return (isinstance(testee, str)
or not isinstance(testee, collections.Iterable))
or not isinstance(testee, collections.abc.Iterable))


def _as_list_of_coords(cube, names_or_coords):
Expand Down
9 changes: 5 additions & 4 deletions esmvalcore/preprocessor/_regrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,17 @@ def _stock_cube(spec, lat_offset=True, lon_offset=True):
# Construct the latitude coordinate, with bounds.
if lat_offset:
latdata = np.linspace(_LAT_MIN + mid_dlat, _LAT_MAX - mid_dlat,
_LAT_RANGE / dlat)
int(_LAT_RANGE / dlat))
else:
latdata = np.linspace(_LAT_MIN, _LAT_MAX, _LAT_RANGE / dlat + 1)
latdata = np.linspace(_LAT_MIN, _LAT_MAX, int(_LAT_RANGE / dlat) + 1)

# Construct the longitude coordinat, with bounds.
if lon_offset:
londata = np.linspace(_LON_MIN + mid_dlon, _LON_MAX - mid_dlon,
_LON_RANGE / dlon)
int(_LON_RANGE / dlon))
else:
londata = np.linspace(_LON_MIN, _LON_MAX - dlon, _LON_RANGE / dlon)
londata = np.linspace(_LON_MIN, _LON_MAX - dlon,
int(_LON_RANGE / dlon))

lats = iris.coords.DimCoord(
latdata,
Expand Down
1 change: 0 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ addopts =
--cov-report=term
--cov-report=xml:test-reports/coverage.xml
--cov-report=html:test-reports/coverage_html
--junit-xml=test-reports/report.xml
--html=test-reports/report.html
env =
MPLBACKEND = Agg
Expand Down
3 changes: 0 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@
# Test dependencies
# Execute 'python setup.py test' to run tests
'test': [
'easytest',
'mock',
'nose',
'pytest>=3.9',
'pytest-cov',
'pytest-env',
Expand Down
2 changes: 1 addition & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"""
import unittest
from functools import wraps
from unittest import mock

import mock
import numpy as np


Expand Down
11 changes: 6 additions & 5 deletions tests/integration/cmor/_fixes/cmip5/test_gfdl_esm2g.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
"""Tests for fixes of GFDL-ESM2G (CMIP5)."""
import unittest
from unittest import mock

import iris
from iris.cube import Cube
import mock
import pytest
from cf_units import Unit
from iris.cube import Cube

from esmvalcore.cmor._fixes.cmip5.gfdl_esm2g import (AllVars, Areacello, Co2,
FgCo2, Usi, Vsi,
_get_and_remove)
from esmvalcore.cmor.fix import Fix
from esmvalcore.cmor._fixes.cmip5.gfdl_esm2g import (_get_and_remove, AllVars,
Co2, FgCo2, Usi, Vsi,
Areacello)

CUBE_1 = iris.cube.Cube([1.0], long_name='to_be_rm')
CUBE_2 = iris.cube.Cube([1.0], long_name='not_to_be_rm')
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/cmor/_fixes/cmip6/test_ipsl_cm6a_lr.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ def test_fix_metadata_ocean_var(self):

self.assertEqual(len(cubes), 1)
cube = cubes[0]
self.assertEquals(cube.coord('latitude').var_name, 'lat')
self.assertEquals(cube.coord('longitude').var_name, 'lon')
self.assertEqual(cube.coord('latitude').var_name, 'lat')
self.assertEqual(cube.coord('longitude').var_name, 'lon')
self.cube.coord('cell_area')

def test_fix_data_other_var(self):
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/preprocessor/_io/test_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ def test_callback_fix_lat_units(self):
self.assertTrue((cube.data == np.array([1, 2])).all())
self.assertTrue((cube.coord('latitude').points == np.array([1,
2])).all())
self.assertEquals(cube.coord('latitude').units, 'degrees_north')
self.assertEqual(cube.coord('latitude').units, 'degrees_north')
2 changes: 1 addition & 1 deletion tests/integration/test_recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
from pathlib import Path
from pprint import pformat
from textwrap import dedent
from unittest.mock import create_autospec

import iris
import pytest
import yaml
from mock import create_autospec

import esmvalcore
from esmvalcore._recipe import TASKSEP, read_recipe_file
Expand Down
3 changes: 1 addition & 2 deletions tests/unit/cmor/test_fix.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
"""Unit tests for the variable_info module."""

import unittest

import mock
from unittest import mock

from esmvalcore.cmor.fix import Fix, fix_data, fix_file, fix_metadata

Expand Down
10 changes: 8 additions & 2 deletions tests/unit/preprocessor/_derive/test_uajet.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@
import numpy as np
import pytest

import esmvalcore.preprocessor._derive.uajet as uajet
from esmvalcore.preprocessor._derive import uajet

TIME_COORD = iris.coords.DimCoord([1.0, 2.0, 3.0], standard_name='time')
LEV_COORD = iris.coords.DimCoord([80000.0, 83000.0, 87000.0],
standard_name='air_pressure')
LON_COORD = iris.coords.DimCoord([0.0, 90.0, 180.0, 240.0, 360.0],
LON_COORD = iris.coords.DimCoord([0.0, 90.0, 180.0, 270.0],
bounds=[
[-45., 45.],
[45., 135.],
[135., 225.],
[225., 315.],
],
standard_name='longitude')


Expand Down
3 changes: 2 additions & 1 deletion tests/unit/preprocessor/_mapping/test_mapping.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""Unit tests for the esmvalcore.preprocessor._mapping module."""
from unittest import mock

import cf_units
import iris
import mock
import numpy as np

import tests
Expand Down
10 changes: 5 additions & 5 deletions tests/unit/preprocessor/_regrid/test__stock_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"""

import unittest
from unittest import mock

import iris
import mock
import numpy as np

import tests
Expand All @@ -23,14 +23,14 @@ def _check(self, dx, dy, lat_off=True, lon_off=True):
mid_dx, mid_dy = dx / 2, dy / 2
if lat_off and lon_off:
expected_lat_points = np.linspace(
_LAT_MIN + mid_dy, _LAT_MAX - mid_dy, _LAT_RANGE / dy)
_LAT_MIN + mid_dy, _LAT_MAX - mid_dy, int(_LAT_RANGE / dy))
expected_lon_points = np.linspace(
_LON_MIN + mid_dx, _LON_MAX - mid_dx, _LON_RANGE / dx)
_LON_MIN + mid_dx, _LON_MAX - mid_dx, int(_LON_RANGE / dx))
else:
expected_lat_points = np.linspace(_LAT_MIN, _LAT_MAX,
_LAT_RANGE / dy + 1)
int(_LAT_RANGE / dy) + 1)
expected_lon_points = np.linspace(_LON_MIN, _LON_MAX - dx,
_LON_RANGE / dx)
int(_LON_RANGE / dx))

# Check the stock cube coordinates.
self.assertEqual(self.mock_DimCoord.call_count, 2)
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/preprocessor/_regrid/test_extract_levels.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""Unit tests for :func:`esmvalcore.preprocessor.regrid.extract_levels`."""

import unittest
from unittest import mock

import iris
import mock
import numpy as np
from numpy import ma

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/preprocessor/_regrid/test_regrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"""

import unittest
from unittest import mock

import iris
import mock

import tests
from esmvalcore.preprocessor import regrid
Expand Down
16 changes: 11 additions & 5 deletions tests/unit/preprocessor/_regrid_esmpy/test_regrid_esmpy.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
"""Unit tests for the esmvalcore.preprocessor._regrid_esmpy module."""
from unittest import mock

import cf_units
import iris
import mock
import numpy as np
from iris.exceptions import CoordinateNotFoundError

import tests
from esmvalcore.preprocessor._regrid_esmpy import (
build_regridder, build_regridder_2d, coords_iris_to_esmpy,
cube_to_empty_field, get_grid, get_grid_representant,
get_grid_representants, get_representant, is_lon_circular, regrid)
from esmvalcore.preprocessor._regrid_esmpy import (build_regridder,
build_regridder_2d,
coords_iris_to_esmpy,
cube_to_empty_field,
get_grid,
get_grid_representant,
get_grid_representants,
get_representant,
is_lon_circular, regrid)


def identity(*args, **kwargs):
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/preprocessor/_time/test_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ def test_extract_time_no_slice(self):
def test_extract_time_one_time(self):
"""Test extract_time with one time step."""
cube = _create_sample_cube()
cube.coord('time').guess_bounds()
cube.remove_coord('month_number')
cube = cube.collapsed('time', iris.analysis.MEAN)
sliced = extract_time(cube, 1950, 1, 1, 1952, 12, 31)
assert_array_equal(np.array([360.]), sliced.coord('time').points)
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/preprocessor/_units/test_convert_units.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def test_convert_compatible_units(self):
result = convert_units(self.arr, 'degC')
expected_data = np.array([[-273.15, -272.15], [-271.15, -270.15]])
expected_units = cf_units.Unit('degC')
self.assertEquals(result.units, expected_units)
self.assertEqual(result.units, expected_units)
self.assert_array_equal(result.data, expected_data)


Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""Unit tests for :mod:`esmvalcore.preprocessor._weighting`."""
from collections import OrderedDict
from unittest import mock

import iris
import mock
import numpy as np
import pytest
from cf_units import Unit
Expand Down