(self)
return sample_count
Count, set, and return the total number of samples in the data file.
        If there is no data file but there are annotations, use the end index
        of the final annotation instead. If there are no annotations, use 0.
        For complex data, a 'sample' includes both the real and imaginary part.
Count, set, and return the total number of samples in the data file.
        If there is no data file but there are annotations, use the end index
        of the final annotation instead. If there are no annotations, use 0.
        For complex data, a 'sample' includes both the real and imaginary part.
Count set and return the total number of samples in the data file . If there is no data file but there are annotations use the end index of the final annotation instead . If there are no annotations use 0 . For complex data a sample includes both the real and imaginary part .
def _count_samples(self):
        """
        Count, set, and return the total number of samples in the data file.
        If there is no data file but there are annotations, use the end index
        of the final annotation instead. If there are no annotations, use 0.
        For complex data, a 'sample' includes both the real and imaginary part.
        """
        annotations = self.get_annotations()
        if self.data_file is None:
            if len(annotations) > 0:
                sample_count = annotations[-1][self.START_INDEX_KEY] + annotations[-1][self.LENGTH_INDEX_KEY]
            else:
                sample_count = 0
        else:
            file_size = path.getsize(self.data_file) - self.get_global_field(self.TRAILING_BYTES_KEY, 0)  # in bytes
            sample_size = self.get_sample_size() # size of a sample in bytes
            num_channels = self.get_num_channels()
            sample_count = file_size // sample_size // num_channels
            if file_size % (sample_size * num_channels) != 0:
                warnings.warn(f'File `{self.data_file}` does not contain an integer '
                    'number of samples across channels. It may be invalid data.')
            if len(annotations) > 0 and annotations[-1][self.START_INDEX_KEY] + annotations[-1][self.LENGTH_INDEX_KEY] > sample_count:
                warnings.warn(f'File `{self.data_file}` ends before the final annotation '
                    'in the corresponding SigMF metadata.')
        self.sample_count = sample_count
        return sample_count
def _count_samples ( self ) : annotations = self . get_annotations ( ) if self . data_file is None : if len ( annotations ) > 0 : sample_count = annotations [ - 1 ] [ self . START_INDEX_KEY ] + annotations [ - 1 ] [ self . LENGTH_INDEX_KEY ] else : sample_count = 0 else : file_size = path . getsize ( self . data_file ) - self . get_global_field ( self . TRAILING_BYTES_KEY , 0 ) # in bytes sample_size = self . get_sample_size ( ) # size of a sample in bytes num_channels = self . get_num_channels ( ) sample_count = file_size // sample_size // num_channels if file_size % ( sample_size * num_channels ) != 0 : warnings . warn ( f'File `{self.data_file}` does not contain an integer ' 'number of samples across channels. It may be invalid data.' ) if len ( annotations ) > 0 and annotations [ - 1 ] [ self . START_INDEX_KEY ] + annotations [ - 1 ] [ self . LENGTH_INDEX_KEY ] > sample_count : warnings . warn ( f'File `{self.data_file}` ends before the final annotation ' 'in the corresponding SigMF metadata.' ) self . sample_count = sample_count return sample_count