<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def add_attr(self, name, object, description='', chain=-1, array=False):
 """Add an attribute to the chain. description may not be supported for every date type. if array is true, create an Array object. """


        if not np.isscalar(chain):
            raise TypeError("chain must be a scalar integer.")

        table = self._tables[chain]

        if array is False:
            table.set_attr(name, object)
            obj = getattr(table.attrs, name)
        else:
            # Create an array in the group
            if description == '':
                description = name
            group = table._g_getparent()
            self._h5file.create_array(group, name, object, description)
            obj = getattr(group, name)

        setattr(self, name, obj)