From 01f207aa49b5726a8b02f07f2bfc9641f48fa71f Mon Sep 17 00:00:00 2001 From: Gloin1313 Date: Thu, 2 Mar 2017 15:56:20 +0000 Subject: [PATCH] `Colorclip` changed `col`>`color` (#424) * Changed the `col` paramater of `ColorClip` to `color` and added a DeprecationWarning if the users tries to use `col` * Update VideoFileClip.py * Added warnings * Update (#3) * Fixed copy-paste typo Changed documentation for the color parameter to distinguish from bg_color * Fixed missing list (using python 3) * fixed module hierarchy for Trajectory * fixed addy * small recipe * on_color function docstring has wrong parameter The docstring for the on_color method has a parameter of bg_color but the function uses color as the parameter. * Update README.rst Changed Code Block to use Python Syntax Highlighting * fix deprecation message currently, the docstring is nonsense. ``` The function ``concatenate_videoclips`` is deprecated and is kept temporarily for backwards compatibility. Please use the new name, ``concatenate_videoclips``, instead. ``` * ImageSequenceClip: Check for fps and durations rather than fps and duration * Add a test case. * Add another test * ensures int arguments to np.reshape; closes #383 * fix issue #401 * fix issue #335 * Update maintainer section in README * make concatenate_videoclips Python 3 compatible.. fix issue #313 * Increment release version * CompositeVideoClip doesn't accept an argument of transparent * move PY3 variable to compat.py * fix movie => moviepy typo * fix issue #341 * Fixed typo #375 https://github.com/Zulko/moviepy/issues/375 fixed * fix issue #357, which makes real problem more obvious (media file does not exist * Revert "small recipe (mirroring a video)" * Fixed indentation * .gitignore ignore Mac-specific files, Jetbrains settings dir * README.rst make mention of Gitter, add PyPI and Gitter badge * README.rst wording, formatting * README.rst structure link targets, add co-maintainers (with @username) * README.rst move maintainers, contributing sections; change docs x-reference name * README.rst fix grammar * fix issue 145. raise Exception when concatenate method != chain or compose * make PEP8 compatible * fix PR #413 . (issue #357) * create test for issue #145 * add tests/media to .gitignore * fix Issue #385 , no DirectoryClip class (#434) * fix issue #385 , no DirectoryClip class * replace DirectoryClip with ImageSequenceClip * fix issue 417, unicode has no attribute 'shape' error. * add test for issue 417 * add test for issue 417 * Fixed resize documentation issue #319 (#346) * Handle bytes when listing fonts in VideoClip.py (#306) Handle bytes when listing fonts in VideoClip.py * add test for PR306 * add test for PR306 (#440) * create test file for pull requests (#433) * Test issue 407 (video has a valid fps after concatenate function) (#443) * Move PR test to test_PR.py file (#444) * move PR test from test_issues.py to test_PR.py * add code to download python_logo.png * remove duplicate test_issue_417 function * add testing with travis-ci (#447) added testing via travis-ci * put DEVNULL into compat.py (#432) * add travis-ci badge to readme file * pick highest fps when concatenating (#416) * readers.py cast chunksize from float to int * choose highest fps of clips when concatenating * pick highest fps when concatenating * pick highest fps when concatenating * fps either max or none * remove resolve markers removed resolve markers such as HEAD, etc so that the file will compile correctly. Remove some double blank lines, etc * update concatenate.py; add c.fps is not None * add test for issue 416 * fix test_issue_416 * Update Gloin (#4) * Fixed copy-paste typo Changed documentation for the color parameter to distinguish from bg_color * Fixed missing list (using python 3) * fixed module hierarchy for Trajectory * fixed addy * small recipe * on_color function docstring has wrong parameter The docstring for the on_color method has a parameter of bg_color but the function uses color as the parameter. * Update README.rst Changed Code Block to use Python Syntax Highlighting * fix deprecation message currently, the docstring is nonsense. ``` The function ``concatenate_videoclips`` is deprecated and is kept temporarily for backwards compatibility. Please use the new name, ``concatenate_videoclips``, instead. ``` * ImageSequenceClip: Check for fps and durations rather than fps and duration * Add a test case. * Add another test * ensures int arguments to np.reshape; closes #383 * fix issue #401 * fix issue #335 * Update maintainer section in README * make concatenate_videoclips Python 3 compatible.. fix issue #313 * Increment release version * CompositeVideoClip doesn't accept an argument of transparent * move PY3 variable to compat.py * fix movie => moviepy typo * fix issue #341 * Fixed typo #375 https://github.com/Zulko/moviepy/issues/375 fixed * fix issue #357, which makes real problem more obvious (media file does not exist * Revert "small recipe (mirroring a video)" * Fixed indentation * .gitignore ignore Mac-specific files, Jetbrains settings dir * README.rst make mention of Gitter, add PyPI and Gitter badge * README.rst wording, formatting * README.rst structure link targets, add co-maintainers (with @username) * README.rst move maintainers, contributing sections; change docs x-reference name * README.rst fix grammar * fix issue 145. raise Exception when concatenate method != chain or compose * make PEP8 compatible * fix PR #413 . (issue #357) * create test for issue #145 * add tests/media to .gitignore * fix Issue #385 , no DirectoryClip class (#434) * fix issue #385 , no DirectoryClip class * replace DirectoryClip with ImageSequenceClip * fix issue 417, unicode has no attribute 'shape' error. * add test for issue 417 * add test for issue 417 * Fixed resize documentation issue #319 (#346) * Handle bytes when listing fonts in VideoClip.py (#306) Handle bytes when listing fonts in VideoClip.py * add test for PR306 * add test for PR306 (#440) * create test file for pull requests (#433) * Test issue 407 (video has a valid fps after concatenate function) (#443) * Move PR test to test_PR.py file (#444) * move PR test from test_issues.py to test_PR.py * add code to download python_logo.png * remove duplicate test_issue_417 function * add testing with travis-ci (#447) added testing via travis-ci * put DEVNULL into compat.py (#432) * add travis-ci badge to readme file * pick highest fps when concatenating (#416) * readers.py cast chunksize from float to int * choose highest fps of clips when concatenating * pick highest fps when concatenating * pick highest fps when concatenating * fps either max or none * remove resolve markers removed resolve markers such as HEAD, etc so that the file will compile correctly. Remove some double blank lines, etc * update concatenate.py; add c.fps is not None * add test for issue 416 * fix test_issue_416 * Update VideoFileClip.py * Added test * Added return for PEP 8 compliance * Change --- moviepy/video/VideoClip.py | 20 ++++++++++++++++---- tests/test_PR.py | 10 ++++++++++ 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/moviepy/video/VideoClip.py b/moviepy/video/VideoClip.py index 6a7a6c8ec..73266242a 100644 --- a/moviepy/video/VideoClip.py +++ b/moviepy/video/VideoClip.py @@ -10,6 +10,7 @@ import multiprocessing import tempfile from copy import copy +import warnings from tqdm import tqdm import numpy as np @@ -1031,13 +1032,24 @@ class ColorClip(ImageClip): ismask Set to true if the clip will be used as a mask. - """ + col + Has been deprecated. Do not use. + """ - def __init__(self, size, col=(0, 0, 0), ismask=False, duration=None): + def __init__(self, size, color=None, ismask=False, duration=None, col=None): + if col is not None: + warnings.warn("The `ColorClip` parameter `col` has been deprecated." + " Please use `color` instead", DeprecationWarning) + if color is not None: + warnings.warn("The arguments `color` and `col` have both been " + "passed to `ColorClip` so `col` has been ignored.", + UserWarning) + else: + color = col w, h = size - shape = (h, w) if np.isscalar(col) else (h, w, len(col)) - ImageClip.__init__(self, np.tile(col, w * h).reshape(shape), + shape = (h, w) if np.isscalar(color) else (h, w, len(color)) + ImageClip.__init__(self, np.tile(color, w * h).reshape(shape), ismask=ismask, duration=duration) diff --git a/tests/test_PR.py b/tests/test_PR.py index cbb4f2d6f..36583ae81 100644 --- a/tests/test_PR.py +++ b/tests/test_PR.py @@ -32,5 +32,15 @@ def test_PR_339(): #overlay = TextClip(txt='foo', method='label') pass + +def test_PR_424(): + # Recommended use + clip = ColorClip([1000, 600], color=(60, 60, 60), duration=10) + # Uses `col` so should work the same as above, but give warning + clip = ColorClip([1000, 600], col=(60, 60, 60), duration=10) + # Should give 2 warnings and use `color`, not `col` + clip = ColorClip([1000, 600], color=(60, 60, 60), duration=10, col=(2,2,2)) + + if __name__ == '__main__': pytest.main()