Skip to content

Commit

Permalink
feature 140 fix import of hovmoeller (#197)
Browse files Browse the repository at this point in the history
* ignore pycache files

* fix import of config

* fix import of constants

* added test to ensure import of subset of package works correctly. The import tests are based on how the package is imported in real examples such as METplus use cases

* changed imports to be relative to package so that all imports will still work. METplotpy/metplotpy does not need to be added to python path to find the files in the package. updated pytests so that they do not have import errors

* changed scripts that will be called directly to use full paths to imports of metplotpy functions instead of relative paths -- relative paths are not allowed when calling a script directly

* removed pycache files from repo

* added missing dunder init file

* added another missing dunder init file

* added another missing dunder init file

* changed more imports

* added another pytest for the import commands used in another METplus use case

* get correct path to config file even if pytest is run outside of the test/hovmoeller directory

* change output directory to the current directory, which corresponds to the directory where the test resides

* while testing Issue #140, found input data directory setting is pointing to a non-existent directory

* while testing Issue #140 fixed the imports for this test

* Update base_plot.py

proposed change to provide more consistency with imports in other plots

* modifications based on changes to the base_plot.py code

* changes to test based on updates to base_plot.py

* updates based on changes to base_plot.py

* updates based on changes to base_plot.py

* Revert "while testing Issue #140 fixed the imports for this test"

This reverts commit c5efd2b.

* fixed relative import

* issue #140 update test to reflect change to base_plot.py

* issue #140 update test to reflect change to base_plot.py

* reorganized tests based on plot type

* Moved to appropriate sub-directories

* Moved to appropriate sub-directory

* Moved to subdirectory

* issue #140 update test to reflect change to base_plot.py and directory structure

* issue #140 reverted to original directory structure

* #140 skip test, requires large dataset and special packages

* #140 tests skipped, need updating to reflect changes to the histogram code

* only a test fixture in this file, but updated the METPLOTPY_BASE to reflect changes to base_plot.py

* #140 updates to test to reflect changes to base_plot.py

* #140 updated test to reflect change to base_plot.py

* #140 update to reflect change to base_plot.py

* #140 skipping, these tests require different packages and large sample datasets

* #140 fixed import, tests are skipped-they require special packages and data

* #140 update to reflect change in base_plot.py

* #140 modifications to order of tests and skip image testing to allow proper cleanup.  Image test is not a reliable way to test if the generated image matches to an expected image due to differences between machines

* #140 scikit image error, skipping image comparison

* #140 skip image comparison- depends on which machine this test is running

* #140 skip image comparison- depends on which machine is running this test

* #140 removed unused imports

* #140 removed unused import to sys

* #140 remove unused import of sys

* #140 remove unused import of sys

* #140 remove unused import to sys

* #140 remove unused sys import

* #140 remove unused imports for sys and pytest

* #140 skip image comparison, fails on linux hosts

* #140 skip image comparison

* #140 skip image comparison

* #140 skip image comparison

* #140 skip image comparison

* #140 skip image comparison

Co-authored-by: MET Tools Test Account <[email protected]>
Co-authored-by: Minna Win <[email protected]>
Co-authored-by: bikegeek <[email protected]>
Co-authored-by: bikegeek <[email protected]>
  • Loading branch information
5 people authored Feb 17, 2022
1 parent 64df6ab commit 4633689
Show file tree
Hide file tree
Showing 82 changed files with 332 additions and 280 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ docs/_build

docs/examples/*


__pycache__/
Empty file.
10 changes: 5 additions & 5 deletions metplotpy/plots/bar/bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
from plotly.subplots import make_subplots
from plotly.graph_objects import Figure

from plots.constants import PLOTLY_AXIS_LINE_COLOR, PLOTLY_AXIS_LINE_WIDTH, PLOTLY_PAPER_BGCOOR
from plots.bar.bar_config import BarConfig
from plots.bar.bar_series import BarSeries
from plots.base_plot import BasePlot
import plots.util as util
from metplotpy.plots.constants import PLOTLY_AXIS_LINE_COLOR, PLOTLY_AXIS_LINE_WIDTH, PLOTLY_PAPER_BGCOOR
from metplotpy.plots.bar.bar_config import BarConfig
from metplotpy.plots.bar.bar_series import BarSeries
from metplotpy.plots.base_plot import BasePlot
from metplotpy.plots import util

import metcalcpy.util.utils as calc_util

Expand Down
6 changes: 3 additions & 3 deletions metplotpy/plots/bar/bar_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

import itertools

from plots.config import Config
import plots.constants as constants
import plots.util as util
from ..config import Config
from .. import constants
from .. import util

import metcalcpy.util.utils as utils

Expand Down
4 changes: 2 additions & 2 deletions metplotpy/plots/bar/bar_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
from pandas import DataFrame

import metcalcpy.util.utils as utils
from plots import GROUP_SEPARATOR
from .. import GROUP_SEPARATOR

from plots.series import Series
from ..series import Series


class BarSeries(Series):
Expand Down
4 changes: 2 additions & 2 deletions metplotpy/plots/base_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import yaml
from typing import Union

from plots.config import Config
from .config import Config


class BasePlot:
Expand Down Expand Up @@ -39,7 +39,7 @@ def __init__(self, parameters, default_conf_filename):
# Determine location of the default YAML config files and then
# read defaults stored in YAML formatted file into the dictionary
if 'METPLOTPY_BASE' in os.environ:
location = os.path.join(os.environ['METPLOTPY_BASE'], 'plots/config')
location = os.path.join(os.environ['METPLOTPY_BASE'], 'metplotpy/plots/config')
else:
location = os.path.realpath(os.path.join(os.getcwd(), '../config'))

Expand Down
10 changes: 5 additions & 5 deletions metplotpy/plots/box/box.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@

import metcalcpy.util.utils as calc_util

from plots.base_plot import BasePlot
from plots.box.box_config import BoxConfig
from plots.box.box_series import BoxSeries
import plots.util as util
from plots.constants import PLOTLY_AXIS_LINE_COLOR, PLOTLY_AXIS_LINE_WIDTH, PLOTLY_PAPER_BGCOOR
from metplotpy.plots.base_plot import BasePlot
from metplotpy.plots.box.box_config import BoxConfig
from metplotpy.plots.box.box_series import BoxSeries
from metplotpy.plots import util
from metplotpy.plots.constants import PLOTLY_AXIS_LINE_COLOR, PLOTLY_AXIS_LINE_WIDTH, PLOTLY_PAPER_BGCOOR


class Box(BasePlot):
Expand Down
6 changes: 3 additions & 3 deletions metplotpy/plots/box/box_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

import itertools

from plots.config import Config
import plots.constants as constants
import plots.util as util
from ..config import Config
from .. import constants
from .. import util

import metcalcpy.util.utils as utils

Expand Down
2 changes: 1 addition & 1 deletion metplotpy/plots/box/box_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from pandas import DataFrame

import metcalcpy.util.utils as utils
from plots.series import Series
from ..series import Series


class BoxSeries(Series):
Expand Down
2 changes: 1 addition & 1 deletion metplotpy/plots/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from typing import Union

import metcalcpy.util.utils as utils
import plots.constants as constants
from . import constants


class Config:
Expand Down
12 changes: 6 additions & 6 deletions metplotpy/plots/contour/contour.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
from plotly.subplots import make_subplots
from plotly.graph_objects import Figure

from plots.constants import PLOTLY_PAPER_BGCOOR
from plots.base_plot import BasePlot
import plots.util as util
from plots.contour.contour_config import ContourConfig
from plots.contour.contour_series import ContourSeries
from plots.series import Series
from metplotpy.plots.constants import PLOTLY_PAPER_BGCOOR
from metplotpy.plots.base_plot import BasePlot
from metplotpy.plots import util
from metplotpy.plots.contour.contour_config import ContourConfig
from metplotpy.plots.contour.contour_series import ContourSeries
from metplotpy.plots.series import Series

import metcalcpy.util.utils as calc_util

Expand Down
6 changes: 3 additions & 3 deletions metplotpy/plots/contour/contour_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"""
__author__ = 'Tatiana Burek'

from plots.config import Config
import plots.constants as constants
import plots.util as util
from ..config import Config
from .. import constants
from .. import util

import metcalcpy.util.utils as utils

Expand Down
2 changes: 1 addition & 1 deletion metplotpy/plots/contour/contour_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from typing import Union
import numpy as np

from plots.series import Series
from ..series import Series


class ContourSeries(Series):
Expand Down
14 changes: 7 additions & 7 deletions metplotpy/plots/eclv/eclv.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
import plotly.graph_objects as go

from metcalcpy.event_equalize import event_equalize
from plots.base_plot import BasePlot
from plots.constants import PLOTLY_AXIS_LINE_COLOR, PLOTLY_AXIS_LINE_WIDTH
from plots.eclv.eclv_config import EclvConfig
from plots.eclv.eclv_series import EclvSeries
from plots.line.line import Line
import plots.util as util
from plots.series import Series
from metplotpy.plots.base_plot import BasePlot
from metplotpy.plots.constants import PLOTLY_AXIS_LINE_COLOR, PLOTLY_AXIS_LINE_WIDTH
from metplotpy.plots.eclv.eclv_config import EclvConfig
from metplotpy.plots.eclv.eclv_series import EclvSeries
from metplotpy.plots.line.line import Line
from metplotpy.plots import util
from metplotpy.plots.series import Series

import metcalcpy.util.utils as calc_util

Expand Down
2 changes: 1 addition & 1 deletion metplotpy/plots/eclv/eclv_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
__author__ = 'Tatiana Burek'

import itertools
from plots.line.line_config import LineConfig
from ..line.line_config import LineConfig


class EclvConfig(LineConfig):
Expand Down
2 changes: 1 addition & 1 deletion metplotpy/plots/eclv/eclv_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from scipy.stats import norm

import metcalcpy.util.utils as utils
from plots.line.line_series import LineSeries
from ..line.line_series import LineSeries


class EclvSeries(LineSeries):
Expand Down
10 changes: 5 additions & 5 deletions metplotpy/plots/ens_ss/ens_ss.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
from plotly.graph_objects import Figure

from metcalcpy.event_equalize import event_equalize
from plots.constants import PLOTLY_AXIS_LINE_COLOR, PLOTLY_AXIS_LINE_WIDTH, PLOTLY_PAPER_BGCOOR
from plots.ens_ss.ens_ss_config import EnsSsConfig
from plots.ens_ss.ens_ss_series import EnsSsSeries
from plots.base_plot import BasePlot
import plots.util as util
from metplotpy.plots.constants import PLOTLY_AXIS_LINE_COLOR, PLOTLY_AXIS_LINE_WIDTH, PLOTLY_PAPER_BGCOOR
from metplotpy.plots.ens_ss.ens_ss_config import EnsSsConfig
from metplotpy.plots.ens_ss.ens_ss_series import EnsSsSeries
from metplotpy.plots.base_plot import BasePlot
import metplotpy.plots.util as util
import metcalcpy.util.utils as utils


Expand Down
6 changes: 3 additions & 3 deletions metplotpy/plots/ens_ss/ens_ss_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

import itertools

from plots.config import Config
import plots.constants as constants
import plots.util as util
from ..config import Config
from .. import constants
from .. import util

import metcalcpy.util.utils as utils

Expand Down
4 changes: 2 additions & 2 deletions metplotpy/plots/ens_ss/ens_ss_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
from scipy.stats import norm

import metcalcpy.util.utils as utils
from plots import GROUP_SEPARATOR
from .. import GROUP_SEPARATOR

from plots.series import Series
from ..series import Series


class EnsSsSeries(Series):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
from plotly.subplots import make_subplots
from plotly.graph_objects import Figure

from plots.constants import PLOTLY_AXIS_LINE_COLOR, PLOTLY_AXIS_LINE_WIDTH, PLOTLY_PAPER_BGCOOR
from plots.equivalence_testing_bounds.equivalence_testing_bounds_series \
from metplotpy.plots.constants import PLOTLY_AXIS_LINE_COLOR, PLOTLY_AXIS_LINE_WIDTH, PLOTLY_PAPER_BGCOOR
from metplotpy.plots.equivalence_testing_bounds.equivalence_testing_bounds_series \
import EquivalenceTestingBoundsSeries
from plots.line.line_config import LineConfig
from plots.line.line_series import LineSeries
from plots.base_plot import BasePlot
import plots.util as util
from metplotpy.plots.line.line_config import LineConfig
from metplotpy.plots.line.line_series import LineSeries
from metplotpy.plots.base_plot import BasePlot
from metplotpy.plots import util

import metcalcpy.util.utils as calc_util

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

import metcalcpy.util.utils as utils
from metcalcpy.sum_stat import calculate_statistic
from plots import GROUP_SEPARATOR
from plots.line.line_series import LineSeries
from .. import GROUP_SEPARATOR
from ..line.line_series import LineSeries


class EquivalenceTestingBoundsSeries(LineSeries):
Expand Down
13 changes: 7 additions & 6 deletions metplotpy/plots/histogram/hist.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
from plotly.subplots import make_subplots
from plotly.graph_objects import Figure

import plots.histogram.hist_config
from plots.constants import PLOTLY_AXIS_LINE_COLOR, PLOTLY_AXIS_LINE_WIDTH, PLOTLY_PAPER_BGCOOR
from plots.histogram.hist_series import HistSeries
from plots.base_plot import BasePlot
import plots.util as util
from ..histogram import hist_config
from ..constants import PLOTLY_AXIS_LINE_COLOR, PLOTLY_AXIS_LINE_WIDTH, PLOTLY_PAPER_BGCOOR
from ..histogram.hist_series import HistSeries
from ..base_plot import BasePlot
from .. import util

import metcalcpy.util.utils as utils
from metcalcpy.event_equalize import event_equalize

Expand Down Expand Up @@ -48,7 +49,7 @@ def __init__(self, parameters: dict) -> None:
# instantiate a HistogramConfig object, which holds all the necessary settings from the
# config file that represents the BasePlot object.
self.config_obj = \
getattr(sys.modules['plots.histogram.hist_config'],
getattr(sys.modules['hist_config'],
self.config_obj_name)(self.parameters)

# Check that we have all the necessary settings for each ser
Expand Down
6 changes: 3 additions & 3 deletions metplotpy/plots/histogram/hist_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

import itertools

from plots.config import Config
import plots.constants as constants
import plots.util as util
from ..config import Config
from .. import constants
from .. import util

import metcalcpy.util.utils as utils

Expand Down
2 changes: 1 addition & 1 deletion metplotpy/plots/histogram/hist_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import numpy as np

import metcalcpy.util.utils as utils
from plots.series import Series
from ..series import Series


class HistSeries(Series):
Expand Down
2 changes: 1 addition & 1 deletion metplotpy/plots/histogram/histogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import pandas as pd
import numpy as np

from plots.base_plot import BasePlot
from metplotpy.plots.base_plot import BasePlot


class Histogram(BasePlot):
Expand Down
6 changes: 3 additions & 3 deletions metplotpy/plots/histogram/prob_hist.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
from typing import Union
import yaml

from plots.histogram.hist import Hist
from plots.histogram.hist_series import HistSeries
import plots.util as util
from metplotpy.plots.histogram.hist import Hist
from metplotpy.plots.histogram.hist_series import HistSeries
from metplotpy.plots import util


class ProbHist(Hist):
Expand Down
6 changes: 3 additions & 3 deletions metplotpy/plots/histogram/rank_hist.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

import yaml

from plots.histogram.hist import Hist
import plots.util as util
from plots.histogram.hist_series import HistSeries
from metplotpy.plots.histogram.hist import Hist
from metplotpy.plots import util
from metplotpy.plots.histogram.hist_series import HistSeries


class RankHist(Hist):
Expand Down
7 changes: 3 additions & 4 deletions metplotpy/plots/histogram/rel_hist.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@

import yaml

import plots.util as util
from plots.histogram.hist import Hist

from plots.histogram.hist_series import HistSeries
from metplotpy.plots import util
from metplotpy.plots.histogram.hist import Hist
from metplotpy.plots.histogram.hist_series import HistSeries


class RelHist(Hist):
Expand Down
Empty file.
5 changes: 3 additions & 2 deletions metplotpy/plots/histogram_2d/histogram_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@
import yaml
import xarray as xr
import plotly.graph_objects as go
import plots.util as util

from .. import util

"""
Import BasePlot class
"""
from plots.base_plot import BasePlot
from ..base_plot import BasePlot


class Histogram_2d(BasePlot):
Expand Down
4 changes: 1 addition & 3 deletions metplotpy/plots/hovmoeller/hovmoeller.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
"""
Import BasePlot class
"""
#from ..base_plot import BasePlot
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir)))
from base_plot import BasePlot
from metplotpy.plots.base_plot import BasePlot


class Hovmoeller(BasePlot):
Expand Down
Loading

0 comments on commit 4633689

Please sign in to comment.