Skip to content

Commit

Permalink
delayed import from numpy (via scikit-image)
Browse files Browse the repository at this point in the history
ImportError: cannot import name '_validate_lengths' from 'numpy.lib.arraypad'
  • Loading branch information
sdpython committed Mar 2, 2019
1 parent 4b8fe85 commit 13cf599
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
12 changes: 2 additions & 10 deletions _unittests/ut_art/test_video_download.py
Expand Up @@ -7,8 +7,7 @@
import sys
import os
import unittest
from pyquickhelper.loghelper import fLOG
from pyquickhelper.pycode import get_temp_folder, ExtTestCase, is_travis_or_appveyor
from pyquickhelper.pycode import get_temp_folder, ExtTestCase, is_travis_or_appveyor, skipif_circleci


try:
Expand All @@ -30,15 +29,8 @@

class TestVideoDownload(ExtTestCase):

@skipif_circleci("unexpected error: KeyError: 'url_encoded_fmt_stream_map'")
def test_video_download(self):
fLOG(
__file__,
self._testMethodName,
OutputPrint=__name__ == "__main__")

if is_travis_or_appveyor() == "circleci":
# unexpected error: KeyError: 'url_encoded_fmt_stream_map'
return
temp = get_temp_folder(__file__, "temp_video_download")
download_youtube_video('vHcfbOqYztU', output_path=temp)
exp = os.path.join(temp, "vidéo tres courte.mp4")
Expand Down
3 changes: 2 additions & 1 deletion src/code_beatrix/art/video.py
Expand Up @@ -21,7 +21,6 @@
from moviepy.video.compositing.concatenate import concatenate_videoclips
from moviepy.audio.AudioClip import concatenate_audioclips, AudioArrayClip
from PIL import Image, ImageFont, ImageDraw
from skimage.io._plugins.pil_plugin import pil_to_ndarray
from skimage.transform import rescale
from .moviepy_context import AudioContext, VideoContext, get_wrapped, clean_video

Expand Down Expand Up @@ -726,6 +725,7 @@ def video_image(image_or_file, duration=None, zoom=None, opacity=None, **kwargs)
raise ValueError(
"Image is not RGB or RGBA shape={0}".format(img.shape))
if img.shape[2] == 3:
from skimage.io._plugins.pil_plugin import pil_to_ndarray
pilimg = Image.fromarray(img).convert('RGBA')
img = pil_to_ndarray(pilimg)
if opacity is None:
Expand All @@ -738,6 +738,7 @@ def video_image(image_or_file, duration=None, zoom=None, opacity=None, **kwargs)
raise TypeError("opacity should be int or float or None")
return ImageClip(img, duration=duration, transparent=True, **kwargs)
elif isinstance(image_or_file, Image.Image):
from skimage.io._plugins.pil_plugin import pil_to_ndarray
if image_or_file.mode != 'RGBA':
image_or_file = image_or_file.convert('RGBA')
if zoom is not None:
Expand Down

0 comments on commit 13cf599

Please sign in to comment.