#! /usr/bin/env python
"""The Landlab

:Package name: TheLandlab
:Release date: 2018-09-18
:Authors: Greg Tucker, Nicole Gasparini, Erkan Istanbulluoglu, Daniel Hobley,
    Sai Nudurupati, Jordan Adams, Eric Hutton, Katherine Barnhart, Margaux
    Mouchene, Nathon Lyons
:URL: http://csdms.colorado.edu/trac/landlab
:License: MIT
"""

from __future__ import absolute_import

import os

from numpy import set_printoptions

from ._registry import registry
from ._version import get_versions
from .core.model_component import Component
from .core.model_parameter_dictionary import (
    MissingKeyError,
    ModelParameterDictionary,
    ParameterValueError,
)
from .core.model_parameter_loader import load_params
from .field.scalar_data_fields import FieldError
from .framework.collections import Arena, NoProvidersError, Palette
from .framework.decorators import Implements, ImplementsOrRaise
from .framework.framework import Framework
from .grid import (
    ACTIVE_LINK,
    BAD_INDEX_VALUE,
    CLOSED_BOUNDARY,
    CORE_NODE,
    FIXED_GRADIENT_BOUNDARY,
    FIXED_LINK,
    FIXED_VALUE_BOUNDARY,
    INACTIVE_LINK,
    LOOPED_BOUNDARY,
    HexModelGrid,
    ModelGrid,
    RadialModelGrid,
    RasterModelGrid,
    VoronoiDelaunayGrid,
    create_and_initialize_grid,
)
from .plot import (
    analyze_channel_network_and_plot,
    imshow_cell_grid,
    imshow_grid,
    imshow_grid_at_node,
    imshow_node_grid,
)

try:
    set_printoptions(legacy="1.13")
except TypeError:
    pass
finally:
    del set_printoptions

cite_as = registry.format_citations

if "DISPLAY" not in os.environ:
    try:
        import matplotlib
    except ImportError:
        import warnings
        warnings.warn("matplotlib not found", ImportWarning)
    else:
        matplotlib.use("Agg")


__all__ = [
    "registry",
    "ModelParameterDictionary",
    "MissingKeyError",
    "ParameterValueError",
    "Component",
    "Palette",
    "Arena",
    "NoProvidersError",
    "Implements",
    "ImplementsOrRaise",
    "Framework",
    "FieldError",
    "LandlabTester",
    "load_params",
    "ModelGrid",
    "HexModelGrid",
    "RadialModelGrid",
    "RasterModelGrid",
    "VoronoiDelaunayGrid",
    "BAD_INDEX_VALUE",
    "CORE_NODE",
    "FIXED_VALUE_BOUNDARY",
    "FIXED_GRADIENT_BOUNDARY",
    "LOOPED_BOUNDARY",
    "CLOSED_BOUNDARY",
    "ACTIVE_LINK",
    "FIXED_LINK",
    "INACTIVE_LINK",
    "create_and_initialize_grid",
    "imshow_grid",
    "imshow_node_grid",
    "imshow_cell_grid",
    "imshow_grid_at_node",
    "analyze_channel_network_and_plot",
]

__version__ = get_versions()["version"]
del get_versions

@@ -327,17 +327,16 @@
 MIT%0A%22%22%22%0A
-%0A
 from __f
@@ -367,16 +367,97 @@
 import%0A%0A
+if %22DISPLAY%22 not in os.environ:%0A    import matplotlib%0A    matplotlib.use(%22Agg%22)%0A%0A
 import o
@@ -1638,225 +1638,8 @@
 ns%0A%0A
-if %22DISPLAY%22 not in os.environ:%0A    try:%0A        import matplotlib%0A    except ImportError:%0A        import warnings%0A        warnings.warn(%22matplotlib not found%22, ImportWarning)%0A    else:%0A        matplotlib.use(%22Agg%22)%0A%0A
 %0A__a

Set matplotlib backend before anything else.