<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def number_of(self, axis):
 """Return the number of in one axis, as generally as possible. Parameters axis : str Name of the axis (such as 'trial', 'time', etc) Returns ------- int or ndarray (dtype='int') number of trial (as int) or number of element in the selected axis (if any of the other axiss) as 1d array. Raises ------ KeyError If the requested axis is not in the data. Notes ----- or is it better to catch the exception? """

        if axis == 'trial':
            return len(self.data)
        else:
            n_trial = self.number_of('trial')
            output = empty(n_trial, dtype='int')
            for i in range(n_trial):
                output[i] = len(self.axis[axis][i])

            return output