<commit_before>#!/usr/bin/env python

# $Id$

"""
The stpyfits module is an extension to the pyfits module which offers
additional features specific to STScI.  These features include the handling
of Constant Data Value Arrays.

The pyfits module is:
"""

from __future__ import division
from pyfits import *
import pyfits
import re

try:
   numpyVersion = np.__version__
except:
   raise RuntimeError, "The numpy array package is required for use."

__version__ = '1.0' + '/' + pyfits.__version__

if pyfits.__doc__:
    __doc__ = __doc__ + pyfits.__doc__

class st_HDUList(pyfits.HDUList):
    """
    A class that extends the pyfits.HDUList class to extend its behavior to
    implement STScI specific extensions to Pyfits.

    Base Class methods reimplemented: writeto, __getitem__, and flush.

    The pyfits.HDUList class is:

    """

    __doc__ = __doc__ + pyfits.HDUList.__doc__

    def writeto(self, name, output_verify='exception', clobber=False,
                classExtensions={}, checksum=False):
        _assignSt_pyfitsClassExtensions(classExtensions)
        pyfits.HDUList.writeto(self, name, output_verify, clobber,
                               classExtensions, checksum)

    writeto.__doc__ = pyfits.HDUList.writeto.__doc__

    def __getitem__(self, key, classExtensions={}):
        _assignSt_pyfitsClassExtensions(classExtensions)
        item = pyfits.HDUList.__getitem__(self, key, classExtensions)

        return item

    __getitem__.__doc__ = pyfits.HDUList.__getitem__.__doc__

    def flush(self, output_verify='exception', verbose=0, classExtensions={}):
        _assignSt_pyfitsClassExtensions(classExtensions)
        pyfits.HDUList.flush(self, output_verify, verbose, classExtensions)

    flush.__doc__ = pyfits.HDUList.flush.__doc__

HDUList = st_HDUList

class st_File(core._File):
    """
    A class that extends the pyfits._File class to extend its behavior to
    implement STScI specific extensions to Pyfits.

    Base Class methods reimplemented: _readHDU, writeHDUheader, and
    writeHDUdata.

    The pyfits._File class is:

    """
    __doc__ = __doc__ + core._File.__doc__
#
#   some needed regular expressions as class attributes
#
    pixvalue_RE = re.compile('PIXVALUE=')
    naxis_RE = re.compile('NAXIS   = ')
    npixn_RE = re.compile(r'NPIX(\d+)\s*=\s*(\d+)')
    naxisVal_len1_RE = re.compile('0')
    naxisVal_len2_RE = re.compile('[ 0]|[0 ]')
    naxisVal_len3_RE = re.compile('[  0]|[ 0 ]|[0  ]')

    def _readHDU(self):
#
#       Call base class _readHDU to perform generic reading of header
#<commit_msg>Upgraded HDUList.append and insert to handle cases where we are adding a primary hdu in a location where an extension hdu belongs (ect)<commit_after>#!/usr/bin/env python

# $Id$

"""
The stpyfits module is an extension to the pyfits module which offers
additional features specific to STScI.  These features include the handling
of Constant Data Value Arrays.

The pyfits module is:
"""

from __future__ import division
from pyfits import *
import pyfits
import re

try:
   numpyVersion = np.__version__
except:
   raise RuntimeError, "The numpy array package is required for use."

__version__ = '1.0.1' + '/' + pyfits.__version__

if pyfits.__doc__:
    __doc__ = __doc__ + pyfits.__doc__

class st_HDUList(pyfits.HDUList):
    """
    A class that extends the pyfits.HDUList class to extend its behavior to
    implement STScI specific extensions to Pyfits.

    Base Class methods reimplemented: writeto, __getitem__, insert, append,
    and flush.

    The pyfits.HDUList class is:

    """

    __doc__ = __doc__ + pyfits.HDUList.__doc__

    def writeto(self, name, output_verify='exception', clobber=False,
                classExtensions={}, checksum=False):
        _assignSt_pyfitsClassExtensions(classExtensions)
        pyfits.HDUList.writeto(self, name, output_verify, clobber,
                               classExtensions, checksum)

    writeto.__doc__ = pyfits.HDUList.writeto.__doc__

    def __getitem__(self, key, classExtensions={}):
        _assignSt_pyfitsClassExtensions(classExtensions)
        item = pyfits.HDUList.__getitem__(self, key, classExtensions)

        return item

    __getitem__.__doc__ = pyfits.HDUList.__getitem__.__doc__

    def flush(self, output_verify='exception', verbose=0, classExtensions={}):
        _assignSt_pyfitsClassExtensions(classExtensions)
        pyfits.HDUList.flush(self, output_verify, verbose, classExtensions)

    flush.__doc__ = pyfits.HDUList.flush.__doc__

    def insert(self, index, hdu, classExtensions={}):
        _assignSt_pyfitsClassExtensions(classExtensions)
        pyfits.HDUList.insert(self, index, hdu, classExtensions)

    insert.__doc__ = pyfits.HDUList.insert.__doc__

    def append(self, hdu, classExtensions={}):
        _assignSt_pyfitsClassExtensions(classExtensions)
        pyfits.HDUList.append(self, hdu, classExtensions)

    insert.__doc__ = pyfits.HDUList.append.__doc__

HDUList = st_HDUList

class st_File(core._File):
    """
    A class that extends the pyfits._File class to extend its behavior to
    implement STScI specific extensions to Pyfits.

    Base Class methods reimplemented: _readHDU, writeHDUheader, and
    writeHDUdata.

    The pyfits._File class is:

    """
    __doc__ = __doc__ + core._File.__doc__
#
#   some needed regular expressions as class attributes
#
    pixvalue_RE = re.compile('PIXVALUE=')
    naxis_RE = re.compile('NAXIS   = ')
    npixn_RE = re.compile(r'NPIX(\d+)\s*=\s*(\d+)')
    naxisVal_len1_RE = re.compile('0')
    naxisVal_len2_RE = re.compile('[ 0]|[0 ]')
    naxisVal_len3_RE = re.compile('[  0]|[ 0 ]|[0  ]')

    def _readHDU(self):
#
#       Call base class _readHDU to perform generic reading of header
#
{'fraction_non_alphanumeric': 0.09344490934449093, 'fraction_numerical': 0.004358437935843794, 'mean_word_length': 3.549563838223632, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1823390', 'n_tokens_mistral': 1912, 'n_tokens_neox': 1808, 'n_words': 476}