# Path: lib/cartopy/tests/crs/helpers.py
# def check_proj_params(name, crs, other_args):
#     expected = other_args | {f'proj={name}', 'no_defs'}
#     proj_params = set(crs.proj4_init.lstrip('+').split(' +'))
#     assert expected == proj_params


import numpy as np
import pytest
import cartopy.crs as ccrs
from numpy.testing import assert_almost_equal
from .helpers import check_proj_params
"""
Tests for the InterruptedGoodeHomolosine coordinate system.

"""




@pytest.mark.parametrize("emphasis", ["land", "ocean"])
def test_default(emphasis):
    igh = ccrs.InterruptedGoodeHomolosine(emphasis=emphasis)
    other_args = {"ellps=WGS84", "lon_0=0"}
    if emphasis == "land":
        check_proj_params("igh", igh, other_args)
    elif emphasis == "ocean":
        check_proj_params("igh_o", igh, other_args)
    assert_almost_equal(
        np.array(igh.x_limits), [-20037508.3427892, 20037508.3427892]
    )
    assert_almost_equal(
        np.array(igh.y_limits), [-8683259.7164347, 8683259.7164347]
    )


@pytest.mark.parametrize("emphasis", ["land", "ocean"])
def test_eccentric_globe(emphasis):
    globe = ccrs.Globe(semimajor_axis=1000, semiminor_axis=500, ellipse=None)
    igh = ccrs.InterruptedGoodeHomolosine(globe=globe, emphasis=emphasis)
    other_args = {"a=1000", "b=500", "lon_0=0"}
    if emphasis == "land":

# Path: lib/cartopy/tests/crs/helpers.py
# def check_proj_params(name, crs, other_args):
#     expected = other_args | {f'proj={name}', 'no_defs'}
#     proj_params = set(crs.proj4_init.lstrip('+').split(' +'))
#     assert expected == proj_params


# Path: lib/cartopy/tests/crs/test_interrupted_goode_homolosine.py
import numpy as np
import pytest
import cartopy.crs as ccrs
from numpy.testing import assert_almost_equal
from .helpers import check_proj_params

"""
Tests for the InterruptedGoodeHomolosine coordinate system.

"""




@pytest.mark.parametrize("emphasis", ["land", "ocean"])
def test_default(emphasis):
    igh = ccrs.InterruptedGoodeHomolosine(emphasis=emphasis)
    other_args = {"ellps=WGS84", "lon_0=0"}
    if emphasis == "land":
        check_proj_params("igh", igh, other_args)
    elif emphasis == "ocean":
        check_proj_params("igh_o", igh, other_args)
    assert_almost_equal(
        np.array(igh.x_limits), [-20037508.3427892, 20037508.3427892]
    )
    assert_almost_equal(
        np.array(igh.y_limits), [-8683259.7164347, 8683259.7164347]
    )


@pytest.mark.parametrize("emphasis", ["land", "ocean"])
def test_eccentric_globe(emphasis):
    globe = ccrs.Globe(semimajor_axis=1000, semiminor_axis=500, ellipse=None)
    igh = ccrs.InterruptedGoodeHomolosine(globe=globe, emphasis=emphasis)
    other_args = {"a=1000", "b=500", "lon_0=0"}
    if emphasis == "land":

        check_proj_params("igh", igh, other_args)