Menu

Helper Module for Deep Learning.

Source code for pynet.augmentation.utils

# -*- coding: utf-8 -*-
##########################################################################
# NSAp - Copyright (C) CEA, 2020
# Distributed under the terms of the CeCILL-B license, as published by
# the CEA-CNRS-INRIA. Refer to the LICENSE file or to
# http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
# for details.
##########################################################################


"""
A module with common functions.
"""

# Import
import numbers


[docs]def interval(obj, lower=None): """ Listify an object. Parameters ---------- obj: 2-uplet or number the object used to build the interval. lower: number, default None the lower bound of the interval. If not specified, a symetric interval is generated. Returns ------- interval: 2-uplet an interval. """ if isinstance(obj, numbers.Number): if obj < 0: raise ValueError("Specified interval value must be positive.") if lower is None: lower = -obj return (lower, obj) if len(obj) != 2: raise ValueError("Interval must be specified with 2 values.") min_val, max_val = obj if min_val > max_val: raise ValueError("Wrong interval boudaries.") return tuple(obj)

Follow us

© 2019, pynet developers .
Inspired by AZMIND template.