Skip to content

Commit

Permalink
Black whitespace changes
Browse files Browse the repository at this point in the history
  • Loading branch information
tburrows13 committed Oct 1, 2020
1 parent 6dc5317 commit cff36b7
Show file tree
Hide file tree
Showing 52 changed files with 309 additions and 270 deletions.
8 changes: 4 additions & 4 deletions ez_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,10 @@ def download_setuptools(

def _extractall(self, path=".", members=None):
"""Extract all members from the archive to the current working
directory and set owner, modification time and permissions on
directories afterwards. `path' specifies a different directory
to extract to. `members' is optional and must be a subset of the
list returned by getmembers().
directory and set owner, modification time and permissions on
directories afterwards. `path' specifies a different directory
to extract to. `members' is optional and must be a subset of the
list returned by getmembers().
"""
import copy
import operator
Expand Down
42 changes: 21 additions & 21 deletions moviepy/Clip.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,25 @@ class Clip:

"""
Base class of all clips (VideoClips and AudioClips).
Base class of all clips (VideoClips and AudioClips).
Attributes
-----------
Attributes
-----------
start:
When the clip is included in a composition, time of the
composition at which the clip starts playing (in seconds).
start:
When the clip is included in a composition, time of the
composition at which the clip starts playing (in seconds).
end:
When the clip is included in a composition, time of the
composition at which the clip stops playing (in seconds).
end:
When the clip is included in a composition, time of the
composition at which the clip stops playing (in seconds).
duration:
Duration of the clip (in seconds). Some clips are infinite, in
this case their duration will be ``None``.
duration:
Duration of the clip (in seconds). Some clips are infinite, in
this case their duration will be ``None``.
"""
"""

# prefix for all temporary video and audio files.
# You can overwrite it with
Expand All @@ -60,8 +60,8 @@ def __init__(self):
self.memoize_frame = None

def copy(self):
""" Shallow copy of the clip.
"""Shallow copy of the clip.
Returns a shallow copy of the clip whose mask and audio will
be shallow copies of the clip's mask and audio if they exist.
Expand Down Expand Up @@ -98,7 +98,7 @@ def get_frame(self, t):
return self.make_frame(t)

def fl(self, fun, apply_to=None, keep_duration=True):
""" General processing of a clip.
"""General processing of a clip.
Returns a new Clip whose frames are a transformation
(through function ``fun``) of the frames of the current clip.
Expand Down Expand Up @@ -300,8 +300,8 @@ def set_make_frame(self, make_frame):

@outplace
def set_fps(self, fps):
""" Returns a copy of the clip with a new default fps for functions like
write_videofile, iterframe, etc. """
"""Returns a copy of the clip with a new default fps for functions like
write_videofile, iterframe, etc."""
self.fps = fps

@outplace
Expand Down Expand Up @@ -440,7 +440,7 @@ def cutout(self, ta, tb):
@requires_duration
@use_clip_fps_by_default
def iter_frames(self, fps=None, with_times=False, logger=None, dtype=None):
""" Iterates over all the frames of the clip.
"""Iterates over all the frames of the clip.
Returns each frame of the clip as a HxWxN np.array,
where N=1 for mask clips and N=3 for RGB clips.
Expand Down Expand Up @@ -479,8 +479,8 @@ def iter_frames(self, fps=None, with_times=False, logger=None, dtype=None):
yield frame

def close(self):
"""
Release any resources that are in use.
"""
Release any resources that are in use.
"""

# Implementation note for subclasses:
Expand Down
59 changes: 29 additions & 30 deletions moviepy/audio/AudioClip.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,37 @@


class AudioClip(Clip):
""" Base class for audio clips.
"""Base class for audio clips.
See ``AudioFileClip`` and ``CompositeSoundClip`` for usable classes.
An AudioClip is a Clip with a ``make_frame`` attribute of
the form `` t -> [ f_t ]`` for mono sound and
``t-> [ f1_t, f2_t ]`` for stereo sound (the arrays are Numpy arrays).
The `f_t` are floats between -1 and 1. These bounds can be
trespassed without problems (the program will put the
sound back into the bounds at conversion time, without much impact).
sound back into the bounds at conversion time, without much impact).
Parameters
-----------
make_frame
A function `t-> frame at time t`. The frame does not mean much
for a sound, it is just a float. What 'makes' the sound are
the variations of that float in the time.
nchannels
Number of channels (one or two for mono or stereo).
Examples
---------
>>> # Plays the note A (a sine wave of frequency 440HZ)
>>> import numpy as np
>>> make_frame = lambda t: 2*[ np.sin(440 * 2 * np.pi * t) ]
>>> clip = AudioClip(make_frame, duration=5)
>>> clip.preview()
"""

def __init__(self, make_frame=None, duration=None, fps=None):
Expand Down Expand Up @@ -70,8 +70,7 @@ def iter_chunks(
nbytes=2,
logger=None,
):
""" Iterator that returns the whole sound array of the clip by chunks
"""
"""Iterator that returns the whole sound array of the clip by chunks"""
if fps is None:
fps = self.fps
logger = proglog.default_bar_logger(logger)
Expand Down Expand Up @@ -99,18 +98,18 @@ def to_soundarray(
"""
Transforms the sound into an array that can be played by pygame
or written in a wav file. See ``AudioClip.preview``.
Parameters
------------
fps
Frame rate of the sound for the conversion.
44100 for top quality.
nbytes
Number of bytes to encode the sound: 1 for 8bit sound,
2 for 16bit, 4 for 32bit sound.
"""
if fps is None:
fps = self.fps
Expand Down Expand Up @@ -172,7 +171,7 @@ def write_audiofile(
write_logfile=False,
logger="bar",
):
""" Writes an audio file from the AudioClip.
"""Writes an audio file from the AudioClip.
Parameters
Expand Down Expand Up @@ -206,7 +205,7 @@ def write_audiofile(
write_logfile
If true, produces a detailed logfile named filename + '.log'
when writing the file
logger
Either 'bar' or None or any Proglog logger
Expand Down Expand Up @@ -244,20 +243,20 @@ def write_audiofile(

class AudioArrayClip(AudioClip):
"""
An audio clip made from a sound array.
Parameters
-----------
array
A Numpy array representing the sound, of size Nx1 for mono,
Nx2 for stereo.
fps
Frames per second : speed at which the sound is supposed to be
played.
"""

def __init__(self, array, fps):
Expand All @@ -268,8 +267,8 @@ def __init__(self, array, fps):
self.duration = 1.0 * len(array) / fps

def make_frame(t):
""" complicated, but must be able to handle the case where t
is a list of the form sin(t) """
"""complicated, but must be able to handle the case where t
is a list of the form sin(t)"""

if isinstance(t, np.ndarray):
array_inds = np.round(self.fps * t).astype(int)
Expand All @@ -289,18 +288,18 @@ def make_frame(t):


class CompositeAudioClip(AudioClip):
""" Clip made by composing several AudioClips.
"""Clip made by composing several AudioClips.
An audio clip made by putting together several audio clips.
Parameters
------------
clips
List of audio clips, which may start playing at different times or
together. If all have their ``duration`` attribute set, the
duration of the composite clip is computed automatically.
"""

