From 28ec9339b048a2598b80b3aa427404e48d863583 Mon Sep 17 00:00:00 2001 From: Flavio Schneider Date: Thu, 8 Sep 2022 11:55:47 +0200 Subject: [PATCH] fix: replace prod not supported py3.7 --- audio_diffusion_pytorch/model.py | 3 +-- audio_diffusion_pytorch/utils.py | 5 +++++ setup.py | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/audio_diffusion_pytorch/model.py b/audio_diffusion_pytorch/model.py index 0860929..53830ea 100644 --- a/audio_diffusion_pytorch/model.py +++ b/audio_diffusion_pytorch/model.py @@ -1,5 +1,4 @@ import random -from math import prod from typing import Optional, Sequence, Union import torch @@ -16,7 +15,7 @@ Schedule, ) from .modules import Encoder1d, ResnetBlock1d, UNet1d -from .utils import default, to_list +from .utils import default, prod, to_list """ Diffusion Classes (generic for 1d data) """ diff --git a/audio_diffusion_pytorch/utils.py b/audio_diffusion_pytorch/utils.py index 48d80c4..ec38653 100644 --- a/audio_diffusion_pytorch/utils.py +++ b/audio_diffusion_pytorch/utils.py @@ -1,3 +1,4 @@ +from functools import reduce from inspect import isfunction from typing import Callable, List, Optional, Sequence, TypeVar, Union @@ -30,3 +31,7 @@ def to_list(val: Union[T, Sequence[T]]) -> List[T]: if isinstance(val, list): return val return [val] # type: ignore + + +def prod(vals: Sequence[int]) -> int: + return reduce(lambda x, y: x * y, vals) diff --git a/setup.py b/setup.py index 4339d90..83cd055 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ setup( name="audio-diffusion-pytorch", packages=find_packages(exclude=[]), - version="0.0.25", + version="0.0.26", license="MIT", description="Audio Diffusion - PyTorch", long_description_content_type="text/markdown",