'Calculate the value for the ``DATASUM`` card in the HDU.'

def _calculate_datasum(self, blocking):

    if self._has_data:
        d = self.data
        if _is_pseudo_unsigned(self.data.dtype):
            d = np.array((self.data - _unsigned_zero(self.data.dtype)), dtype='i{}'.format(self.data.dtype.itemsize))
        if (d.dtype.str[0] != '>'):
            if d.flags.writeable:
                byteswapped = True
                d = d.byteswap(True)
                d.dtype = d.dtype.newbyteorder('>')
            else:
                d = d.byteswap(False)
                d.dtype = d.dtype.newbyteorder('>')
                byteswapped = False
        else:
            byteswapped = False
        cs = self._compute_checksum(d.flatten().view(np.uint8), blocking=blocking)
        if (byteswapped and (not _is_pseudo_unsigned(self.data.dtype))):
            d.byteswap(True)
            d.dtype = d.dtype.newbyteorder('<')
        return cs
    else:
        return super(_ImageBaseHDU, self)._calculate_datasum(blocking=blocking)
