Skip to content
Permalink
Browse files

delayed import from numpy (via scikit-image)

ImportError: cannot import name '_validate_lengths' from 'numpy.lib.arraypad'
  • Loading branch information...
sdpython committed Mar 2, 2019
1 parent 4b8fe85 commit 13cf599df15cd62b15d4eb6c6ec5ba2f012d7ecb
Showing with 4 additions and 11 deletions.
  1. +2 −10 _unittests/ut_art/test_video_download.py
  2. +2 −1 src/code_beatrix/art/video.py
@@ -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:
@@ -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")
@@ -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

@@ -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:
@@ -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:

0 comments on commit 13cf599

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.