Skip to content

Commit

Permalink
Clean up submodule imports/mocks. Add comment to conf.py
Browse files Browse the repository at this point in the history
  • Loading branch information
teabolt committed Jun 14, 2019
1 parent 41b7aa6 commit 382f572
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
15 changes: 7 additions & 8 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def __getattr__(cls, name):
return Mock()


# Note that we must import all sub-modules too
MOCK_MODULES = [
'lightning',
'lightning.impl',
Expand All @@ -48,18 +49,16 @@ def __getattr__(cls, name):
'xgboost',
'lightgbm',
'catboost',
'pandas',
'pytest',
'PIL',
'matplotlib.pyplot',
'matplotlib',
'matplotlib.cm',
'keras',
'keras.backend',
'keras.models',
'keras.layers',
'keras.preprocessing',
'keras.preprocessing.image'
'pandas',
'PIL',
'matplotlib',
'matplotlib.pyplot',
'matplotlib.cm',
'pytest',
]
sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES)

Expand Down
5 changes: 2 additions & 3 deletions eli5/keras.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from typing import Optional, Union, Callable, Tuple
from typing import Union, Optional, Callable, Tuple

import numpy as np # type: ignore
import keras # type: ignore
import keras.backend as K # type: ignore
from keras.models import Model # type: ignore
from keras.layers import Layer, Lambda # type: ignore
from keras.preprocessing.image import load_img, img_to_array, array_to_img # type: ignore

from eli5.base import Explanation
from eli5.explain import explain_prediction
Expand Down Expand Up @@ -359,7 +358,7 @@ def image_from_path(img_path, image_shape=None):
# TODO: Take in PIL image object, or an array
# "pipeline": path str -> PIL image -> numpy array
# TODO: multiple images
im = load_img(img_path, target_size=image_shape)
im = keras.preprocessing.image.load_img(img_path, target_size=image_shape)
x = img_to_array(im)

# we need to insert an axis at the 0th position to indicate the batch size (required by the model's input)
Expand Down

0 comments on commit 382f572

Please sign in to comment.