def __init__(self, clips):
Expand Down
4 changes: 2 additions & 2 deletions moviepy/audio/fx/audio_fadein.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

@audio_video_fx
def audio_fadein(clip, duration):
""" Return an audio (or video) clip that is first mute, then the
sound arrives progressively over ``duration`` seconds. """
"""Return an audio (or video) clip that is first mute, then the
sound arrives progressively over ``duration`` seconds."""

def fading(gf, t):
gft = gf(t)
Expand Down
4 changes: 2 additions & 2 deletions moviepy/audio/fx/audio_fadeout.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
@audio_video_fx
@requires_duration
def audio_fadeout(clip, duration):
""" Return a sound clip where the sound fades out progressively
over ``duration`` seconds at the end of the clip. """
"""Return a sound clip where the sound fades out progressively
over ``duration`` seconds at the end of the clip."""

def fading(gf, t):
gft = gf(t)
Expand Down
4 changes: 2 additions & 2 deletions moviepy/audio/fx/audio_left_right.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

def audio_left_right(audioclip, left=1, right=1, merge=False):
"""
NOT YET FINISHED
NOT YET FINISHED
For a stereo audioclip, this function enables to change the volume
of the left and right channel separately (with the factors `left`
and `right`)
Expand Down
2 changes: 1 addition & 1 deletion moviepy/audio/fx/audio_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


def audio_loop(audioclip, nloops=None, duration=None):
""" Loops over an audio clip.
"""Loops over an audio clip.
Returns an audio clip that plays the given clip either
`nloops` times, or during `duration` seconds.
Expand Down
2 changes: 1 addition & 1 deletion moviepy/audio/fx/audio_normalize.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

@audio_video_fx
def audio_normalize(clip):
""" Return a clip whose volume is normalized to 0db.
"""Return a clip whose volume is normalized to 0db.
Return an audio (or video) clip whose audio volume is normalized
so that the maximum volume is at 0db, the maximum achievable volume.
Expand Down
2 changes: 1 addition & 1 deletion moviepy/audio/fx/volumex.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

@audio_video_fx
def volumex(clip, factor):
""" Returns a clip with audio volume multiplied by the
"""Returns a clip with audio volume multiplied by the
value `factor`. Can be applied to both audio and video clips.
This effect is loaded as a clip method when you use moviepy.editor,
Expand Down
6 changes: 3 additions & 3 deletions moviepy/audio/io/AudioFileClip.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ def __init__(self, filename, buffersize=200000, nbytes=2, fps=44100):
self.nchannels = self.reader.nchannels

def coreader(self):
""" Returns a copy of the AudioFileClip, i.e. a new entrance point
to the audio file. Use copy when you have different clips
watching the audio file at different times. """
"""Returns a copy of the AudioFileClip, i.e. a new entrance point
to the audio file. Use copy when you have different clips
watching the audio file at different times."""
return AudioFileClip(self.filename, self.buffersize)

def close(self):
Expand Down
4 changes: 2 additions & 2 deletions moviepy/audio/tools/cuts.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@


def find_audio_period(aclip, t_min=0.1, t_max=2, t_res=0.01):
""" Finds the period, in seconds of an audioclip.
"""Finds the period, in seconds of an audioclip.
The beat is then given by bpm = 60/T
t_min and _tmax are bounds for the returned value, t_res
Expand Down
12 changes: 6 additions & 6 deletions moviepy/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ def convert_masks_to_RGB(f, clip, *a, **k):

@decorator.decorator
def apply_to_mask(f, clip, *a, **k):
""" This decorator will apply the same function f to the mask of
the clip created with f """
"""This decorator will apply the same function f to the mask of
the clip created with f"""

newclip = f(clip, *a, **k)
if getattr(newclip, "mask", None):
Expand All @@ -37,8 +37,8 @@ def apply_to_mask(f, clip, *a, **k):

@decorator.decorator
def apply_to_audio(f, clip, *a, **k):
""" This decorator will apply the function f to the audio of
the clip created with f """
"""This decorator will apply the function f to the audio of
the clip created with f"""

newclip = f(clip, *a, **k)
if getattr(newclip, "audio", None):
Expand All @@ -58,8 +58,8 @@ def requires_duration(f, clip, *a, **k):

@decorator.decorator
def audio_video_fx(f, clip, *a, **k):
""" Use an audio function on a video/audio clip
"""Use an audio function on a video/audio clip
This decorator tells that the function f (audioclip -> audioclip)
can be also used on a video clip, at which case it returns a
videoclip with unmodified video and modified audio.
Expand Down
Loading

0 comments on commit cff36b7

Please sign in to comment.