def check_validity(self):
        """
        Raise an error if any invalid attribute found.

        Raises
        ------
        TypeError
            If an attribute has an invalid type.
        ValueError
            If an attribute has an invalid value (of the correct type).

        """
        # tracks
        for track in self.tracks:
            if not isinstance(track, Track):
                raise TypeError("`tracks` must be a list of "
                                "`pypianoroll.Track` instances.")
            track.check_validity()
        # tempo
        if not isinstance(self.tempo, np.ndarray):
            raise TypeError("`tempo` must be int or a numpy array.")
        elif not np.issubdtype(self.tempo.dtype, np.number):
            raise TypeError("Data type of `tempo` must be a subdtype of "
                            "np.number.")
        elif self.tempo.ndim != 1:
            raise ValueError("`tempo` must be a 1D numpy array.")
        if np.any(self.tempo <= 0.0):
            raise ValueError("`tempo` should contain only positive numbers.")
        # downbeat
        if self.downbeat is not None:
            if not isinstance(self.downbeat, np.ndarray):
                raise TypeError("`downbeat` must be a numpy array.")
            if not np.issubdtype(self.downbeat.dtype, np.bool_):
                raise TypeError("Data type of `downbeat` must be bool.")
            if self.downbeat.ndim != 1:
                raise ValueError("`downbeat` must be a 1D numpy array.")
        # beat_resolution
        if not isinstance(self.beat_resolution, int):
            raise TypeError("`beat_resolution` must be int.")
        if self.beat_resolution < 1:
            raise ValueError("`beat_resolution` must be a positive integer.")
        # name
        if not isinstance(self.name, string_types):
            raise TypeError("`name` must be a string.")
def check_validity ( self ) : for track in self . tracks : if not isinstance ( track , Track ) : raise TypeError ( "`tracks` must be a list of " "`pypianoroll.Track` instances." ) track . check_validity ( ) if not isinstance ( self . tempo , np . ndarray ) : raise TypeError ( "`tempo` must be int or a numpy array." ) elif not np . issubdtype ( self . tempo . dtype , np . number ) : raise TypeError ( "Data type of `tempo` must be a subdtype of " "np.number." ) elif self . tempo . ndim != 1 : raise ValueError ( "`tempo` must be a 1D numpy array." ) if np . any ( self . tempo <= 0.0 ) : raise ValueError ( "`tempo` should contain only positive numbers." ) if self . downbeat is not None : if not isinstance ( self . downbeat , np . ndarray ) : raise TypeError ( "`downbeat` must be a numpy array." ) if not np . issubdtype ( self . downbeat . dtype , np . bool_ ) : raise TypeError ( "Data type of `downbeat` must be bool." ) if self . downbeat . ndim != 1 : raise ValueError ( "`downbeat` must be a 1D numpy array." ) if not isinstance ( self . beat_resolution , int ) : raise TypeError ( "`beat_resolution` must be int." ) if self . beat_resolution < 1 : raise ValueError ( "`beat_resolution` must be a positive integer." ) if not isinstance ( self . name , string_types ) : raise TypeError ( "`name` must be a string." )
Raise an error if any invalid attribute found.

        Raises
        ------
        TypeError
            If an attribute has an invalid type.
        ValueError
            If an attribute has an invalid value (of the correct type).