photutils-0.2.1/0000700000214200020070000000000012646264032015723 5ustar lbradleySTSCI\science00000000000000photutils-0.2.1/ah_bootstrap.py0000600000214200020070000010650212630427746020776 0ustar lbradleySTSCI\science00000000000000""" This bootstrap module contains code for ensuring that the astropy_helpers package will be importable by the time the setup.py script runs. It also includes some workarounds to ensure that a recent-enough version of setuptools is being used for the installation. This module should be the first thing imported in the setup.py of distributions that make use of the utilities in astropy_helpers. If the distribution ships with its own copy of astropy_helpers, this module will first attempt to import from the shipped copy. However, it will also check PyPI to see if there are any bug-fix releases on top of the current version that may be useful to get past platform-specific bugs that have been fixed. When running setup.py, use the ``--offline`` command-line option to disable the auto-upgrade checks. When this module is imported or otherwise executed it automatically calls a main function that attempts to read the project's setup.cfg file, which it checks for a configuration section called ``[ah_bootstrap]`` the presences of that section, and options therein, determine the next step taken: If it contains an option called ``auto_use`` with a value of ``True``, it will automatically call the main function of this module called `use_astropy_helpers` (see that function's docstring for full details). Otherwise no further action is taken (however, ``ah_bootstrap.use_astropy_helpers`` may be called manually from within the setup.py script). Additional options in the ``[ah_boostrap]`` section of setup.cfg have the same names as the arguments to `use_astropy_helpers`, and can be used to configure the bootstrap script when ``auto_use = True``. See https://github.com/astropy/astropy-helpers for more details, and for the latest version of this module. """ import contextlib import errno import imp import io import locale import os import re import subprocess as sp import sys try: from ConfigParser import ConfigParser, RawConfigParser except ImportError: from configparser import ConfigParser, RawConfigParser if sys.version_info[0] < 3: _str_types = (str, unicode) _text_type = unicode PY3 = False else: _str_types = (str, bytes) _text_type = str PY3 = True # What follows are several import statements meant to deal with install-time # issues with either missing or misbehaving pacakges (including making sure # setuptools itself is installed): # Some pre-setuptools checks to ensure that either distribute or setuptools >= # 0.7 is used (over pre-distribute setuptools) if it is available on the path; # otherwise the latest setuptools will be downloaded and bootstrapped with # ``ez_setup.py``. This used to be included in a separate file called # setuptools_bootstrap.py; but it was combined into ah_bootstrap.py try: import pkg_resources _setuptools_req = pkg_resources.Requirement.parse('setuptools>=0.7') # This may raise a DistributionNotFound in which case no version of # setuptools or distribute is properly installed _setuptools = pkg_resources.get_distribution('setuptools') if _setuptools not in _setuptools_req: # Older version of setuptools; check if we have distribute; again if # this results in DistributionNotFound we want to give up _distribute = pkg_resources.get_distribution('distribute') if _setuptools != _distribute: # It's possible on some pathological systems to have an old version # of setuptools and distribute on sys.path simultaneously; make # sure distribute is the one that's used sys.path.insert(1, _distribute.location) _distribute.activate() imp.reload(pkg_resources) except: # There are several types of exceptions that can occur here; if all else # fails bootstrap and use the bootstrapped version from ez_setup import use_setuptools use_setuptools() # Note: The following import is required as a workaround to # https://github.com/astropy/astropy-helpers/issues/89; if we don't import this # module now, it will get cleaned up after `run_setup` is called, but that will # later cause the TemporaryDirectory class defined in it to stop working when # used later on by setuptools try: import setuptools.py31compat except ImportError: pass # matplotlib can cause problems if it is imported from within a call of # run_setup(), because in some circumstances it will try to write to the user's # home directory, resulting in a SandboxViolation. See # https://github.com/matplotlib/matplotlib/pull/4165 # Making sure matplotlib, if it is available, is imported early in the setup # process can mitigate this (note importing matplotlib.pyplot has the same # issue) try: import matplotlib matplotlib.use('Agg') import matplotlib.pyplot except: # Ignore if this fails for *any* reason* pass # End compatibility imports... # In case it didn't successfully import before the ez_setup checks import pkg_resources from setuptools import Distribution from setuptools.package_index import PackageIndex from setuptools.sandbox import run_setup from distutils import log from distutils.debug import DEBUG # TODO: Maybe enable checking for a specific version of astropy_helpers? DIST_NAME = 'astropy-helpers' PACKAGE_NAME = 'astropy_helpers' # Defaults for other options DOWNLOAD_IF_NEEDED = True INDEX_URL = 'https://pypi.python.org/simple' USE_GIT = True OFFLINE = False AUTO_UPGRADE = True # A list of all the configuration options and their required types CFG_OPTIONS = [ ('auto_use', bool), ('path', str), ('download_if_needed', bool), ('index_url', str), ('use_git', bool), ('offline', bool), ('auto_upgrade', bool) ] class _Bootstrapper(object): """ Bootstrapper implementation. See ``use_astropy_helpers`` for parameter documentation. """ def __init__(self, path=None, index_url=None, use_git=None, offline=None, download_if_needed=None, auto_upgrade=None): if path is None: path = PACKAGE_NAME if not (isinstance(path, _str_types) or path is False): raise TypeError('path must be a string or False') if PY3 and not isinstance(path, _text_type): fs_encoding = sys.getfilesystemencoding() path = path.decode(fs_encoding) # path to unicode self.path = path # Set other option attributes, using defaults where necessary self.index_url = index_url if index_url is not None else INDEX_URL self.offline = offline if offline is not None else OFFLINE # If offline=True, override download and auto-upgrade if self.offline: download_if_needed = False auto_upgrade = False self.download = (download_if_needed if download_if_needed is not None else DOWNLOAD_IF_NEEDED) self.auto_upgrade = (auto_upgrade if auto_upgrade is not None else AUTO_UPGRADE) # If this is a release then the .git directory will not exist so we # should not use git. git_dir_exists = os.path.exists(os.path.join(os.path.dirname(__file__), '.git')) if use_git is None and not git_dir_exists: use_git = False self.use_git = use_git if use_git is not None else USE_GIT # Declared as False by default--later we check if astropy-helpers can be # upgraded from PyPI, but only if not using a source distribution (as in # the case of import from a git submodule) self.is_submodule = False @classmethod def main(cls, argv=None): if argv is None: argv = sys.argv config = cls.parse_config() config.update(cls.parse_command_line(argv)) auto_use = config.pop('auto_use', False) bootstrapper = cls(**config) if auto_use: # Run the bootstrapper, otherwise the setup.py is using the old # use_astropy_helpers() interface, in which case it will run the # bootstrapper manually after reconfiguring it. bootstrapper.run() return bootstrapper @classmethod def parse_config(cls): if not os.path.exists('setup.cfg'): return {} cfg = ConfigParser() try: cfg.read('setup.cfg') except Exception as e: if DEBUG: raise log.error( "Error reading setup.cfg: {0!r}\n{1} will not be " "automatically bootstrapped and package installation may fail." "\n{2}".format(e, PACKAGE_NAME, _err_help_msg)) return {} if not cfg.has_section('ah_bootstrap'): return {} config = {} for option, type_ in CFG_OPTIONS: if not cfg.has_option('ah_bootstrap', option): continue if type_ is bool: value = cfg.getboolean('ah_bootstrap', option) else: value = cfg.get('ah_bootstrap', option) config[option] = value return config @classmethod def parse_command_line(cls, argv=None): if argv is None: argv = sys.argv config = {} # For now we just pop recognized ah_bootstrap options out of the # arg list. This is imperfect; in the unlikely case that a setup.py # custom command or even custom Distribution class defines an argument # of the same name then we will break that. However there's a catch22 # here that we can't just do full argument parsing right here, because # we don't yet know *how* to parse all possible command-line arguments. if '--no-git' in argv: config['use_git'] = False argv.remove('--no-git') if '--offline' in argv: config['offline'] = True argv.remove('--offline') return config def run(self): strategies = ['local_directory', 'local_file', 'index'] dist = None # First, remove any previously imported versions of astropy_helpers; # this is necessary for nested installs where one package's installer # is installing another package via setuptools.sandbox.run_setup, as in # the case of setup_requires for key in list(sys.modules): try: if key == PACKAGE_NAME or key.startswith(PACKAGE_NAME + '.'): del sys.modules[key] except AttributeError: # Sometimes mysterious non-string things can turn up in # sys.modules continue # Check to see if the path is a submodule self.is_submodule = self._check_submodule() for strategy in strategies: method = getattr(self, 'get_{0}_dist'.format(strategy)) dist = method() if dist is not None: break else: raise _AHBootstrapSystemExit( "No source found for the {0!r} package; {0} must be " "available and importable as a prerequisite to building " "or installing this package.".format(PACKAGE_NAME)) # This is a bit hacky, but if astropy_helpers was loaded from a # directory/submodule its Distribution object gets a "precedence" of # "DEVELOP_DIST". However, in other cases it gets a precedence of # "EGG_DIST". However, when activing the distribution it will only be # placed early on sys.path if it is treated as an EGG_DIST, so always # do that dist = dist.clone(precedence=pkg_resources.EGG_DIST) # Otherwise we found a version of astropy-helpers, so we're done # Just active the found distribution on sys.path--if we did a # download this usually happens automatically but it doesn't hurt to # do it again # Note: Adding the dist to the global working set also activates it # (makes it importable on sys.path) by default. try: pkg_resources.working_set.add(dist, replace=True) except TypeError: # Some (much) older versions of setuptools do not have the # replace=True option here. These versions are old enough that all # bets may be off anyways, but it's easy enough to work around just # in case... if dist.key in pkg_resources.working_set.by_key: del pkg_resources.working_set.by_key[dist.key] pkg_resources.working_set.add(dist) @property def config(self): """ A `dict` containing the options this `_Bootstrapper` was configured with. """ return dict((optname, getattr(self, optname)) for optname, _ in CFG_OPTIONS if hasattr(self, optname)) def get_local_directory_dist(self): """ Handle importing a vendored package from a subdirectory of the source distribution. """ if not os.path.isdir(self.path): return log.info('Attempting to import astropy_helpers from {0} {1!r}'.format( 'submodule' if self.is_submodule else 'directory', self.path)) dist = self._directory_import() if dist is None: log.warn( 'The requested path {0!r} for importing {1} does not ' 'exist, or does not contain a copy of the {1} ' 'package.'.format(self.path, PACKAGE_NAME)) elif self.auto_upgrade and not self.is_submodule: # A version of astropy-helpers was found on the available path, but # check to see if a bugfix release is available on PyPI upgrade = self._do_upgrade(dist) if upgrade is not None: dist = upgrade return dist def get_local_file_dist(self): """ Handle importing from a source archive; this also uses setup_requires but points easy_install directly to the source archive. """ if not os.path.isfile(self.path): return log.info('Attempting to unpack and import astropy_helpers from ' '{0!r}'.format(self.path)) try: dist = self._do_download(find_links=[self.path]) except Exception as e: if DEBUG: raise log.warn( 'Failed to import {0} from the specified archive {1!r}: ' '{2}'.format(PACKAGE_NAME, self.path, str(e))) dist = None if dist is not None and self.auto_upgrade: # A version of astropy-helpers was found on the available path, but # check to see if a bugfix release is available on PyPI upgrade = self._do_upgrade(dist) if upgrade is not None: dist = upgrade return dist def get_index_dist(self): if not self.download: log.warn('Downloading {0!r} disabled.'.format(DIST_NAME)) return None log.warn( "Downloading {0!r}; run setup.py with the --offline option to " "force offline installation.".format(DIST_NAME)) try: dist = self._do_download() except Exception as e: if DEBUG: raise log.warn( 'Failed to download and/or install {0!r} from {1!r}:\n' '{2}'.format(DIST_NAME, self.index_url, str(e))) dist = None # No need to run auto-upgrade here since we've already presumably # gotten the most up-to-date version from the package index return dist def _directory_import(self): """ Import astropy_helpers from the given path, which will be added to sys.path. Must return True if the import succeeded, and False otherwise. """ # Return True on success, False on failure but download is allowed, and # otherwise raise SystemExit path = os.path.abspath(self.path) # Use an empty WorkingSet rather than the man # pkg_resources.working_set, since on older versions of setuptools this # will invoke a VersionConflict when trying to install an upgrade ws = pkg_resources.WorkingSet([]) ws.add_entry(path) dist = ws.by_key.get(DIST_NAME) if dist is None: # We didn't find an egg-info/dist-info in the given path, but if a # setup.py exists we can generate it setup_py = os.path.join(path, 'setup.py') if os.path.isfile(setup_py): with _silence(): run_setup(os.path.join(path, 'setup.py'), ['egg_info']) for dist in pkg_resources.find_distributions(path, True): # There should be only one... return dist return dist def _do_download(self, version='', find_links=None): if find_links: allow_hosts = '' index_url = None else: allow_hosts = None index_url = self.index_url # Annoyingly, setuptools will not handle other arguments to # Distribution (such as options) before handling setup_requires, so it # is not straightforward to programmatically augment the arguments which # are passed to easy_install class _Distribution(Distribution): def get_option_dict(self, command_name): opts = Distribution.get_option_dict(self, command_name) if command_name == 'easy_install': if find_links is not None: opts['find_links'] = ('setup script', find_links) if index_url is not None: opts['index_url'] = ('setup script', index_url) if allow_hosts is not None: opts['allow_hosts'] = ('setup script', allow_hosts) return opts if version: req = '{0}=={1}'.format(DIST_NAME, version) else: req = DIST_NAME attrs = {'setup_requires': [req]} try: if DEBUG: _Distribution(attrs=attrs) else: with _silence(): _Distribution(attrs=attrs) # If the setup_requires succeeded it will have added the new dist to # the main working_set return pkg_resources.working_set.by_key.get(DIST_NAME) except Exception as e: if DEBUG: raise msg = 'Error retrieving {0} from {1}:\n{2}' if find_links: source = find_links[0] elif index_url != INDEX_URL: source = index_url else: source = 'PyPI' raise Exception(msg.format(DIST_NAME, source, repr(e))) def _do_upgrade(self, dist): # Build up a requirement for a higher bugfix release but a lower minor # release (so API compatibility is guaranteed) next_version = _next_version(dist.parsed_version) req = pkg_resources.Requirement.parse( '{0}>{1},<{2}'.format(DIST_NAME, dist.version, next_version)) package_index = PackageIndex(index_url=self.index_url) upgrade = package_index.obtain(req) if upgrade is not None: return self._do_download(version=upgrade.version) def _check_submodule(self): """ Check if the given path is a git submodule. See the docstrings for ``_check_submodule_using_git`` and ``_check_submodule_no_git`` for further details. """ if (self.path is None or (os.path.exists(self.path) and not os.path.isdir(self.path))): return False if self.use_git: return self._check_submodule_using_git() else: return self._check_submodule_no_git() def _check_submodule_using_git(self): """ Check if the given path is a git submodule. If so, attempt to initialize and/or update the submodule if needed. This function makes calls to the ``git`` command in subprocesses. The ``_check_submodule_no_git`` option uses pure Python to check if the given path looks like a git submodule, but it cannot perform updates. """ cmd = ['git', 'submodule', 'status', '--', self.path] try: log.info('Running `{0}`; use the --no-git option to disable git ' 'commands'.format(' '.join(cmd))) returncode, stdout, stderr = run_cmd(cmd) except _CommandNotFound: # The git command simply wasn't found; this is most likely the # case on user systems that don't have git and are simply # trying to install the package from PyPI or a source # distribution. Silently ignore this case and simply don't try # to use submodules return False stderr = stderr.strip() if returncode != 0 and stderr: # Unfortunately the return code alone cannot be relied on, as # earlier versions of git returned 0 even if the requested submodule # does not exist # This is a warning that occurs in perl (from running git submodule) # which only occurs with a malformatted locale setting which can # happen sometimes on OSX. See again # https://github.com/astropy/astropy/issues/2749 perl_warning = ('perl: warning: Falling back to the standard locale ' '("C").') if not stderr.strip().endswith(perl_warning): # Some other unknown error condition occurred log.warn('git submodule command failed ' 'unexpectedly:\n{0}'.format(stderr)) return False # Output of `git submodule status` is as follows: # # 1: Status indicator: '-' for submodule is uninitialized, '+' if # submodule is initialized but is not at the commit currently indicated # in .gitmodules (and thus needs to be updated), or 'U' if the # submodule is in an unstable state (i.e. has merge conflicts) # # 2. SHA-1 hash of the current commit of the submodule (we don't really # need this information but it's useful for checking that the output is # correct) # # 3. The output of `git describe` for the submodule's current commit # hash (this includes for example what branches the commit is on) but # only if the submodule is initialized. We ignore this information for # now _git_submodule_status_re = re.compile( '^(?P[+-U ])(?P[0-9a-f]{40}) ' '(?P\S+)( .*)?$') # The stdout should only contain one line--the status of the # requested submodule m = _git_submodule_status_re.match(stdout) if m: # Yes, the path *is* a git submodule self._update_submodule(m.group('submodule'), m.group('status')) return True else: log.warn( 'Unexpected output from `git submodule status`:\n{0}\n' 'Will attempt import from {1!r} regardless.'.format( stdout, self.path)) return False def _check_submodule_no_git(self): """ Like ``_check_submodule_using_git``, but simply parses the .gitmodules file to determine if the supplied path is a git submodule, and does not exec any subprocesses. This can only determine if a path is a submodule--it does not perform updates, etc. This function may need to be updated if the format of the .gitmodules file is changed between git versions. """ gitmodules_path = os.path.abspath('.gitmodules') if not os.path.isfile(gitmodules_path): return False # This is a minimal reader for gitconfig-style files. It handles a few of # the quirks that make gitconfig files incompatible with ConfigParser-style # files, but does not support the full gitconfig syntax (just enough # needed to read a .gitmodules file). gitmodules_fileobj = io.StringIO() # Must use io.open for cross-Python-compatible behavior wrt unicode with io.open(gitmodules_path) as f: for line in f: # gitconfig files are more flexible with leading whitespace; just # go ahead and remove it line = line.lstrip() # comments can start with either # or ; if line and line[0] in (':', ';'): continue gitmodules_fileobj.write(line) gitmodules_fileobj.seek(0) cfg = RawConfigParser() try: cfg.readfp(gitmodules_fileobj) except Exception as exc: log.warn('Malformatted .gitmodules file: {0}\n' '{1} cannot be assumed to be a git submodule.'.format( exc, self.path)) return False for section in cfg.sections(): if not cfg.has_option(section, 'path'): continue submodule_path = cfg.get(section, 'path').rstrip(os.sep) if submodule_path == self.path.rstrip(os.sep): return True return False def _update_submodule(self, submodule, status): if status == ' ': # The submodule is up to date; no action necessary return elif status == '-': if self.offline: raise _AHBootstrapSystemExit( "Cannot initialize the {0} submodule in --offline mode; " "this requires being able to clone the submodule from an " "online repository.".format(submodule)) cmd = ['update', '--init'] action = 'Initializing' elif status == '+': cmd = ['update'] action = 'Updating' if self.offline: cmd.append('--no-fetch') elif status == 'U': raise _AHBoostrapSystemExit( 'Error: Submodule {0} contains unresolved merge conflicts. ' 'Please complete or abandon any changes in the submodule so that ' 'it is in a usable state, then try again.'.format(submodule)) else: log.warn('Unknown status {0!r} for git submodule {1!r}. Will ' 'attempt to use the submodule as-is, but try to ensure ' 'that the submodule is in a clean state and contains no ' 'conflicts or errors.\n{2}'.format(status, submodule, _err_help_msg)) return err_msg = None cmd = ['git', 'submodule'] + cmd + ['--', submodule] log.warn('{0} {1} submodule with: `{2}`'.format( action, submodule, ' '.join(cmd))) try: log.info('Running `{0}`; use the --no-git option to disable git ' 'commands'.format(' '.join(cmd))) returncode, stdout, stderr = run_cmd(cmd) except OSError as e: err_msg = str(e) else: if returncode != 0: err_msg = stderr if err_msg is not None: log.warn('An unexpected error occurred updating the git submodule ' '{0!r}:\n{1}\n{2}'.format(submodule, err_msg, _err_help_msg)) class _CommandNotFound(OSError): """ An exception raised when a command run with run_cmd is not found on the system. """ def run_cmd(cmd): """ Run a command in a subprocess, given as a list of command-line arguments. Returns a ``(returncode, stdout, stderr)`` tuple. """ try: p = sp.Popen(cmd, stdout=sp.PIPE, stderr=sp.PIPE) # XXX: May block if either stdout or stderr fill their buffers; # however for the commands this is currently used for that is # unlikely (they should have very brief output) stdout, stderr = p.communicate() except OSError as e: if DEBUG: raise if e.errno == errno.ENOENT: msg = 'Command not found: `{0}`'.format(' '.join(cmd)) raise _CommandNotFound(msg, cmd) else: raise _AHBoostrapSystemExit( 'An unexpected error occurred when running the ' '`{0}` command:\n{1}'.format(' '.join(cmd), str(e))) # Can fail of the default locale is not configured properly. See # https://github.com/astropy/astropy/issues/2749. For the purposes under # consideration 'latin1' is an acceptable fallback. try: stdio_encoding = locale.getdefaultlocale()[1] or 'latin1' except ValueError: # Due to an OSX oddity locale.getdefaultlocale() can also crash # depending on the user's locale/language settings. See: # http://bugs.python.org/issue18378 stdio_encoding = 'latin1' # Unlikely to fail at this point but even then let's be flexible if not isinstance(stdout, _text_type): stdout = stdout.decode(stdio_encoding, 'replace') if not isinstance(stderr, _text_type): stderr = stderr.decode(stdio_encoding, 'replace') return (p.returncode, stdout, stderr) def _next_version(version): """ Given a parsed version from pkg_resources.parse_version, returns a new version string with the next minor version. Examples ======== >>> _next_version(pkg_resources.parse_version('1.2.3')) '1.3.0' """ if hasattr(version, 'base_version'): # New version parsing from setuptools >= 8.0 if version.base_version: parts = version.base_version.split('.') else: parts = [] else: parts = [] for part in version: if part.startswith('*'): break parts.append(part) parts = [int(p) for p in parts] if len(parts) < 3: parts += [0] * (3 - len(parts)) major, minor, micro = parts[:3] return '{0}.{1}.{2}'.format(major, minor + 1, 0) class _DummyFile(object): """A noop writeable object.""" errors = '' # Required for Python 3.x encoding = 'utf-8' def write(self, s): pass def flush(self): pass @contextlib.contextmanager def _silence(): """A context manager that silences sys.stdout and sys.stderr.""" old_stdout = sys.stdout old_stderr = sys.stderr sys.stdout = _DummyFile() sys.stderr = _DummyFile() exception_occurred = False try: yield except: exception_occurred = True # Go ahead and clean up so that exception handling can work normally sys.stdout = old_stdout sys.stderr = old_stderr raise if not exception_occurred: sys.stdout = old_stdout sys.stderr = old_stderr _err_help_msg = """ If the problem persists consider installing astropy_helpers manually using pip (`pip install astropy_helpers`) or by manually downloading the source archive, extracting it, and installing by running `python setup.py install` from the root of the extracted source code. """ class _AHBootstrapSystemExit(SystemExit): def __init__(self, *args): if not args: msg = 'An unknown problem occurred bootstrapping astropy_helpers.' else: msg = args[0] msg += '\n' + _err_help_msg super(_AHBootstrapSystemExit, self).__init__(msg, *args[1:]) if sys.version_info[:2] < (2, 7): # In Python 2.6 the distutils log does not log warnings, errors, etc. to # stderr so we have to wrap it to ensure consistency at least in this # module import distutils class log(object): def __getattr__(self, attr): return getattr(distutils.log, attr) def warn(self, msg, *args): self._log_to_stderr(distutils.log.WARN, msg, *args) def error(self, msg): self._log_to_stderr(distutils.log.ERROR, msg, *args) def fatal(self, msg): self._log_to_stderr(distutils.log.FATAL, msg, *args) def log(self, level, msg, *args): if level in (distutils.log.WARN, distutils.log.ERROR, distutils.log.FATAL): self._log_to_stderr(level, msg, *args) else: distutils.log.log(level, msg, *args) def _log_to_stderr(self, level, msg, *args): # This is the only truly 'public' way to get the current threshold # of the log current_threshold = distutils.log.set_threshold(distutils.log.WARN) distutils.log.set_threshold(current_threshold) if level >= current_threshold: if args: msg = msg % args sys.stderr.write('%s\n' % msg) sys.stderr.flush() log = log() BOOTSTRAPPER = _Bootstrapper.main() def use_astropy_helpers(**kwargs): """ Ensure that the `astropy_helpers` module is available and is importable. This supports automatic submodule initialization if astropy_helpers is included in a project as a git submodule, or will download it from PyPI if necessary. Parameters ---------- path : str or None, optional A filesystem path relative to the root of the project's source code that should be added to `sys.path` so that `astropy_helpers` can be imported from that path. If the path is a git submodule it will automatically be initialized and/or updated. The path may also be to a ``.tar.gz`` archive of the astropy_helpers source distribution. In this case the archive is automatically unpacked and made temporarily available on `sys.path` as a ``.egg`` archive. If `None` skip straight to downloading. download_if_needed : bool, optional If the provided filesystem path is not found an attempt will be made to download astropy_helpers from PyPI. It will then be made temporarily available on `sys.path` as a ``.egg`` archive (using the ``setup_requires`` feature of setuptools. If the ``--offline`` option is given at the command line the value of this argument is overridden to `False`. index_url : str, optional If provided, use a different URL for the Python package index than the main PyPI server. use_git : bool, optional If `False` no git commands will be used--this effectively disables support for git submodules. If the ``--no-git`` option is given at the command line the value of this argument is overridden to `False`. auto_upgrade : bool, optional By default, when installing a package from a non-development source distribution ah_boostrap will try to automatically check for patch releases to astropy-helpers on PyPI and use the patched version over any bundled versions. Setting this to `False` will disable that functionality. If the ``--offline`` option is given at the command line the value of this argument is overridden to `False`. offline : bool, optional If `False` disable all actions that require an internet connection, including downloading packages from the package index and fetching updates to any git submodule. Defaults to `True`. """ global BOOTSTRAPPER config = BOOTSTRAPPER.config config.update(**kwargs) # Create a new bootstrapper with the updated configuration and run it BOOTSTRAPPER = _Bootstrapper(**config) BOOTSTRAPPER.run() photutils-0.2.1/astropy_helpers/0000700000214200020070000000000012646264032021146 5ustar lbradleySTSCI\science00000000000000photutils-0.2.1/astropy_helpers/.travis.yml0000600000214200020070000000344012632702254023260 0ustar lbradleySTSCI\science00000000000000# We set the language to c because python isn't supported on the MacOS X nodes # on Travis. However, the language ends up being irrelevant anyway, since we # install Python ourselves using conda. language: c os: - osx - linux env: matrix: - PYTHON_VERSION=2.6 - PYTHON_VERSION=2.7 - PYTHON_VERSION=3.3 - PYTHON_VERSION=3.4 - PYTHON_VERSION=3.5 global: - SETUPTOOLS_VERSION=stable - CONDA_DEPENDENCIES="pytest sphinx cython numpy" - PIP_DEPENDENCIES="coveralls pytest-cov" matrix: include: - os: linux env: PYTHON_VERSION=2.7 SETUPTOOLS_VERSION=dev CONDA_DEPENDENCIES="pytest sphinx cython numpy mercurial mock" before_install: - if [[ $TRAVIS_OS_NAME == linux ]]; then sudo apt-get update; sudo apt-get install graphviz; fi - if [[ $TRAVIS_OS_NAME == osx ]]; then brew update; brew install graphviz; fi install: - git clone git://github.com/astropy/ci-helpers.git - source ci-helpers/travis/setup_conda_$TRAVIS_OS_NAME.sh # We cannot install the developer version of setuptools using pip because # pip tries to remove the previous version of setuptools before the # installation is complete, which causes issues. Instead, we just install # setuptools manually. - if [[ $SETUPTOOLS_VERSION == dev ]]; then hg clone https://bitbucket.org/pypa/setuptools; cd setuptools; python setup.py install; cd ..; fi before_script: # Some of the tests use git commands that require a user to be configured - git config --global user.name "A U Thor" - git config --global user.email "author@example.com" script: # Use full path for coveragerc; see issue #193 - py.test --cov astropy_helpers --cov-config $(pwd)/astropy_helpers/tests/coveragerc astropy_helpers after_success: - coveralls photutils-0.2.1/astropy_helpers/ah_bootstrap.py0000600000214200020070000010650212606736443024221 0ustar lbradleySTSCI\science00000000000000""" This bootstrap module contains code for ensuring that the astropy_helpers package will be importable by the time the setup.py script runs. It also includes some workarounds to ensure that a recent-enough version of setuptools is being used for the installation. This module should be the first thing imported in the setup.py of distributions that make use of the utilities in astropy_helpers. If the distribution ships with its own copy of astropy_helpers, this module will first attempt to import from the shipped copy. However, it will also check PyPI to see if there are any bug-fix releases on top of the current version that may be useful to get past platform-specific bugs that have been fixed. When running setup.py, use the ``--offline`` command-line option to disable the auto-upgrade checks. When this module is imported or otherwise executed it automatically calls a main function that attempts to read the project's setup.cfg file, which it checks for a configuration section called ``[ah_bootstrap]`` the presences of that section, and options therein, determine the next step taken: If it contains an option called ``auto_use`` with a value of ``True``, it will automatically call the main function of this module called `use_astropy_helpers` (see that function's docstring for full details). Otherwise no further action is taken (however, ``ah_bootstrap.use_astropy_helpers`` may be called manually from within the setup.py script). Additional options in the ``[ah_boostrap]`` section of setup.cfg have the same names as the arguments to `use_astropy_helpers`, and can be used to configure the bootstrap script when ``auto_use = True``. See https://github.com/astropy/astropy-helpers for more details, and for the latest version of this module. """ import contextlib import errno import imp import io import locale import os import re import subprocess as sp import sys try: from ConfigParser import ConfigParser, RawConfigParser except ImportError: from configparser import ConfigParser, RawConfigParser if sys.version_info[0] < 3: _str_types = (str, unicode) _text_type = unicode PY3 = False else: _str_types = (str, bytes) _text_type = str PY3 = True # What follows are several import statements meant to deal with install-time # issues with either missing or misbehaving pacakges (including making sure # setuptools itself is installed): # Some pre-setuptools checks to ensure that either distribute or setuptools >= # 0.7 is used (over pre-distribute setuptools) if it is available on the path; # otherwise the latest setuptools will be downloaded and bootstrapped with # ``ez_setup.py``. This used to be included in a separate file called # setuptools_bootstrap.py; but it was combined into ah_bootstrap.py try: import pkg_resources _setuptools_req = pkg_resources.Requirement.parse('setuptools>=0.7') # This may raise a DistributionNotFound in which case no version of # setuptools or distribute is properly installed _setuptools = pkg_resources.get_distribution('setuptools') if _setuptools not in _setuptools_req: # Older version of setuptools; check if we have distribute; again if # this results in DistributionNotFound we want to give up _distribute = pkg_resources.get_distribution('distribute') if _setuptools != _distribute: # It's possible on some pathological systems to have an old version # of setuptools and distribute on sys.path simultaneously; make # sure distribute is the one that's used sys.path.insert(1, _distribute.location) _distribute.activate() imp.reload(pkg_resources) except: # There are several types of exceptions that can occur here; if all else # fails bootstrap and use the bootstrapped version from ez_setup import use_setuptools use_setuptools() # Note: The following import is required as a workaround to # https://github.com/astropy/astropy-helpers/issues/89; if we don't import this # module now, it will get cleaned up after `run_setup` is called, but that will # later cause the TemporaryDirectory class defined in it to stop working when # used later on by setuptools try: import setuptools.py31compat except ImportError: pass # matplotlib can cause problems if it is imported from within a call of # run_setup(), because in some circumstances it will try to write to the user's # home directory, resulting in a SandboxViolation. See # https://github.com/matplotlib/matplotlib/pull/4165 # Making sure matplotlib, if it is available, is imported early in the setup # process can mitigate this (note importing matplotlib.pyplot has the same # issue) try: import matplotlib matplotlib.use('Agg') import matplotlib.pyplot except: # Ignore if this fails for *any* reason* pass # End compatibility imports... # In case it didn't successfully import before the ez_setup checks import pkg_resources from setuptools import Distribution from setuptools.package_index import PackageIndex from setuptools.sandbox import run_setup from distutils import log from distutils.debug import DEBUG # TODO: Maybe enable checking for a specific version of astropy_helpers? DIST_NAME = 'astropy-helpers' PACKAGE_NAME = 'astropy_helpers' # Defaults for other options DOWNLOAD_IF_NEEDED = True INDEX_URL = 'https://pypi.python.org/simple' USE_GIT = True OFFLINE = False AUTO_UPGRADE = True # A list of all the configuration options and their required types CFG_OPTIONS = [ ('auto_use', bool), ('path', str), ('download_if_needed', bool), ('index_url', str), ('use_git', bool), ('offline', bool), ('auto_upgrade', bool) ] class _Bootstrapper(object): """ Bootstrapper implementation. See ``use_astropy_helpers`` for parameter documentation. """ def __init__(self, path=None, index_url=None, use_git=None, offline=None, download_if_needed=None, auto_upgrade=None): if path is None: path = PACKAGE_NAME if not (isinstance(path, _str_types) or path is False): raise TypeError('path must be a string or False') if PY3 and not isinstance(path, _text_type): fs_encoding = sys.getfilesystemencoding() path = path.decode(fs_encoding) # path to unicode self.path = path # Set other option attributes, using defaults where necessary self.index_url = index_url if index_url is not None else INDEX_URL self.offline = offline if offline is not None else OFFLINE # If offline=True, override download and auto-upgrade if self.offline: download_if_needed = False auto_upgrade = False self.download = (download_if_needed if download_if_needed is not None else DOWNLOAD_IF_NEEDED) self.auto_upgrade = (auto_upgrade if auto_upgrade is not None else AUTO_UPGRADE) # If this is a release then the .git directory will not exist so we # should not use git. git_dir_exists = os.path.exists(os.path.join(os.path.dirname(__file__), '.git')) if use_git is None and not git_dir_exists: use_git = False self.use_git = use_git if use_git is not None else USE_GIT # Declared as False by default--later we check if astropy-helpers can be # upgraded from PyPI, but only if not using a source distribution (as in # the case of import from a git submodule) self.is_submodule = False @classmethod def main(cls, argv=None): if argv is None: argv = sys.argv config = cls.parse_config() config.update(cls.parse_command_line(argv)) auto_use = config.pop('auto_use', False) bootstrapper = cls(**config) if auto_use: # Run the bootstrapper, otherwise the setup.py is using the old # use_astropy_helpers() interface, in which case it will run the # bootstrapper manually after reconfiguring it. bootstrapper.run() return bootstrapper @classmethod def parse_config(cls): if not os.path.exists('setup.cfg'): return {} cfg = ConfigParser() try: cfg.read('setup.cfg') except Exception as e: if DEBUG: raise log.error( "Error reading setup.cfg: {0!r}\n{1} will not be " "automatically bootstrapped and package installation may fail." "\n{2}".format(e, PACKAGE_NAME, _err_help_msg)) return {} if not cfg.has_section('ah_bootstrap'): return {} config = {} for option, type_ in CFG_OPTIONS: if not cfg.has_option('ah_bootstrap', option): continue if type_ is bool: value = cfg.getboolean('ah_bootstrap', option) else: value = cfg.get('ah_bootstrap', option) config[option] = value return config @classmethod def parse_command_line(cls, argv=None): if argv is None: argv = sys.argv config = {} # For now we just pop recognized ah_bootstrap options out of the # arg list. This is imperfect; in the unlikely case that a setup.py # custom command or even custom Distribution class defines an argument # of the same name then we will break that. However there's a catch22 # here that we can't just do full argument parsing right here, because # we don't yet know *how* to parse all possible command-line arguments. if '--no-git' in argv: config['use_git'] = False argv.remove('--no-git') if '--offline' in argv: config['offline'] = True argv.remove('--offline') return config def run(self): strategies = ['local_directory', 'local_file', 'index'] dist = None # First, remove any previously imported versions of astropy_helpers; # this is necessary for nested installs where one package's installer # is installing another package via setuptools.sandbox.run_setup, as in # the case of setup_requires for key in list(sys.modules): try: if key == PACKAGE_NAME or key.startswith(PACKAGE_NAME + '.'): del sys.modules[key] except AttributeError: # Sometimes mysterious non-string things can turn up in # sys.modules continue # Check to see if the path is a submodule self.is_submodule = self._check_submodule() for strategy in strategies: method = getattr(self, 'get_{0}_dist'.format(strategy)) dist = method() if dist is not None: break else: raise _AHBootstrapSystemExit( "No source found for the {0!r} package; {0} must be " "available and importable as a prerequisite to building " "or installing this package.".format(PACKAGE_NAME)) # This is a bit hacky, but if astropy_helpers was loaded from a # directory/submodule its Distribution object gets a "precedence" of # "DEVELOP_DIST". However, in other cases it gets a precedence of # "EGG_DIST". However, when activing the distribution it will only be # placed early on sys.path if it is treated as an EGG_DIST, so always # do that dist = dist.clone(precedence=pkg_resources.EGG_DIST) # Otherwise we found a version of astropy-helpers, so we're done # Just active the found distribution on sys.path--if we did a # download this usually happens automatically but it doesn't hurt to # do it again # Note: Adding the dist to the global working set also activates it # (makes it importable on sys.path) by default. try: pkg_resources.working_set.add(dist, replace=True) except TypeError: # Some (much) older versions of setuptools do not have the # replace=True option here. These versions are old enough that all # bets may be off anyways, but it's easy enough to work around just # in case... if dist.key in pkg_resources.working_set.by_key: del pkg_resources.working_set.by_key[dist.key] pkg_resources.working_set.add(dist) @property def config(self): """ A `dict` containing the options this `_Bootstrapper` was configured with. """ return dict((optname, getattr(self, optname)) for optname, _ in CFG_OPTIONS if hasattr(self, optname)) def get_local_directory_dist(self): """ Handle importing a vendored package from a subdirectory of the source distribution. """ if not os.path.isdir(self.path): return log.info('Attempting to import astropy_helpers from {0} {1!r}'.format( 'submodule' if self.is_submodule else 'directory', self.path)) dist = self._directory_import() if dist is None: log.warn( 'The requested path {0!r} for importing {1} does not ' 'exist, or does not contain a copy of the {1} ' 'package.'.format(self.path, PACKAGE_NAME)) elif self.auto_upgrade and not self.is_submodule: # A version of astropy-helpers was found on the available path, but # check to see if a bugfix release is available on PyPI upgrade = self._do_upgrade(dist) if upgrade is not None: dist = upgrade return dist def get_local_file_dist(self): """ Handle importing from a source archive; this also uses setup_requires but points easy_install directly to the source archive. """ if not os.path.isfile(self.path): return log.info('Attempting to unpack and import astropy_helpers from ' '{0!r}'.format(self.path)) try: dist = self._do_download(find_links=[self.path]) except Exception as e: if DEBUG: raise log.warn( 'Failed to import {0} from the specified archive {1!r}: ' '{2}'.format(PACKAGE_NAME, self.path, str(e))) dist = None if dist is not None and self.auto_upgrade: # A version of astropy-helpers was found on the available path, but # check to see if a bugfix release is available on PyPI upgrade = self._do_upgrade(dist) if upgrade is not None: dist = upgrade return dist def get_index_dist(self): if not self.download: log.warn('Downloading {0!r} disabled.'.format(DIST_NAME)) return None log.warn( "Downloading {0!r}; run setup.py with the --offline option to " "force offline installation.".format(DIST_NAME)) try: dist = self._do_download() except Exception as e: if DEBUG: raise log.warn( 'Failed to download and/or install {0!r} from {1!r}:\n' '{2}'.format(DIST_NAME, self.index_url, str(e))) dist = None # No need to run auto-upgrade here since we've already presumably # gotten the most up-to-date version from the package index return dist def _directory_import(self): """ Import astropy_helpers from the given path, which will be added to sys.path. Must return True if the import succeeded, and False otherwise. """ # Return True on success, False on failure but download is allowed, and # otherwise raise SystemExit path = os.path.abspath(self.path) # Use an empty WorkingSet rather than the man # pkg_resources.working_set, since on older versions of setuptools this # will invoke a VersionConflict when trying to install an upgrade ws = pkg_resources.WorkingSet([]) ws.add_entry(path) dist = ws.by_key.get(DIST_NAME) if dist is None: # We didn't find an egg-info/dist-info in the given path, but if a # setup.py exists we can generate it setup_py = os.path.join(path, 'setup.py') if os.path.isfile(setup_py): with _silence(): run_setup(os.path.join(path, 'setup.py'), ['egg_info']) for dist in pkg_resources.find_distributions(path, True): # There should be only one... return dist return dist def _do_download(self, version='', find_links=None): if find_links: allow_hosts = '' index_url = None else: allow_hosts = None index_url = self.index_url # Annoyingly, setuptools will not handle other arguments to # Distribution (such as options) before handling setup_requires, so it # is not straightforward to programmatically augment the arguments which # are passed to easy_install class _Distribution(Distribution): def get_option_dict(self, command_name): opts = Distribution.get_option_dict(self, command_name) if command_name == 'easy_install': if find_links is not None: opts['find_links'] = ('setup script', find_links) if index_url is not None: opts['index_url'] = ('setup script', index_url) if allow_hosts is not None: opts['allow_hosts'] = ('setup script', allow_hosts) return opts if version: req = '{0}=={1}'.format(DIST_NAME, version) else: req = DIST_NAME attrs = {'setup_requires': [req]} try: if DEBUG: _Distribution(attrs=attrs) else: with _silence(): _Distribution(attrs=attrs) # If the setup_requires succeeded it will have added the new dist to # the main working_set return pkg_resources.working_set.by_key.get(DIST_NAME) except Exception as e: if DEBUG: raise msg = 'Error retrieving {0} from {1}:\n{2}' if find_links: source = find_links[0] elif index_url != INDEX_URL: source = index_url else: source = 'PyPI' raise Exception(msg.format(DIST_NAME, source, repr(e))) def _do_upgrade(self, dist): # Build up a requirement for a higher bugfix release but a lower minor # release (so API compatibility is guaranteed) next_version = _next_version(dist.parsed_version) req = pkg_resources.Requirement.parse( '{0}>{1},<{2}'.format(DIST_NAME, dist.version, next_version)) package_index = PackageIndex(index_url=self.index_url) upgrade = package_index.obtain(req) if upgrade is not None: return self._do_download(version=upgrade.version) def _check_submodule(self): """ Check if the given path is a git submodule. See the docstrings for ``_check_submodule_using_git`` and ``_check_submodule_no_git`` for further details. """ if (self.path is None or (os.path.exists(self.path) and not os.path.isdir(self.path))): return False if self.use_git: return self._check_submodule_using_git() else: return self._check_submodule_no_git() def _check_submodule_using_git(self): """ Check if the given path is a git submodule. If so, attempt to initialize and/or update the submodule if needed. This function makes calls to the ``git`` command in subprocesses. The ``_check_submodule_no_git`` option uses pure Python to check if the given path looks like a git submodule, but it cannot perform updates. """ cmd = ['git', 'submodule', 'status', '--', self.path] try: log.info('Running `{0}`; use the --no-git option to disable git ' 'commands'.format(' '.join(cmd))) returncode, stdout, stderr = run_cmd(cmd) except _CommandNotFound: # The git command simply wasn't found; this is most likely the # case on user systems that don't have git and are simply # trying to install the package from PyPI or a source # distribution. Silently ignore this case and simply don't try # to use submodules return False stderr = stderr.strip() if returncode != 0 and stderr: # Unfortunately the return code alone cannot be relied on, as # earlier versions of git returned 0 even if the requested submodule # does not exist # This is a warning that occurs in perl (from running git submodule) # which only occurs with a malformatted locale setting which can # happen sometimes on OSX. See again # https://github.com/astropy/astropy/issues/2749 perl_warning = ('perl: warning: Falling back to the standard locale ' '("C").') if not stderr.strip().endswith(perl_warning): # Some other unknown error condition occurred log.warn('git submodule command failed ' 'unexpectedly:\n{0}'.format(stderr)) return False # Output of `git submodule status` is as follows: # # 1: Status indicator: '-' for submodule is uninitialized, '+' if # submodule is initialized but is not at the commit currently indicated # in .gitmodules (and thus needs to be updated), or 'U' if the # submodule is in an unstable state (i.e. has merge conflicts) # # 2. SHA-1 hash of the current commit of the submodule (we don't really # need this information but it's useful for checking that the output is # correct) # # 3. The output of `git describe` for the submodule's current commit # hash (this includes for example what branches the commit is on) but # only if the submodule is initialized. We ignore this information for # now _git_submodule_status_re = re.compile( '^(?P[+-U ])(?P[0-9a-f]{40}) ' '(?P\S+)( .*)?$') # The stdout should only contain one line--the status of the # requested submodule m = _git_submodule_status_re.match(stdout) if m: # Yes, the path *is* a git submodule self._update_submodule(m.group('submodule'), m.group('status')) return True else: log.warn( 'Unexpected output from `git submodule status`:\n{0}\n' 'Will attempt import from {1!r} regardless.'.format( stdout, self.path)) return False def _check_submodule_no_git(self): """ Like ``_check_submodule_using_git``, but simply parses the .gitmodules file to determine if the supplied path is a git submodule, and does not exec any subprocesses. This can only determine if a path is a submodule--it does not perform updates, etc. This function may need to be updated if the format of the .gitmodules file is changed between git versions. """ gitmodules_path = os.path.abspath('.gitmodules') if not os.path.isfile(gitmodules_path): return False # This is a minimal reader for gitconfig-style files. It handles a few of # the quirks that make gitconfig files incompatible with ConfigParser-style # files, but does not support the full gitconfig syntax (just enough # needed to read a .gitmodules file). gitmodules_fileobj = io.StringIO() # Must use io.open for cross-Python-compatible behavior wrt unicode with io.open(gitmodules_path) as f: for line in f: # gitconfig files are more flexible with leading whitespace; just # go ahead and remove it line = line.lstrip() # comments can start with either # or ; if line and line[0] in (':', ';'): continue gitmodules_fileobj.write(line) gitmodules_fileobj.seek(0) cfg = RawConfigParser() try: cfg.readfp(gitmodules_fileobj) except Exception as exc: log.warn('Malformatted .gitmodules file: {0}\n' '{1} cannot be assumed to be a git submodule.'.format( exc, self.path)) return False for section in cfg.sections(): if not cfg.has_option(section, 'path'): continue submodule_path = cfg.get(section, 'path').rstrip(os.sep) if submodule_path == self.path.rstrip(os.sep): return True return False def _update_submodule(self, submodule, status): if status == ' ': # The submodule is up to date; no action necessary return elif status == '-': if self.offline: raise _AHBootstrapSystemExit( "Cannot initialize the {0} submodule in --offline mode; " "this requires being able to clone the submodule from an " "online repository.".format(submodule)) cmd = ['update', '--init'] action = 'Initializing' elif status == '+': cmd = ['update'] action = 'Updating' if self.offline: cmd.append('--no-fetch') elif status == 'U': raise _AHBoostrapSystemExit( 'Error: Submodule {0} contains unresolved merge conflicts. ' 'Please complete or abandon any changes in the submodule so that ' 'it is in a usable state, then try again.'.format(submodule)) else: log.warn('Unknown status {0!r} for git submodule {1!r}. Will ' 'attempt to use the submodule as-is, but try to ensure ' 'that the submodule is in a clean state and contains no ' 'conflicts or errors.\n{2}'.format(status, submodule, _err_help_msg)) return err_msg = None cmd = ['git', 'submodule'] + cmd + ['--', submodule] log.warn('{0} {1} submodule with: `{2}`'.format( action, submodule, ' '.join(cmd))) try: log.info('Running `{0}`; use the --no-git option to disable git ' 'commands'.format(' '.join(cmd))) returncode, stdout, stderr = run_cmd(cmd) except OSError as e: err_msg = str(e) else: if returncode != 0: err_msg = stderr if err_msg is not None: log.warn('An unexpected error occurred updating the git submodule ' '{0!r}:\n{1}\n{2}'.format(submodule, err_msg, _err_help_msg)) class _CommandNotFound(OSError): """ An exception raised when a command run with run_cmd is not found on the system. """ def run_cmd(cmd): """ Run a command in a subprocess, given as a list of command-line arguments. Returns a ``(returncode, stdout, stderr)`` tuple. """ try: p = sp.Popen(cmd, stdout=sp.PIPE, stderr=sp.PIPE) # XXX: May block if either stdout or stderr fill their buffers; # however for the commands this is currently used for that is # unlikely (they should have very brief output) stdout, stderr = p.communicate() except OSError as e: if DEBUG: raise if e.errno == errno.ENOENT: msg = 'Command not found: `{0}`'.format(' '.join(cmd)) raise _CommandNotFound(msg, cmd) else: raise _AHBoostrapSystemExit( 'An unexpected error occurred when running the ' '`{0}` command:\n{1}'.format(' '.join(cmd), str(e))) # Can fail of the default locale is not configured properly. See # https://github.com/astropy/astropy/issues/2749. For the purposes under # consideration 'latin1' is an acceptable fallback. try: stdio_encoding = locale.getdefaultlocale()[1] or 'latin1' except ValueError: # Due to an OSX oddity locale.getdefaultlocale() can also crash # depending on the user's locale/language settings. See: # http://bugs.python.org/issue18378 stdio_encoding = 'latin1' # Unlikely to fail at this point but even then let's be flexible if not isinstance(stdout, _text_type): stdout = stdout.decode(stdio_encoding, 'replace') if not isinstance(stderr, _text_type): stderr = stderr.decode(stdio_encoding, 'replace') return (p.returncode, stdout, stderr) def _next_version(version): """ Given a parsed version from pkg_resources.parse_version, returns a new version string with the next minor version. Examples ======== >>> _next_version(pkg_resources.parse_version('1.2.3')) '1.3.0' """ if hasattr(version, 'base_version'): # New version parsing from setuptools >= 8.0 if version.base_version: parts = version.base_version.split('.') else: parts = [] else: parts = [] for part in version: if part.startswith('*'): break parts.append(part) parts = [int(p) for p in parts] if len(parts) < 3: parts += [0] * (3 - len(parts)) major, minor, micro = parts[:3] return '{0}.{1}.{2}'.format(major, minor + 1, 0) class _DummyFile(object): """A noop writeable object.""" errors = '' # Required for Python 3.x encoding = 'utf-8' def write(self, s): pass def flush(self): pass @contextlib.contextmanager def _silence(): """A context manager that silences sys.stdout and sys.stderr.""" old_stdout = sys.stdout old_stderr = sys.stderr sys.stdout = _DummyFile() sys.stderr = _DummyFile() exception_occurred = False try: yield except: exception_occurred = True # Go ahead and clean up so that exception handling can work normally sys.stdout = old_stdout sys.stderr = old_stderr raise if not exception_occurred: sys.stdout = old_stdout sys.stderr = old_stderr _err_help_msg = """ If the problem persists consider installing astropy_helpers manually using pip (`pip install astropy_helpers`) or by manually downloading the source archive, extracting it, and installing by running `python setup.py install` from the root of the extracted source code. """ class _AHBootstrapSystemExit(SystemExit): def __init__(self, *args): if not args: msg = 'An unknown problem occurred bootstrapping astropy_helpers.' else: msg = args[0] msg += '\n' + _err_help_msg super(_AHBootstrapSystemExit, self).__init__(msg, *args[1:]) if sys.version_info[:2] < (2, 7): # In Python 2.6 the distutils log does not log warnings, errors, etc. to # stderr so we have to wrap it to ensure consistency at least in this # module import distutils class log(object): def __getattr__(self, attr): return getattr(distutils.log, attr) def warn(self, msg, *args): self._log_to_stderr(distutils.log.WARN, msg, *args) def error(self, msg): self._log_to_stderr(distutils.log.ERROR, msg, *args) def fatal(self, msg): self._log_to_stderr(distutils.log.FATAL, msg, *args) def log(self, level, msg, *args): if level in (distutils.log.WARN, distutils.log.ERROR, distutils.log.FATAL): self._log_to_stderr(level, msg, *args) else: distutils.log.log(level, msg, *args) def _log_to_stderr(self, level, msg, *args): # This is the only truly 'public' way to get the current threshold # of the log current_threshold = distutils.log.set_threshold(distutils.log.WARN) distutils.log.set_threshold(current_threshold) if level >= current_threshold: if args: msg = msg % args sys.stderr.write('%s\n' % msg) sys.stderr.flush() log = log() BOOTSTRAPPER = _Bootstrapper.main() def use_astropy_helpers(**kwargs): """ Ensure that the `astropy_helpers` module is available and is importable. This supports automatic submodule initialization if astropy_helpers is included in a project as a git submodule, or will download it from PyPI if necessary. Parameters ---------- path : str or None, optional A filesystem path relative to the root of the project's source code that should be added to `sys.path` so that `astropy_helpers` can be imported from that path. If the path is a git submodule it will automatically be initialized and/or updated. The path may also be to a ``.tar.gz`` archive of the astropy_helpers source distribution. In this case the archive is automatically unpacked and made temporarily available on `sys.path` as a ``.egg`` archive. If `None` skip straight to downloading. download_if_needed : bool, optional If the provided filesystem path is not found an attempt will be made to download astropy_helpers from PyPI. It will then be made temporarily available on `sys.path` as a ``.egg`` archive (using the ``setup_requires`` feature of setuptools. If the ``--offline`` option is given at the command line the value of this argument is overridden to `False`. index_url : str, optional If provided, use a different URL for the Python package index than the main PyPI server. use_git : bool, optional If `False` no git commands will be used--this effectively disables support for git submodules. If the ``--no-git`` option is given at the command line the value of this argument is overridden to `False`. auto_upgrade : bool, optional By default, when installing a package from a non-development source distribution ah_boostrap will try to automatically check for patch releases to astropy-helpers on PyPI and use the patched version over any bundled versions. Setting this to `False` will disable that functionality. If the ``--offline`` option is given at the command line the value of this argument is overridden to `False`. offline : bool, optional If `False` disable all actions that require an internet connection, including downloading packages from the package index and fetching updates to any git submodule. Defaults to `True`. """ global BOOTSTRAPPER config = BOOTSTRAPPER.config config.update(**kwargs) # Create a new bootstrapper with the updated configuration and run it BOOTSTRAPPER = _Bootstrapper(**config) BOOTSTRAPPER.run() photutils-0.2.1/astropy_helpers/appveyor.yml0000600000214200020070000000230312632702254023534 0ustar lbradleySTSCI\science00000000000000# AppVeyor.com is a Continuous Integration service to build and run tests under # Windows environment: global: PYTHON: "C:\\conda" MINICONDA_VERSION: "3.5.5" CMD_IN_ENV: "cmd /E:ON /V:ON /C .\\ci-helpers\\appveyor\\windows_sdk.cmd" PYTHON_ARCH: "64" # needs to be set for CMD_IN_ENV to succeed. If a mix # of 32 bit and 64 bit builds are needed, move this # to the matrix section. CONDA_DEPENDENCIES: "numpy Cython sphinx pytest" matrix: - PYTHON_VERSION: "2.6" - PYTHON_VERSION: "2.7" - PYTHON_VERSION: "3.4" platform: -x64 install: # Set up ci-helpers - "git clone git://github.com/astropy/ci-helpers.git" - "powershell ci-helpers/appveyor/install-miniconda.ps1" - "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%" - "activate test" # Some of the tests use git commands that require a user to be configured - git config --global user.name "A U Thor" - git config --global user.email "author@example.com" # Install graphviz - cinst graphviz.portable # Not a .NET project, we build SunPy in the install step instead build: false test_script: - "%CMD_IN_ENV% py.test" photutils-0.2.1/astropy_helpers/astropy_helpers/0000700000214200020070000000000012646264032024371 5ustar lbradleySTSCI\science00000000000000photutils-0.2.1/astropy_helpers/astropy_helpers/__init__.py0000600000214200020070000000345412632702120026500 0ustar lbradleySTSCI\science00000000000000try: from .version import version as __version__ from .version import githash as __githash__ except ImportError: __version__ = '' __githash__ = '' # If we've made it as far as importing astropy_helpers, we don't need # ah_bootstrap in sys.modules anymore. Getting rid of it is actually necessary # if the package we're installing has a setup_requires of another package that # uses astropy_helpers (and possibly a different version at that) # See https://github.com/astropy/astropy/issues/3541 import sys if 'ah_bootstrap' in sys.modules: del sys.modules['ah_bootstrap'] # Note, this is repeated from ah_bootstrap.py, but is here too in case this # astropy-helpers was upgraded to from an older version that did not have this # check in its ah_bootstrap. # matplotlib can cause problems if it is imported from within a call of # run_setup(), because in some circumstances it will try to write to the user's # home directory, resulting in a SandboxViolation. See # https://github.com/matplotlib/matplotlib/pull/4165 # Making sure matplotlib, if it is available, is imported early in the setup # process can mitigate this (note importing matplotlib.pyplot has the same # issue) try: import matplotlib matplotlib.use('Agg') import matplotlib.pyplot except: # Ignore if this fails for *any* reason* pass import os # Ensure that all module-level code in astropy or other packages know that # we're in setup mode: if ('__main__' in sys.modules and hasattr(sys.modules['__main__'], '__file__')): filename = os.path.basename(sys.modules['__main__'].__file__) if filename.rstrip('co') == 'setup.py': if sys.version_info[0] >= 3: import builtins else: import __builtin__ as builtins builtins._ASTROPY_SETUP_ = True del filename photutils-0.2.1/astropy_helpers/astropy_helpers/commands/0000700000214200020070000000000012646264032026172 5ustar lbradleySTSCI\science00000000000000photutils-0.2.1/astropy_helpers/astropy_helpers/commands/__init__.py0000600000214200020070000000000012477406127030300 0ustar lbradleySTSCI\science00000000000000photutils-0.2.1/astropy_helpers/astropy_helpers/commands/_dummy.py0000600000214200020070000000557412632702254030051 0ustar lbradleySTSCI\science00000000000000""" Provides a base class for a 'dummy' setup.py command that has no functionality (probably due to a missing requirement). This dummy command can raise an exception when it is run, explaining to the user what dependencies must be met to use this command. The reason this is at all tricky is that we want the command to be able to provide this message even when the user passes arguments to the command. If we don't know ahead of time what arguments the command can take, this is difficult, because distutils does not allow unknown arguments to be passed to a setup.py command. This hacks around that restriction to provide a useful error message even when a user passes arguments to the dummy implementation of a command. Use this like: try: from some_dependency import SetupCommand except ImportError: from ._dummy import _DummyCommand class SetupCommand(_DummyCommand): description = \ 'Implementation of SetupCommand from some_dependency; ' 'some_dependency must be installed to run this command' # This is the message that will be raised when a user tries to # run this command--define it as a class attribute. error_msg = \ "The 'setup_command' command requires the some_dependency " "package to be installed and importable." """ import sys from setuptools import Command from distutils.errors import DistutilsArgError from textwrap import dedent class _DummyCommandMeta(type): """ Causes an exception to be raised on accessing attributes of a command class so that if ``./setup.py command_name`` is run with additional command-line options we can provide a useful error message instead of the default that tells users the options are unrecognized. """ def __init__(cls, name, bases, members): if bases == (Command, object): # This is the _DummyCommand base class, presumably return if not hasattr(cls, 'description'): raise TypeError( "_DummyCommand subclass must have a 'description' " "attribute.") if not hasattr(cls, 'error_msg'): raise TypeError( "_DummyCommand subclass must have an 'error_msg' " "attribute.") def __getattribute__(cls, attr): if attr in ('description', 'error_msg'): # Allow cls.description to work so that `./setup.py # --help-commands` still works return super(_DummyCommandMeta, cls).__getattribute__(attr) raise DistutilsArgError(cls.error_msg) if sys.version_info[0] < 3: exec(dedent(""" class _DummyCommand(Command, object): __metaclass__ = _DummyCommandMeta """)) else: exec(dedent(""" class _DummyCommand(Command, object, metaclass=_DummyCommandMeta): pass """)) photutils-0.2.1/astropy_helpers/astropy_helpers/commands/_test_compat.py0000600000214200020070000002666212632702120031231 0ustar lbradleySTSCI\science00000000000000""" Old implementation of ``./setup.py test`` command. This has been moved to astropy.tests as of Astropy v1.1.0, but a copy of the implementation is kept here for backwards compatibility. """ from __future__ import absolute_import, unicode_literals import inspect import os import shutil import subprocess import sys import tempfile from setuptools import Command from ..compat import _fix_user_options PY3 = sys.version_info[0] == 3 class AstropyTest(Command, object): description = 'Run the tests for this package' user_options = [ ('package=', 'P', "The name of a specific package to test, e.g. 'io.fits' or 'utils'. " "If nothing is specified, all default tests are run."), ('test-path=', 't', 'Specify a test location by path. If a relative path to a .py file, ' 'it is relative to the built package, so e.g., a leading "astropy/" ' 'is necessary. If a relative path to a .rst file, it is relative to ' 'the directory *below* the --docs-path directory, so a leading ' '"docs/" is usually necessary. May also be an absolute path.'), ('verbose-results', 'V', 'Turn on verbose output from pytest.'), ('plugins=', 'p', 'Plugins to enable when running pytest.'), ('pastebin=', 'b', "Enable pytest pastebin output. Either 'all' or 'failed'."), ('args=', 'a', 'Additional arguments to be passed to pytest.'), ('remote-data', 'R', 'Run tests that download remote data.'), ('pep8', '8', 'Enable PEP8 checking and disable regular tests. ' 'Requires the pytest-pep8 plugin.'), ('pdb', 'd', 'Start the interactive Python debugger on errors.'), ('coverage', 'c', 'Create a coverage report. Requires the coverage package.'), ('open-files', 'o', 'Fail if any tests leave files open. Requires the ' 'psutil package.'), ('parallel=', 'j', 'Run the tests in parallel on the specified number of ' 'CPUs. If negative, all the cores on the machine will be ' 'used. Requires the pytest-xdist plugin.'), ('docs-path=', None, 'The path to the documentation .rst files. If not provided, and ' 'the current directory contains a directory called "docs", that ' 'will be used.'), ('skip-docs', None, "Don't test the documentation .rst files."), ('repeat=', None, 'How many times to repeat each test (can be used to check for ' 'sporadic failures).'), ('temp-root=', None, 'The root directory in which to create the temporary testing files. ' 'If unspecified the system default is used (e.g. /tmp) as explained ' 'in the documentation for tempfile.mkstemp.') ] user_options = _fix_user_options(user_options) package_name = '' def initialize_options(self): self.package = None self.test_path = None self.verbose_results = False self.plugins = None self.pastebin = None self.args = None self.remote_data = False self.pep8 = False self.pdb = False self.coverage = False self.open_files = False self.parallel = 0 self.docs_path = None self.skip_docs = False self.repeat = None self.temp_root = None def finalize_options(self): # Normally we would validate the options here, but that's handled in # run_tests pass # Most of the test runner arguments have the same name as attributes on # this command class, with one exception (for now) _test_runner_arg_attr_map = { 'verbose': 'verbose_results' } def generate_testing_command(self): """ Build a Python script to run the tests. """ cmd_pre = '' # Commands to run before the test function cmd_post = '' # Commands to run after the test function if self.coverage: pre, post = self._generate_coverage_commands() cmd_pre += pre cmd_post += post def get_attr(arg): attr = self._test_runner_arg_attr_map.get(arg, arg) return getattr(self, attr) test_args = filter(lambda arg: hasattr(self, arg), self._get_test_runner_args()) test_args = ', '.join('{0}={1!r}'.format(arg, get_attr(arg)) for arg in test_args) if PY3: set_flag = "import builtins; builtins._ASTROPY_TEST_ = True" else: set_flag = "import __builtin__; __builtin__._ASTROPY_TEST_ = True" cmd = ('{cmd_pre}{0}; import {1.package_name}, sys; result = ' '{1.package_name}.test({test_args}); {cmd_post}' 'sys.exit(result)') return cmd.format(set_flag, self, cmd_pre=cmd_pre, cmd_post=cmd_post, test_args=test_args) def _validate_required_deps(self): """ This method checks that any required modules are installed before running the tests. """ try: import astropy except ImportError: raise ImportError( "The 'test' command requires the astropy package to be " "installed and importable.") def run(self): """ Run the tests! """ # Ensure there is a doc path if self.docs_path is None: if os.path.exists('docs'): self.docs_path = os.path.abspath('docs') # Build a testing install of the package self._build_temp_install() # Ensure all required packages are installed self._validate_required_deps() # Run everything in a try: finally: so that the tmp dir gets deleted. try: # Construct this modules testing command cmd = self.generate_testing_command() # Run the tests in a subprocess--this is necessary since # new extension modules may have appeared, and this is the # easiest way to set up a new environment # On Python 3.x prior to 3.3, the creation of .pyc files # is not atomic. py.test jumps through some hoops to make # this work by parsing import statements and carefully # importing files atomically. However, it can't detect # when __import__ is used, so its carefulness still fails. # The solution here (admittedly a bit of a hack), is to # turn off the generation of .pyc files altogether by # passing the `-B` switch to `python`. This does mean # that each core will have to compile .py file to bytecode # itself, rather than getting lucky and borrowing the work # already done by another core. Compilation is an # insignificant fraction of total testing time, though, so # it's probably not worth worrying about. retcode = subprocess.call([sys.executable, '-B', '-c', cmd], cwd=self.testing_path, close_fds=False) finally: # Remove temporary directory shutil.rmtree(self.tmp_dir) raise SystemExit(retcode) def _build_temp_install(self): """ Build the package and copy the build to a temporary directory for the purposes of testing this avoids creating pyc and __pycache__ directories inside the build directory """ self.reinitialize_command('build', inplace=True) self.run_command('build') build_cmd = self.get_finalized_command('build') new_path = os.path.abspath(build_cmd.build_lib) # On OSX the default path for temp files is under /var, but in most # cases on OSX /var is actually a symlink to /private/var; ensure we # dereference that link, because py.test is very sensitive to relative # paths... tmp_dir = tempfile.mkdtemp(prefix=self.package_name + '-test-', dir=self.temp_root) self.tmp_dir = os.path.realpath(tmp_dir) self.testing_path = os.path.join(self.tmp_dir, os.path.basename(new_path)) shutil.copytree(new_path, self.testing_path) new_docs_path = os.path.join(self.tmp_dir, os.path.basename(self.docs_path)) shutil.copytree(self.docs_path, new_docs_path) self.docs_path = new_docs_path shutil.copy('setup.cfg', self.tmp_dir) def _generate_coverage_commands(self): """ This method creates the post and pre commands if coverage is to be generated """ if self.parallel != 0: raise ValueError( "--coverage can not be used with --parallel") try: import coverage except ImportError: raise ImportError( "--coverage requires that the coverage package is " "installed.") # Don't use get_pkg_data_filename here, because it # requires importing astropy.config and thus screwing # up coverage results for those packages. coveragerc = os.path.join( self.testing_path, self.package_name, 'tests', 'coveragerc') # We create a coveragerc that is specific to the version # of Python we're running, so that we can mark branches # as being specifically for Python 2 or Python 3 with open(coveragerc, 'r') as fd: coveragerc_content = fd.read() if PY3: ignore_python_version = '2' else: ignore_python_version = '3' coveragerc_content = coveragerc_content.replace( "{ignore_python_version}", ignore_python_version).replace( "{packagename}", self.package_name) tmp_coveragerc = os.path.join(self.tmp_dir, 'coveragerc') with open(tmp_coveragerc, 'wb') as tmp: tmp.write(coveragerc_content.encode('utf-8')) cmd_pre = ( 'import coverage; ' 'cov = coverage.coverage(data_file="{0}", config_file="{1}"); ' 'cov.start();'.format( os.path.abspath(".coverage"), tmp_coveragerc)) cmd_post = ( 'cov.stop(); ' 'from astropy.tests.helper import _save_coverage; ' '_save_coverage(cov, result, "{0}", "{1}");'.format( os.path.abspath('.'), self.testing_path)) return cmd_pre, cmd_post def _get_test_runner_args(self): """ A hack to determine what arguments are supported by the package's test() function. In the future there should be a more straightforward API to determine this (really it should be determined by the ``TestRunner`` class for whatever version of Astropy is in use). """ if PY3: import builtins builtins._ASTROPY_TEST_ = True else: import __builtin__ __builtin__._ASTROPY_TEST_ = True try: pkg = __import__(self.package_name) if not hasattr(pkg, 'test'): raise ImportError( 'package {0} does not have a {0}.test() function as ' 'required by the Astropy test runner'.format(package_name)) argspec = inspect.getargspec(pkg.test) return argspec.args finally: if PY3: del builtins._ASTROPY_TEST_ else: del __builtin__._ASTROPY_TEST_ photutils-0.2.1/astropy_helpers/astropy_helpers/commands/build_ext.py0000600000214200020070000004566512640232360030536 0ustar lbradleySTSCI\science00000000000000import errno import os import re import shlex import shutil import subprocess import sys import textwrap from distutils import log, ccompiler, sysconfig from distutils.cmd import Command from distutils.core import Extension from distutils.ccompiler import get_default_compiler from setuptools.command.build_ext import build_ext as SetuptoolsBuildExt from ..utils import get_numpy_include_path, invalidate_caches, classproperty from ..version_helpers import get_pkg_version_module def should_build_with_cython(package, release=None): """Returns the previously used Cython version (or 'unknown' if not previously built) if Cython should be used to build extension modules from pyx files. If the ``release`` parameter is not specified an attempt is made to determine the release flag from `astropy.version`. """ try: version_module = __import__(package + '.cython_version', fromlist=['release', 'cython_version']) except ImportError: version_module = None if release is None and version_module is not None: try: release = version_module.release except AttributeError: pass try: cython_version = version_module.cython_version except AttributeError: cython_version = 'unknown' # Only build with Cython if, of course, Cython is installed, we're in a # development version (i.e. not release) or the Cython-generated source # files haven't been created yet (cython_version == 'unknown'). The latter # case can happen even when release is True if checking out a release tag # from the repository have_cython = False try: import Cython have_cython = True except ImportError: pass if have_cython and (not release or cython_version == 'unknown'): return cython_version else: return False _compiler_versions = {} def get_compiler_version(compiler): if compiler in _compiler_versions: return _compiler_versions[compiler] # Different flags to try to get the compiler version # TODO: It might be worth making this configurable to support # arbitrary odd compilers; though all bets may be off in such # cases anyway flags = ['--version', '--Version', '-version', '-Version', '-v', '-V'] def try_get_version(flag): process = subprocess.Popen( shlex.split(compiler, posix=('win' not in sys.platform)) + [flag], stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = process.communicate() if process.returncode != 0: return 'unknown' output = stdout.strip().decode('latin-1') # Safest bet if not output: # Some compilers return their version info on stderr output = stderr.strip().decode('latin-1') if not output: output = 'unknown' return output for flag in flags: version = try_get_version(flag) if version != 'unknown': break # Cache results to speed up future calls _compiler_versions[compiler] = version return version # TODO: I think this can be reworked without having to create the class # programmatically. def generate_build_ext_command(packagename, release): """ Creates a custom 'build_ext' command that allows for manipulating some of the C extension options at build time. We use a function to build the class since the base class for build_ext may be different depending on certain build-time parameters (for example, we may use Cython's build_ext instead of the default version in distutils). Uses the default distutils.command.build_ext by default. """ class build_ext(SetuptoolsBuildExt, object): package_name = packagename is_release = release _user_options = SetuptoolsBuildExt.user_options[:] _boolean_options = SetuptoolsBuildExt.boolean_options[:] _help_options = SetuptoolsBuildExt.help_options[:] force_rebuild = False _broken_compiler_mapping = [ ('i686-apple-darwin[0-9]*-llvm-gcc-4.2', 'clang') ] # Warning: Spaghetti code ahead. # During setup.py, the setup_helpers module needs the ability to add # items to a command's user_options list. At this stage we don't know # whether or not we can build with Cython, and so don't know for sure # what base class will be used for build_ext; nevertheless we want to # be able to provide a list to add options into. # # Later, once setup() has been called we should have all build # dependencies included via setup_requires available. distutils needs # to be able to access the user_options as a *class* attribute before # the class has been initialized, but we do need to be able to # enumerate the options for the correct base class at that point @classproperty def user_options(cls): from distutils import core if core._setup_distribution is None: # We haven't gotten into setup() yet, and the Distribution has # not yet been initialized return cls._user_options return cls._final_class.user_options @classproperty def boolean_options(cls): # Similar to user_options above from distutils import core if core._setup_distribution is None: # We haven't gotten into setup() yet, and the Distribution has # not yet been initialized return cls._boolean_options return cls._final_class.boolean_options @classproperty def help_options(cls): # Similar to user_options above from distutils import core if core._setup_distribution is None: # We haven't gotten into setup() yet, and the Distribution has # not yet been initialized return cls._help_options return cls._final_class.help_options @classproperty(lazy=True) def _final_class(cls): """ Late determination of what the build_ext base class should be, depending on whether or not Cython is available. """ uses_cython = should_build_with_cython(cls.package_name, cls.is_release) if uses_cython: # We need to decide late on whether or not to use Cython's # build_ext (since Cython may not be available earlier in the # setup.py if it was brought in via setup_requires) from Cython.Distutils import build_ext as base_cls else: base_cls = SetuptoolsBuildExt # Create and return an instance of a new class based on this class # using one of the above possible base classes def merge_options(attr): base = getattr(base_cls, attr) ours = getattr(cls, '_' + attr) all_base = set(opt[0] for opt in base) return base + [opt for opt in ours if opt[0] not in all_base] boolean_options = (base_cls.boolean_options + [opt for opt in cls._boolean_options if opt not in base_cls.boolean_options]) members = dict(cls.__dict__) members.update({ 'user_options': merge_options('user_options'), 'help_options': merge_options('help_options'), 'boolean_options': boolean_options, 'uses_cython': uses_cython, }) # Update the base class for the original build_ext command build_ext.__bases__ = (base_cls, object) # Create a new class for the existing class, but now with the # appropriate base class depending on whether or not to use Cython. # Ensure that object is one of the bases to make a new-style class. return type(cls.__name__, (build_ext,), members) def __new__(cls, *args, **kwargs): # By the time the command is actually instantialized, the # Distribution instance for the build has been instantiated, which # means setup_requires has been processed--now we can determine # what base class we can use for the actual build, and return an # instance of a build_ext command that uses that base class (right # now the options being Cython.Distutils.build_ext, or the stock # setuptools build_ext) new_cls = super(build_ext, cls._final_class).__new__( cls._final_class) # Since the new cls is not a subclass of the original cls, we must # manually call its __init__ new_cls.__init__(*args, **kwargs) return new_cls def finalize_options(self): # Add a copy of the _compiler.so module as well, but only if there # are in fact C modules to compile (otherwise there's no reason to # include a record of the compiler used) # Note, self.extensions may not be set yet, but # self.distribution.ext_modules is where any extension modules # passed to setup() can be found self._adjust_compiler() extensions = self.distribution.ext_modules if extensions: src_path = os.path.relpath( os.path.join(os.path.dirname(__file__), 'src')) shutil.copy2(os.path.join(src_path, 'compiler.c'), os.path.join(self.package_name, '_compiler.c')) ext = Extension(self.package_name + '._compiler', [os.path.join(self.package_name, '_compiler.c')]) extensions.insert(0, ext) super(build_ext, self).finalize_options() # Generate if self.uses_cython: try: from Cython import __version__ as cython_version except ImportError: # This shouldn't happen if we made it this far cython_version = None if (cython_version is not None and cython_version != self.uses_cython): self.force_rebuild = True # Update the used cython version self.uses_cython = cython_version # Regardless of the value of the '--force' option, force a rebuild # if the debug flag changed from the last build if self.force_rebuild: self.force = True def run(self): # For extensions that require 'numpy' in their include dirs, # replace 'numpy' with the actual paths np_include = get_numpy_include_path() for extension in self.extensions: if 'numpy' in extension.include_dirs: idx = extension.include_dirs.index('numpy') extension.include_dirs.insert(idx, np_include) extension.include_dirs.remove('numpy') self._check_cython_sources(extension) super(build_ext, self).run() # Update cython_version.py if building with Cython try: cython_version = get_pkg_version_module( packagename, fromlist=['cython_version'])[0] except (AttributeError, ImportError): cython_version = 'unknown' if self.uses_cython and self.uses_cython != cython_version: package_dir = os.path.relpath(packagename) cython_py = os.path.join(package_dir, 'cython_version.py') with open(cython_py, 'w') as f: f.write('# Generated file; do not modify\n') f.write('cython_version = {0!r}\n'.format(self.uses_cython)) if os.path.isdir(self.build_lib): # The build/lib directory may not exist if the build_py # command was not previously run, which may sometimes be # the case self.copy_file(cython_py, os.path.join(self.build_lib, cython_py), preserve_mode=False) invalidate_caches() def _adjust_compiler(self): """ This function detects broken compilers and switches to another. If the environment variable CC is explicitly set, or a compiler is specified on the commandline, no override is performed -- the purpose here is to only override a default compiler. The specific compilers with problems are: * The default compiler in XCode-4.2, llvm-gcc-4.2, segfaults when compiling wcslib. The set of broken compilers can be updated by changing the compiler_mapping variable. It is a list of 2-tuples where the first in the pair is a regular expression matching the version of the broken compiler, and the second is the compiler to change to. """ if 'CC' in os.environ: # Check that CC is not set to llvm-gcc-4.2 c_compiler = os.environ['CC'] try: version = get_compiler_version(c_compiler) except OSError: msg = textwrap.dedent( """ The C compiler set by the CC environment variable: {compiler:s} cannot be found or executed. """.format(compiler=c_compiler)) log.warn(msg) sys.exit(1) for broken, fixed in self._broken_compiler_mapping: if re.match(broken, version): msg = textwrap.dedent( """Compiler specified by CC environment variable ({compiler:s}:{version:s}) will fail to compile {pkg:s}. Please set CC={fixed:s} and try again. You can do this, for example, by running: CC={fixed:s} python setup.py where is the command you ran. """.format(compiler=c_compiler, version=version, pkg=self.package_name, fixed=fixed)) log.warn(msg) sys.exit(1) # If C compiler is set via CC, and isn't broken, we are good to go. We # should definitely not try accessing the compiler specified by # ``sysconfig.get_config_var('CC')`` lower down, because this may fail # if the compiler used to compile Python is missing (and maybe this is # why the user is setting CC). For example, the official Python 2.7.3 # MacOS X binary was compiled with gcc-4.2, which is no longer available # in XCode 4. return if self.compiler is not None: # At this point, self.compiler will be set only if a compiler # was specified in the command-line or via setup.cfg, in which # case we don't do anything return compiler_type = ccompiler.get_default_compiler() if compiler_type == 'unix': # We have to get the compiler this way, as this is the one that is # used if os.environ['CC'] is not set. It is actually read in from # the Python Makefile. Note that this is not necessarily the same # compiler as returned by ccompiler.new_compiler() c_compiler = sysconfig.get_config_var('CC') try: version = get_compiler_version(c_compiler) except OSError: msg = textwrap.dedent( """ The C compiler used to compile Python {compiler:s}, and which is normally used to compile C extensions, is not available. You can explicitly specify which compiler to use by setting the CC environment variable, for example: CC=gcc python setup.py or if you are using MacOS X, you can try: CC=clang python setup.py """.format(compiler=c_compiler)) log.warn(msg) sys.exit(1) for broken, fixed in self._broken_compiler_mapping: if re.match(broken, version): os.environ['CC'] = fixed break def _check_cython_sources(self, extension): """ Where relevant, make sure that the .c files associated with .pyx modules are present (if building without Cython installed). """ # Determine the compiler we'll be using if self.compiler is None: compiler = get_default_compiler() else: compiler = self.compiler # Replace .pyx with C-equivalents, unless c files are missing for jdx, src in enumerate(extension.sources): base, ext = os.path.splitext(src) pyxfn = base + '.pyx' cfn = base + '.c' cppfn = base + '.cpp' if not os.path.isfile(pyxfn): continue if self.uses_cython: extension.sources[jdx] = pyxfn else: if os.path.isfile(cfn): extension.sources[jdx] = cfn elif os.path.isfile(cppfn): extension.sources[jdx] = cppfn else: msg = ( 'Could not find C/C++ file {0}.(c/cpp) for Cython ' 'file {1} when building extension {2}. Cython ' 'must be installed to build from a git ' 'checkout.'.format(base, pyxfn, extension.name)) raise IOError(errno.ENOENT, msg, cfn) # Current versions of Cython use deprecated Numpy API features # the use of which produces a few warnings when compiling. # These additional flags should squelch those warnings. # TODO: Feel free to remove this if/when a Cython update # removes use of the deprecated Numpy API if compiler == 'unix': extension.extra_compile_args.extend([ '-Wp,-w', '-Wno-unused-function']) return build_ext photutils-0.2.1/astropy_helpers/astropy_helpers/commands/build_py.py0000600000214200020070000000265612477406127030373 0ustar lbradleySTSCI\science00000000000000from setuptools.command.build_py import build_py as SetuptoolsBuildPy from ..utils import _get_platlib_dir class AstropyBuildPy(SetuptoolsBuildPy): user_options = SetuptoolsBuildPy.user_options[:] boolean_options = SetuptoolsBuildPy.boolean_options[:] def finalize_options(self): # Update build_lib settings from the build command to always put # build files in platform-specific subdirectories of build/, even # for projects with only pure-Python source (this is desirable # specifically for support of multiple Python version). build_cmd = self.get_finalized_command('build') platlib_dir = _get_platlib_dir(build_cmd) build_cmd.build_purelib = platlib_dir build_cmd.build_lib = platlib_dir self.build_lib = platlib_dir SetuptoolsBuildPy.finalize_options(self) def run_2to3(self, files, doctests=False): # Filter the files to exclude things that shouldn't be 2to3'd skip_2to3 = self.distribution.skip_2to3 filtered_files = [] for filename in files: for package in skip_2to3: if filename[len(self.build_lib) + 1:].startswith(package): break else: filtered_files.append(filename) SetuptoolsBuildPy.run_2to3(self, filtered_files, doctests) def run(self): # first run the normal build_py SetuptoolsBuildPy.run(self) photutils-0.2.1/astropy_helpers/astropy_helpers/commands/build_sphinx.py0000600000214200020070000002266712632702254031251 0ustar lbradleySTSCI\science00000000000000from __future__ import print_function import inspect import os import pkgutil import re import shutil import subprocess import sys import textwrap from distutils import log from distutils.cmd import DistutilsOptionError import sphinx from sphinx.setup_command import BuildDoc as SphinxBuildDoc from ..utils import minversion PY3 = sys.version_info[0] >= 3 class AstropyBuildSphinx(SphinxBuildDoc): """ A version of the ``build_sphinx`` command that uses the version of Astropy that is built by the setup ``build`` command, rather than whatever is installed on the system. To build docs against the installed version, run ``make html`` in the ``astropy/docs`` directory. This also automatically creates the docs/_static directories--this is needed because GitHub won't create the _static dir because it has no tracked files. """ description = 'Build Sphinx documentation for Astropy environment' user_options = SphinxBuildDoc.user_options[:] user_options.append(('warnings-returncode', 'w', 'Parses the sphinx output and sets the return code to 1 if there ' 'are any warnings. Note that this will cause the sphinx log to ' 'only update when it completes, rather than continuously as is ' 'normally the case.')) user_options.append(('clean-docs', 'l', 'Completely clean previous builds, including ' 'automodapi-generated files before building new ones')) user_options.append(('no-intersphinx', 'n', 'Skip intersphinx, even if conf.py says to use it')) user_options.append(('open-docs-in-browser', 'o', 'Open the docs in a browser (using the webbrowser module) if the ' 'build finishes successfully.')) boolean_options = SphinxBuildDoc.boolean_options[:] boolean_options.append('warnings-returncode') boolean_options.append('clean-docs') boolean_options.append('no-intersphinx') boolean_options.append('open-docs-in-browser') _self_iden_rex = re.compile(r"self\.([^\d\W][\w]+)", re.UNICODE) def initialize_options(self): SphinxBuildDoc.initialize_options(self) self.clean_docs = False self.no_intersphinx = False self.open_docs_in_browser = False self.warnings_returncode = False def finalize_options(self): #Clear out previous sphinx builds, if requested if self.clean_docs: dirstorm = [os.path.join(self.source_dir, 'api')] if self.build_dir is None: dirstorm.append('docs/_build') else: dirstorm.append(self.build_dir) for d in dirstorm: if os.path.isdir(d): log.info('Cleaning directory ' + d) shutil.rmtree(d) else: log.info('Not cleaning directory ' + d + ' because ' 'not present or not a directory') SphinxBuildDoc.finalize_options(self) def run(self): # TODO: Break this method up into a few more subroutines and # document them better import webbrowser if PY3: from urllib.request import pathname2url else: from urllib import pathname2url # This is used at the very end of `run` to decide if sys.exit should # be called. If it's None, it won't be. retcode = None # If possible, create the _static dir if self.build_dir is not None: # the _static dir should be in the same place as the _build dir # for Astropy basedir, subdir = os.path.split(self.build_dir) if subdir == '': # the path has a trailing /... basedir, subdir = os.path.split(basedir) staticdir = os.path.join(basedir, '_static') if os.path.isfile(staticdir): raise DistutilsOptionError( 'Attempted to build_sphinx in a location where' + staticdir + 'is a file. Must be a directory.') self.mkpath(staticdir) # Now make sure Astropy is built and determine where it was built build_cmd = self.reinitialize_command('build') build_cmd.inplace = 0 self.run_command('build') build_cmd = self.get_finalized_command('build') build_cmd_path = os.path.abspath(build_cmd.build_lib) ah_importer = pkgutil.get_importer('astropy_helpers') ah_path = os.path.abspath(ah_importer.path) # Now generate the source for and spawn a new process that runs the # command. This is needed to get the correct imports for the built # version runlines, runlineno = inspect.getsourcelines(SphinxBuildDoc.run) subproccode = textwrap.dedent(""" from sphinx.setup_command import * os.chdir({srcdir!r}) sys.path.insert(0, {build_cmd_path!r}) sys.path.insert(0, {ah_path!r}) """).format(build_cmd_path=build_cmd_path, ah_path=ah_path, srcdir=self.source_dir) # runlines[1:] removes 'def run(self)' on the first line subproccode += textwrap.dedent(''.join(runlines[1:])) # All "self.foo" in the subprocess code needs to be replaced by the # values taken from the current self in *this* process subproccode = self._self_iden_rex.split(subproccode) for i in range(1, len(subproccode), 2): iden = subproccode[i] val = getattr(self, iden) if iden.endswith('_dir'): # Directories should be absolute, because the `chdir` call # in the new process moves to a different directory subproccode[i] = repr(os.path.abspath(val)) else: subproccode[i] = repr(val) subproccode = ''.join(subproccode) # This is a quick gross hack, but it ensures that the code grabbed from # SphinxBuildDoc.run will work in Python 2 if it uses the print # function if minversion(sphinx, '1.3'): subproccode = 'from __future__ import print_function' + subproccode if self.no_intersphinx: # the confoverrides variable in sphinx.setup_command.BuildDoc can # be used to override the conf.py ... but this could well break # if future versions of sphinx change the internals of BuildDoc, # so remain vigilant! subproccode = subproccode.replace('confoverrides = {}', 'confoverrides = {\'intersphinx_mapping\':{}}') log.debug('Starting subprocess of {0} with python code:\n{1}\n' '[CODE END])'.format(sys.executable, subproccode)) # To return the number of warnings, we need to capture stdout. This # prevents a continuous updating at the terminal, but there's no # apparent way around this. if self.warnings_returncode: proc = subprocess.Popen([sys.executable, '-c', subproccode], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) with proc.stdout: for line in iter(proc.stdout.readline, b''): line = line.strip(b'\n') print(line.decode('utf-8')) if 'build succeeded.' in str(line): retcode = 0 else: retcode = 1 # Poll to set proc.retcode proc.wait() if retcode != 0: if os.environ.get('TRAVIS', None) == 'true': #this means we are in the travis build, so customize #the message appropriately. msg = ('The build_sphinx travis build FAILED ' 'because sphinx issued documentation ' 'warnings (scroll up to see the warnings).') else: # standard failure message msg = ('build_sphinx returning a non-zero exit ' 'code because sphinx issued documentation ' 'warnings.') log.warn(msg) else: proc = subprocess.Popen([sys.executable], stdin=subprocess.PIPE) proc.communicate(subproccode.encode('utf-8')) if proc.returncode == 0: if self.open_docs_in_browser: if self.builder == 'html': absdir = os.path.abspath(self.builder_target_dir) index_path = os.path.join(absdir, 'index.html') fileurl = 'file://' + pathname2url(index_path) webbrowser.open(fileurl) else: log.warn('open-docs-in-browser option was given, but ' 'the builder is not html! Ignoring.') else: log.warn('Sphinx Documentation subprocess failed with return ' 'code ' + str(proc.returncode)) retcode = proc.returncode if retcode is not None: # this is potentially dangerous in that there might be something # after the call to `setup` in `setup.py`, and exiting here will # prevent that from running. But there's no other apparent way # to signal what the return code should be. sys.exit(retcode) class AstropyBuildDocs(AstropyBuildSphinx): description = 'alias to the build_sphinx command' photutils-0.2.1/astropy_helpers/astropy_helpers/commands/install.py0000600000214200020070000000074612477406127030230 0ustar lbradleySTSCI\science00000000000000from setuptools.command.install import install as SetuptoolsInstall from ..utils import _get_platlib_dir class AstropyInstall(SetuptoolsInstall): user_options = SetuptoolsInstall.user_options[:] boolean_options = SetuptoolsInstall.boolean_options[:] def finalize_options(self): build_cmd = self.get_finalized_command('build') platlib_dir = _get_platlib_dir(build_cmd) self.build_lib = platlib_dir SetuptoolsInstall.finalize_options(self) photutils-0.2.1/astropy_helpers/astropy_helpers/commands/install_lib.py0000600000214200020070000000100012477406127031036 0ustar lbradleySTSCI\science00000000000000from setuptools.command.install_lib import install_lib as SetuptoolsInstallLib from ..utils import _get_platlib_dir class AstropyInstallLib(SetuptoolsInstallLib): user_options = SetuptoolsInstallLib.user_options[:] boolean_options = SetuptoolsInstallLib.boolean_options[:] def finalize_options(self): build_cmd = self.get_finalized_command('build') platlib_dir = _get_platlib_dir(build_cmd) self.build_dir = platlib_dir SetuptoolsInstallLib.finalize_options(self) photutils-0.2.1/astropy_helpers/astropy_helpers/commands/register.py0000600000214200020070000000454712477406127030411 0ustar lbradleySTSCI\science00000000000000from setuptools.command.register import register as SetuptoolsRegister class AstropyRegister(SetuptoolsRegister): """Extends the built in 'register' command to support a ``--hidden`` option to make the registered version hidden on PyPI by default. The result of this is that when a version is registered as "hidden" it can still be downloaded from PyPI, but it does not show up in the list of actively supported versions under http://pypi.python.org/pypi/astropy, and is not set as the most recent version. Although this can always be set through the web interface it may be more convenient to be able to specify via the 'register' command. Hidden may also be considered a safer default when running the 'register' command, though this command uses distutils' normal behavior if the ``--hidden`` option is omitted. """ user_options = SetuptoolsRegister.user_options + [ ('hidden', None, 'mark this release as hidden on PyPI by default') ] boolean_options = SetuptoolsRegister.boolean_options + ['hidden'] def initialize_options(self): SetuptoolsRegister.initialize_options(self) self.hidden = False def build_post_data(self, action): data = SetuptoolsRegister.build_post_data(self, action) if action == 'submit' and self.hidden: data['_pypi_hidden'] = '1' return data def _set_config(self): # The original register command is buggy--if you use .pypirc with a # server-login section *at all* the repository you specify with the -r # option will be overwritten with either the repository in .pypirc or # with the default, # If you do not have a .pypirc using the -r option will just crash. # Way to go distutils # If we don't set self.repository back to a default value _set_config # can crash if there was a user-supplied value for this option; don't # worry, we'll get the real value back afterwards self.repository = 'pypi' SetuptoolsRegister._set_config(self) options = self.distribution.get_option_dict('register') if 'repository' in options: source, value = options['repository'] # Really anything that came from setup.cfg or the command line # should override whatever was in .pypirc self.repository = value photutils-0.2.1/astropy_helpers/astropy_helpers/commands/setup_package.py0000600000214200020070000000016712477406127031372 0ustar lbradleySTSCI\science00000000000000from os.path import join def get_package_data(): return {'astropy_helpers.commands': [join('src', 'compiler.c')]} photutils-0.2.1/astropy_helpers/astropy_helpers/commands/src/0000700000214200020070000000000012646264032026761 5ustar lbradleySTSCI\science00000000000000photutils-0.2.1/astropy_helpers/astropy_helpers/commands/src/compiler.c0000600000214200020070000000573112477406127030754 0ustar lbradleySTSCI\science00000000000000#include /*************************************************************************** * Macros for determining the compiler version. * * These are borrowed from boost, and majorly abridged to include only * the compilers we care about. ***************************************************************************/ #ifndef PY3K #if PY_MAJOR_VERSION >= 3 #define PY3K 1 #else #define PY3K 0 #endif #endif #define STRINGIZE(X) DO_STRINGIZE(X) #define DO_STRINGIZE(X) #X #if defined __clang__ /* Clang C++ emulates GCC, so it has to appear early. */ # define COMPILER "Clang version " __clang_version__ #elif defined(__INTEL_COMPILER) || defined(__ICL) || defined(__ICC) || defined(__ECC) /* Intel */ # if defined(__INTEL_COMPILER) # define INTEL_VERSION __INTEL_COMPILER # elif defined(__ICL) # define INTEL_VERSION __ICL # elif defined(__ICC) # define INTEL_VERSION __ICC # elif defined(__ECC) # define INTEL_VERSION __ECC # endif # define COMPILER "Intel C compiler version " STRINGIZE(INTEL_VERSION) #elif defined(__GNUC__) /* gcc */ # define COMPILER "GCC version " __VERSION__ #elif defined(__SUNPRO_CC) /* Sun Workshop Compiler */ # define COMPILER "Sun compiler version " STRINGIZE(__SUNPRO_CC) #elif defined(_MSC_VER) /* Microsoft Visual C/C++ Must be last since other compilers define _MSC_VER for compatibility as well */ # if _MSC_VER < 1200 # define COMPILER_VERSION 5.0 # elif _MSC_VER < 1300 # define COMPILER_VERSION 6.0 # elif _MSC_VER == 1300 # define COMPILER_VERSION 7.0 # elif _MSC_VER == 1310 # define COMPILER_VERSION 7.1 # elif _MSC_VER == 1400 # define COMPILER_VERSION 8.0 # elif _MSC_VER == 1500 # define COMPILER_VERSION 9.0 # elif _MSC_VER == 1600 # define COMPILER_VERSION 10.0 # else # define COMPILER_VERSION _MSC_VER # endif # define COMPILER "Microsoft Visual C++ version " STRINGIZE(COMPILER_VERSION) #else /* Fallback */ # define COMPILER "Unknown compiler" #endif /*************************************************************************** * Module-level ***************************************************************************/ struct module_state { /* The Sun compiler can't handle empty structs */ #if defined(__SUNPRO_C) || defined(_MSC_VER) int _dummy; #endif }; #if PY3K static struct PyModuleDef moduledef = { PyModuleDef_HEAD_INIT, "_compiler", NULL, sizeof(struct module_state), NULL, NULL, NULL, NULL, NULL }; #define INITERROR return NULL PyMODINIT_FUNC PyInit__compiler(void) #else #define INITERROR return PyMODINIT_FUNC init_compiler(void) #endif { PyObject* m; #if PY3K m = PyModule_Create(&moduledef); #else m = Py_InitModule3("_compiler", NULL, NULL); #endif if (m == NULL) INITERROR; PyModule_AddStringConstant(m, "compiler", COMPILER); #if PY3K return m; #endif } photutils-0.2.1/astropy_helpers/astropy_helpers/commands/test.py0000600000214200020070000000251412632702254027525 0ustar lbradleySTSCI\science00000000000000""" Different implementations of the ``./setup.py test`` command depending on what's locally available. If Astropy v1.1.0.dev or later is available it should be possible to import AstropyTest from ``astropy.tests.command``. If ``astropy`` can be imported but not ``astropy.tests.command`` (i.e. an older version of Astropy), we can use the backwards-compat implementation of the command. If Astropy can't be imported at all then there is a skeleton implementation that allows users to at least discover the ``./setup.py test`` command and learn that they need Astropy to run it. """ # Previously these except statements caught only ImportErrors, but there are # some other obscure exceptional conditions that can occur when importing # astropy.tests (at least on older versions) that can cause these imports to # fail try: import astropy try: from astropy.tests.command import AstropyTest except Exception: from ._test_compat import AstropyTest except Exception: # No astropy at all--provide the dummy implementation from ._dummy import _DummyCommand class AstropyTest(_DummyCommand): command_name = 'test' description = 'Run the tests for this package' error_msg = ( "The 'test' command requires the astropy package to be " "installed and importable.") photutils-0.2.1/astropy_helpers/astropy_helpers/compat/0000700000214200020070000000000012646264032025654 5ustar lbradleySTSCI\science00000000000000photutils-0.2.1/astropy_helpers/astropy_helpers/compat/__init__.py0000600000214200020070000000056012346164025027766 0ustar lbradleySTSCI\science00000000000000def _fix_user_options(options): """ This is for Python 2.x and 3.x compatibility. distutils expects Command options to all be byte strings on Python 2 and Unicode strings on Python 3. """ def to_str_or_none(x): if x is None: return None return str(x) return [tuple(to_str_or_none(x) for x in y) for y in options] photutils-0.2.1/astropy_helpers/astropy_helpers/compat/_subprocess_py2/0000700000214200020070000000000012646264032030775 5ustar lbradleySTSCI\science00000000000000photutils-0.2.1/astropy_helpers/astropy_helpers/compat/_subprocess_py2/__init__.py0000600000214200020070000000243212346164025033107 0ustar lbradleySTSCI\science00000000000000from __future__ import absolute_import from subprocess import * def check_output(*popenargs, **kwargs): r"""Run command with arguments and return its output as a byte string. If the exit code was non-zero it raises a CalledProcessError. The CalledProcessError object will have the return code in the returncode attribute and output in the output attribute. The arguments are the same as for the Popen constructor. Example:: >>> check_output(["ls", "-l", "/dev/null"]) 'crw-rw-rw- 1 root root 1, 3 Oct 18 2007 /dev/null\n' The stdout argument is not allowed as it is used internally. To capture standard error in the result, use stderr=STDOUT.:: >>> check_output(["/bin/sh", "-c", ... "ls -l non_existent_file ; exit 0"], ... stderr=STDOUT) 'ls: non_existent_file: No such file or directory\n' """ if 'stdout' in kwargs: raise ValueError('stdout argument not allowed, it will be overridden.') process = Popen(stdout=PIPE, *popenargs, **kwargs) output, unused_err = process.communicate() retcode = process.poll() if retcode: cmd = kwargs.get("args") if cmd is None: cmd = popenargs[0] raise CalledProcessError(retcode, cmd) return output photutils-0.2.1/astropy_helpers/astropy_helpers/compat/subprocess.py0000600000214200020070000000105012346164025030412 0ustar lbradleySTSCI\science00000000000000""" A replacement wrapper around the subprocess module that adds check_output (which was only added to Python in 2.7. Instead of importing subprocess, other modules should use this as follows:: from astropy.utils.compat import subprocess This module is safe to import from anywhere within astropy. """ from __future__ import absolute_import, print_function import subprocess # python2.7 and later provide a check_output method if not hasattr(subprocess, 'check_output'): from ._subprocess_py2 import check_output from subprocess import * photutils-0.2.1/astropy_helpers/astropy_helpers/distutils_helpers.py0000600000214200020070000001735512477406127030533 0ustar lbradleySTSCI\science00000000000000""" This module contains various utilities for introspecting the distutils module and the setup process. Some of these utilities require the `astropy_helpers.setup_helpers.register_commands` function to be called first, as it will affect introspection of setuptools command-line arguments. Other utilities in this module do not have that restriction. """ import os import sys from distutils import ccompiler from distutils.dist import Distribution from distutils.errors import DistutilsError from .utils import silence # This function, and any functions that call it, require the setup in # `astropy_helpers.setup_helpers.register_commands` to be run first. def get_dummy_distribution(): """ Returns a distutils Distribution object used to instrument the setup environment before calling the actual setup() function. """ from .setup_helpers import _module_state if _module_state['registered_commands'] is None: raise RuntimeError( 'astropy_helpers.setup_helpers.register_commands() must be ' 'called before using ' 'astropy_helpers.setup_helpers.get_dummy_distribution()') # Pre-parse the Distutils command-line options and config files to if # the option is set. dist = Distribution({'script_name': os.path.basename(sys.argv[0]), 'script_args': sys.argv[1:]}) dist.cmdclass.update(_module_state['registered_commands']) with silence(): try: dist.parse_config_files() dist.parse_command_line() except (DistutilsError, AttributeError, SystemExit): # Let distutils handle DistutilsErrors itself AttributeErrors can # get raise for ./setup.py --help SystemExit can be raised if a # display option was used, for example pass return dist def get_distutils_option(option, commands): """ Returns the value of the given distutils option. Parameters ---------- option : str The name of the option commands : list of str The list of commands on which this option is available Returns ------- val : str or None the value of the given distutils option. If the option is not set, returns None. """ dist = get_dummy_distribution() for cmd in commands: cmd_opts = dist.command_options.get(cmd) if cmd_opts is not None and option in cmd_opts: return cmd_opts[option][1] else: return None def get_distutils_build_option(option): """ Returns the value of the given distutils build option. Parameters ---------- option : str The name of the option Returns ------- val : str or None The value of the given distutils build option. If the option is not set, returns None. """ return get_distutils_option(option, ['build', 'build_ext', 'build_clib']) def get_distutils_install_option(option): """ Returns the value of the given distutils install option. Parameters ---------- option : str The name of the option Returns ------- val : str or None The value of the given distutils build option. If the option is not set, returns None. """ return get_distutils_option(option, ['install']) def get_distutils_build_or_install_option(option): """ Returns the value of the given distutils build or install option. Parameters ---------- option : str The name of the option Returns ------- val : str or None The value of the given distutils build or install option. If the option is not set, returns None. """ return get_distutils_option(option, ['build', 'build_ext', 'build_clib', 'install']) def get_compiler_option(): """ Determines the compiler that will be used to build extension modules. Returns ------- compiler : str The compiler option specified for the build, build_ext, or build_clib command; or the default compiler for the platform if none was specified. """ compiler = get_distutils_build_option('compiler') if compiler is None: return ccompiler.get_default_compiler() return compiler def add_command_option(command, name, doc, is_bool=False): """ Add a custom option to a setup command. Issues a warning if the option already exists on that command. Parameters ---------- command : str The name of the command as given on the command line name : str The name of the build option doc : str A short description of the option, for the `--help` message is_bool : bool, optional When `True`, the option is a boolean option and doesn't require an associated value. """ dist = get_dummy_distribution() cmdcls = dist.get_command_class(command) if (hasattr(cmdcls, '_astropy_helpers_options') and name in cmdcls._astropy_helpers_options): return attr = name.replace('-', '_') if hasattr(cmdcls, attr): raise RuntimeError( '{0!r} already has a {1!r} class attribute, barring {2!r} from ' 'being usable as a custom option name.'.format(cmdcls, attr, name)) for idx, cmd in enumerate(cmdcls.user_options): if cmd[0] == name: log.warn('Overriding existing {0!r} option ' '{1!r}'.format(command, name)) del cmdcls.user_options[idx] if name in cmdcls.boolean_options: cmdcls.boolean_options.remove(name) break cmdcls.user_options.append((name, None, doc)) if is_bool: cmdcls.boolean_options.append(name) # Distutils' command parsing requires that a command object have an # attribute with the same name as the option (with '-' replaced with '_') # in order for that option to be recognized as valid setattr(cmdcls, attr, None) # This caches the options added through add_command_option so that if it is # run multiple times in the same interpreter repeated adds are ignored # (this way we can still raise a RuntimeError if a custom option overrides # a built-in option) if not hasattr(cmdcls, '_astropy_helpers_options'): cmdcls._astropy_helpers_options = set([name]) else: cmdcls._astropy_helpers_options.add(name) def get_distutils_display_options(): """ Returns a set of all the distutils display options in their long and short forms. These are the setup.py arguments such as --name or --version which print the project's metadata and then exit. Returns ------- opts : set The long and short form display option arguments, including the - or -- """ short_display_opts = set('-' + o[1] for o in Distribution.display_options if o[1]) long_display_opts = set('--' + o[0] for o in Distribution.display_options) # Include -h and --help which are not explicitly listed in # Distribution.display_options (as they are handled by optparse) short_display_opts.add('-h') long_display_opts.add('--help') # This isn't the greatest approach to hardcode these commands. # However, there doesn't seem to be a good way to determine # whether build *will be* run as part of the command at this # phase. display_commands = set([ 'clean', 'register', 'setopt', 'saveopts', 'egg_info', 'alias']) return short_display_opts.union(long_display_opts.union(display_commands)) def is_distutils_display_option(): """ Returns True if sys.argv contains any of the distutils display options such as --version or --name. """ display_options = get_distutils_display_options() return bool(set(sys.argv[1:]).intersection(display_options)) photutils-0.2.1/astropy_helpers/astropy_helpers/git_helpers.py0000600000214200020070000001372712477406127027271 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst """ Utilities for retrieving revision information from a project's git repository. """ # Do not remove the following comment; it is used by # astropy_helpers.version_helpers to determine the beginning of the code in # this module # BEGIN import locale import os import subprocess import warnings def _decode_stdio(stream): try: stdio_encoding = locale.getdefaultlocale()[1] or 'utf-8' except ValueError: stdio_encoding = 'utf-8' try: text = stream.decode(stdio_encoding) except UnicodeDecodeError: # Final fallback text = stream.decode('latin1') return text def update_git_devstr(version, path=None): """ Updates the git revision string if and only if the path is being imported directly from a git working copy. This ensures that the revision number in the version string is accurate. """ try: # Quick way to determine if we're in git or not - returns '' if not devstr = get_git_devstr(sha=True, show_warning=False, path=path) except OSError: return version if not devstr: # Probably not in git so just pass silently return version if 'dev' in version: # update to the current git revision version_base = version.split('.dev', 1)[0] devstr = get_git_devstr(sha=False, show_warning=False, path=path) return version_base + '.dev' + devstr else: #otherwise it's already the true/release version return version def get_git_devstr(sha=False, show_warning=True, path=None): """ Determines the number of revisions in this repository. Parameters ---------- sha : bool If True, the full SHA1 hash will be returned. Otherwise, the total count of commits in the repository will be used as a "revision number". show_warning : bool If True, issue a warning if git returns an error code, otherwise errors pass silently. path : str or None If a string, specifies the directory to look in to find the git repository. If `None`, the current working directory is used, and must be the root of the git repository. If given a filename it uses the directory containing that file. Returns ------- devversion : str Either a string with the revision number (if `sha` is False), the SHA1 hash of the current commit (if `sha` is True), or an empty string if git version info could not be identified. """ if path is None: path = os.getcwd() if not _get_repo_path(path, levels=0): return '' if not os.path.isdir(path): path = os.path.abspath(os.path.dirname(path)) if sha: # Faster for getting just the hash of HEAD cmd = ['rev-parse', 'HEAD'] else: cmd = ['rev-list', '--count', 'HEAD'] def run_git(cmd): try: p = subprocess.Popen(['git'] + cmd, cwd=path, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE) stdout, stderr = p.communicate() except OSError as e: if show_warning: warnings.warn('Error running git: ' + str(e)) return (None, b'', b'') if p.returncode == 128: if show_warning: warnings.warn('No git repository present at {0!r}! Using ' 'default dev version.'.format(path)) return (p.returncode, b'', b'') if p.returncode == 129: if show_warning: warnings.warn('Your git looks old (does it support {0}?); ' 'consider upgrading to v1.7.2 or ' 'later.'.format(cmd[0])) return (p.returncode, stdout, stderr) elif p.returncode != 0: if show_warning: warnings.warn('Git failed while determining revision ' 'count: {0}'.format(_decode_stdio(stderr))) return (p.returncode, stdout, stderr) return p.returncode, stdout, stderr returncode, stdout, stderr = run_git(cmd) if not sha and returncode == 129: # git returns 129 if a command option failed to parse; in # particular this could happen in git versions older than 1.7.2 # where the --count option is not supported # Also use --abbrev-commit and --abbrev=0 to display the minimum # number of characters needed per-commit (rather than the full hash) cmd = ['rev-list', '--abbrev-commit', '--abbrev=0', 'HEAD'] returncode, stdout, stderr = run_git(cmd) # Fall back on the old method of getting all revisions and counting # the lines if returncode == 0: return str(stdout.count(b'\n')) else: return '' elif sha: return _decode_stdio(stdout)[:40] else: return _decode_stdio(stdout).strip() def _get_repo_path(pathname, levels=None): """ Given a file or directory name, determine the root of the git repository this path is under. If given, this won't look any higher than ``levels`` (that is, if ``levels=0`` then the given path must be the root of the git repository and is returned if so. Returns `None` if the given path could not be determined to belong to a git repo. """ if os.path.isfile(pathname): current_dir = os.path.abspath(os.path.dirname(pathname)) elif os.path.isdir(pathname): current_dir = os.path.abspath(pathname) else: return None current_level = 0 while levels is None or current_level <= levels: if os.path.exists(os.path.join(current_dir, '.git')): return current_dir current_level += 1 if current_dir == os.path.dirname(current_dir): break current_dir = os.path.dirname(current_dir) return None photutils-0.2.1/astropy_helpers/astropy_helpers/setup_helpers.py0000600000214200020070000006310612632702254027633 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst """ This module contains a number of utilities for use during setup/build/packaging that are useful to astropy as a whole. """ from __future__ import absolute_import, print_function import collections import os import re import shutil import subprocess import sys import textwrap import traceback import warnings from distutils import log from distutils.dist import Distribution from distutils.errors import DistutilsOptionError, DistutilsModuleError from distutils.core import Extension from distutils.core import Command from distutils.command.sdist import sdist as DistutilsSdist from setuptools import find_packages as _find_packages from .distutils_helpers import * from .version_helpers import get_pkg_version_module from .utils import (silence, walk_skip_hidden, import_file, extends_doc, resolve_name, AstropyDeprecationWarning) from .commands.build_ext import generate_build_ext_command from .commands.build_py import AstropyBuildPy from .commands.install import AstropyInstall from .commands.install_lib import AstropyInstallLib from .commands.register import AstropyRegister from .commands.test import AstropyTest # These imports are not used in this module, but are included for backwards # compat with older versions of this module from .utils import get_numpy_include_path, write_if_different from .commands.build_ext import should_build_with_cython, get_compiler_version _module_state = { 'registered_commands': None, 'have_sphinx': False, 'package_cache': None, } try: import sphinx _module_state['have_sphinx'] = True except ValueError as e: # This can occur deep in the bowels of Sphinx's imports by way of docutils # and an occurrence of this bug: http://bugs.python.org/issue18378 # In this case sphinx is effectively unusable if 'unknown locale' in e.args[0]: log.warn( "Possible misconfiguration of one of the environment variables " "LC_ALL, LC_CTYPES, LANG, or LANGUAGE. For an example of how to " "configure your system's language environment on OSX see " "http://blog.remibergsma.com/2012/07/10/" "setting-locales-correctly-on-mac-osx-terminal-application/") except ImportError: pass except SyntaxError: # occurs if markupsafe is recent version, which doesn't support Python 3.2 pass PY3 = sys.version_info[0] >= 3 # This adds a new keyword to the setup() function Distribution.skip_2to3 = [] def adjust_compiler(package): """ This function detects broken compilers and switches to another. If the environment variable CC is explicitly set, or a compiler is specified on the commandline, no override is performed -- the purpose here is to only override a default compiler. The specific compilers with problems are: * The default compiler in XCode-4.2, llvm-gcc-4.2, segfaults when compiling wcslib. The set of broken compilers can be updated by changing the compiler_mapping variable. It is a list of 2-tuples where the first in the pair is a regular expression matching the version of the broken compiler, and the second is the compiler to change to. """ warnings.warn( 'Direct use of the adjust_compiler function in setup.py is ' 'deprecated and can be removed from your setup.py. This ' 'functionality is now incorporated directly into the build_ext ' 'command.', AstropyDeprecationWarning) def get_debug_option(packagename): """ Determines if the build is in debug mode. Returns ------- debug : bool True if the current build was started with the debug option, False otherwise. """ try: current_debug = get_pkg_version_module(packagename, fromlist=['debug'])[0] except (ImportError, AttributeError): current_debug = None # Only modify the debug flag if one of the build commands was explicitly # run (i.e. not as a sub-command of something else) dist = get_dummy_distribution() if any(cmd in dist.commands for cmd in ['build', 'build_ext']): debug = bool(get_distutils_build_option('debug')) else: debug = bool(current_debug) if current_debug is not None and current_debug != debug: build_ext_cmd = dist.get_command_class('build_ext') build_ext_cmd.force_rebuild = True return debug def register_commands(package, version, release, srcdir='.'): if _module_state['registered_commands'] is not None: return _module_state['registered_commands'] if _module_state['have_sphinx']: from .commands.build_sphinx import AstropyBuildSphinx, AstropyBuildDocs else: AstropyBuildSphinx = AstropyBuildDocs = FakeBuildSphinx _module_state['registered_commands'] = registered_commands = { 'test': generate_test_command(package), # Use distutils' sdist because it respects package_data. # setuptools/distributes sdist requires duplication of information in # MANIFEST.in 'sdist': DistutilsSdist, # The exact form of the build_ext command depends on whether or not # we're building a release version 'build_ext': generate_build_ext_command(package, release), # We have a custom build_py to generate the default configuration file 'build_py': AstropyBuildPy, # Since install can (in some circumstances) be run without # first building, we also need to override install and # install_lib. See #2223 'install': AstropyInstall, 'install_lib': AstropyInstallLib, 'register': AstropyRegister, 'build_sphinx': AstropyBuildSphinx, 'build_docs': AstropyBuildDocs } # Need to override the __name__ here so that the commandline options are # presented as being related to the "build" command, for example; normally # this wouldn't be necessary since commands also have a command_name # attribute, but there is a bug in distutils' help display code that it # uses __name__ instead of command_name. Yay distutils! for name, cls in registered_commands.items(): cls.__name__ = name # Add a few custom options; more of these can be added by specific packages # later for option in [ ('use-system-libraries', "Use system libraries whenever possible", True)]: add_command_option('build', *option) add_command_option('install', *option) add_command_hooks(registered_commands, srcdir=srcdir) return registered_commands def add_command_hooks(commands, srcdir='.'): """ Look through setup_package.py modules for functions with names like ``pre__hook`` and ``post__hook`` where ```` is the name of a ``setup.py`` command (e.g. build_ext). If either hook is present this adds a wrapped version of that command to the passed in ``commands`` `dict`. ``commands`` may be pre-populated with other custom distutils command classes that should be wrapped if there are hooks for them (e.g. `AstropyBuildPy`). """ hook_re = re.compile(r'^(pre|post)_(.+)_hook$') # Distutils commands have a method of the same name, but it is not a # *classmethod* (which probably didn't exist when distutils was first # written) def get_command_name(cmdcls): if hasattr(cmdcls, 'command_name'): return cmdcls.command_name else: return cmdcls.__name__ packages = filter_packages(find_packages(srcdir)) dist = get_dummy_distribution() hooks = collections.defaultdict(dict) for setuppkg in iter_setup_packages(srcdir, packages): for name, obj in vars(setuppkg).items(): match = hook_re.match(name) if not match: continue hook_type = match.group(1) cmd_name = match.group(2) cmd_cls = dist.get_command_class(cmd_name) if hook_type not in hooks[cmd_name]: hooks[cmd_name][hook_type] = [] hooks[cmd_name][hook_type].append((setuppkg.__name__, obj)) for cmd_name, cmd_hooks in hooks.items(): commands[cmd_name] = generate_hooked_command( cmd_name, dist.get_command_class(cmd_name), cmd_hooks) def generate_hooked_command(cmd_name, cmd_cls, hooks): """ Returns a generated subclass of ``cmd_cls`` that runs the pre- and post-command hooks for that command before and after the ``cmd_cls.run`` method. """ def run(self, orig_run=cmd_cls.run): self.run_command_hooks('pre_hooks') orig_run(self) self.run_command_hooks('post_hooks') return type(cmd_name, (cmd_cls, object), {'run': run, 'run_command_hooks': run_command_hooks, 'pre_hooks': hooks.get('pre', []), 'post_hooks': hooks.get('post', [])}) def run_command_hooks(cmd_obj, hook_kind): """Run hooks registered for that command and phase. *cmd_obj* is a finalized command object; *hook_kind* is either 'pre_hook' or 'post_hook'. """ hooks = getattr(cmd_obj, hook_kind, None) if not hooks: return for modname, hook in hooks: if isinstance(hook, str): try: hook_obj = resolve_name(hook) except ImportError as exc: raise DistutilsModuleError( 'cannot find hook {0}: {1}'.format(hook, err)) else: hook_obj = hook if not callable(hook_obj): raise DistutilsOptionError('hook {0!r} is not callable' % hook) log.info('running {0} from {1} for {2} command'.format( hook_kind.rstrip('s'), modname, cmd_obj.get_command_name())) try : hook_obj(cmd_obj) except Exception as exc: log.error('{0} command hook {1} raised an exception: %s\n'.format( hook_obj.__name__, cmd_obj.get_command_name())) log.error(traceback.format_exc()) sys.exit(1) def generate_test_command(package_name): """ Creates a custom 'test' command for the given package which sets the command's ``package_name`` class attribute to the name of the package being tested. """ return type(package_name.title() + 'Test', (AstropyTest,), {'package_name': package_name}) def update_package_files(srcdir, extensions, package_data, packagenames, package_dirs): """ This function is deprecated and maintained for backward compatibility with affiliated packages. Affiliated packages should update their setup.py to use `get_package_info` instead. """ info = get_package_info(srcdir) extensions.extend(info['ext_modules']) package_data.update(info['package_data']) packagenames = list(set(packagenames + info['packages'])) package_dirs.update(info['package_dir']) def get_package_info(srcdir='.', exclude=()): """ Collates all of the information for building all subpackages subpackages and returns a dictionary of keyword arguments that can be passed directly to `distutils.setup`. The purpose of this function is to allow subpackages to update the arguments to the package's ``setup()`` function in its setup.py script, rather than having to specify all extensions/package data directly in the ``setup.py``. See Astropy's own ``setup.py`` for example usage and the Astropy development docs for more details. This function obtains that information by iterating through all packages in ``srcdir`` and locating a ``setup_package.py`` module. This module can contain the following functions: ``get_extensions()``, ``get_package_data()``, ``get_build_options()``, ``get_external_libraries()``, and ``requires_2to3()``. Each of those functions take no arguments. - ``get_extensions`` returns a list of `distutils.extension.Extension` objects. - ``get_package_data()`` returns a dict formatted as required by the ``package_data`` argument to ``setup()``. - ``get_build_options()`` returns a list of tuples describing the extra build options to add. - ``get_external_libraries()`` returns a list of libraries that can optionally be built using external dependencies. - ``get_entry_points()`` returns a dict formatted as required by the ``entry_points`` argument to ``setup()``. - ``requires_2to3()`` should return `True` when the source code requires `2to3` processing to run on Python 3.x. If ``requires_2to3()`` is missing, it is assumed to return `True`. """ ext_modules = [] packages = [] package_data = {} package_dir = {} skip_2to3 = [] # Use the find_packages tool to locate all packages and modules packages = filter_packages(find_packages(srcdir, exclude=exclude)) # For each of the setup_package.py modules, extract any # information that is needed to install them. The build options # are extracted first, so that their values will be available in # subsequent calls to `get_extensions`, etc. for setuppkg in iter_setup_packages(srcdir, packages): if hasattr(setuppkg, 'get_build_options'): options = setuppkg.get_build_options() for option in options: add_command_option('build', *option) if hasattr(setuppkg, 'get_external_libraries'): libraries = setuppkg.get_external_libraries() for library in libraries: add_external_library(library) if hasattr(setuppkg, 'requires_2to3'): requires_2to3 = setuppkg.requires_2to3() else: requires_2to3 = True if not requires_2to3: skip_2to3.append( os.path.dirname(setuppkg.__file__)) for setuppkg in iter_setup_packages(srcdir, packages): # get_extensions must include any Cython extensions by their .pyx # filename. if hasattr(setuppkg, 'get_extensions'): ext_modules.extend(setuppkg.get_extensions()) if hasattr(setuppkg, 'get_package_data'): package_data.update(setuppkg.get_package_data()) # Locate any .pyx files not already specified, and add their extensions in. # The default include dirs include numpy to facilitate numerical work. ext_modules.extend(get_cython_extensions(srcdir, packages, ext_modules, ['numpy'])) # Now remove extensions that have the special name 'skip_cython', as they # exist Only to indicate that the cython extensions shouldn't be built for i, ext in reversed(list(enumerate(ext_modules))): if ext.name == 'skip_cython': del ext_modules[i] # On Microsoft compilers, we need to pass the '/MANIFEST' # commandline argument. This was the default on MSVC 9.0, but is # now required on MSVC 10.0, but it doesn't seem to hurt to add # it unconditionally. if get_compiler_option() == 'msvc': for ext in ext_modules: ext.extra_link_args.append('/MANIFEST') return { 'ext_modules': ext_modules, 'packages': packages, 'package_dir': package_dir, 'package_data': package_data, 'skip_2to3': skip_2to3 } def iter_setup_packages(srcdir, packages): """ A generator that finds and imports all of the ``setup_package.py`` modules in the source packages. Returns ------- modgen : generator A generator that yields (modname, mod), where `mod` is the module and `modname` is the module name for the ``setup_package.py`` modules. """ for packagename in packages: package_parts = packagename.split('.') package_path = os.path.join(srcdir, *package_parts) setup_package = os.path.relpath( os.path.join(package_path, 'setup_package.py')) if os.path.isfile(setup_package): module = import_file(setup_package, name=packagename + '.setup_package') yield module def iter_pyx_files(package_dir, package_name): """ A generator that yields Cython source files (ending in '.pyx') in the source packages. Returns ------- pyxgen : generator A generator that yields (extmod, fullfn) where `extmod` is the full name of the module that the .pyx file would live in based on the source directory structure, and `fullfn` is the path to the .pyx file. """ for dirpath, dirnames, filenames in walk_skip_hidden(package_dir): for fn in filenames: if fn.endswith('.pyx'): fullfn = os.path.relpath(os.path.join(dirpath, fn)) # Package must match file name extmod = '.'.join([package_name, fn[:-4]]) yield (extmod, fullfn) break # Don't recurse into subdirectories def get_cython_extensions(srcdir, packages, prevextensions=tuple(), extincludedirs=None): """ Looks for Cython files and generates Extensions if needed. Parameters ---------- srcdir : str Path to the root of the source directory to search. prevextensions : list of `~distutils.core.Extension` objects The extensions that are already defined. Any .pyx files already here will be ignored. extincludedirs : list of str or None Directories to include as the `include_dirs` argument to the generated `~distutils.core.Extension` objects. Returns ------- exts : list of `~distutils.core.Extension` objects The new extensions that are needed to compile all .pyx files (does not include any already in `prevextensions`). """ # Vanilla setuptools and old versions of distribute include Cython files # as .c files in the sources, not .pyx, so we cannot simply look for # existing .pyx sources in the previous sources, but we should also check # for .c files with the same remaining filename. So we look for .pyx and # .c files, and we strip the extension. prevsourcepaths = [] ext_modules = [] for ext in prevextensions: for s in ext.sources: if s.endswith(('.pyx', '.c', '.cpp')): sourcepath = os.path.realpath(os.path.splitext(s)[0]) prevsourcepaths.append(sourcepath) for package_name in packages: package_parts = package_name.split('.') package_path = os.path.join(srcdir, *package_parts) for extmod, pyxfn in iter_pyx_files(package_path, package_name): sourcepath = os.path.realpath(os.path.splitext(pyxfn)[0]) if sourcepath not in prevsourcepaths: ext_modules.append(Extension(extmod, [pyxfn], include_dirs=extincludedirs)) return ext_modules class DistutilsExtensionArgs(collections.defaultdict): """ A special dictionary whose default values are the empty list. This is useful for building up a set of arguments for `distutils.Extension` without worrying whether the entry is already present. """ def __init__(self, *args, **kwargs): def default_factory(): return [] super(DistutilsExtensionArgs, self).__init__( default_factory, *args, **kwargs) def update(self, other): for key, val in other.items(): self[key].extend(val) def pkg_config(packages, default_libraries, executable='pkg-config'): """ Uses pkg-config to update a set of distutils Extension arguments to include the flags necessary to link against the given packages. If the pkg-config lookup fails, default_libraries is applied to libraries. Parameters ---------- packages : list of str A list of pkg-config packages to look up. default_libraries : list of str A list of library names to use if the pkg-config lookup fails. Returns ------- config : dict A dictionary containing keyword arguments to `distutils.Extension`. These entries include: - ``include_dirs``: A list of include directories - ``library_dirs``: A list of library directories - ``libraries``: A list of libraries - ``define_macros``: A list of macro defines - ``undef_macros``: A list of macros to undefine - ``extra_compile_args``: A list of extra arguments to pass to the compiler """ flag_map = {'-I': 'include_dirs', '-L': 'library_dirs', '-l': 'libraries', '-D': 'define_macros', '-U': 'undef_macros'} command = "{0} --libs --cflags {1}".format(executable, ' '.join(packages)), result = DistutilsExtensionArgs() try: pipe = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE) output = pipe.communicate()[0].strip() except subprocess.CalledProcessError as e: lines = [ "{0} failed. This may cause the build to fail below.".format(executable), " command: {0}".format(e.cmd), " returncode: {0}".format(e.returncode), " output: {0}".format(e.output) ] log.warn('\n'.join(lines)) result['libraries'].extend(default_libraries) else: if pipe.returncode != 0: lines = [ "pkg-config could not lookup up package(s) {0}.".format( ", ".join(packages)), "This may cause the build to fail below." ] log.warn('\n'.join(lines)) result['libraries'].extend(default_libraries) else: for token in output.split(): # It's not clear what encoding the output of # pkg-config will come to us in. It will probably be # some combination of pure ASCII (for the compiler # flags) and the filesystem encoding (for any argument # that includes directories or filenames), but this is # just conjecture, as the pkg-config documentation # doesn't seem to address it. arg = token[:2].decode('ascii') value = token[2:].decode(sys.getfilesystemencoding()) if arg in flag_map: if arg == '-D': value = tuple(value.split('=', 1)) result[flag_map[arg]].append(value) else: result['extra_compile_args'].append(value) return result def add_external_library(library): """ Add a build option for selecting the internal or system copy of a library. Parameters ---------- library : str The name of the library. If the library is `foo`, the build option will be called `--use-system-foo`. """ for command in ['build', 'build_ext', 'install']: add_command_option(command, str('use-system-' + library), 'Use the system {0} library'.format(library), is_bool=True) def use_system_library(library): """ Returns `True` if the build configuration indicates that the given library should use the system copy of the library rather than the internal one. For the given library `foo`, this will be `True` if `--use-system-foo` or `--use-system-libraries` was provided at the commandline or in `setup.cfg`. Parameters ---------- library : str The name of the library Returns ------- use_system : bool `True` if the build should use the system copy of the library. """ return ( get_distutils_build_or_install_option('use_system_{0}'.format(library)) or get_distutils_build_or_install_option('use_system_libraries')) @extends_doc(_find_packages) def find_packages(where='.', exclude=(), invalidate_cache=False): """ This version of ``find_packages`` caches previous results to speed up subsequent calls. Use ``invalide_cache=True`` to ignore cached results from previous ``find_packages`` calls, and repeat the package search. """ if not invalidate_cache and _module_state['package_cache'] is not None: return _module_state['package_cache'] packages = _find_packages(where=where, exclude=exclude) _module_state['package_cache'] = packages return packages def filter_packages(packagenames): """ Removes some packages from the package list that shouldn't be installed on the current version of Python. """ if PY3: exclude = '_py2' else: exclude = '_py3' return [x for x in packagenames if not x.endswith(exclude)] class FakeBuildSphinx(Command): """ A dummy build_sphinx command that is called if Sphinx is not installed and displays a relevant error message """ #user options inherited from sphinx.setup_command.BuildDoc user_options = [ ('fresh-env', 'E', '' ), ('all-files', 'a', ''), ('source-dir=', 's', ''), ('build-dir=', None, ''), ('config-dir=', 'c', ''), ('builder=', 'b', ''), ('project=', None, ''), ('version=', None, ''), ('release=', None, ''), ('today=', None, ''), ('link-index', 'i', ''), ] #user options appended in astropy.setup_helpers.AstropyBuildSphinx user_options.append(('warnings-returncode', 'w','')) user_options.append(('clean-docs', 'l', '')) user_options.append(('no-intersphinx', 'n', '')) user_options.append(('open-docs-in-browser', 'o','')) def initialize_options(self): try: raise RuntimeError("Sphinx must be installed for build_sphinx") except: log.error('error : Sphinx must be installed for build_sphinx') sys.exit(1) photutils-0.2.1/astropy_helpers/astropy_helpers/sphinx/0000700000214200020070000000000012646264032025702 5ustar lbradleySTSCI\science00000000000000photutils-0.2.1/astropy_helpers/astropy_helpers/sphinx/__init__.py0000600000214200020070000000041412346164025030012 0ustar lbradleySTSCI\science00000000000000""" This package contains utilities and extensions for the Astropy sphinx documentation. In particular, the `astropy.sphinx.conf` should be imported by the sphinx ``conf.py`` file for affiliated packages that wish to make use of the Astropy documentation format. """ photutils-0.2.1/astropy_helpers/astropy_helpers/sphinx/conf.py0000600000214200020070000002564212605531163027211 0ustar lbradleySTSCI\science00000000000000# -*- coding: utf-8 -*- # Licensed under a 3-clause BSD style license - see LICENSE.rst # # Astropy shared Sphinx settings. These settings are shared between # astropy itself and affiliated packages. # # Note that not all possible configuration values are present in this file. # # All configuration values have a default; values that are commented out # serve to show the default. import os import warnings from os import path # -- General configuration ---------------------------------------------------- # The version check in Sphinx itself can only compare the major and # minor parts of the version number, not the micro. To do a more # specific version check, call check_sphinx_version("x.y.z.") from # your project's conf.py needs_sphinx = '1.2' on_rtd = os.environ.get('READTHEDOCS', None) == 'True' def check_sphinx_version(expected_version): import sphinx from distutils import version sphinx_version = version.LooseVersion(sphinx.__version__) expected_version = version.LooseVersion(expected_version) if sphinx_version < expected_version: raise RuntimeError( "At least Sphinx version {0} is required to build this " "documentation. Found {1}.".format( expected_version, sphinx_version)) # Configuration for intersphinx: refer to the Python standard library. intersphinx_mapping = { 'python': ('http://docs.python.org/', None), 'python3': ('http://docs.python.org/3/', path.abspath(path.join(path.dirname(__file__), 'local/python3links.inv'))), 'numpy': ('http://docs.scipy.org/doc/numpy/', None), 'scipy': ('http://docs.scipy.org/doc/scipy/reference/', None), 'matplotlib': ('http://matplotlib.org/', None), 'astropy': ('http://docs.astropy.org/en/stable/', None), 'h5py': ('http://docs.h5py.org/en/latest/', None) } # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. exclude_patterns = ['_build'] # Add any paths that contain templates here, relative to this directory. # templates_path = ['_templates'] # The suffix of source filenames. source_suffix = '.rst' # The encoding of source files. #source_encoding = 'utf-8-sig' # The master toctree document. master_doc = 'index' # The reST default role (used for this markup: `text`) to use for all # documents. Set to the "smart" one. default_role = 'obj' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. #language = None # This is added to the end of RST files - a good place to put substitutions to # be used globally. rst_epilog = """ .. _Astropy: http://astropy.org """ # -- Project information ------------------------------------------------------ # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: #today = '' # Else, today_fmt is used as the format for a strftime call. #today_fmt = '%B %d, %Y' # If true, '()' will be appended to :func: etc. cross-reference text. #add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). #add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. #show_authors = False # The name of the Pygments (syntax highlighting) style to use. #pygments_style = 'sphinx' # A list of ignored prefixes for module index sorting. #modindex_common_prefix = [] # -- Settings for extensions and extension options ---------------------------- # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ 'sphinx.ext.autodoc', 'sphinx.ext.intersphinx', 'sphinx.ext.todo', 'sphinx.ext.coverage', 'sphinx.ext.inheritance_diagram', 'astropy_helpers.sphinx.ext.numpydoc', 'astropy_helpers.sphinx.ext.astropyautosummary', 'astropy_helpers.sphinx.ext.autodoc_enhancements', 'astropy_helpers.sphinx.ext.automodsumm', 'astropy_helpers.sphinx.ext.automodapi', 'astropy_helpers.sphinx.ext.tocdepthfix', 'astropy_helpers.sphinx.ext.doctest', 'astropy_helpers.sphinx.ext.changelog_links', 'astropy_helpers.sphinx.ext.viewcode', # Use patched version of viewcode 'astropy_helpers.sphinx.ext.smart_resolver' ] if on_rtd: extensions.append('sphinx.ext.mathjax') else: extensions.append('sphinx.ext.pngmath') # Above, we use a patched version of viewcode rather than 'sphinx.ext.viewcode' # This can be changed to the sphinx version once the following issue is fixed # in sphinx: # https://bitbucket.org/birkenfeld/sphinx/issue/623/ # extension-viewcode-fails-with-function try: import matplotlib.sphinxext.plot_directive extensions += [matplotlib.sphinxext.plot_directive.__name__] # AttributeError is checked here in case matplotlib is installed but # Sphinx isn't. Note that this module is imported by the config file # generator, even if we're not building the docs. except (ImportError, AttributeError): warnings.warn( "matplotlib's plot_directive could not be imported. " + "Inline plots will not be included in the output") # Don't show summaries of the members in each class along with the # class' docstring numpydoc_show_class_members = False autosummary_generate = True automodapi_toctreedirnm = 'api' # Class documentation should contain *both* the class docstring and # the __init__ docstring autoclass_content = "both" # Render inheritance diagrams in SVG graphviz_output_format = "svg" graphviz_dot_args = [ '-Nfontsize=10', '-Nfontname=Helvetica Neue, Helvetica, Arial, sans-serif', '-Efontsize=10', '-Efontname=Helvetica Neue, Helvetica, Arial, sans-serif', '-Gfontsize=10', '-Gfontname=Helvetica Neue, Helvetica, Arial, sans-serif' ] # -- Options for HTML output ------------------------------------------------- # Add any paths that contain custom themes here, relative to this directory. html_theme_path = [path.abspath(path.join(path.dirname(__file__), 'themes'))] # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. html_theme = 'bootstrap-astropy' # Custom sidebar templates, maps document names to template names. html_sidebars = { '**': ['localtoc.html'], 'search': [], 'genindex': [], 'py-modindex': [], } # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. # included in the bootstrap-astropy theme html_favicon = path.join(html_theme_path[0], html_theme, 'static', 'astropy_logo.ico') # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. html_last_updated_fmt = '%d %b %Y' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. #html_theme_options = {} # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". #html_title = None # A shorter title for the navigation bar. Default is the same as html_title. #html_short_title = None # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. #html_use_smartypants = True # Additional templates that should be rendered to pages, maps page names to # template names. #html_additional_pages = {} # If false, no module index is generated. #html_domain_indices = True # If false, no index is generated. #html_use_index = True # If true, the index is split into individual pages for each letter. #html_split_index = False # If true, links to the reST sources are added to the pages. #html_show_sourcelink = True # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. #html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. #html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages will # contain a tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. #html_use_opensearch = '' # This is the file name suffix for HTML files (e.g. ".xhtml"). #html_file_suffix = None # -- Options for LaTeX output ------------------------------------------------ # The paper size ('letter' or 'a4'). #latex_paper_size = 'letter' # The font size ('10pt', '11pt' or '12pt'). #latex_font_size = '10pt' # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. latex_use_parts = True # If true, show page references after internal links. #latex_show_pagerefs = False # If true, show URL addresses after external links. #latex_show_urls = False # Additional stuff for the LaTeX preamble. latex_preamble = r""" % Use a more modern-looking monospace font \usepackage{inconsolata} % The enumitem package provides unlimited nesting of lists and enums. % Sphinx may use this in the future, in which case this can be removed. % See https://bitbucket.org/birkenfeld/sphinx/issue/777/latex-output-too-deeply-nested \usepackage{enumitem} \setlistdepth{15} % In the parameters section, place a newline after the Parameters % header. (This is stolen directly from Numpy's conf.py, since it % affects Numpy-style docstrings). \usepackage{expdlist} \let\latexdescription=\description \def\description{\latexdescription{}{} \breaklabel} % Support the superscript Unicode numbers used by the "unicode" units % formatter \DeclareUnicodeCharacter{2070}{\ensuremath{^0}} \DeclareUnicodeCharacter{00B9}{\ensuremath{^1}} \DeclareUnicodeCharacter{00B2}{\ensuremath{^2}} \DeclareUnicodeCharacter{00B3}{\ensuremath{^3}} \DeclareUnicodeCharacter{2074}{\ensuremath{^4}} \DeclareUnicodeCharacter{2075}{\ensuremath{^5}} \DeclareUnicodeCharacter{2076}{\ensuremath{^6}} \DeclareUnicodeCharacter{2077}{\ensuremath{^7}} \DeclareUnicodeCharacter{2078}{\ensuremath{^8}} \DeclareUnicodeCharacter{2079}{\ensuremath{^9}} \DeclareUnicodeCharacter{207B}{\ensuremath{^-}} \DeclareUnicodeCharacter{00B0}{\ensuremath{^{\circ}}} \DeclareUnicodeCharacter{2032}{\ensuremath{^{\prime}}} \DeclareUnicodeCharacter{2033}{\ensuremath{^{\prime\prime}}} % Make the "warning" and "notes" sections use a sans-serif font to % make them stand out more. \renewenvironment{notice}[2]{ \def\py@noticetype{#1} \csname py@noticestart@#1\endcsname \textsf{\textbf{#2}} }{\csname py@noticeend@\py@noticetype\endcsname} """ # Documents to append as an appendix to all manuals. #latex_appendices = [] # If false, no module index is generated. #latex_domain_indices = True # The name of an image file (relative to this directory) to place at the top of # the title page. #latex_logo = None # -- Options for the linkcheck builder ---------------------------------------- # A timeout value, in seconds, for the linkcheck builder linkcheck_timeout = 60 photutils-0.2.1/astropy_helpers/astropy_helpers/sphinx/ext/0000700000214200020070000000000012646264032026502 5ustar lbradleySTSCI\science00000000000000photutils-0.2.1/astropy_helpers/astropy_helpers/sphinx/ext/__init__.py0000600000214200020070000000013612346164025030613 0ustar lbradleySTSCI\science00000000000000from __future__ import division, absolute_import, print_function from .numpydoc import setup photutils-0.2.1/astropy_helpers/astropy_helpers/sphinx/ext/astropyautosummary.py0000600000214200020070000001054312632702254033067 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst """ This sphinx extension builds off of `sphinx.ext.autosummary` to clean up some issues it presents in the Astropy docs. The main issue this fixes is the summary tables getting cut off before the end of the sentence in some cases. Note: Sphinx 1.2 appears to have fixed the the main issues in the stock autosummary extension that are addressed by this extension. So use of this extension with newer versions of Sphinx is deprecated. """ import re from distutils.version import LooseVersion import sphinx from sphinx.ext.autosummary import Autosummary from ...utils import deprecated # used in AstropyAutosummary.get_items _itemsummrex = re.compile(r'^([A-Z].*?\.(?:\s|$))') @deprecated('1.0', message='AstropyAutosummary is only needed when used ' 'with Sphinx versions less than 1.2') class AstropyAutosummary(Autosummary): def get_items(self, names): """Try to import the given names, and return a list of ``[(name, signature, summary_string, real_name), ...]``. """ from sphinx.ext.autosummary import (get_import_prefixes_from_env, import_by_name, get_documenter, mangle_signature) env = self.state.document.settings.env prefixes = get_import_prefixes_from_env(env) items = [] max_item_chars = 50 for name in names: display_name = name if name.startswith('~'): name = name[1:] display_name = name.split('.')[-1] try: import_by_name_values = import_by_name(name, prefixes=prefixes) except ImportError: self.warn('[astropyautosummary] failed to import %s' % name) items.append((name, '', '', name)) continue # to accommodate Sphinx v1.2.2 and v1.2.3 if len(import_by_name_values) == 3: real_name, obj, parent = import_by_name_values elif len(import_by_name_values) == 4: real_name, obj, parent, module_name = import_by_name_values # NB. using real_name here is important, since Documenters # handle module prefixes slightly differently documenter = get_documenter(obj, parent)(self, real_name) if not documenter.parse_name(): self.warn('[astropyautosummary] failed to parse name %s' % real_name) items.append((display_name, '', '', real_name)) continue if not documenter.import_object(): self.warn('[astropyautosummary] failed to import object %s' % real_name) items.append((display_name, '', '', real_name)) continue # -- Grab the signature sig = documenter.format_signature() if not sig: sig = '' else: max_chars = max(10, max_item_chars - len(display_name)) sig = mangle_signature(sig, max_chars=max_chars) sig = sig.replace('*', r'\*') # -- Grab the summary doc = list(documenter.process_doc(documenter.get_doc())) while doc and not doc[0].strip(): doc.pop(0) m = _itemsummrex.search(" ".join(doc).strip()) if m: summary = m.group(1).strip() elif doc: summary = doc[0].strip() else: summary = '' items.append((display_name, sig, summary, real_name)) return items def setup(app): # need autosummary, of course app.setup_extension('sphinx.ext.autosummary') # Don't make the replacement if Sphinx is at least 1.2 if LooseVersion(sphinx.__version__) < LooseVersion('1.2.0'): # this replaces the default autosummary with the astropy one app.add_directive('autosummary', AstropyAutosummary) elif LooseVersion(sphinx.__version__) < LooseVersion('1.3.2'): # Patch Autosummary again, but to work around an upstream bug; see # https://github.com/astropy/astropy-helpers/issues/172 class PatchedAutosummary(Autosummary): def get_items(self, names): self.genopt['imported-members'] = True return Autosummary.get_items(self, names) app.add_directive('autosummary', PatchedAutosummary) photutils-0.2.1/astropy_helpers/astropy_helpers/sphinx/ext/autodoc_enhancements.py0000600000214200020070000000673412605531163033253 0ustar lbradleySTSCI\science00000000000000""" Miscellaneous enhancements to help autodoc along. """ import inspect import sys import types from sphinx.ext.autodoc import AttributeDocumenter, ModuleDocumenter from sphinx.util.inspect import isdescriptor if sys.version_info[0] == 3: class_types = (type,) else: class_types = (type, types.ClassType) MethodDescriptorType = type(type.__subclasses__) # See # https://github.com/astropy/astropy-helpers/issues/116#issuecomment-71254836 # for further background on this. def type_object_attrgetter(obj, attr, *defargs): """ This implements an improved attrgetter for type objects (i.e. classes) that can handle class attributes that are implemented as properties on a metaclass. Normally `getattr` on a class with a `property` (say, "foo"), would return the `property` object itself. However, if the class has a metaclass which *also* defines a `property` named "foo", ``getattr(cls, 'foo')`` will find the "foo" property on the metaclass and resolve it. For the purposes of autodoc we just want to document the "foo" property defined on the class, not on the metaclass. For example:: >>> class Meta(type): ... @property ... def foo(cls): ... return 'foo' ... >>> class MyClass(metaclass=Meta): ... @property ... def foo(self): ... \"\"\"Docstring for MyClass.foo property.\"\"\" ... return 'myfoo' ... >>> getattr(MyClass, 'foo') 'foo' >>> type_object_attrgetter(MyClass, 'foo') >>> type_object_attrgetter(MyClass, 'foo').__doc__ 'Docstring for MyClass.foo property.' The last line of the example shows the desired behavior for the purposes of autodoc. """ for base in obj.__mro__: if attr in base.__dict__: if isinstance(base.__dict__[attr], property): # Note, this should only be used for properties--for any other # type of descriptor (classmethod, for example) this can mess # up existing expectations of what getattr(cls, ...) returns return base.__dict__[attr] break return getattr(obj, attr, *defargs) # Provided to work around a bug in Sphinx # See https://github.com/sphinx-doc/sphinx/pull/1843 class AttributeDocumenter(AttributeDocumenter): @classmethod def can_document_member(cls, member, membername, isattr, parent): non_attr_types = cls.method_types + class_types + \ (MethodDescriptorType,) isdatadesc = isdescriptor(member) and not \ isinstance(member, non_attr_types) and not \ type(member).__name__ == "instancemethod" # That last condition addresses an obscure case of C-defined # methods using a deprecated type in Python 3, that is not otherwise # exported anywhere by Python return isdatadesc or (not isinstance(parent, ModuleDocumenter) and not inspect.isroutine(member) and not isinstance(member, class_types)) def setup(app): # Must have the autodoc extension set up first so we can override it app.setup_extension('sphinx.ext.autodoc') # Need to import this too since it re-registers all the documenter types # =_= import sphinx.ext.autosummary.generate app.add_autodoc_attrgetter(type, type_object_attrgetter) app.add_autodocumenter(AttributeDocumenter) photutils-0.2.1/astropy_helpers/astropy_helpers/sphinx/ext/automodapi.py0000600000214200020070000003164712605531164031231 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst """ This sphinx extension adds a tools to simplify generating the API documentation for Astropy packages and affiliated packages. .. _automodapi: ======================== automodapi directive ======================== This directive takes a single argument that must be a module or package. It will produce a block of documentation that includes the docstring for the package, an :ref:`automodsumm` directive, and an :ref:`automod-diagram` if there are any classes in the module. If only the main docstring of the module/package is desired in the documentation, use `automodule`_ instead of `automodapi`_. It accepts the following options: * ``:no-inheritance-diagram:`` If present, the inheritance diagram will not be shown even if the module/package has classes. * ``:skip: str`` This option results in the specified object being skipped, that is the object will *not* be included in the generated documentation. This option may appear any number of times to skip multiple objects. * ``:no-main-docstr:`` If present, the docstring for the module/package will not be generated. The function and class tables will still be used, however. * ``:headings: str`` Specifies the characters (in one string) used as the heading levels used for the generated section. This must have at least 2 characters (any after 2 will be ignored). This also *must* match the rest of the documentation on this page for sphinx to be happy. Defaults to "-^", which matches the convention used for Python's documentation, assuming the automodapi call is inside a top-level section (which usually uses '='). * ``:no-heading:`` If specified do not create a top level heading for the section. That is, do not create a title heading with text like "packagename Package". The actual docstring for the package/module will still be shown, though, unless ``:no-main-docstr:`` is given. * ``:allowed-package-names: str`` Specifies the packages that functions/classes documented here are allowed to be from, as comma-separated list of package names. If not given, only objects that are actually in a subpackage of the package currently being documented are included. This extension also adds two sphinx configuration options: * ``automodapi_toctreedirnm`` This must be a string that specifies the name of the directory the automodsumm generated documentation ends up in. This directory path should be relative to the documentation root (e.g., same place as ``index.rst``). Defaults to ``'api'``. * ``automodapi_writereprocessed`` Should be a bool, and if `True`, will cause `automodapi`_ to write files with any `automodapi`_ sections replaced with the content Sphinx processes after `automodapi`_ has run. The output files are not actually used by sphinx, so this option is only for figuring out the cause of sphinx warnings or other debugging. Defaults to `False`. .. _automodule: http://sphinx-doc.org/latest/ext/autodoc.html?highlight=automodule#directive-automodule """ # Implementation note: # The 'automodapi' directive is not actually implemented as a docutils # directive. Instead, this extension searches for the 'automodapi' text in # all sphinx documents, and replaces it where necessary from a template built # into this extension. This is necessary because automodsumm (and autosummary) # use the "builder-inited" event, which comes before the directives are # actually built. import inspect import os import re import sys from .utils import find_mod_objs if sys.version_info[0] == 3: text_type = str else: text_type = unicode automod_templ_modheader = """ {modname} {pkgormod} {modhds}{pkgormodhds} {automoduleline} """ automod_templ_classes = """ Classes {clshds} .. automodsumm:: {modname} :classes-only: {clsfuncoptions} """ automod_templ_funcs = """ Functions {funchds} .. automodsumm:: {modname} :functions-only: {clsfuncoptions} """ automod_templ_inh = """ Class Inheritance Diagram {clsinhsechds} .. automod-diagram:: {modname} :private-bases: :parts: 1 {allowedpkgnms} """ _automodapirex = re.compile(r'^(?:\s*\.\.\s+automodapi::\s*)([A-Za-z0-9_.]+)' r'\s*$((?:\n\s+:[a-zA-Z_\-]+:.*$)*)', flags=re.MULTILINE) # the last group of the above regex is intended to go into finall with the below _automodapiargsrex = re.compile(r':([a-zA-Z_\-]+):(.*)$', flags=re.MULTILINE) def automodapi_replace(sourcestr, app, dotoctree=True, docname=None, warnings=True): """ Replaces `sourcestr`'s entries of ".. automdapi::" with the automodapi template form based on provided options. This is used with the sphinx event 'source-read' to replace `automodapi`_ entries before sphinx actually processes them, as automodsumm needs the code to be present to generate stub documentation. Parameters ---------- sourcestr : str The string with sphinx source to be checked for automodapi replacement. app : `sphinx.application.Application` The sphinx application. dotoctree : bool If `True`, a ":toctree:" option will be added in the ".. automodsumm::" sections of the template, pointing to the appropriate "generated" directory based on the Astropy convention (e.g. in ``docs/api``) docname : str The name of the file for this `sourcestr` (if known - if not, it can be `None`). If not provided and `dotoctree` is `True`, the generated files may end up in the wrong place. warnings : bool If `False`, all warnings that would normally be issued are silenced. Returns ------- newstr :str The string with automodapi entries replaced with the correct sphinx markup. """ spl = _automodapirex.split(sourcestr) if len(spl) > 1: # automodsumm is in this document if dotoctree: toctreestr = ':toctree: ' dirnm = app.config.automodapi_toctreedirnm if not dirnm.endswith("/"): dirnm += "/" if docname is not None: toctreestr += '../' * docname.count('/') + dirnm else: toctreestr += dirnm else: toctreestr = '' newstrs = [spl[0]] for grp in range(len(spl) // 3): modnm = spl[grp * 3 + 1] # find where this is in the document for warnings if docname is None: location = None else: location = (docname, spl[0].count('\n')) # initialize default options toskip = [] inhdiag = maindocstr = top_head = True hds = '-^' allowedpkgnms = [] # look for actual options unknownops = [] for opname, args in _automodapiargsrex.findall(spl[grp * 3 + 2]): if opname == 'skip': toskip.append(args.strip()) elif opname == 'no-inheritance-diagram': inhdiag = False elif opname == 'no-main-docstr': maindocstr = False elif opname == 'headings': hds = args elif opname == 'no-heading': top_head = False elif opname == 'allowed-package-names': allowedpkgnms.append(args.strip()) else: unknownops.append(opname) #join all the allowedpkgnms if len(allowedpkgnms) == 0: allowedpkgnms = '' onlylocals = True else: allowedpkgnms = ':allowed-package-names: ' + ','.join(allowedpkgnms) onlylocals = allowedpkgnms # get the two heading chars if len(hds) < 2: msg = 'Not enough headings (got {0}, need 2), using default -^' if warnings: app.warn(msg.format(len(hds)), location) hds = '-^' h1, h2 = hds.lstrip()[:2] # tell sphinx that the remaining args are invalid. if len(unknownops) > 0 and app is not None: opsstrs = ','.join(unknownops) msg = 'Found additional options ' + opsstrs + ' in automodapi.' if warnings: app.warn(msg, location) ispkg, hascls, hasfuncs = _mod_info(modnm, toskip, onlylocals=onlylocals) # add automodule directive only if no-main-docstr isn't present if maindocstr: automodline = '.. automodule:: {modname}'.format(modname=modnm) else: automodline = '' if top_head: newstrs.append(automod_templ_modheader.format(modname=modnm, modhds=h1 * len(modnm), pkgormod='Package' if ispkg else 'Module', pkgormodhds=h1 * (8 if ispkg else 7), automoduleline=automodline)) else: newstrs.append(automod_templ_modheader.format( modname='', modhds='', pkgormod='', pkgormodhds='', automoduleline=automodline)) #construct the options for the class/function sections #start out indented at 4 spaces, but need to keep the indentation. clsfuncoptions = [] if toctreestr: clsfuncoptions.append(toctreestr) if toskip: clsfuncoptions.append(':skip: ' + ','.join(toskip)) if allowedpkgnms: clsfuncoptions.append(allowedpkgnms) clsfuncoptionstr = '\n '.join(clsfuncoptions) if hasfuncs: newstrs.append(automod_templ_funcs.format( modname=modnm, funchds=h2 * 9, clsfuncoptions=clsfuncoptionstr)) if hascls: newstrs.append(automod_templ_classes.format( modname=modnm, clshds=h2 * 7, clsfuncoptions=clsfuncoptionstr)) if inhdiag and hascls: # add inheritance diagram if any classes are in the module newstrs.append(automod_templ_inh.format( modname=modnm, clsinhsechds=h2 * 25, allowedpkgnms=allowedpkgnms)) newstrs.append(spl[grp * 3 + 3]) newsourcestr = ''.join(newstrs) if app.config.automodapi_writereprocessed: # sometimes they are unicode, sometimes not, depending on how # sphinx has processed things if isinstance(newsourcestr, text_type): ustr = newsourcestr else: ustr = newsourcestr.decode(app.config.source_encoding) if docname is None: with open(os.path.join(app.srcdir, 'unknown.automodapi'), 'a') as f: f.write('\n**NEW DOC**\n\n') f.write(ustr) else: env = app.builder.env # Determine the filename associated with this doc (specifically # the extension) filename = docname + os.path.splitext(env.doc2path(docname))[1] filename += '.automodapi' with open(os.path.join(app.srcdir, filename), 'w') as f: f.write(ustr) return newsourcestr else: return sourcestr def _mod_info(modname, toskip=[], onlylocals=True): """ Determines if a module is a module or a package and whether or not it has classes or functions. """ hascls = hasfunc = False for localnm, fqnm, obj in zip(*find_mod_objs(modname, onlylocals=onlylocals)): if localnm not in toskip: hascls = hascls or inspect.isclass(obj) hasfunc = hasfunc or inspect.isroutine(obj) if hascls and hasfunc: break # find_mod_objs has already imported modname # TODO: There is probably a cleaner way to do this, though this is pretty # reliable for all Python versions for most cases that we care about. pkg = sys.modules[modname] ispkg = (hasattr(pkg, '__file__') and isinstance(pkg.__file__, str) and os.path.split(pkg.__file__)[1].startswith('__init__.py')) return ispkg, hascls, hasfunc def process_automodapi(app, docname, source): source[0] = automodapi_replace(source[0], app, True, docname) def setup(app): # need automodsumm for automodapi app.setup_extension('astropy_helpers.sphinx.ext.automodsumm') app.connect('source-read', process_automodapi) app.add_config_value('automodapi_toctreedirnm', 'api', True) app.add_config_value('automodapi_writereprocessed', False, True) photutils-0.2.1/astropy_helpers/astropy_helpers/sphinx/ext/automodsumm.py0000600000214200020070000005610412605531164031434 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst """ This sphinx extension adds two directives for summarizing the public members of a module or package. These directives are primarily for use with the `automodapi`_ extension, but can be used independently. .. _automodsumm: ======================= automodsumm directive ======================= This directive will produce an "autosummary"-style table for public attributes of a specified module. See the `sphinx.ext.autosummary`_ extension for details on this process. The main difference from the `autosummary`_ directive is that `autosummary`_ requires manually inputting all attributes that appear in the table, while this captures the entries automatically. This directive requires a single argument that must be a module or package. It also accepts any options supported by the `autosummary`_ directive- see `sphinx.ext.autosummary`_ for details. It also accepts two additional options: * ``:classes-only:`` If present, the autosummary table will only contain entries for classes. This cannot be used at the same time with ``:functions-only:`` . * ``:functions-only:`` If present, the autosummary table will only contain entries for functions. This cannot be used at the same time with ``:classes-only:`` . * ``:skip: obj1, [obj2, obj3, ...]`` If present, specifies that the listed objects should be skipped and not have their documentation generated, nor be included in the summary table. * ``:allowed-package-names: pkgormod1, [pkgormod2, pkgormod3, ...]`` Specifies the packages that functions/classes documented here are allowed to be from, as comma-separated list of package names. If not given, only objects that are actually in a subpackage of the package currently being documented are included. This extension also adds one sphinx configuration option: * ``automodsumm_writereprocessed`` Should be a bool, and if True, will cause `automodsumm`_ to write files with any ``automodsumm`` sections replaced with the content Sphinx processes after ``automodsumm`` has run. The output files are not actually used by sphinx, so this option is only for figuring out the cause of sphinx warnings or other debugging. Defaults to `False`. .. _sphinx.ext.autosummary: http://sphinx-doc.org/latest/ext/autosummary.html .. _autosummary: http://sphinx-doc.org/latest/ext/autosummary.html#directive-autosummary .. _automod-diagram: =========================== automod-diagram directive =========================== This directive will produce an inheritance diagram like that of the `sphinx.ext.inheritance_diagram`_ extension. This directive requires a single argument that must be a module or package. It accepts no options. .. note:: Like 'inheritance-diagram', 'automod-diagram' requires `graphviz `_ to generate the inheritance diagram. .. _sphinx.ext.inheritance_diagram: http://sphinx-doc.org/latest/ext/inheritance.html """ import inspect import os import re from distutils.version import LooseVersion import sphinx from sphinx.ext.autosummary import Autosummary from sphinx.ext.inheritance_diagram import InheritanceDiagram from docutils.parsers.rst.directives import flag from .utils import find_mod_objs from .astropyautosummary import AstropyAutosummary # Don't use AstropyAutosummary with newer versions of Sphinx # See https://github.com/astropy/astropy-helpers/pull/129 if LooseVersion(sphinx.__version__) < LooseVersion('1.2.0'): BaseAutosummary = AstropyAutosummary else: BaseAutosummary = Autosummary def _str_list_converter(argument): """ A directive option conversion function that converts the option into a list of strings. Used for 'skip' option. """ if argument is None: return [] else: return [s.strip() for s in argument.split(',')] class Automodsumm(BaseAutosummary): required_arguments = 1 optional_arguments = 0 final_argument_whitespace = False has_content = False option_spec = dict(Autosummary.option_spec) option_spec['functions-only'] = flag option_spec['classes-only'] = flag option_spec['skip'] = _str_list_converter option_spec['allowed-package-names'] = _str_list_converter def run(self): env = self.state.document.settings.env modname = self.arguments[0] self.warnings = [] nodelist = [] try: localnames, fqns, objs = find_mod_objs(modname) except ImportError: self.warnings = [] self.warn("Couldn't import module " + modname) return self.warnings try: # set self.content to trick the Autosummary internals. # Be sure to respect functions-only and classes-only. funconly = 'functions-only' in self.options clsonly = 'classes-only' in self.options skipnames = [] if 'skip' in self.options: option_skipnames = set(self.options['skip']) for lnm in localnames: if lnm in option_skipnames: option_skipnames.remove(lnm) skipnames.append(lnm) if len(option_skipnames) > 0: self.warn('Tried to skip objects {objs} in module {mod}, ' 'but they were not present. Ignoring.'.format( objs=option_skipnames, mod=modname)) if funconly and not clsonly: cont = [] for nm, obj in zip(localnames, objs): if nm not in skipnames and inspect.isroutine(obj): cont.append(nm) elif clsonly: cont = [] for nm, obj in zip(localnames, objs): if nm not in skipnames and inspect.isclass(obj): cont.append(nm) else: if clsonly and funconly: self.warning('functions-only and classes-only both ' 'defined. Skipping.') cont = [nm for nm in localnames if nm not in skipnames] self.content = cont # for some reason, even though ``currentmodule`` is substituted in, # sphinx doesn't necessarily recognize this fact. So we just force # it internally, and that seems to fix things env.temp_data['py:module'] = modname # can't use super because Sphinx/docutils has trouble return # super(Autosummary,self).run() nodelist.extend(Autosummary.run(self)) return self.warnings + nodelist finally: # has_content = False for the Automodsumm self.content = [] def get_items(self, names): self.genopt['imported-members'] = True return Autosummary.get_items(self, names) #<-------------------automod-diagram stuff------------------------------------> class Automoddiagram(InheritanceDiagram): option_spec = dict(InheritanceDiagram.option_spec) option_spec['allowed-package-names'] = _str_list_converter def run(self): try: ols = self.options.get('allowed-package-names', []) ols = True if len(ols) == 0 else ols # if none are given, assume only local nms, objs = find_mod_objs(self.arguments[0], onlylocals=ols)[1:] except ImportError: self.warnings = [] self.warn("Couldn't import module " + self.arguments[0]) return self.warnings clsnms = [] for n, o in zip(nms, objs): if inspect.isclass(o): clsnms.append(n) oldargs = self.arguments try: if len(clsnms) > 0: self.arguments = [' '.join(clsnms)] return InheritanceDiagram.run(self) finally: self.arguments = oldargs #<---------------------automodsumm generation stuff---------------------------> def process_automodsumm_generation(app): env = app.builder.env filestosearch = [] for docname in env.found_docs: filename = env.doc2path(docname) if os.path.isfile(filename): filestosearch.append(docname + os.path.splitext(filename)[1]) liness = [] for sfn in filestosearch: lines = automodsumm_to_autosummary_lines(sfn, app) liness.append(lines) if app.config.automodsumm_writereprocessed: if lines: # empty list means no automodsumm entry is in the file outfn = os.path.join(app.srcdir, sfn) + '.automodsumm' with open(outfn, 'w') as f: for l in lines: f.write(l) f.write('\n') for sfn, lines in zip(filestosearch, liness): suffix = os.path.splitext(sfn)[1] if len(lines) > 0: generate_automodsumm_docs(lines, sfn, builder=app.builder, warn=app.warn, info=app.info, suffix=suffix, base_path=app.srcdir) #_automodsummrex = re.compile(r'^(\s*)\.\. automodsumm::\s*([A-Za-z0-9_.]+)\s*' # r'\n\1(\s*)(\S|$)', re.MULTILINE) _lineendrex = r'(?:\n|$)' _hdrex = r'^\n?(\s*)\.\. automodsumm::\s*(\S+)\s*' + _lineendrex _oprex1 = r'(?:\1(\s+)\S.*' + _lineendrex + ')' _oprex2 = r'(?:\1\4\S.*' + _lineendrex + ')' _automodsummrex = re.compile(_hdrex + '(' + _oprex1 + '?' + _oprex2 + '*)', re.MULTILINE) def automodsumm_to_autosummary_lines(fn, app): """ Generates lines from a file with an "automodsumm" entry suitable for feeding into "autosummary". Searches the provided file for `automodsumm` directives and returns a list of lines specifying the `autosummary` commands for the modules requested. This does *not* return the whole file contents - just an autosummary section in place of any :automodsumm: entries. Note that any options given for `automodsumm` are also included in the generated `autosummary` section. Parameters ---------- fn : str The name of the file to search for `automodsumm` entries. app : sphinx.application.Application The sphinx Application object Return ------ lines : list of str Lines for all `automodsumm` entries with the entries replaced by `autosummary` and the module's members added. """ fullfn = os.path.join(app.builder.env.srcdir, fn) with open(fullfn) as fr: if 'astropy_helpers.sphinx.ext.automodapi' in app._extensions: from astropy_helpers.sphinx.ext.automodapi import automodapi_replace # Must do the automodapi on the source to get the automodsumm # that might be in there docname = os.path.splitext(fn)[0] filestr = automodapi_replace(fr.read(), app, True, docname, False) else: filestr = fr.read() spl = _automodsummrex.split(filestr) #0th entry is the stuff before the first automodsumm line indent1s = spl[1::5] mods = spl[2::5] opssecs = spl[3::5] indent2s = spl[4::5] remainders = spl[5::5] # only grab automodsumm sections and convert them to autosummary with the # entries for all the public objects newlines = [] #loop over all automodsumms in this document for i, (i1, i2, modnm, ops, rem) in enumerate(zip(indent1s, indent2s, mods, opssecs, remainders)): allindent = i1 + ('' if i2 is None else i2) #filter out functions-only and classes-only options if present oplines = ops.split('\n') toskip = [] allowedpkgnms = [] funcsonly = clssonly = False for i, ln in reversed(list(enumerate(oplines))): if ':functions-only:' in ln: funcsonly = True del oplines[i] if ':classes-only:' in ln: clssonly = True del oplines[i] if ':skip:' in ln: toskip.extend(_str_list_converter(ln.replace(':skip:', ''))) del oplines[i] if ':allowed-package-names:' in ln: allowedpkgnms.extend(_str_list_converter(ln.replace(':allowed-package-names:', ''))) del oplines[i] if funcsonly and clssonly: msg = ('Defined both functions-only and classes-only options. ' 'Skipping this directive.') lnnum = sum([spl[j].count('\n') for j in range(i * 5 + 1)]) app.warn('[automodsumm]' + msg, (fn, lnnum)) continue # Use the currentmodule directive so we can just put the local names # in the autosummary table. Note that this doesn't always seem to # actually "take" in Sphinx's eyes, so in `Automodsumm.run`, we have to # force it internally, as well. newlines.extend([i1 + '.. currentmodule:: ' + modnm, '', '.. autosummary::']) newlines.extend(oplines) ols = True if len(allowedpkgnms) == 0 else allowedpkgnms for nm, fqn, obj in zip(*find_mod_objs(modnm, onlylocals=ols)): if nm in toskip: continue if funcsonly and not inspect.isroutine(obj): continue if clssonly and not inspect.isclass(obj): continue newlines.append(allindent + nm) # add one newline at the end of the autosummary block newlines.append('') return newlines def generate_automodsumm_docs(lines, srcfn, suffix='.rst', warn=None, info=None, base_path=None, builder=None, template_dir=None): """ This function is adapted from `sphinx.ext.autosummary.generate.generate_autosummmary_docs` to generate source for the automodsumm directives that should be autosummarized. Unlike generate_autosummary_docs, this function is called one file at a time. """ from sphinx.jinja2glue import BuiltinTemplateLoader from sphinx.ext.autosummary import import_by_name, get_documenter from sphinx.ext.autosummary.generate import (find_autosummary_in_lines, _simple_info, _simple_warn) from sphinx.util.osutil import ensuredir from sphinx.util.inspect import safe_getattr from jinja2 import FileSystemLoader, TemplateNotFound from jinja2.sandbox import SandboxedEnvironment if info is None: info = _simple_info if warn is None: warn = _simple_warn #info('[automodsumm] generating automodsumm for: ' + srcfn) # Create our own templating environment - here we use Astropy's # templates rather than the default autosummary templates, in order to # allow docstrings to be shown for methods. template_dirs = [os.path.join(os.path.dirname(__file__), 'templates'), os.path.join(base_path, '_templates')] if builder is not None: # allow the user to override the templates template_loader = BuiltinTemplateLoader() template_loader.init(builder, dirs=template_dirs) else: if template_dir: template_dirs.insert(0, template_dir) template_loader = FileSystemLoader(template_dirs) template_env = SandboxedEnvironment(loader=template_loader) # read #items = find_autosummary_in_files(sources) items = find_autosummary_in_lines(lines, filename=srcfn) if len(items) > 0: msg = '[automodsumm] {1}: found {0} automodsumm entries to generate' info(msg.format(len(items), srcfn)) # gennms = [item[0] for item in items] # if len(gennms) > 20: # gennms = gennms[:10] + ['...'] + gennms[-10:] # info('[automodsumm] generating autosummary for: ' + ', '.join(gennms)) # remove possible duplicates items = dict([(item, True) for item in items]).keys() # keep track of new files new_files = [] # write for name, path, template_name in sorted(items): if path is None: # The corresponding autosummary:: directive did not have # a :toctree: option continue path = os.path.abspath(path) ensuredir(path) try: import_by_name_values = import_by_name(name) except ImportError as e: warn('[automodsumm] failed to import %r: %s' % (name, e)) continue # if block to accommodate Sphinx's v1.2.2 and v1.2.3 respectively if len(import_by_name_values) == 3: name, obj, parent = import_by_name_values elif len(import_by_name_values) == 4: name, obj, parent, module_name = import_by_name_values fn = os.path.join(path, name + suffix) # skip it if it exists if os.path.isfile(fn): continue new_files.append(fn) f = open(fn, 'w') try: doc = get_documenter(obj, parent) if template_name is not None: template = template_env.get_template(template_name) else: tmplstr = 'autosummary/%s.rst' try: template = template_env.get_template(tmplstr % doc.objtype) except TemplateNotFound: template = template_env.get_template(tmplstr % 'base') def get_members_mod(obj, typ, include_public=[]): """ typ = None -> all """ items = [] for name in dir(obj): try: documenter = get_documenter(safe_getattr(obj, name), obj) except AttributeError: continue if typ is None or documenter.objtype == typ: items.append(name) public = [x for x in items if x in include_public or not x.startswith('_')] return public, items def get_members_class(obj, typ, include_public=[], include_base=False): """ typ = None -> all include_base -> include attrs that are from a base class """ items = [] # using dir gets all of the attributes, including the elements # from the base class, otherwise use __slots__ or __dict__ if include_base: names = dir(obj) else: if hasattr(obj, '__slots__'): names = tuple(getattr(obj, '__slots__')) else: names = getattr(obj, '__dict__').keys() for name in names: try: documenter = get_documenter(safe_getattr(obj, name), obj) except AttributeError: continue if typ is None or documenter.objtype == typ: items.append(name) public = [x for x in items if x in include_public or not x.startswith('_')] return public, items ns = {} if doc.objtype == 'module': ns['members'] = get_members_mod(obj, None) ns['functions'], ns['all_functions'] = \ get_members_mod(obj, 'function') ns['classes'], ns['all_classes'] = \ get_members_mod(obj, 'class') ns['exceptions'], ns['all_exceptions'] = \ get_members_mod(obj, 'exception') elif doc.objtype == 'class': api_class_methods = ['__init__', '__call__'] ns['members'] = get_members_class(obj, None) ns['methods'], ns['all_methods'] = \ get_members_class(obj, 'method', api_class_methods) ns['attributes'], ns['all_attributes'] = \ get_members_class(obj, 'attribute') ns['methods'].sort() ns['attributes'].sort() parts = name.split('.') if doc.objtype in ('method', 'attribute'): mod_name = '.'.join(parts[:-2]) cls_name = parts[-2] obj_name = '.'.join(parts[-2:]) ns['class'] = cls_name else: mod_name, obj_name = '.'.join(parts[:-1]), parts[-1] ns['fullname'] = name ns['module'] = mod_name ns['objname'] = obj_name ns['name'] = parts[-1] ns['objtype'] = doc.objtype ns['underline'] = len(name) * '=' # We now check whether a file for reference footnotes exists for # the module being documented. We first check if the # current module is a file or a directory, as this will give a # different path for the reference file. For example, if # documenting astropy.wcs then the reference file is at # ../wcs/references.txt, while if we are documenting # astropy.config.logging_helper (which is at # astropy/config/logging_helper.py) then the reference file is set # to ../config/references.txt if '.' in mod_name: mod_name_dir = mod_name.replace('.', '/').split('/', 1)[1] else: mod_name_dir = mod_name if not os.path.isdir(os.path.join(base_path, mod_name_dir)) \ and os.path.isdir(os.path.join(base_path, mod_name_dir.rsplit('/', 1)[0])): mod_name_dir = mod_name_dir.rsplit('/', 1)[0] # We then have to check whether it exists, and if so, we pass it # to the template. if os.path.exists(os.path.join(base_path, mod_name_dir, 'references.txt')): # An important subtlety here is that the path we pass in has # to be relative to the file being generated, so we have to # figure out the right number of '..'s ndirsback = path.replace(base_path, '').count('/') ref_file_rel_segments = ['..'] * ndirsback ref_file_rel_segments.append(mod_name_dir) ref_file_rel_segments.append('references.txt') ns['referencefile'] = os.path.join(*ref_file_rel_segments) rendered = template.render(**ns) f.write(rendered) finally: f.close() def setup(app): # need our autosummary and autodoc fixes app.setup_extension('astropy_helpers.sphinx.ext.astropyautosummary') app.setup_extension('astropy_helpers.sphinx.ext.autodoc_enhancements') # need inheritance-diagram for automod-diagram app.setup_extension('sphinx.ext.inheritance_diagram') app.add_directive('automod-diagram', Automoddiagram) app.add_directive('automodsumm', Automodsumm) app.connect('builder-inited', process_automodsumm_generation) app.add_config_value('automodsumm_writereprocessed', False, True) photutils-0.2.1/astropy_helpers/astropy_helpers/sphinx/ext/changelog_links.py0000600000214200020070000000542012371220367032204 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst """ This sphinx extension makes the issue numbers in the changelog into links to GitHub issues. """ from __future__ import print_function import re from docutils.nodes import Text, reference BLOCK_PATTERN = re.compile('\[#.+\]', flags=re.DOTALL) ISSUE_PATTERN = re.compile('#[0-9]+') def process_changelog_links(app, doctree, docname): for rex in app.changelog_links_rexes: if rex.match(docname): break else: # if the doc doesn't match any of the changelog regexes, don't process return app.info('[changelog_links] Adding changelog links to "{0}"'.format(docname)) for item in doctree.traverse(): if not isinstance(item, Text): continue # We build a new list of items to replace the current item. If # a link is found, we need to use a 'reference' item. children = [] # First cycle through blocks of issues (delimited by []) then # iterate inside each one to find the individual issues. prev_block_end = 0 for block in BLOCK_PATTERN.finditer(item): block_start, block_end = block.start(), block.end() children.append(Text(item[prev_block_end:block_start])) block = item[block_start:block_end] prev_end = 0 for m in ISSUE_PATTERN.finditer(block): start, end = m.start(), m.end() children.append(Text(block[prev_end:start])) issue_number = block[start:end] refuri = app.config.github_issues_url + issue_number[1:] children.append(reference(text=issue_number, name=issue_number, refuri=refuri)) prev_end = end prev_block_end = block_end # If no issues were found, this adds the whole item, # otherwise it adds the remaining text. children.append(Text(block[prev_end:block_end])) # If no blocks were found, this adds the whole item, otherwise # it adds the remaining text. children.append(Text(item[prev_block_end:])) # Replace item by the new list of items we have generated, # which may contain links. item.parent.replace(item, children) def setup_patterns_rexes(app): app.changelog_links_rexes = [re.compile(pat) for pat in app.config.changelog_links_docpattern] def setup(app): app.connect('doctree-resolved', process_changelog_links) app.connect('builder-inited', setup_patterns_rexes) app.add_config_value('github_issues_url', None, True) app.add_config_value('changelog_links_docpattern', ['.*changelog.*', 'whatsnew/.*'], True) photutils-0.2.1/astropy_helpers/astropy_helpers/sphinx/ext/comment_eater.py0000600000214200020070000001245112346164025031701 0ustar lbradleySTSCI\science00000000000000from __future__ import division, absolute_import, print_function import sys if sys.version_info[0] >= 3: from io import StringIO else: from io import StringIO import compiler import inspect import textwrap import tokenize from .compiler_unparse import unparse class Comment(object): """ A comment block. """ is_comment = True def __init__(self, start_lineno, end_lineno, text): # int : The first line number in the block. 1-indexed. self.start_lineno = start_lineno # int : The last line number. Inclusive! self.end_lineno = end_lineno # str : The text block including '#' character but not any leading spaces. self.text = text def add(self, string, start, end, line): """ Add a new comment line. """ self.start_lineno = min(self.start_lineno, start[0]) self.end_lineno = max(self.end_lineno, end[0]) self.text += string def __repr__(self): return '%s(%r, %r, %r)' % (self.__class__.__name__, self.start_lineno, self.end_lineno, self.text) class NonComment(object): """ A non-comment block of code. """ is_comment = False def __init__(self, start_lineno, end_lineno): self.start_lineno = start_lineno self.end_lineno = end_lineno def add(self, string, start, end, line): """ Add lines to the block. """ if string.strip(): # Only add if not entirely whitespace. self.start_lineno = min(self.start_lineno, start[0]) self.end_lineno = max(self.end_lineno, end[0]) def __repr__(self): return '%s(%r, %r)' % (self.__class__.__name__, self.start_lineno, self.end_lineno) class CommentBlocker(object): """ Pull out contiguous comment blocks. """ def __init__(self): # Start with a dummy. self.current_block = NonComment(0, 0) # All of the blocks seen so far. self.blocks = [] # The index mapping lines of code to their associated comment blocks. self.index = {} def process_file(self, file): """ Process a file object. """ if sys.version_info[0] >= 3: nxt = file.__next__ else: nxt = file.next for token in tokenize.generate_tokens(nxt): self.process_token(*token) self.make_index() def process_token(self, kind, string, start, end, line): """ Process a single token. """ if self.current_block.is_comment: if kind == tokenize.COMMENT: self.current_block.add(string, start, end, line) else: self.new_noncomment(start[0], end[0]) else: if kind == tokenize.COMMENT: self.new_comment(string, start, end, line) else: self.current_block.add(string, start, end, line) def new_noncomment(self, start_lineno, end_lineno): """ We are transitioning from a noncomment to a comment. """ block = NonComment(start_lineno, end_lineno) self.blocks.append(block) self.current_block = block def new_comment(self, string, start, end, line): """ Possibly add a new comment. Only adds a new comment if this comment is the only thing on the line. Otherwise, it extends the noncomment block. """ prefix = line[:start[1]] if prefix.strip(): # Oops! Trailing comment, not a comment block. self.current_block.add(string, start, end, line) else: # A comment block. block = Comment(start[0], end[0], string) self.blocks.append(block) self.current_block = block def make_index(self): """ Make the index mapping lines of actual code to their associated prefix comments. """ for prev, block in zip(self.blocks[:-1], self.blocks[1:]): if not block.is_comment: self.index[block.start_lineno] = prev def search_for_comment(self, lineno, default=None): """ Find the comment block just before the given line number. Returns None (or the specified default) if there is no such block. """ if not self.index: self.make_index() block = self.index.get(lineno, None) text = getattr(block, 'text', default) return text def strip_comment_marker(text): """ Strip # markers at the front of a block of comment text. """ lines = [] for line in text.splitlines(): lines.append(line.lstrip('#')) text = textwrap.dedent('\n'.join(lines)) return text def get_class_traits(klass): """ Yield all of the documentation for trait definitions on a class object. """ # FIXME: gracefully handle errors here or in the caller? source = inspect.getsource(klass) cb = CommentBlocker() cb.process_file(StringIO(source)) mod_ast = compiler.parse(source) class_ast = mod_ast.node.nodes[0] for node in class_ast.code.nodes: # FIXME: handle other kinds of assignments? if isinstance(node, compiler.ast.Assign): name = node.nodes[0].name rhs = unparse(node.expr).strip() doc = strip_comment_marker(cb.search_for_comment(node.lineno, default='')) yield name, rhs, doc photutils-0.2.1/astropy_helpers/astropy_helpers/sphinx/ext/compiler_unparse.py0000600000214200020070000006024412346164025032431 0ustar lbradleySTSCI\science00000000000000""" Turn compiler.ast structures back into executable python code. The unparse method takes a compiler.ast tree and transforms it back into valid python code. It is incomplete and currently only works for import statements, function calls, function definitions, assignments, and basic expressions. Inspired by python-2.5-svn/Demo/parser/unparse.py fixme: We may want to move to using _ast trees because the compiler for them is about 6 times faster than compiler.compile. """ from __future__ import division, absolute_import, print_function import sys from compiler.ast import Const, Name, Tuple, Div, Mul, Sub, Add if sys.version_info[0] >= 3: from io import StringIO else: from StringIO import StringIO def unparse(ast, single_line_functions=False): s = StringIO() UnparseCompilerAst(ast, s, single_line_functions) return s.getvalue().lstrip() op_precedence = { 'compiler.ast.Power':3, 'compiler.ast.Mul':2, 'compiler.ast.Div':2, 'compiler.ast.Add':1, 'compiler.ast.Sub':1 } class UnparseCompilerAst: """ Methods in this class recursively traverse an AST and output source code for the abstract syntax; original formatting is disregarged. """ ######################################################################### # object interface. ######################################################################### def __init__(self, tree, file = sys.stdout, single_line_functions=False): """ Unparser(tree, file=sys.stdout) -> None. Print the source for tree to file. """ self.f = file self._single_func = single_line_functions self._do_indent = True self._indent = 0 self._dispatch(tree) self._write("\n") self.f.flush() ######################################################################### # Unparser private interface. ######################################################################### ### format, output, and dispatch methods ################################ def _fill(self, text = ""): "Indent a piece of text, according to the current indentation level" if self._do_indent: self._write("\n"+" "*self._indent + text) else: self._write(text) def _write(self, text): "Append a piece of text to the current line." self.f.write(text) def _enter(self): "Print ':', and increase the indentation." self._write(": ") self._indent += 1 def _leave(self): "Decrease the indentation level." self._indent -= 1 def _dispatch(self, tree): "_dispatcher function, _dispatching tree type T to method _T." if isinstance(tree, list): for t in tree: self._dispatch(t) return meth = getattr(self, "_"+tree.__class__.__name__) if tree.__class__.__name__ == 'NoneType' and not self._do_indent: return meth(tree) ######################################################################### # compiler.ast unparsing methods. # # There should be one method per concrete grammar type. They are # organized in alphabetical order. ######################################################################### def _Add(self, t): self.__binary_op(t, '+') def _And(self, t): self._write(" (") for i, node in enumerate(t.nodes): self._dispatch(node) if i != len(t.nodes)-1: self._write(") and (") self._write(")") def _AssAttr(self, t): """ Handle assigning an attribute of an object """ self._dispatch(t.expr) self._write('.'+t.attrname) def _Assign(self, t): """ Expression Assignment such as "a = 1". This only handles assignment in expressions. Keyword assignment is handled separately. """ self._fill() for target in t.nodes: self._dispatch(target) self._write(" = ") self._dispatch(t.expr) if not self._do_indent: self._write('; ') def _AssName(self, t): """ Name on left hand side of expression. Treat just like a name on the right side of an expression. """ self._Name(t) def _AssTuple(self, t): """ Tuple on left hand side of an expression. """ # _write each elements, separated by a comma. for element in t.nodes[:-1]: self._dispatch(element) self._write(", ") # Handle the last one without writing comma last_element = t.nodes[-1] self._dispatch(last_element) def _AugAssign(self, t): """ +=,-=,*=,/=,**=, etc. operations """ self._fill() self._dispatch(t.node) self._write(' '+t.op+' ') self._dispatch(t.expr) if not self._do_indent: self._write(';') def _Bitand(self, t): """ Bit and operation. """ for i, node in enumerate(t.nodes): self._write("(") self._dispatch(node) self._write(")") if i != len(t.nodes)-1: self._write(" & ") def _Bitor(self, t): """ Bit or operation """ for i, node in enumerate(t.nodes): self._write("(") self._dispatch(node) self._write(")") if i != len(t.nodes)-1: self._write(" | ") def _CallFunc(self, t): """ Function call. """ self._dispatch(t.node) self._write("(") comma = False for e in t.args: if comma: self._write(", ") else: comma = True self._dispatch(e) if t.star_args: if comma: self._write(", ") else: comma = True self._write("*") self._dispatch(t.star_args) if t.dstar_args: if comma: self._write(", ") else: comma = True self._write("**") self._dispatch(t.dstar_args) self._write(")") def _Compare(self, t): self._dispatch(t.expr) for op, expr in t.ops: self._write(" " + op + " ") self._dispatch(expr) def _Const(self, t): """ A constant value such as an integer value, 3, or a string, "hello". """ self._dispatch(t.value) def _Decorators(self, t): """ Handle function decorators (eg. @has_units) """ for node in t.nodes: self._dispatch(node) def _Dict(self, t): self._write("{") for i, (k, v) in enumerate(t.items): self._dispatch(k) self._write(": ") self._dispatch(v) if i < len(t.items)-1: self._write(", ") self._write("}") def _Discard(self, t): """ Node for when return value is ignored such as in "foo(a)". """ self._fill() self._dispatch(t.expr) def _Div(self, t): self.__binary_op(t, '/') def _Ellipsis(self, t): self._write("...") def _From(self, t): """ Handle "from xyz import foo, bar as baz". """ # fixme: Are From and ImportFrom handled differently? self._fill("from ") self._write(t.modname) self._write(" import ") for i, (name,asname) in enumerate(t.names): if i != 0: self._write(", ") self._write(name) if asname is not None: self._write(" as "+asname) def _Function(self, t): """ Handle function definitions """ if t.decorators is not None: self._fill("@") self._dispatch(t.decorators) self._fill("def "+t.name + "(") defaults = [None] * (len(t.argnames) - len(t.defaults)) + list(t.defaults) for i, arg in enumerate(zip(t.argnames, defaults)): self._write(arg[0]) if arg[1] is not None: self._write('=') self._dispatch(arg[1]) if i < len(t.argnames)-1: self._write(', ') self._write(")") if self._single_func: self._do_indent = False self._enter() self._dispatch(t.code) self._leave() self._do_indent = True def _Getattr(self, t): """ Handle getting an attribute of an object """ if isinstance(t.expr, (Div, Mul, Sub, Add)): self._write('(') self._dispatch(t.expr) self._write(')') else: self._dispatch(t.expr) self._write('.'+t.attrname) def _If(self, t): self._fill() for i, (compare,code) in enumerate(t.tests): if i == 0: self._write("if ") else: self._write("elif ") self._dispatch(compare) self._enter() self._fill() self._dispatch(code) self._leave() self._write("\n") if t.else_ is not None: self._write("else") self._enter() self._fill() self._dispatch(t.else_) self._leave() self._write("\n") def _IfExp(self, t): self._dispatch(t.then) self._write(" if ") self._dispatch(t.test) if t.else_ is not None: self._write(" else (") self._dispatch(t.else_) self._write(")") def _Import(self, t): """ Handle "import xyz.foo". """ self._fill("import ") for i, (name,asname) in enumerate(t.names): if i != 0: self._write(", ") self._write(name) if asname is not None: self._write(" as "+asname) def _Keyword(self, t): """ Keyword value assignment within function calls and definitions. """ self._write(t.name) self._write("=") self._dispatch(t.expr) def _List(self, t): self._write("[") for i,node in enumerate(t.nodes): self._dispatch(node) if i < len(t.nodes)-1: self._write(", ") self._write("]") def _Module(self, t): if t.doc is not None: self._dispatch(t.doc) self._dispatch(t.node) def _Mul(self, t): self.__binary_op(t, '*') def _Name(self, t): self._write(t.name) def _NoneType(self, t): self._write("None") def _Not(self, t): self._write('not (') self._dispatch(t.expr) self._write(')') def _Or(self, t): self._write(" (") for i, node in enumerate(t.nodes): self._dispatch(node) if i != len(t.nodes)-1: self._write(") or (") self._write(")") def _Pass(self, t): self._write("pass\n") def _Printnl(self, t): self._fill("print ") if t.dest: self._write(">> ") self._dispatch(t.dest) self._write(", ") comma = False for node in t.nodes: if comma: self._write(', ') else: comma = True self._dispatch(node) def _Power(self, t): self.__binary_op(t, '**') def _Return(self, t): self._fill("return ") if t.value: if isinstance(t.value, Tuple): text = ', '.join([ name.name for name in t.value.asList() ]) self._write(text) else: self._dispatch(t.value) if not self._do_indent: self._write('; ') def _Slice(self, t): self._dispatch(t.expr) self._write("[") if t.lower: self._dispatch(t.lower) self._write(":") if t.upper: self._dispatch(t.upper) #if t.step: # self._write(":") # self._dispatch(t.step) self._write("]") def _Sliceobj(self, t): for i, node in enumerate(t.nodes): if i != 0: self._write(":") if not (isinstance(node, Const) and node.value is None): self._dispatch(node) def _Stmt(self, tree): for node in tree.nodes: self._dispatch(node) def _Sub(self, t): self.__binary_op(t, '-') def _Subscript(self, t): self._dispatch(t.expr) self._write("[") for i, value in enumerate(t.subs): if i != 0: self._write(",") self._dispatch(value) self._write("]") def _TryExcept(self, t): self._fill("try") self._enter() self._dispatch(t.body) self._leave() for handler in t.handlers: self._fill('except ') self._dispatch(handler[0]) if handler[1] is not None: self._write(', ') self._dispatch(handler[1]) self._enter() self._dispatch(handler[2]) self._leave() if t.else_: self._fill("else") self._enter() self._dispatch(t.else_) self._leave() def _Tuple(self, t): if not t.nodes: # Empty tuple. self._write("()") else: self._write("(") # _write each elements, separated by a comma. for element in t.nodes[:-1]: self._dispatch(element) self._write(", ") # Handle the last one without writing comma last_element = t.nodes[-1] self._dispatch(last_element) self._write(")") def _UnaryAdd(self, t): self._write("+") self._dispatch(t.expr) def _UnarySub(self, t): self._write("-") self._dispatch(t.expr) def _With(self, t): self._fill('with ') self._dispatch(t.expr) if t.vars: self._write(' as ') self._dispatch(t.vars.name) self._enter() self._dispatch(t.body) self._leave() self._write('\n') def _int(self, t): self._write(repr(t)) def __binary_op(self, t, symbol): # Check if parenthesis are needed on left side and then dispatch has_paren = False left_class = str(t.left.__class__) if (left_class in op_precedence.keys() and op_precedence[left_class] < op_precedence[str(t.__class__)]): has_paren = True if has_paren: self._write('(') self._dispatch(t.left) if has_paren: self._write(')') # Write the appropriate symbol for operator self._write(symbol) # Check if parenthesis are needed on the right side and then dispatch has_paren = False right_class = str(t.right.__class__) if (right_class in op_precedence.keys() and op_precedence[right_class] < op_precedence[str(t.__class__)]): has_paren = True if has_paren: self._write('(') self._dispatch(t.right) if has_paren: self._write(')') def _float(self, t): # if t is 0.1, str(t)->'0.1' while repr(t)->'0.1000000000001' # We prefer str here. self._write(str(t)) def _str(self, t): self._write(repr(t)) def _tuple(self, t): self._write(str(t)) ######################################################################### # These are the methods from the _ast modules unparse. # # As our needs to handle more advanced code increase, we may want to # modify some of the methods below so that they work for compiler.ast. ######################################################################### # # stmt # def _Expr(self, tree): # self._fill() # self._dispatch(tree.value) # # def _Import(self, t): # self._fill("import ") # first = True # for a in t.names: # if first: # first = False # else: # self._write(", ") # self._write(a.name) # if a.asname: # self._write(" as "+a.asname) # ## def _ImportFrom(self, t): ## self._fill("from ") ## self._write(t.module) ## self._write(" import ") ## for i, a in enumerate(t.names): ## if i == 0: ## self._write(", ") ## self._write(a.name) ## if a.asname: ## self._write(" as "+a.asname) ## # XXX(jpe) what is level for? ## # # def _Break(self, t): # self._fill("break") # # def _Continue(self, t): # self._fill("continue") # # def _Delete(self, t): # self._fill("del ") # self._dispatch(t.targets) # # def _Assert(self, t): # self._fill("assert ") # self._dispatch(t.test) # if t.msg: # self._write(", ") # self._dispatch(t.msg) # # def _Exec(self, t): # self._fill("exec ") # self._dispatch(t.body) # if t.globals: # self._write(" in ") # self._dispatch(t.globals) # if t.locals: # self._write(", ") # self._dispatch(t.locals) # # def _Print(self, t): # self._fill("print ") # do_comma = False # if t.dest: # self._write(">>") # self._dispatch(t.dest) # do_comma = True # for e in t.values: # if do_comma:self._write(", ") # else:do_comma=True # self._dispatch(e) # if not t.nl: # self._write(",") # # def _Global(self, t): # self._fill("global") # for i, n in enumerate(t.names): # if i != 0: # self._write(",") # self._write(" " + n) # # def _Yield(self, t): # self._fill("yield") # if t.value: # self._write(" (") # self._dispatch(t.value) # self._write(")") # # def _Raise(self, t): # self._fill('raise ') # if t.type: # self._dispatch(t.type) # if t.inst: # self._write(", ") # self._dispatch(t.inst) # if t.tback: # self._write(", ") # self._dispatch(t.tback) # # # def _TryFinally(self, t): # self._fill("try") # self._enter() # self._dispatch(t.body) # self._leave() # # self._fill("finally") # self._enter() # self._dispatch(t.finalbody) # self._leave() # # def _excepthandler(self, t): # self._fill("except ") # if t.type: # self._dispatch(t.type) # if t.name: # self._write(", ") # self._dispatch(t.name) # self._enter() # self._dispatch(t.body) # self._leave() # # def _ClassDef(self, t): # self._write("\n") # self._fill("class "+t.name) # if t.bases: # self._write("(") # for a in t.bases: # self._dispatch(a) # self._write(", ") # self._write(")") # self._enter() # self._dispatch(t.body) # self._leave() # # def _FunctionDef(self, t): # self._write("\n") # for deco in t.decorators: # self._fill("@") # self._dispatch(deco) # self._fill("def "+t.name + "(") # self._dispatch(t.args) # self._write(")") # self._enter() # self._dispatch(t.body) # self._leave() # # def _For(self, t): # self._fill("for ") # self._dispatch(t.target) # self._write(" in ") # self._dispatch(t.iter) # self._enter() # self._dispatch(t.body) # self._leave() # if t.orelse: # self._fill("else") # self._enter() # self._dispatch(t.orelse) # self._leave # # def _While(self, t): # self._fill("while ") # self._dispatch(t.test) # self._enter() # self._dispatch(t.body) # self._leave() # if t.orelse: # self._fill("else") # self._enter() # self._dispatch(t.orelse) # self._leave # # # expr # def _Str(self, tree): # self._write(repr(tree.s)) ## # def _Repr(self, t): # self._write("`") # self._dispatch(t.value) # self._write("`") # # def _Num(self, t): # self._write(repr(t.n)) # # def _ListComp(self, t): # self._write("[") # self._dispatch(t.elt) # for gen in t.generators: # self._dispatch(gen) # self._write("]") # # def _GeneratorExp(self, t): # self._write("(") # self._dispatch(t.elt) # for gen in t.generators: # self._dispatch(gen) # self._write(")") # # def _comprehension(self, t): # self._write(" for ") # self._dispatch(t.target) # self._write(" in ") # self._dispatch(t.iter) # for if_clause in t.ifs: # self._write(" if ") # self._dispatch(if_clause) # # def _IfExp(self, t): # self._dispatch(t.body) # self._write(" if ") # self._dispatch(t.test) # if t.orelse: # self._write(" else ") # self._dispatch(t.orelse) # # unop = {"Invert":"~", "Not": "not", "UAdd":"+", "USub":"-"} # def _UnaryOp(self, t): # self._write(self.unop[t.op.__class__.__name__]) # self._write("(") # self._dispatch(t.operand) # self._write(")") # # binop = { "Add":"+", "Sub":"-", "Mult":"*", "Div":"/", "Mod":"%", # "LShift":">>", "RShift":"<<", "BitOr":"|", "BitXor":"^", "BitAnd":"&", # "FloorDiv":"//", "Pow": "**"} # def _BinOp(self, t): # self._write("(") # self._dispatch(t.left) # self._write(")" + self.binop[t.op.__class__.__name__] + "(") # self._dispatch(t.right) # self._write(")") # # boolops = {_ast.And: 'and', _ast.Or: 'or'} # def _BoolOp(self, t): # self._write("(") # self._dispatch(t.values[0]) # for v in t.values[1:]: # self._write(" %s " % self.boolops[t.op.__class__]) # self._dispatch(v) # self._write(")") # # def _Attribute(self,t): # self._dispatch(t.value) # self._write(".") # self._write(t.attr) # ## def _Call(self, t): ## self._dispatch(t.func) ## self._write("(") ## comma = False ## for e in t.args: ## if comma: self._write(", ") ## else: comma = True ## self._dispatch(e) ## for e in t.keywords: ## if comma: self._write(", ") ## else: comma = True ## self._dispatch(e) ## if t.starargs: ## if comma: self._write(", ") ## else: comma = True ## self._write("*") ## self._dispatch(t.starargs) ## if t.kwargs: ## if comma: self._write(", ") ## else: comma = True ## self._write("**") ## self._dispatch(t.kwargs) ## self._write(")") # # # slice # def _Index(self, t): # self._dispatch(t.value) # # def _ExtSlice(self, t): # for i, d in enumerate(t.dims): # if i != 0: # self._write(': ') # self._dispatch(d) # # # others # def _arguments(self, t): # first = True # nonDef = len(t.args)-len(t.defaults) # for a in t.args[0:nonDef]: # if first:first = False # else: self._write(", ") # self._dispatch(a) # for a,d in zip(t.args[nonDef:], t.defaults): # if first:first = False # else: self._write(", ") # self._dispatch(a), # self._write("=") # self._dispatch(d) # if t.vararg: # if first:first = False # else: self._write(", ") # self._write("*"+t.vararg) # if t.kwarg: # if first:first = False # else: self._write(", ") # self._write("**"+t.kwarg) # ## def _keyword(self, t): ## self._write(t.arg) ## self._write("=") ## self._dispatch(t.value) # # def _Lambda(self, t): # self._write("lambda ") # self._dispatch(t.args) # self._write(": ") # self._dispatch(t.body) photutils-0.2.1/astropy_helpers/astropy_helpers/sphinx/ext/docscrape.py0000600000214200020070000003771312346164025031032 0ustar lbradleySTSCI\science00000000000000"""Extract reference documentation from the NumPy source tree. """ from __future__ import division, absolute_import, print_function import inspect import textwrap import re import pydoc from warnings import warn import collections import sys class Reader(object): """A line-based string reader. """ def __init__(self, data): """ Parameters ---------- data : str String with lines separated by '\n'. """ if isinstance(data,list): self._str = data else: self._str = data.split('\n') # store string as list of lines self.reset() def __getitem__(self, n): return self._str[n] def reset(self): self._l = 0 # current line nr def read(self): if not self.eof(): out = self[self._l] self._l += 1 return out else: return '' def seek_next_non_empty_line(self): for l in self[self._l:]: if l.strip(): break else: self._l += 1 def eof(self): return self._l >= len(self._str) def read_to_condition(self, condition_func): start = self._l for line in self[start:]: if condition_func(line): return self[start:self._l] self._l += 1 if self.eof(): return self[start:self._l+1] return [] def read_to_next_empty_line(self): self.seek_next_non_empty_line() def is_empty(line): return not line.strip() return self.read_to_condition(is_empty) def read_to_next_unindented_line(self): def is_unindented(line): return (line.strip() and (len(line.lstrip()) == len(line))) return self.read_to_condition(is_unindented) def peek(self,n=0): if self._l + n < len(self._str): return self[self._l + n] else: return '' def is_empty(self): return not ''.join(self._str).strip() class NumpyDocString(object): def __init__(self, docstring, config={}): docstring = textwrap.dedent(docstring).split('\n') self._doc = Reader(docstring) self._parsed_data = { 'Signature': '', 'Summary': [''], 'Extended Summary': [], 'Parameters': [], 'Returns': [], 'Raises': [], 'Warns': [], 'Other Parameters': [], 'Attributes': [], 'Methods': [], 'See Also': [], 'Notes': [], 'Warnings': [], 'References': '', 'Examples': '', 'index': {} } self._parse() def __getitem__(self,key): return self._parsed_data[key] def __setitem__(self,key,val): if key not in self._parsed_data: warn("Unknown section %s" % key) else: self._parsed_data[key] = val def _is_at_section(self): self._doc.seek_next_non_empty_line() if self._doc.eof(): return False l1 = self._doc.peek().strip() # e.g. Parameters if l1.startswith('.. index::'): return True l2 = self._doc.peek(1).strip() # ---------- or ========== return l2.startswith('-'*len(l1)) or l2.startswith('='*len(l1)) def _strip(self,doc): i = 0 j = 0 for i,line in enumerate(doc): if line.strip(): break for j,line in enumerate(doc[::-1]): if line.strip(): break return doc[i:len(doc)-j] def _read_to_next_section(self): section = self._doc.read_to_next_empty_line() while not self._is_at_section() and not self._doc.eof(): if not self._doc.peek(-1).strip(): # previous line was empty section += [''] section += self._doc.read_to_next_empty_line() return section def _read_sections(self): while not self._doc.eof(): data = self._read_to_next_section() name = data[0].strip() if name.startswith('..'): # index section yield name, data[1:] elif len(data) < 2: yield StopIteration else: yield name, self._strip(data[2:]) def _parse_param_list(self,content): r = Reader(content) params = [] while not r.eof(): header = r.read().strip() if ' : ' in header: arg_name, arg_type = header.split(' : ')[:2] else: arg_name, arg_type = header, '' desc = r.read_to_next_unindented_line() desc = dedent_lines(desc) params.append((arg_name,arg_type,desc)) return params _name_rgx = re.compile(r"^\s*(:(?P\w+):`(?P[a-zA-Z0-9_.-]+)`|" r" (?P[a-zA-Z0-9_.-]+))\s*", re.X) def _parse_see_also(self, content): """ func_name : Descriptive text continued text another_func_name : Descriptive text func_name1, func_name2, :meth:`func_name`, func_name3 """ items = [] def parse_item_name(text): """Match ':role:`name`' or 'name'""" m = self._name_rgx.match(text) if m: g = m.groups() if g[1] is None: return g[3], None else: return g[2], g[1] raise ValueError("%s is not a item name" % text) def push_item(name, rest): if not name: return name, role = parse_item_name(name) items.append((name, list(rest), role)) del rest[:] current_func = None rest = [] for line in content: if not line.strip(): continue m = self._name_rgx.match(line) if m and line[m.end():].strip().startswith(':'): push_item(current_func, rest) current_func, line = line[:m.end()], line[m.end():] rest = [line.split(':', 1)[1].strip()] if not rest[0]: rest = [] elif not line.startswith(' '): push_item(current_func, rest) current_func = None if ',' in line: for func in line.split(','): if func.strip(): push_item(func, []) elif line.strip(): current_func = line elif current_func is not None: rest.append(line.strip()) push_item(current_func, rest) return items def _parse_index(self, section, content): """ .. index: default :refguide: something, else, and more """ def strip_each_in(lst): return [s.strip() for s in lst] out = {} section = section.split('::') if len(section) > 1: out['default'] = strip_each_in(section[1].split(','))[0] for line in content: line = line.split(':') if len(line) > 2: out[line[1]] = strip_each_in(line[2].split(',')) return out def _parse_summary(self): """Grab signature (if given) and summary""" if self._is_at_section(): return # If several signatures present, take the last one while True: summary = self._doc.read_to_next_empty_line() summary_str = " ".join([s.strip() for s in summary]).strip() if re.compile('^([\w., ]+=)?\s*[\w\.]+\(.*\)$').match(summary_str): self['Signature'] = summary_str if not self._is_at_section(): continue break if summary is not None: self['Summary'] = summary if not self._is_at_section(): self['Extended Summary'] = self._read_to_next_section() def _parse(self): self._doc.reset() self._parse_summary() for (section,content) in self._read_sections(): if not section.startswith('..'): section = ' '.join([s.capitalize() for s in section.split(' ')]) if section in ('Parameters', 'Returns', 'Raises', 'Warns', 'Other Parameters', 'Attributes', 'Methods'): self[section] = self._parse_param_list(content) elif section.startswith('.. index::'): self['index'] = self._parse_index(section, content) elif section == 'See Also': self['See Also'] = self._parse_see_also(content) else: self[section] = content # string conversion routines def _str_header(self, name, symbol='-'): return [name, len(name)*symbol] def _str_indent(self, doc, indent=4): out = [] for line in doc: out += [' '*indent + line] return out def _str_signature(self): if self['Signature']: return [self['Signature'].replace('*','\*')] + [''] else: return [''] def _str_summary(self): if self['Summary']: return self['Summary'] + [''] else: return [] def _str_extended_summary(self): if self['Extended Summary']: return self['Extended Summary'] + [''] else: return [] def _str_param_list(self, name): out = [] if self[name]: out += self._str_header(name) for param,param_type,desc in self[name]: if param_type: out += ['%s : %s' % (param, param_type)] else: out += [param] out += self._str_indent(desc) out += [''] return out def _str_section(self, name): out = [] if self[name]: out += self._str_header(name) out += self[name] out += [''] return out def _str_see_also(self, func_role): if not self['See Also']: return [] out = [] out += self._str_header("See Also") last_had_desc = True for func, desc, role in self['See Also']: if role: link = ':%s:`%s`' % (role, func) elif func_role: link = ':%s:`%s`' % (func_role, func) else: link = "`%s`_" % func if desc or last_had_desc: out += [''] out += [link] else: out[-1] += ", %s" % link if desc: out += self._str_indent([' '.join(desc)]) last_had_desc = True else: last_had_desc = False out += [''] return out def _str_index(self): idx = self['index'] out = [] out += ['.. index:: %s' % idx.get('default','')] for section, references in idx.items(): if section == 'default': continue out += [' :%s: %s' % (section, ', '.join(references))] return out def __str__(self, func_role=''): out = [] out += self._str_signature() out += self._str_summary() out += self._str_extended_summary() for param_list in ('Parameters', 'Returns', 'Other Parameters', 'Raises', 'Warns'): out += self._str_param_list(param_list) out += self._str_section('Warnings') out += self._str_see_also(func_role) for s in ('Notes','References','Examples'): out += self._str_section(s) for param_list in ('Attributes', 'Methods'): out += self._str_param_list(param_list) out += self._str_index() return '\n'.join(out) def indent(str,indent=4): indent_str = ' '*indent if str is None: return indent_str lines = str.split('\n') return '\n'.join(indent_str + l for l in lines) def dedent_lines(lines): """Deindent a list of lines maximally""" return textwrap.dedent("\n".join(lines)).split("\n") def header(text, style='-'): return text + '\n' + style*len(text) + '\n' class FunctionDoc(NumpyDocString): def __init__(self, func, role='func', doc=None, config={}): self._f = func self._role = role # e.g. "func" or "meth" if doc is None: if func is None: raise ValueError("No function or docstring given") doc = inspect.getdoc(func) or '' NumpyDocString.__init__(self, doc) if not self['Signature'] and func is not None: func, func_name = self.get_func() try: # try to read signature if sys.version_info[0] >= 3: argspec = inspect.getfullargspec(func) else: argspec = inspect.getargspec(func) argspec = inspect.formatargspec(*argspec) argspec = argspec.replace('*','\*') signature = '%s%s' % (func_name, argspec) except TypeError as e: signature = '%s()' % func_name self['Signature'] = signature def get_func(self): func_name = getattr(self._f, '__name__', self.__class__.__name__) if inspect.isclass(self._f): func = getattr(self._f, '__call__', self._f.__init__) else: func = self._f return func, func_name def __str__(self): out = '' func, func_name = self.get_func() signature = self['Signature'].replace('*', '\*') roles = {'func': 'function', 'meth': 'method'} if self._role: if self._role not in roles: print("Warning: invalid role %s" % self._role) out += '.. %s:: %s\n \n\n' % (roles.get(self._role,''), func_name) out += super(FunctionDoc, self).__str__(func_role=self._role) return out class ClassDoc(NumpyDocString): extra_public_methods = ['__call__'] def __init__(self, cls, doc=None, modulename='', func_doc=FunctionDoc, config={}): if not inspect.isclass(cls) and cls is not None: raise ValueError("Expected a class or None, but got %r" % cls) self._cls = cls if modulename and not modulename.endswith('.'): modulename += '.' self._mod = modulename if doc is None: if cls is None: raise ValueError("No class or documentation string given") doc = pydoc.getdoc(cls) NumpyDocString.__init__(self, doc) if config.get('show_class_members', True): def splitlines_x(s): if not s: return [] else: return s.splitlines() for field, items in [('Methods', self.methods), ('Attributes', self.properties)]: if not self[field]: doc_list = [] for name in sorted(items): try: doc_item = pydoc.getdoc(getattr(self._cls, name)) doc_list.append((name, '', splitlines_x(doc_item))) except AttributeError: pass # method doesn't exist self[field] = doc_list @property def methods(self): if self._cls is None: return [] return [name for name,func in inspect.getmembers(self._cls) if ((not name.startswith('_') or name in self.extra_public_methods) and isinstance(func, collections.Callable))] @property def properties(self): if self._cls is None: return [] return [name for name,func in inspect.getmembers(self._cls) if not name.startswith('_') and (func is None or isinstance(func, property) or inspect.isgetsetdescriptor(func))] photutils-0.2.1/astropy_helpers/astropy_helpers/sphinx/ext/docscrape_sphinx.py0000600000214200020070000002233512346164025032415 0ustar lbradleySTSCI\science00000000000000from __future__ import division, absolute_import, print_function import sys, re, inspect, textwrap, pydoc import sphinx import collections from .docscrape import NumpyDocString, FunctionDoc, ClassDoc if sys.version_info[0] >= 3: sixu = lambda s: s else: sixu = lambda s: unicode(s, 'unicode_escape') class SphinxDocString(NumpyDocString): def __init__(self, docstring, config={}): NumpyDocString.__init__(self, docstring, config=config) self.load_config(config) def load_config(self, config): self.use_plots = config.get('use_plots', False) self.class_members_toctree = config.get('class_members_toctree', True) # string conversion routines def _str_header(self, name, symbol='`'): return ['.. rubric:: ' + name, ''] def _str_field_list(self, name): return [':' + name + ':'] def _str_indent(self, doc, indent=4): out = [] for line in doc: out += [' '*indent + line] return out def _str_signature(self): return [''] if self['Signature']: return ['``%s``' % self['Signature']] + [''] else: return [''] def _str_summary(self): return self['Summary'] + [''] def _str_extended_summary(self): return self['Extended Summary'] + [''] def _str_returns(self): out = [] if self['Returns']: out += self._str_field_list('Returns') out += [''] for param, param_type, desc in self['Returns']: if param_type: out += self._str_indent(['**%s** : %s' % (param.strip(), param_type)]) else: out += self._str_indent([param.strip()]) if desc: out += [''] out += self._str_indent(desc, 8) out += [''] return out def _str_param_list(self, name): out = [] if self[name]: out += self._str_field_list(name) out += [''] for param, param_type, desc in self[name]: if param_type: out += self._str_indent(['**%s** : %s' % (param.strip(), param_type)]) else: out += self._str_indent(['**%s**' % param.strip()]) if desc: out += [''] out += self._str_indent(desc, 8) out += [''] return out @property def _obj(self): if hasattr(self, '_cls'): return self._cls elif hasattr(self, '_f'): return self._f return None def _str_member_list(self, name): """ Generate a member listing, autosummary:: table where possible, and a table where not. """ out = [] if self[name]: out += ['.. rubric:: %s' % name, ''] prefix = getattr(self, '_name', '') if prefix: prefix = '~%s.' % prefix autosum = [] others = [] for param, param_type, desc in self[name]: param = param.strip() # Check if the referenced member can have a docstring or not param_obj = getattr(self._obj, param, None) if not (callable(param_obj) or isinstance(param_obj, property) or inspect.isgetsetdescriptor(param_obj)): param_obj = None if param_obj and (pydoc.getdoc(param_obj) or not desc): # Referenced object has a docstring autosum += [" %s%s" % (prefix, param)] else: others.append((param, param_type, desc)) if autosum: out += ['.. autosummary::'] if self.class_members_toctree: out += [' :toctree:'] out += [''] + autosum if others: maxlen_0 = max(3, max([len(x[0]) for x in others])) hdr = sixu("=")*maxlen_0 + sixu(" ") + sixu("=")*10 fmt = sixu('%%%ds %%s ') % (maxlen_0,) out += ['', hdr] for param, param_type, desc in others: desc = sixu(" ").join(x.strip() for x in desc).strip() if param_type: desc = "(%s) %s" % (param_type, desc) out += [fmt % (param.strip(), desc)] out += [hdr] out += [''] return out def _str_section(self, name): out = [] if self[name]: out += self._str_header(name) out += [''] content = textwrap.dedent("\n".join(self[name])).split("\n") out += content out += [''] return out def _str_see_also(self, func_role): out = [] if self['See Also']: see_also = super(SphinxDocString, self)._str_see_also(func_role) out = ['.. seealso::', ''] out += self._str_indent(see_also[2:]) return out def _str_warnings(self): out = [] if self['Warnings']: out = ['.. warning::', ''] out += self._str_indent(self['Warnings']) return out def _str_index(self): idx = self['index'] out = [] if len(idx) == 0: return out out += ['.. index:: %s' % idx.get('default','')] for section, references in idx.items(): if section == 'default': continue elif section == 'refguide': out += [' single: %s' % (', '.join(references))] else: out += [' %s: %s' % (section, ','.join(references))] return out def _str_references(self): out = [] if self['References']: out += self._str_header('References') if isinstance(self['References'], str): self['References'] = [self['References']] out.extend(self['References']) out += [''] # Latex collects all references to a separate bibliography, # so we need to insert links to it if sphinx.__version__ >= "0.6": out += ['.. only:: latex',''] else: out += ['.. latexonly::',''] items = [] for line in self['References']: m = re.match(r'.. \[([a-z0-9._-]+)\]', line, re.I) if m: items.append(m.group(1)) out += [' ' + ", ".join(["[%s]_" % item for item in items]), ''] return out def _str_examples(self): examples_str = "\n".join(self['Examples']) if (self.use_plots and 'import matplotlib' in examples_str and 'plot::' not in examples_str): out = [] out += self._str_header('Examples') out += ['.. plot::', ''] out += self._str_indent(self['Examples']) out += [''] return out else: return self._str_section('Examples') def __str__(self, indent=0, func_role="obj"): out = [] out += self._str_signature() out += self._str_index() + [''] out += self._str_summary() out += self._str_extended_summary() out += self._str_param_list('Parameters') out += self._str_returns() for param_list in ('Other Parameters', 'Raises', 'Warns'): out += self._str_param_list(param_list) out += self._str_warnings() out += self._str_see_also(func_role) out += self._str_section('Notes') out += self._str_references() out += self._str_examples() for param_list in ('Attributes', 'Methods'): out += self._str_member_list(param_list) out = self._str_indent(out,indent) return '\n'.join(out) class SphinxFunctionDoc(SphinxDocString, FunctionDoc): def __init__(self, obj, doc=None, config={}): self.load_config(config) FunctionDoc.__init__(self, obj, doc=doc, config=config) class SphinxClassDoc(SphinxDocString, ClassDoc): def __init__(self, obj, doc=None, func_doc=None, config={}): self.load_config(config) ClassDoc.__init__(self, obj, doc=doc, func_doc=None, config=config) class SphinxObjDoc(SphinxDocString): def __init__(self, obj, doc=None, config={}): self._f = obj self.load_config(config) SphinxDocString.__init__(self, doc, config=config) def get_doc_object(obj, what=None, doc=None, config={}): if what is None: if inspect.isclass(obj): what = 'class' elif inspect.ismodule(obj): what = 'module' elif isinstance(obj, collections.Callable): what = 'function' else: what = 'object' if what == 'class': return SphinxClassDoc(obj, func_doc=SphinxFunctionDoc, doc=doc, config=config) elif what in ('function', 'method'): return SphinxFunctionDoc(obj, doc=doc, config=config) else: if doc is None: doc = pydoc.getdoc(obj) return SphinxObjDoc(obj, doc, config=config) photutils-0.2.1/astropy_helpers/astropy_helpers/sphinx/ext/doctest.py0000600000214200020070000000243612444350332030523 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst """ This is a set of three directives that allow us to insert metadata about doctests into the .rst files so the testing framework knows which tests to skip. This is quite different from the doctest extension in Sphinx itself, which actually does something. For astropy, all of the testing is centrally managed from py.test and Sphinx is not used for running tests. """ import re from docutils.nodes import literal_block from sphinx.util.compat import Directive class DoctestSkipDirective(Directive): has_content = True def run(self): # Check if there is any valid argument, and skip it. Currently only # 'win32' is supported in astropy.tests.pytest_plugins. if re.match('win32', self.content[0]): self.content = self.content[2:] code = '\n'.join(self.content) return [literal_block(code, code)] class DoctestRequiresDirective(DoctestSkipDirective): # This is silly, but we really support an unbounded number of # optional arguments optional_arguments = 64 def setup(app): app.add_directive('doctest-requires', DoctestRequiresDirective) app.add_directive('doctest-skip', DoctestSkipDirective) app.add_directive('doctest-skip-all', DoctestSkipDirective) photutils-0.2.1/astropy_helpers/astropy_helpers/sphinx/ext/edit_on_github.py0000600000214200020070000001340712355051562032045 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst """ This extension makes it easy to edit documentation on github. It adds links associated with each docstring that go to the corresponding view source page on Github. From there, the user can push the "Edit" button, edit the docstring, and submit a pull request. It has the following configuration options (to be set in the project's ``conf.py``): * ``edit_on_github_project`` The name of the github project, in the form "username/projectname". * ``edit_on_github_branch`` The name of the branch to edit. If this is a released version, this should be a git tag referring to that version. For a dev version, it often makes sense for it to be "master". It may also be a git hash. * ``edit_on_github_source_root`` The location within the source tree of the root of the Python package. Defaults to "lib". * ``edit_on_github_doc_root`` The location within the source tree of the root of the documentation source. Defaults to "doc", but it may make sense to set it to "doc/source" if the project uses a separate source directory. * ``edit_on_github_docstring_message`` The phrase displayed in the links to edit a docstring. Defaults to "[edit on github]". * ``edit_on_github_page_message`` The phrase displayed in the links to edit a RST page. Defaults to "[edit this page on github]". * ``edit_on_github_help_message`` The phrase displayed as a tooltip on the edit links. Defaults to "Push the Edit button on the next page" * ``edit_on_github_skip_regex`` When the path to the .rst file matches this regular expression, no "edit this page on github" link will be added. Defaults to ``"_.*"``. """ import inspect import os import re import sys from docutils import nodes from sphinx import addnodes def import_object(modname, name): """ Import the object given by *modname* and *name* and return it. If not found, or the import fails, returns None. """ try: __import__(modname) mod = sys.modules[modname] obj = mod for part in name.split('.'): obj = getattr(obj, part) return obj except: return None def get_url_base(app): return 'http://github.com/%s/tree/%s/' % ( app.config.edit_on_github_project, app.config.edit_on_github_branch) def doctree_read(app, doctree): # Get the configuration parameters if app.config.edit_on_github_project == 'REQUIRED': raise ValueError( "The edit_on_github_project configuration variable must be " "provided in the conf.py") source_root = app.config.edit_on_github_source_root url = get_url_base(app) docstring_message = app.config.edit_on_github_docstring_message # Handle the docstring-editing links for objnode in doctree.traverse(addnodes.desc): if objnode.get('domain') != 'py': continue names = set() for signode in objnode: if not isinstance(signode, addnodes.desc_signature): continue modname = signode.get('module') if not modname: continue fullname = signode.get('fullname') if fullname in names: # only one link per name, please continue names.add(fullname) obj = import_object(modname, fullname) anchor = None if obj is not None: try: lines, lineno = inspect.getsourcelines(obj) except: pass else: anchor = '#L%d' % lineno if anchor: real_modname = inspect.getmodule(obj).__name__ path = '%s%s%s.py%s' % ( url, source_root, real_modname.replace('.', '/'), anchor) onlynode = addnodes.only(expr='html') onlynode += nodes.reference( reftitle=app.config.edit_on_github_help_message, refuri=path) onlynode[0] += nodes.inline( '', '', nodes.raw('', ' ', format='html'), nodes.Text(docstring_message), classes=['edit-on-github', 'viewcode-link']) signode += onlynode def html_page_context(app, pagename, templatename, context, doctree): if (templatename == 'page.html' and not re.match(app.config.edit_on_github_skip_regex, pagename)): doc_root = app.config.edit_on_github_doc_root if doc_root != '' and not doc_root.endswith('/'): doc_root += '/' doc_path = os.path.relpath(doctree.get('source'), app.builder.srcdir) url = get_url_base(app) page_message = app.config.edit_on_github_page_message context['edit_on_github'] = url + doc_root + doc_path context['edit_on_github_page_message'] = ( app.config.edit_on_github_page_message) def setup(app): app.add_config_value('edit_on_github_project', 'REQUIRED', True) app.add_config_value('edit_on_github_branch', 'master', True) app.add_config_value('edit_on_github_source_root', 'lib', True) app.add_config_value('edit_on_github_doc_root', 'doc', True) app.add_config_value('edit_on_github_docstring_message', '[edit on github]', True) app.add_config_value('edit_on_github_page_message', 'Edit This Page on Github', True) app.add_config_value('edit_on_github_help_message', 'Push the Edit button on the next page', True) app.add_config_value('edit_on_github_skip_regex', '_.*', True) app.connect('doctree-read', doctree_read) app.connect('html-page-context', html_page_context) photutils-0.2.1/astropy_helpers/astropy_helpers/sphinx/ext/numpydoc.py0000600000214200020070000001441412346164025030716 0ustar lbradleySTSCI\science00000000000000""" ======== numpydoc ======== Sphinx extension that handles docstrings in the Numpy standard format. [1] It will: - Convert Parameters etc. sections to field lists. - Convert See Also section to a See also entry. - Renumber references. - Extract the signature from the docstring, if it can't be determined otherwise. .. [1] https://github.com/numpy/numpy/blob/master/doc/HOWTO_DOCUMENT.rst.txt """ from __future__ import division, absolute_import, print_function import os, sys, re, pydoc import sphinx import inspect import collections if sphinx.__version__ < '1.0.1': raise RuntimeError("Sphinx 1.0.1 or newer is required") from .docscrape_sphinx import get_doc_object, SphinxDocString from sphinx.util.compat import Directive if sys.version_info[0] >= 3: sixu = lambda s: s else: sixu = lambda s: unicode(s, 'unicode_escape') def mangle_docstrings(app, what, name, obj, options, lines, reference_offset=[0]): cfg = dict(use_plots=app.config.numpydoc_use_plots, show_class_members=app.config.numpydoc_show_class_members, class_members_toctree=app.config.numpydoc_class_members_toctree, ) if what == 'module': # Strip top title title_re = re.compile(sixu('^\\s*[#*=]{4,}\\n[a-z0-9 -]+\\n[#*=]{4,}\\s*'), re.I|re.S) lines[:] = title_re.sub(sixu(''), sixu("\n").join(lines)).split(sixu("\n")) else: doc = get_doc_object(obj, what, sixu("\n").join(lines), config=cfg) if sys.version_info[0] >= 3: doc = str(doc) else: doc = unicode(doc) lines[:] = doc.split(sixu("\n")) if app.config.numpydoc_edit_link and hasattr(obj, '__name__') and \ obj.__name__: if hasattr(obj, '__module__'): v = dict(full_name=sixu("%s.%s") % (obj.__module__, obj.__name__)) else: v = dict(full_name=obj.__name__) lines += [sixu(''), sixu('.. htmlonly::'), sixu('')] lines += [sixu(' %s') % x for x in (app.config.numpydoc_edit_link % v).split("\n")] # replace reference numbers so that there are no duplicates references = [] for line in lines: line = line.strip() m = re.match(sixu('^.. \\[([a-z0-9_.-])\\]'), line, re.I) if m: references.append(m.group(1)) # start renaming from the longest string, to avoid overwriting parts references.sort(key=lambda x: -len(x)) if references: for i, line in enumerate(lines): for r in references: if re.match(sixu('^\\d+$'), r): new_r = sixu("R%d") % (reference_offset[0] + int(r)) else: new_r = sixu("%s%d") % (r, reference_offset[0]) lines[i] = lines[i].replace(sixu('[%s]_') % r, sixu('[%s]_') % new_r) lines[i] = lines[i].replace(sixu('.. [%s]') % r, sixu('.. [%s]') % new_r) reference_offset[0] += len(references) def mangle_signature(app, what, name, obj, options, sig, retann): # Do not try to inspect classes that don't define `__init__` if (inspect.isclass(obj) and (not hasattr(obj, '__init__') or 'initializes x; see ' in pydoc.getdoc(obj.__init__))): return '', '' if not (isinstance(obj, collections.Callable) or hasattr(obj, '__argspec_is_invalid_')): return if not hasattr(obj, '__doc__'): return doc = SphinxDocString(pydoc.getdoc(obj)) if doc['Signature']: sig = re.sub(sixu("^[^(]*"), sixu(""), doc['Signature']) return sig, sixu('') def setup(app, get_doc_object_=get_doc_object): if not hasattr(app, 'add_config_value'): return # probably called by nose, better bail out global get_doc_object get_doc_object = get_doc_object_ app.connect('autodoc-process-docstring', mangle_docstrings) app.connect('autodoc-process-signature', mangle_signature) app.add_config_value('numpydoc_edit_link', None, False) app.add_config_value('numpydoc_use_plots', None, False) app.add_config_value('numpydoc_show_class_members', True, True) app.add_config_value('numpydoc_class_members_toctree', True, True) # Extra mangling domains app.add_domain(NumpyPythonDomain) app.add_domain(NumpyCDomain) #------------------------------------------------------------------------------ # Docstring-mangling domains #------------------------------------------------------------------------------ from docutils.statemachine import ViewList from sphinx.domains.c import CDomain from sphinx.domains.python import PythonDomain class ManglingDomainBase(object): directive_mangling_map = {} def __init__(self, *a, **kw): super(ManglingDomainBase, self).__init__(*a, **kw) self.wrap_mangling_directives() def wrap_mangling_directives(self): for name, objtype in list(self.directive_mangling_map.items()): self.directives[name] = wrap_mangling_directive( self.directives[name], objtype) class NumpyPythonDomain(ManglingDomainBase, PythonDomain): name = 'np' directive_mangling_map = { 'function': 'function', 'class': 'class', 'exception': 'class', 'method': 'function', 'classmethod': 'function', 'staticmethod': 'function', 'attribute': 'attribute', } indices = [] class NumpyCDomain(ManglingDomainBase, CDomain): name = 'np-c' directive_mangling_map = { 'function': 'function', 'member': 'attribute', 'macro': 'function', 'type': 'class', 'var': 'object', } def wrap_mangling_directive(base_directive, objtype): class directive(base_directive): def run(self): env = self.state.document.settings.env name = None if self.arguments: m = re.match(r'^(.*\s+)?(.*?)(\(.*)?', self.arguments[0]) name = m.group(2).strip() if not name: name = self.arguments[0] lines = list(self.content) mangle_docstrings(env.app, objtype, name, None, None, lines) self.content = ViewList(lines, self.content.parent) return base_directive.run(self) return directive photutils-0.2.1/astropy_helpers/astropy_helpers/sphinx/ext/phantom_import.py0000600000214200020070000001333612346164025032122 0ustar lbradleySTSCI\science00000000000000""" ============== phantom_import ============== Sphinx extension to make directives from ``sphinx.ext.autodoc`` and similar extensions to use docstrings loaded from an XML file. This extension loads an XML file in the Pydocweb format [1] and creates a dummy module that contains the specified docstrings. This can be used to get the current docstrings from a Pydocweb instance without needing to rebuild the documented module. .. [1] http://code.google.com/p/pydocweb """ from __future__ import division, absolute_import, print_function import imp, sys, compiler, types, os, inspect, re def setup(app): app.connect('builder-inited', initialize) app.add_config_value('phantom_import_file', None, True) def initialize(app): fn = app.config.phantom_import_file if (fn and os.path.isfile(fn)): print("[numpydoc] Phantom importing modules from", fn, "...") import_phantom_module(fn) #------------------------------------------------------------------------------ # Creating 'phantom' modules from an XML description #------------------------------------------------------------------------------ def import_phantom_module(xml_file): """ Insert a fake Python module to sys.modules, based on a XML file. The XML file is expected to conform to Pydocweb DTD. The fake module will contain dummy objects, which guarantee the following: - Docstrings are correct. - Class inheritance relationships are correct (if present in XML). - Function argspec is *NOT* correct (even if present in XML). Instead, the function signature is prepended to the function docstring. - Class attributes are *NOT* correct; instead, they are dummy objects. Parameters ---------- xml_file : str Name of an XML file to read """ import lxml.etree as etree object_cache = {} tree = etree.parse(xml_file) root = tree.getroot() # Sort items so that # - Base classes come before classes inherited from them # - Modules come before their contents all_nodes = dict([(n.attrib['id'], n) for n in root]) def _get_bases(node, recurse=False): bases = [x.attrib['ref'] for x in node.findall('base')] if recurse: j = 0 while True: try: b = bases[j] except IndexError: break if b in all_nodes: bases.extend(_get_bases(all_nodes[b])) j += 1 return bases type_index = ['module', 'class', 'callable', 'object'] def base_cmp(a, b): x = cmp(type_index.index(a.tag), type_index.index(b.tag)) if x != 0: return x if a.tag == 'class' and b.tag == 'class': a_bases = _get_bases(a, recurse=True) b_bases = _get_bases(b, recurse=True) x = cmp(len(a_bases), len(b_bases)) if x != 0: return x if a.attrib['id'] in b_bases: return -1 if b.attrib['id'] in a_bases: return 1 return cmp(a.attrib['id'].count('.'), b.attrib['id'].count('.')) nodes = root.getchildren() nodes.sort(base_cmp) # Create phantom items for node in nodes: name = node.attrib['id'] doc = (node.text or '').decode('string-escape') + "\n" if doc == "\n": doc = "" # create parent, if missing parent = name while True: parent = '.'.join(parent.split('.')[:-1]) if not parent: break if parent in object_cache: break obj = imp.new_module(parent) object_cache[parent] = obj sys.modules[parent] = obj # create object if node.tag == 'module': obj = imp.new_module(name) obj.__doc__ = doc sys.modules[name] = obj elif node.tag == 'class': bases = [object_cache[b] for b in _get_bases(node) if b in object_cache] bases.append(object) init = lambda self: None init.__doc__ = doc obj = type(name, tuple(bases), {'__doc__': doc, '__init__': init}) obj.__name__ = name.split('.')[-1] elif node.tag == 'callable': funcname = node.attrib['id'].split('.')[-1] argspec = node.attrib.get('argspec') if argspec: argspec = re.sub('^[^(]*', '', argspec) doc = "%s%s\n\n%s" % (funcname, argspec, doc) obj = lambda: 0 obj.__argspec_is_invalid_ = True if sys.version_info[0] >= 3: obj.__name__ = funcname else: obj.func_name = funcname obj.__name__ = name obj.__doc__ = doc if inspect.isclass(object_cache[parent]): obj.__objclass__ = object_cache[parent] else: class Dummy(object): pass obj = Dummy() obj.__name__ = name obj.__doc__ = doc if inspect.isclass(object_cache[parent]): obj.__get__ = lambda: None object_cache[name] = obj if parent: if inspect.ismodule(object_cache[parent]): obj.__module__ = parent setattr(object_cache[parent], name.split('.')[-1], obj) # Populate items for node in root: obj = object_cache.get(node.attrib['id']) if obj is None: continue for ref in node.findall('ref'): if node.tag == 'class': if ref.attrib['ref'].startswith(node.attrib['id'] + '.'): setattr(obj, ref.attrib['name'], object_cache.get(ref.attrib['ref'])) else: setattr(obj, ref.attrib['name'], object_cache.get(ref.attrib['ref'])) photutils-0.2.1/astropy_helpers/astropy_helpers/sphinx/ext/smart_resolver.py0000600000214200020070000000717612444350332032133 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst """ The classes in the astropy docs are documented by their API location, which is not necessarily where they are defined in the source. This causes a problem when certain automated features of the doc build, such as the inheritance diagrams or the `Bases` list of a class reference a class by its canonical location rather than its "user" location. In the `autodoc-process-docstring` event, a mapping from the actual name to the API name is maintained. Later, in the `missing-reference` event, unresolved references are looked up in this dictionary and corrected if possible. """ from docutils.nodes import literal, reference def process_docstring(app, what, name, obj, options, lines): if isinstance(obj, type): env = app.env if not hasattr(env, 'class_name_mapping'): env.class_name_mapping = {} mapping = env.class_name_mapping mapping[obj.__module__ + '.' + obj.__name__] = name def missing_reference_handler(app, env, node, contnode): if not hasattr(env, 'class_name_mapping'): env.class_name_mapping = {} mapping = env.class_name_mapping reftype = node['reftype'] reftarget = node['reftarget'] if reftype in ('obj', 'class', 'exc', 'meth'): reftarget = node['reftarget'] suffix = '' if reftarget not in mapping: if '.' in reftarget: front, suffix = reftarget.rsplit('.', 1) else: suffix = reftarget if suffix.startswith('_') and not suffix.startswith('__'): # If this is a reference to a hidden class or method, # we can't link to it, but we don't want to have a # nitpick warning. return node[0].deepcopy() if reftype in ('obj', 'meth') and '.' in reftarget: if front in mapping: reftarget = front suffix = '.' + suffix if (reftype in ('class', ) and '.' in reftarget and reftarget not in mapping): if '.' in front: reftarget, _ = front.rsplit('.', 1) suffix = '.' + suffix reftarget = reftarget + suffix prefix = reftarget.rsplit('.')[0] if (reftarget not in mapping and prefix in env.intersphinx_named_inventory): if reftarget in env.intersphinx_named_inventory[prefix]['py:class']: newtarget = env.intersphinx_named_inventory[prefix]['py:class'][reftarget][2] if not node['refexplicit'] and \ '~' not in node.rawsource: contnode = literal(text=reftarget) newnode = reference('', '', internal=True) newnode['reftitle'] = reftarget newnode['refuri'] = newtarget newnode.append(contnode) return newnode if reftarget in mapping: newtarget = mapping[reftarget] + suffix if not node['refexplicit'] and not '~' in node.rawsource: contnode = literal(text=newtarget) newnode = env.domains['py'].resolve_xref( env, node['refdoc'], app.builder, 'class', newtarget, node, contnode) if newnode is not None: newnode['reftitle'] = reftarget return newnode def setup(app): app.connect('autodoc-process-docstring', process_docstring) app.connect('missing-reference', missing_reference_handler) photutils-0.2.1/astropy_helpers/astropy_helpers/sphinx/ext/templates/0000700000214200020070000000000012646264032030500 5ustar lbradleySTSCI\science00000000000000photutils-0.2.1/astropy_helpers/astropy_helpers/sphinx/ext/templates/autosummary_core/0000700000214200020070000000000012646264032034076 5ustar lbradleySTSCI\science00000000000000photutils-0.2.1/astropy_helpers/astropy_helpers/sphinx/ext/templates/autosummary_core/base.rst0000600000214200020070000000025212346164025035541 0ustar lbradleySTSCI\science00000000000000{% if referencefile %} .. include:: {{ referencefile }} {% endif %} {{ objname }} {{ underline }} .. currentmodule:: {{ module }} .. auto{{ objtype }}:: {{ objname }} photutils-0.2.1/astropy_helpers/astropy_helpers/sphinx/ext/templates/autosummary_core/class.rst0000600000214200020070000000221112346164025035731 0ustar lbradleySTSCI\science00000000000000{% if referencefile %} .. include:: {{ referencefile }} {% endif %} {{ objname }} {{ underline }} .. currentmodule:: {{ module }} .. autoclass:: {{ objname }} :show-inheritance: {% if '__init__' in methods %} {% set caught_result = methods.remove('__init__') %} {% endif %} {% block attributes_summary %} {% if attributes %} .. rubric:: Attributes Summary .. autosummary:: {% for item in attributes %} ~{{ name }}.{{ item }} {%- endfor %} {% endif %} {% endblock %} {% block methods_summary %} {% if methods %} .. rubric:: Methods Summary .. autosummary:: {% for item in methods %} ~{{ name }}.{{ item }} {%- endfor %} {% endif %} {% endblock %} {% block attributes_documentation %} {% if attributes %} .. rubric:: Attributes Documentation {% for item in attributes %} .. autoattribute:: {{ item }} {%- endfor %} {% endif %} {% endblock %} {% block methods_documentation %} {% if methods %} .. rubric:: Methods Documentation {% for item in methods %} .. automethod:: {{ item }} {%- endfor %} {% endif %} {% endblock %} photutils-0.2.1/astropy_helpers/astropy_helpers/sphinx/ext/templates/autosummary_core/module.rst0000600000214200020070000000127712346164025036124 0ustar lbradleySTSCI\science00000000000000{% if referencefile %} .. include:: {{ referencefile }} {% endif %} {{ objname }} {{ underline }} .. automodule:: {{ fullname }} {% block functions %} {% if functions %} .. rubric:: Functions .. autosummary:: {% for item in functions %} {{ item }} {%- endfor %} {% endif %} {% endblock %} {% block classes %} {% if classes %} .. rubric:: Classes .. autosummary:: {% for item in classes %} {{ item }} {%- endfor %} {% endif %} {% endblock %} {% block exceptions %} {% if exceptions %} .. rubric:: Exceptions .. autosummary:: {% for item in exceptions %} {{ item }} {%- endfor %} {% endif %} {% endblock %} photutils-0.2.1/astropy_helpers/astropy_helpers/sphinx/ext/tests/0000700000214200020070000000000012646264032027644 5ustar lbradleySTSCI\science00000000000000photutils-0.2.1/astropy_helpers/astropy_helpers/sphinx/ext/tests/__init__.py0000600000214200020070000000334112355051562031757 0ustar lbradleySTSCI\science00000000000000import os import subprocess as sp import sys from textwrap import dedent import pytest @pytest.fixture def cython_testpackage(tmpdir, request): """ Creates a trivial Cython package for use with tests. """ test_pkg = tmpdir.mkdir('test_pkg') test_pkg.mkdir('_eva_').ensure('__init__.py') test_pkg.join('_eva_').join('unit02.pyx').write(dedent("""\ def pilot(): \"\"\"Returns the pilot of Eva Unit-02.\"\"\" return True """)) import astropy_helpers test_pkg.join('setup.py').write(dedent("""\ import sys sys.path.insert(0, {0!r}) from os.path import join from setuptools import setup, Extension from astropy_helpers.setup_helpers import register_commands NAME = '_eva_' VERSION = 0.1 RELEASE = True cmdclassd = register_commands(NAME, VERSION, RELEASE) setup( name=NAME, version=VERSION, cmdclass=cmdclassd, ext_modules=[Extension('_eva_.unit02', [join('_eva_', 'unit02.pyx')])] ) """.format(os.path.dirname(astropy_helpers.__path__[0])))) test_pkg.chdir() # Build the Cython module in a subprocess; otherwise strange things can # happen with Cython's global module state sp.call([sys.executable, 'setup.py', 'build_ext', '--inplace']) sys.path.insert(0, str(test_pkg)) import _eva_.unit02 def cleanup(test_pkg=test_pkg): for modname in ['_eva_', '_eva_.unit02']: try: del sys.modules[modname] except KeyError: pass sys.path.remove(str(test_pkg)) request.addfinalizer(cleanup) return test_pkg photutils-0.2.1/astropy_helpers/astropy_helpers/sphinx/ext/tests/test_autodoc_enhancements.py0000600000214200020070000000324312477406127035454 0ustar lbradleySTSCI\science00000000000000import sys from textwrap import dedent import pytest from ..autodoc_enhancements import type_object_attrgetter # Define test classes outside the class; otherwise there is flakiness with the # details of how exec works on different Python versions class Meta(type): @property def foo(cls): return 'foo' if sys.version_info[0] < 3: exec(dedent(""" class MyClass(object): __metaclass__ = Meta @property def foo(self): \"\"\"Docstring for MyClass.foo property.\"\"\" return 'myfoo' """)) else: exec(dedent(""" class MyClass(metaclass=Meta): @property def foo(self): \"\"\"Docstring for MyClass.foo property.\"\"\" return 'myfoo' """)) def test_type_attrgetter(): """ This test essentially reproduces the docstring for `type_object_attrgetter`. Sphinx itself tests the custom attrgetter feature; see: https://bitbucket.org/birkenfeld/sphinx/src/40bd03003ac6fe274ccf3c80d7727509e00a69ea/tests/test_autodoc.py?at=default#cl-502 so rather than a full end-to-end functional test it's simple enough to just test that this function does what it needs to do. """ assert getattr(MyClass, 'foo') == 'foo' obj = type_object_attrgetter(MyClass, 'foo') assert isinstance(obj, property) assert obj.__doc__ == 'Docstring for MyClass.foo property.' with pytest.raises(AttributeError): type_object_attrgetter(MyClass, 'susy') assert type_object_attrgetter(MyClass, 'susy', 'default') == 'default' assert type_object_attrgetter(MyClass, '__dict__') == MyClass.__dict__ photutils-0.2.1/astropy_helpers/astropy_helpers/sphinx/ext/tests/test_automodapi.py0000600000214200020070000001613612477406127033435 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst import os import sys import pytest from . import * from ....utils import iteritems pytest.importorskip('sphinx') # skips these tests if sphinx not present class FakeConfig(object): """ Mocks up a sphinx configuration setting construct for automodapi tests """ def __init__(self, **kwargs): for k, v in iteritems(kwargs): setattr(self, k, v) class FakeApp(object): """ Mocks up a `sphinx.application.Application` object for automodapi tests """ # Some default config values _defaults = { 'automodapi_toctreedirnm': 'api', 'automodapi_writereprocessed': False } def __init__(self, **configs): config = self._defaults.copy() config.update(configs) self.config = FakeConfig(**config) self.info = [] self.warnings = [] def info(self, msg, loc): self.info.append((msg, loc)) def warn(self, msg, loc): self.warnings.append((msg, loc)) am_replacer_str = """ This comes before .. automodapi:: astropy_helpers.sphinx.ext.tests.test_automodapi {options} This comes after """ am_replacer_basic_expected = """ This comes before astropy_helpers.sphinx.ext.tests.test_automodapi Module ------------------------------------------------------- .. automodule:: astropy_helpers.sphinx.ext.tests.test_automodapi Functions ^^^^^^^^^ .. automodsumm:: astropy_helpers.sphinx.ext.tests.test_automodapi :functions-only: :toctree: api/ Classes ^^^^^^^ .. automodsumm:: astropy_helpers.sphinx.ext.tests.test_automodapi :classes-only: :toctree: api/ Class Inheritance Diagram ^^^^^^^^^^^^^^^^^^^^^^^^^ .. automod-diagram:: astropy_helpers.sphinx.ext.tests.test_automodapi :private-bases: :parts: 1 {empty} This comes after """.format(empty='') # the .format is necessary for editors that remove empty-line whitespace def test_am_replacer_basic(): """ Tests replacing an ".. automodapi::" with the automodapi no-option template """ from ..automodapi import automodapi_replace fakeapp = FakeApp() result = automodapi_replace(am_replacer_str.format(options=''), fakeapp) assert result == am_replacer_basic_expected am_replacer_noinh_expected = """ This comes before astropy_helpers.sphinx.ext.tests.test_automodapi Module ------------------------------------------------------- .. automodule:: astropy_helpers.sphinx.ext.tests.test_automodapi Functions ^^^^^^^^^ .. automodsumm:: astropy_helpers.sphinx.ext.tests.test_automodapi :functions-only: :toctree: api/ Classes ^^^^^^^ .. automodsumm:: astropy_helpers.sphinx.ext.tests.test_automodapi :classes-only: :toctree: api/ This comes after """.format(empty='') def test_am_replacer_noinh(): """ Tests replacing an ".. automodapi::" with no-inheritance-diagram option """ from ..automodapi import automodapi_replace fakeapp = FakeApp() ops = ['', ':no-inheritance-diagram:'] ostr = '\n '.join(ops) result = automodapi_replace(am_replacer_str.format(options=ostr), fakeapp) assert result == am_replacer_noinh_expected am_replacer_titleandhdrs_expected = """ This comes before astropy_helpers.sphinx.ext.tests.test_automodapi Module &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& .. automodule:: astropy_helpers.sphinx.ext.tests.test_automodapi Functions ********* .. automodsumm:: astropy_helpers.sphinx.ext.tests.test_automodapi :functions-only: :toctree: api/ Classes ******* .. automodsumm:: astropy_helpers.sphinx.ext.tests.test_automodapi :classes-only: :toctree: api/ Class Inheritance Diagram ************************* .. automod-diagram:: astropy_helpers.sphinx.ext.tests.test_automodapi :private-bases: :parts: 1 {empty} This comes after """.format(empty='') def test_am_replacer_titleandhdrs(): """ Tests replacing an ".. automodapi::" entry with title-setting and header character options. """ from ..automodapi import automodapi_replace fakeapp = FakeApp() ops = ['', ':title: A new title', ':headings: &*'] ostr = '\n '.join(ops) result = automodapi_replace(am_replacer_str.format(options=ostr), fakeapp) assert result == am_replacer_titleandhdrs_expected am_replacer_nomain_str = """ This comes before .. automodapi:: astropy_helpers.sphinx.ext.automodapi :no-main-docstr: This comes after """ am_replacer_nomain_expected = """ This comes before astropy_helpers.sphinx.ext.automodapi Module -------------------------------------------- Functions ^^^^^^^^^ .. automodsumm:: astropy_helpers.sphinx.ext.automodapi :functions-only: :toctree: api/ This comes after """.format(empty='') def test_am_replacer_nomain(): """ Tests replacing an ".. automodapi::" with "no-main-docstring" . """ from ..automodapi import automodapi_replace fakeapp = FakeApp() result = automodapi_replace(am_replacer_nomain_str, fakeapp) assert result == am_replacer_nomain_expected am_replacer_skip_str = """ This comes before .. automodapi:: astropy_helpers.sphinx.ext.automodapi :skip: something1 :skip: something2 This comes after """ am_replacer_skip_expected = """ This comes before astropy_helpers.sphinx.ext.automodapi Module -------------------------------------------- .. automodule:: astropy_helpers.sphinx.ext.automodapi Functions ^^^^^^^^^ .. automodsumm:: astropy_helpers.sphinx.ext.automodapi :functions-only: :toctree: api/ :skip: something1,something2 This comes after """.format(empty='') def test_am_replacer_skip(): """ Tests using the ":skip: option in an ".. automodapi::" . """ from ..automodapi import automodapi_replace fakeapp = FakeApp() result = automodapi_replace(am_replacer_skip_str, fakeapp) assert result == am_replacer_skip_expected am_replacer_invalidop_str = """ This comes before .. automodapi:: astropy_helpers.sphinx.ext.automodapi :invalid-option: This comes after """ def test_am_replacer_invalidop(): """ Tests that a sphinx warning is produced with an invalid option. """ from ..automodapi import automodapi_replace fakeapp = FakeApp() automodapi_replace(am_replacer_invalidop_str, fakeapp) expected_warnings = [('Found additional options invalid-option in ' 'automodapi.', None)] assert fakeapp.warnings == expected_warnings am_replacer_cython_str = """ This comes before .. automodapi:: _eva_.unit02 {options} This comes after """ am_replacer_cython_expected = """ This comes before _eva_.unit02 Module ------------------- .. automodule:: _eva_.unit02 Functions ^^^^^^^^^ .. automodsumm:: _eva_.unit02 :functions-only: :toctree: api/ This comes after """.format(empty='') def test_am_replacer_cython(cython_testpackage): """ Tests replacing an ".. automodapi::" for a Cython module. """ from ..automodapi import automodapi_replace fakeapp = FakeApp() result = automodapi_replace(am_replacer_cython_str.format(options=''), fakeapp) assert result == am_replacer_cython_expected photutils-0.2.1/astropy_helpers/astropy_helpers/sphinx/ext/tests/test_automodsumm.py0000600000214200020070000000456412605531164033640 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst import sys import pytest from . import * from ....utils import iteritems pytest.importorskip('sphinx') # skips these tests if sphinx not present class FakeEnv(object): """ Mocks up a sphinx env setting construct for automodapi tests """ def __init__(self, **kwargs): for k, v in iteritems(kwargs): setattr(self, k, v) class FakeBuilder(object): """ Mocks up a sphinx builder setting construct for automodapi tests """ def __init__(self, **kwargs): self.env = FakeEnv(**kwargs) class FakeApp(object): """ Mocks up a `sphinx.application.Application` object for automodapi tests """ def __init__(self, srcdir, automodapipresent=True): self.builder = FakeBuilder(srcdir=srcdir) self.info = [] self.warnings = [] self._extensions = [] if automodapipresent: self._extensions.append('astropy_helpers.sphinx.ext.automodapi') def info(self, msg, loc): self.info.append((msg, loc)) def warn(self, msg, loc): self.warnings.append((msg, loc)) ams_to_asmry_str = """ Before .. automodsumm:: astropy_helpers.sphinx.ext.automodsumm :p: And After """ ams_to_asmry_expected = """\ .. currentmodule:: astropy_helpers.sphinx.ext.automodsumm .. autosummary:: :p: Automoddiagram Automodsumm automodsumm_to_autosummary_lines generate_automodsumm_docs process_automodsumm_generation setup """ def test_ams_to_asmry(tmpdir): from ..automodsumm import automodsumm_to_autosummary_lines fi = tmpdir.join('automodsumm.rst') fi.write(ams_to_asmry_str) fakeapp = FakeApp(srcdir='') resultlines = automodsumm_to_autosummary_lines(str(fi), fakeapp) assert '\n'.join(resultlines) == ams_to_asmry_expected ams_cython_str = """ Before .. automodsumm:: _eva_.unit02 :functions-only: :p: And After """ ams_cython_expected = """\ .. currentmodule:: _eva_.unit02 .. autosummary:: :p: pilot """ def test_ams_cython(tmpdir, cython_testpackage): from ..automodsumm import automodsumm_to_autosummary_lines fi = tmpdir.join('automodsumm.rst') fi.write(ams_cython_str) fakeapp = FakeApp(srcdir='') resultlines = automodsumm_to_autosummary_lines(str(fi), fakeapp) assert '\n'.join(resultlines) == ams_cython_expected photutils-0.2.1/astropy_helpers/astropy_helpers/sphinx/ext/tests/test_docscrape.py0000600000214200020070000004327112346164025033227 0ustar lbradleySTSCI\science00000000000000# -*- encoding:utf-8 -*- from __future__ import division, absolute_import, print_function import sys, textwrap from ..docscrape import NumpyDocString, FunctionDoc, ClassDoc from ..docscrape_sphinx import SphinxDocString, SphinxClassDoc if sys.version_info[0] >= 3: sixu = lambda s: s else: sixu = lambda s: unicode(s, 'unicode_escape') doc_txt = '''\ numpy.multivariate_normal(mean, cov, shape=None, spam=None) Draw values from a multivariate normal distribution with specified mean and covariance. The multivariate normal or Gaussian distribution is a generalisation of the one-dimensional normal distribution to higher dimensions. Parameters ---------- mean : (N,) ndarray Mean of the N-dimensional distribution. .. math:: (1+2+3)/3 cov : (N, N) ndarray Covariance matrix of the distribution. shape : tuple of ints Given a shape of, for example, (m,n,k), m*n*k samples are generated, and packed in an m-by-n-by-k arrangement. Because each sample is N-dimensional, the output shape is (m,n,k,N). Returns ------- out : ndarray The drawn samples, arranged according to `shape`. If the shape given is (m,n,...), then the shape of `out` is is (m,n,...,N). In other words, each entry ``out[i,j,...,:]`` is an N-dimensional value drawn from the distribution. list of str This is not a real return value. It exists to test anonymous return values. Other Parameters ---------------- spam : parrot A parrot off its mortal coil. Raises ------ RuntimeError Some error Warns ----- RuntimeWarning Some warning Warnings -------- Certain warnings apply. Notes ----- Instead of specifying the full covariance matrix, popular approximations include: - Spherical covariance (`cov` is a multiple of the identity matrix) - Diagonal covariance (`cov` has non-negative elements only on the diagonal) This geometrical property can be seen in two dimensions by plotting generated data-points: >>> mean = [0,0] >>> cov = [[1,0],[0,100]] # diagonal covariance, points lie on x or y-axis >>> x,y = multivariate_normal(mean,cov,5000).T >>> plt.plot(x,y,'x'); plt.axis('equal'); plt.show() Note that the covariance matrix must be symmetric and non-negative definite. References ---------- .. [1] A. Papoulis, "Probability, Random Variables, and Stochastic Processes," 3rd ed., McGraw-Hill Companies, 1991 .. [2] R.O. Duda, P.E. Hart, and D.G. Stork, "Pattern Classification," 2nd ed., Wiley, 2001. See Also -------- some, other, funcs otherfunc : relationship Examples -------- >>> mean = (1,2) >>> cov = [[1,0],[1,0]] >>> x = multivariate_normal(mean,cov,(3,3)) >>> print x.shape (3, 3, 2) The following is probably true, given that 0.6 is roughly twice the standard deviation: >>> print list( (x[0,0,:] - mean) < 0.6 ) [True, True] .. index:: random :refguide: random;distributions, random;gauss ''' doc = NumpyDocString(doc_txt) def test_signature(): assert doc['Signature'].startswith('numpy.multivariate_normal(') assert doc['Signature'].endswith('spam=None)') def test_summary(): assert doc['Summary'][0].startswith('Draw values') assert doc['Summary'][-1].endswith('covariance.') def test_extended_summary(): assert doc['Extended Summary'][0].startswith('The multivariate normal') def test_parameters(): assert len(doc['Parameters']) == 3 assert [n for n,_,_ in doc['Parameters']] == ['mean','cov','shape'] arg, arg_type, desc = doc['Parameters'][1] assert arg_type == '(N, N) ndarray' assert desc[0].startswith('Covariance matrix') assert doc['Parameters'][0][-1][-2] == ' (1+2+3)/3' def test_other_parameters(): assert len(doc['Other Parameters']) == 1 assert [n for n,_,_ in doc['Other Parameters']] == ['spam'] arg, arg_type, desc = doc['Other Parameters'][0] assert arg_type == 'parrot' assert desc[0].startswith('A parrot off its mortal coil') def test_returns(): assert len(doc['Returns']) == 2 arg, arg_type, desc = doc['Returns'][0] assert arg == 'out' assert arg_type == 'ndarray' assert desc[0].startswith('The drawn samples') assert desc[-1].endswith('distribution.') arg, arg_type, desc = doc['Returns'][1] assert arg == 'list of str' assert arg_type == '' assert desc[0].startswith('This is not a real') assert desc[-1].endswith('anonymous return values.') def test_notes(): assert doc['Notes'][0].startswith('Instead') assert doc['Notes'][-1].endswith('definite.') assert len(doc['Notes']) == 17 def test_references(): assert doc['References'][0].startswith('..') assert doc['References'][-1].endswith('2001.') def test_examples(): assert doc['Examples'][0].startswith('>>>') assert doc['Examples'][-1].endswith('True]') def test_index(): assert doc['index']['default'] == 'random' assert len(doc['index']) == 2 assert len(doc['index']['refguide']) == 2 def non_blank_line_by_line_compare(a,b): a = textwrap.dedent(a) b = textwrap.dedent(b) a = [l.rstrip() for l in a.split('\n') if l.strip()] b = [l.rstrip() for l in b.split('\n') if l.strip()] for n,line in enumerate(a): if not line == b[n]: raise AssertionError("Lines %s of a and b differ: " "\n>>> %s\n<<< %s\n" % (n,line,b[n])) def test_str(): non_blank_line_by_line_compare(str(doc), """numpy.multivariate_normal(mean, cov, shape=None, spam=None) Draw values from a multivariate normal distribution with specified mean and covariance. The multivariate normal or Gaussian distribution is a generalisation of the one-dimensional normal distribution to higher dimensions. Parameters ---------- mean : (N,) ndarray Mean of the N-dimensional distribution. .. math:: (1+2+3)/3 cov : (N, N) ndarray Covariance matrix of the distribution. shape : tuple of ints Given a shape of, for example, (m,n,k), m*n*k samples are generated, and packed in an m-by-n-by-k arrangement. Because each sample is N-dimensional, the output shape is (m,n,k,N). Returns ------- out : ndarray The drawn samples, arranged according to `shape`. If the shape given is (m,n,...), then the shape of `out` is is (m,n,...,N). In other words, each entry ``out[i,j,...,:]`` is an N-dimensional value drawn from the distribution. list of str This is not a real return value. It exists to test anonymous return values. Other Parameters ---------------- spam : parrot A parrot off its mortal coil. Raises ------ RuntimeError Some error Warns ----- RuntimeWarning Some warning Warnings -------- Certain warnings apply. See Also -------- `some`_, `other`_, `funcs`_ `otherfunc`_ relationship Notes ----- Instead of specifying the full covariance matrix, popular approximations include: - Spherical covariance (`cov` is a multiple of the identity matrix) - Diagonal covariance (`cov` has non-negative elements only on the diagonal) This geometrical property can be seen in two dimensions by plotting generated data-points: >>> mean = [0,0] >>> cov = [[1,0],[0,100]] # diagonal covariance, points lie on x or y-axis >>> x,y = multivariate_normal(mean,cov,5000).T >>> plt.plot(x,y,'x'); plt.axis('equal'); plt.show() Note that the covariance matrix must be symmetric and non-negative definite. References ---------- .. [1] A. Papoulis, "Probability, Random Variables, and Stochastic Processes," 3rd ed., McGraw-Hill Companies, 1991 .. [2] R.O. Duda, P.E. Hart, and D.G. Stork, "Pattern Classification," 2nd ed., Wiley, 2001. Examples -------- >>> mean = (1,2) >>> cov = [[1,0],[1,0]] >>> x = multivariate_normal(mean,cov,(3,3)) >>> print x.shape (3, 3, 2) The following is probably true, given that 0.6 is roughly twice the standard deviation: >>> print list( (x[0,0,:] - mean) < 0.6 ) [True, True] .. index:: random :refguide: random;distributions, random;gauss""") def test_sphinx_str(): sphinx_doc = SphinxDocString(doc_txt) non_blank_line_by_line_compare(str(sphinx_doc), """ .. index:: random single: random;distributions, random;gauss Draw values from a multivariate normal distribution with specified mean and covariance. The multivariate normal or Gaussian distribution is a generalisation of the one-dimensional normal distribution to higher dimensions. :Parameters: **mean** : (N,) ndarray Mean of the N-dimensional distribution. .. math:: (1+2+3)/3 **cov** : (N, N) ndarray Covariance matrix of the distribution. **shape** : tuple of ints Given a shape of, for example, (m,n,k), m*n*k samples are generated, and packed in an m-by-n-by-k arrangement. Because each sample is N-dimensional, the output shape is (m,n,k,N). :Returns: **out** : ndarray The drawn samples, arranged according to `shape`. If the shape given is (m,n,...), then the shape of `out` is is (m,n,...,N). In other words, each entry ``out[i,j,...,:]`` is an N-dimensional value drawn from the distribution. list of str This is not a real return value. It exists to test anonymous return values. :Other Parameters: **spam** : parrot A parrot off its mortal coil. :Raises: **RuntimeError** Some error :Warns: **RuntimeWarning** Some warning .. warning:: Certain warnings apply. .. seealso:: :obj:`some`, :obj:`other`, :obj:`funcs` :obj:`otherfunc` relationship .. rubric:: Notes Instead of specifying the full covariance matrix, popular approximations include: - Spherical covariance (`cov` is a multiple of the identity matrix) - Diagonal covariance (`cov` has non-negative elements only on the diagonal) This geometrical property can be seen in two dimensions by plotting generated data-points: >>> mean = [0,0] >>> cov = [[1,0],[0,100]] # diagonal covariance, points lie on x or y-axis >>> x,y = multivariate_normal(mean,cov,5000).T >>> plt.plot(x,y,'x'); plt.axis('equal'); plt.show() Note that the covariance matrix must be symmetric and non-negative definite. .. rubric:: References .. [1] A. Papoulis, "Probability, Random Variables, and Stochastic Processes," 3rd ed., McGraw-Hill Companies, 1991 .. [2] R.O. Duda, P.E. Hart, and D.G. Stork, "Pattern Classification," 2nd ed., Wiley, 2001. .. only:: latex [1]_, [2]_ .. rubric:: Examples >>> mean = (1,2) >>> cov = [[1,0],[1,0]] >>> x = multivariate_normal(mean,cov,(3,3)) >>> print x.shape (3, 3, 2) The following is probably true, given that 0.6 is roughly twice the standard deviation: >>> print list( (x[0,0,:] - mean) < 0.6 ) [True, True] """) doc2 = NumpyDocString(""" Returns array of indices of the maximum values of along the given axis. Parameters ---------- a : {array_like} Array to look in. axis : {None, integer} If None, the index is into the flattened array, otherwise along the specified axis""") def test_parameters_without_extended_description(): assert len(doc2['Parameters']) == 2 doc3 = NumpyDocString(""" my_signature(*params, **kwds) Return this and that. """) def test_escape_stars(): signature = str(doc3).split('\n')[0] signature == 'my_signature(\*params, \*\*kwds)' doc4 = NumpyDocString( """a.conj() Return an array with all complex-valued elements conjugated.""") def test_empty_extended_summary(): assert doc4['Extended Summary'] == [] doc5 = NumpyDocString( """ a.something() Raises ------ LinAlgException If array is singular. Warns ----- SomeWarning If needed """) def test_raises(): assert len(doc5['Raises']) == 1 name,_,desc = doc5['Raises'][0] assert name == 'LinAlgException' assert desc == ['If array is singular.'] def test_warns(): assert len(doc5['Warns']) == 1 name,_,desc = doc5['Warns'][0] assert name == 'SomeWarning' assert desc == ['If needed'] def test_see_also(): doc6 = NumpyDocString( """ z(x,theta) See Also -------- func_a, func_b, func_c func_d : some equivalent func foo.func_e : some other func over multiple lines func_f, func_g, :meth:`func_h`, func_j, func_k :obj:`baz.obj_q` :class:`class_j`: fubar foobar """) assert len(doc6['See Also']) == 12 for func, desc, role in doc6['See Also']: if func in ('func_a', 'func_b', 'func_c', 'func_f', 'func_g', 'func_h', 'func_j', 'func_k', 'baz.obj_q'): assert(not desc) else: assert(desc) if func == 'func_h': assert role == 'meth' elif func == 'baz.obj_q': assert role == 'obj' elif func == 'class_j': assert role == 'class' else: assert role is None if func == 'func_d': assert desc == ['some equivalent func'] elif func == 'foo.func_e': assert desc == ['some other func over', 'multiple lines'] elif func == 'class_j': assert desc == ['fubar', 'foobar'] def test_see_also_print(): class Dummy(object): """ See Also -------- func_a, func_b func_c : some relationship goes here func_d """ pass obj = Dummy() s = str(FunctionDoc(obj, role='func')) assert(':func:`func_a`, :func:`func_b`' in s) assert(' some relationship' in s) assert(':func:`func_d`' in s) doc7 = NumpyDocString(""" Doc starts on second line. """) def test_empty_first_line(): assert doc7['Summary'][0].startswith('Doc starts') def test_no_summary(): str(SphinxDocString(""" Parameters ----------""")) def test_unicode(): doc = SphinxDocString(""" öäöäöäöäöåååå öäöäöäööäååå Parameters ---------- ååå : äää ööö Returns ------- ååå : ööö äää """) assert isinstance(doc['Summary'][0], str) assert doc['Summary'][0] == 'öäöäöäöäöåååå' def test_plot_examples(): cfg = dict(use_plots=True) doc = SphinxDocString(""" Examples -------- >>> import matplotlib.pyplot as plt >>> plt.plot([1,2,3],[4,5,6]) >>> plt.show() """, config=cfg) assert 'plot::' in str(doc), str(doc) doc = SphinxDocString(""" Examples -------- .. plot:: import matplotlib.pyplot as plt plt.plot([1,2,3],[4,5,6]) plt.show() """, config=cfg) assert str(doc).count('plot::') == 1, str(doc) def test_class_members(): class Dummy(object): """ Dummy class. """ def spam(self, a, b): """Spam\n\nSpam spam.""" pass def ham(self, c, d): """Cheese\n\nNo cheese.""" pass @property def spammity(self): """Spammity index""" return 0.95 class Ignorable(object): """local class, to be ignored""" pass for cls in (ClassDoc, SphinxClassDoc): doc = cls(Dummy, config=dict(show_class_members=False)) assert 'Methods' not in str(doc), (cls, str(doc)) assert 'spam' not in str(doc), (cls, str(doc)) assert 'ham' not in str(doc), (cls, str(doc)) assert 'spammity' not in str(doc), (cls, str(doc)) assert 'Spammity index' not in str(doc), (cls, str(doc)) doc = cls(Dummy, config=dict(show_class_members=True)) assert 'Methods' in str(doc), (cls, str(doc)) assert 'spam' in str(doc), (cls, str(doc)) assert 'ham' in str(doc), (cls, str(doc)) assert 'spammity' in str(doc), (cls, str(doc)) if cls is SphinxClassDoc: assert '.. autosummary::' in str(doc), str(doc) else: assert 'Spammity index' in str(doc), str(doc) def test_duplicate_signature(): # Duplicate function signatures occur e.g. in ufuncs, when the # automatic mechanism adds one, and a more detailed comes from the # docstring itself. doc = NumpyDocString( """ z(x1, x2) z(a, theta) """) assert doc['Signature'].strip() == 'z(a, theta)' class_doc_txt = """ Foo Parameters ---------- f : callable ``f(t, y, *f_args)`` Aaa. jac : callable ``jac(t, y, *jac_args)`` Bbb. Attributes ---------- t : float Current time. y : ndarray Current variable values. Methods ------- a b c Examples -------- For usage examples, see `ode`. """ def test_class_members_doc(): doc = ClassDoc(None, class_doc_txt) non_blank_line_by_line_compare(str(doc), """ Foo Parameters ---------- f : callable ``f(t, y, *f_args)`` Aaa. jac : callable ``jac(t, y, *jac_args)`` Bbb. Examples -------- For usage examples, see `ode`. Attributes ---------- t : float Current time. y : ndarray Current variable values. Methods ------- a b c .. index:: """) def test_class_members_doc_sphinx(): doc = SphinxClassDoc(None, class_doc_txt) non_blank_line_by_line_compare(str(doc), """ Foo :Parameters: **f** : callable ``f(t, y, *f_args)`` Aaa. **jac** : callable ``jac(t, y, *jac_args)`` Bbb. .. rubric:: Examples For usage examples, see `ode`. .. rubric:: Attributes === ========== t (float) Current time. y (ndarray) Current variable values. === ========== .. rubric:: Methods === ========== a b c === ========== """) photutils-0.2.1/astropy_helpers/astropy_helpers/sphinx/ext/tests/test_utils.py0000600000214200020070000000174312355051562032423 0ustar lbradleySTSCI\science00000000000000#namedtuple is needed for find_mod_objs so it can have a non-local module import sys from collections import namedtuple import pytest from ..utils import find_mod_objs PY3 = sys.version_info[0] >= 3 pytestmark = pytest.mark.skipif("PY3") def test_find_mod_objs(): lnms, fqns, objs = find_mod_objs('astropy_helpers') # this import is after the above call intentionally to make sure # find_mod_objs properly imports astropy on its own import astropy_helpers # just check for astropy.test ... other things might be added, so we # shouldn't check that it's the only thing assert lnms == [] lnms, fqns, objs = find_mod_objs( 'astropy_helpers.sphinx.ext.tests.test_utils', onlylocals=False) assert namedtuple in objs lnms, fqns, objs = find_mod_objs( 'astropy_helpers.sphinx.ext.tests.test_utils', onlylocals=True) assert 'namedtuple' not in lnms assert 'collections.namedtuple' not in fqns assert namedtuple not in objs photutils-0.2.1/astropy_helpers/astropy_helpers/sphinx/ext/tocdepthfix.py0000600000214200020070000000124512346164025031377 0ustar lbradleySTSCI\science00000000000000from sphinx import addnodes def fix_toc_entries(app, doctree): # Get the docname; I don't know why this isn't just passed in to the # callback # This seems a bit unreliable as it's undocumented, but it's not "private" # either: docname = app.builder.env.temp_data['docname'] if app.builder.env.metadata[docname].get('tocdepth', 0) != 0: # We need to reprocess any TOC nodes in the doctree and make sure all # the files listed in any TOCs are noted for treenode in doctree.traverse(addnodes.toctree): app.builder.env.note_toctree(docname, treenode) def setup(app): app.connect('doctree-read', fix_toc_entries) photutils-0.2.1/astropy_helpers/astropy_helpers/sphinx/ext/traitsdoc.py0000600000214200020070000001026112346164025031050 0ustar lbradleySTSCI\science00000000000000""" ========= traitsdoc ========= Sphinx extension that handles docstrings in the Numpy standard format, [1] and support Traits [2]. This extension can be used as a replacement for ``numpydoc`` when support for Traits is required. .. [1] http://projects.scipy.org/numpy/wiki/CodingStyleGuidelines#docstring-standard .. [2] http://code.enthought.com/projects/traits/ """ from __future__ import division, absolute_import, print_function import inspect import os import pydoc import collections from . import docscrape from . import docscrape_sphinx from .docscrape_sphinx import SphinxClassDoc, SphinxFunctionDoc, SphinxDocString from . import numpydoc from . import comment_eater class SphinxTraitsDoc(SphinxClassDoc): def __init__(self, cls, modulename='', func_doc=SphinxFunctionDoc): if not inspect.isclass(cls): raise ValueError("Initialise using a class. Got %r" % cls) self._cls = cls if modulename and not modulename.endswith('.'): modulename += '.' self._mod = modulename self._name = cls.__name__ self._func_doc = func_doc docstring = pydoc.getdoc(cls) docstring = docstring.split('\n') # De-indent paragraph try: indent = min(len(s) - len(s.lstrip()) for s in docstring if s.strip()) except ValueError: indent = 0 for n,line in enumerate(docstring): docstring[n] = docstring[n][indent:] self._doc = docscrape.Reader(docstring) self._parsed_data = { 'Signature': '', 'Summary': '', 'Description': [], 'Extended Summary': [], 'Parameters': [], 'Returns': [], 'Raises': [], 'Warns': [], 'Other Parameters': [], 'Traits': [], 'Methods': [], 'See Also': [], 'Notes': [], 'References': '', 'Example': '', 'Examples': '', 'index': {} } self._parse() def _str_summary(self): return self['Summary'] + [''] def _str_extended_summary(self): return self['Description'] + self['Extended Summary'] + [''] def __str__(self, indent=0, func_role="func"): out = [] out += self._str_signature() out += self._str_index() + [''] out += self._str_summary() out += self._str_extended_summary() for param_list in ('Parameters', 'Traits', 'Methods', 'Returns','Raises'): out += self._str_param_list(param_list) out += self._str_see_also("obj") out += self._str_section('Notes') out += self._str_references() out += self._str_section('Example') out += self._str_section('Examples') out = self._str_indent(out,indent) return '\n'.join(out) def looks_like_issubclass(obj, classname): """ Return True if the object has a class or superclass with the given class name. Ignores old-style classes. """ t = obj if t.__name__ == classname: return True for klass in t.__mro__: if klass.__name__ == classname: return True return False def get_doc_object(obj, what=None, config=None): if what is None: if inspect.isclass(obj): what = 'class' elif inspect.ismodule(obj): what = 'module' elif isinstance(obj, collections.Callable): what = 'function' else: what = 'object' if what == 'class': doc = SphinxTraitsDoc(obj, '', func_doc=SphinxFunctionDoc, config=config) if looks_like_issubclass(obj, 'HasTraits'): for name, trait, comment in comment_eater.get_class_traits(obj): # Exclude private traits. if not name.startswith('_'): doc['Traits'].append((name, trait, comment.splitlines())) return doc elif what in ('function', 'method'): return SphinxFunctionDoc(obj, '', config=config) else: return SphinxDocString(pydoc.getdoc(obj), config=config) def setup(app): # init numpydoc numpydoc.setup(app, get_doc_object) photutils-0.2.1/astropy_helpers/astropy_helpers/sphinx/ext/utils.py0000600000214200020070000000443312346164025030220 0ustar lbradleySTSCI\science00000000000000import inspect import sys def find_mod_objs(modname, onlylocals=False): """ Returns all the public attributes of a module referenced by name. .. note:: The returned list *not* include subpackages or modules of `modname`,nor does it include private attributes (those that beginwith '_' or are not in `__all__`). Parameters ---------- modname : str The name of the module to search. onlylocals : bool If True, only attributes that are either members of `modname` OR one of its modules or subpackages will be included. Returns ------- localnames : list of str A list of the names of the attributes as they are named in the module `modname` . fqnames : list of str A list of the full qualified names of the attributes (e.g., ``astropy.utils.misc.find_mod_objs``). For attributes that are simple variables, this is based on the local name, but for functions or classes it can be different if they are actually defined elsewhere and just referenced in `modname`. objs : list of objects A list of the actual attributes themselves (in the same order as the other arguments) """ __import__(modname) mod = sys.modules[modname] if hasattr(mod, '__all__'): pkgitems = [(k, mod.__dict__[k]) for k in mod.__all__] else: pkgitems = [(k, mod.__dict__[k]) for k in dir(mod) if k[0] != '_'] # filter out modules and pull the names and objs out ismodule = inspect.ismodule localnames = [k for k, v in pkgitems if not ismodule(v)] objs = [v for k, v in pkgitems if not ismodule(v)] # fully qualified names can be determined from the object's module fqnames = [] for obj, lnm in zip(objs, localnames): if hasattr(obj, '__module__') and hasattr(obj, '__name__'): fqnames.append(obj.__module__ + '.' + obj.__name__) else: fqnames.append(modname + '.' + lnm) if onlylocals: valids = [fqn.startswith(modname) for fqn in fqnames] localnames = [e for i, e in enumerate(localnames) if valids[i]] fqnames = [e for i, e in enumerate(fqnames) if valids[i]] objs = [e for i, e in enumerate(objs) if valids[i]] return localnames, fqnames, objs photutils-0.2.1/astropy_helpers/astropy_helpers/sphinx/ext/viewcode.py0000600000214200020070000001752512605531164030673 0ustar lbradleySTSCI\science00000000000000# -*- coding: utf-8 -*- """ sphinx.ext.viewcode ~~~~~~~~~~~~~~~~~~~ Add links to module code in Python object descriptions. :copyright: Copyright 2007-2011 by the Sphinx team, see AUTHORS. :license: BSD, see LICENSE for details. Patched using patch in https://bitbucket.org/birkenfeld/sphinx/issue/623/extension-viewcode-fails-with-function on 21 Aug 2013 by Kyle H Barbary """ from docutils import nodes from sphinx import addnodes from sphinx.locale import _ from sphinx.pycode import ModuleAnalyzer from sphinx.util.inspect import safe_getattr from sphinx.util.nodes import make_refnode import sys import traceback if sys.version < '3': text_type = unicode else: text_type = str from ...utils import iteritems def doctree_read(app, doctree): env = app.builder.env if not hasattr(env, '_viewcode_modules'): env._viewcode_modules = {} def get_full_modname(modname, attribute): try: __import__(modname) except Exception as error: if not app.quiet: app.info(traceback.format_exc().rstrip()) app.warn('viewcode can\'t import %s, failed with error "%s"' % (modname, error)) return None module = sys.modules[modname] try: # Allow an attribute to have multiple parts and incidentally allow # repeated .s in the attribute. attr = attribute.split('.') value = module for attr in attribute.split('.'): if attr: value = safe_getattr(value, attr) except AttributeError: app.warn('Didn\'t find %s in %s' % (attribute, module.__name__)) return None else: return safe_getattr(value, '__module__', None) def has_tag(modname, fullname, docname, refname): entry = env._viewcode_modules.get(modname, None) if entry is None: try: analyzer = ModuleAnalyzer.for_module(modname) except Exception: env._viewcode_modules[modname] = False return analyzer.find_tags() if not isinstance(analyzer.code, text_type): code = analyzer.code.decode(analyzer.encoding) else: code = analyzer.code entry = code, analyzer.tags, {}, refname env._viewcode_modules[modname] = entry elif entry is False: return _, tags, used, _ = entry if fullname in tags: used[fullname] = docname return True for objnode in doctree.traverse(addnodes.desc): if objnode.get('domain') != 'py': continue names = set() for signode in objnode: if not isinstance(signode, addnodes.desc_signature): continue modname = signode.get('module') fullname = signode.get('fullname') refname = modname if env.config.viewcode_import: modname = get_full_modname(modname, fullname) if not modname: continue if not has_tag(modname, fullname, env.docname, refname): continue if fullname in names: # only one link per name, please continue names.add(fullname) pagename = '_modules/' + modname.replace('.', '/') onlynode = addnodes.only(expr='html') onlynode += addnodes.pending_xref( '', reftype='viewcode', refdomain='std', refexplicit=False, reftarget=pagename, refid=fullname, refdoc=env.docname) onlynode[0] += nodes.inline('', _('[source]'), classes=['viewcode-link']) signode += onlynode def missing_reference(app, env, node, contnode): # resolve our "viewcode" reference nodes -- they need special treatment if node['reftype'] == 'viewcode': return make_refnode(app.builder, node['refdoc'], node['reftarget'], node['refid'], contnode) def collect_pages(app): env = app.builder.env if not hasattr(env, '_viewcode_modules'): return highlighter = app.builder.highlighter urito = app.builder.get_relative_uri modnames = set(env._viewcode_modules) app.builder.info(' (%d module code pages)' % len(env._viewcode_modules), nonl=1) for modname, entry in iteritems(env._viewcode_modules): if not entry: continue code, tags, used, refname = entry # construct a page name for the highlighted source pagename = '_modules/' + modname.replace('.', '/') # highlight the source using the builder's highlighter highlighted = highlighter.highlight_block(code, 'python', linenos=False) # split the code into lines lines = highlighted.splitlines() # split off wrap markup from the first line of the actual code before, after = lines[0].split('
')
        lines[0:1] = [before + '
', after]
        # nothing to do for the last line; it always starts with 
anyway # now that we have code lines (starting at index 1), insert anchors for # the collected tags (HACK: this only works if the tag boundaries are # properly nested!) maxindex = len(lines) - 1 for name, docname in iteritems(used): type, start, end = tags[name] backlink = urito(pagename, docname) + '#' + refname + '.' + name lines[start] = ( '
%s' % (name, backlink, _('[docs]')) + lines[start]) lines[min(end - 1, maxindex)] += '
' # try to find parents (for submodules) parents = [] parent = modname while '.' in parent: parent = parent.rsplit('.', 1)[0] if parent in modnames: parents.append({ 'link': urito(pagename, '_modules/' + parent.replace('.', '/')), 'title': parent}) parents.append({'link': urito(pagename, '_modules/index'), 'title': _('Module code')}) parents.reverse() # putting it all together context = { 'parents': parents, 'title': modname, 'body': _('

Source code for %s

') % modname + \ '\n'.join(lines) } yield (pagename, context, 'page.html') if not modnames: return app.builder.info(' _modules/index') html = ['\n'] # the stack logic is needed for using nested lists for submodules stack = [''] for modname in sorted(modnames): if modname.startswith(stack[-1]): stack.append(modname + '.') html.append('
    ') else: stack.pop() while not modname.startswith(stack[-1]): stack.pop() html.append('
') stack.append(modname + '.') html.append('
  • %s
  • \n' % ( urito('_modules/index', '_modules/' + modname.replace('.', '/')), modname)) html.append('' * (len(stack) - 1)) context = { 'title': _('Overview: module code'), 'body': _('

    All modules for which code is available

    ') + \ ''.join(html), } yield ('_modules/index', context, 'page.html') def setup(app): app.add_config_value('viewcode_import', True, False) app.connect('doctree-read', doctree_read) app.connect('html-collect-pages', collect_pages) app.connect('missing-reference', missing_reference) #app.add_config_value('viewcode_include_modules', [], 'env') #app.add_config_value('viewcode_exclude_modules', [], 'env') photutils-0.2.1/astropy_helpers/astropy_helpers/sphinx/local/0000700000214200020070000000000012646264032026774 5ustar lbradleySTSCI\science00000000000000photutils-0.2.1/astropy_helpers/astropy_helpers/sphinx/local/python3links.inv0000600000214200020070000000074312477406127032172 0ustar lbradleySTSCI\science00000000000000# Sphinx inventory version 2 # Project: Python # Version: 3.4 # The remainder of this file is compressed using zlib. xœ¥“OSƒ0Åïù;Ó‹ÀñÏ©÷z®¶SωÜl:à§7@­i‡:¨²ï÷–äm°i*eZPf†-u°Grʸ X“}CÉKXw\YVvcu ÷éCøÜV„u¦L¶®”ƒRiWY¯ Ȥ­Bç°ï”y…­òT䣃¦[–ÞHî[&·*”QwóµæÒŠk½µ‰Øª­ç‘¥ÅVbsÎ𠔈Ü+Í*mÞo®·‘:sî‡öeÄjåf‘ƒ.â¸kp7è"nÐ×R(æà±ïÉœPpÑe²Ã¶"ÌŠµµzÕ¢ô<ðŸnމ{õ˜>õÏIÿ±>XÆÒD4¤ _]ÏLvPêSÊÐphotutils-0.2.1/astropy_helpers/astropy_helpers/sphinx/local/python3links.txt0000600000214200020070000000233612477406127032215 0ustar lbradleySTSCI\science00000000000000# Sphinx inventory version 2 # Project: Python # Version: 3.4 # The remainder of this file should be compressed using zlib. bytes py:function -1 library/functions.html#bytes - TimeoutError py:exception -1 library/exceptions.html#TimeoutError - builtins.object py:class -1 library/functions.html#object - builtins.list py:class -1 library/functions.html#list - builtins.type py:class -1 library/functions.html#type - builtins.classmethod py:class -1 library/functions.html#classmethod - builtins.SyntaxWarning py:exception -1 library/exceptions.html#SyntaxWarning - builtins.RuntimeWarning py:exception -1 library/exceptions.html#RuntimeWarning - builtins.ValueError py:exception -1 library/exceptions.html#ValueError - object py:function -1 library/functions.html#object - object py:class -1 library/functions.html#object - urllib.request.urlopen py:function -1 library/urllib.request.html#urllib.request.urlopen - concurrent.futures.Future py:class -1 library/concurrent.futures.html#concurrent.futures.Future - concurrent.futures.ThreadPoolExecutor py:class -1 library/concurrent.futures.html#concurrent.futures.ThreadPoolExecutor - queue.Queue py:class -1 library/queue.html#queue.Queue - print() py:function -1 library/functions.html#print - photutils-0.2.1/astropy_helpers/astropy_helpers/sphinx/setup_package.py0000600000214200020070000000050412346164025031066 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst def get_package_data(): # Install the theme files return { 'astropy_helpers.sphinx': [ 'ext/templates/*/*', 'local/*.inv', 'themes/bootstrap-astropy/*.*', 'themes/bootstrap-astropy/static/*.*']} photutils-0.2.1/astropy_helpers/astropy_helpers/sphinx/themes/0000700000214200020070000000000012646264032027167 5ustar lbradleySTSCI\science00000000000000photutils-0.2.1/astropy_helpers/astropy_helpers/sphinx/themes/bootstrap-astropy/0000700000214200020070000000000012646264032032703 5ustar lbradleySTSCI\science00000000000000photutils-0.2.1/astropy_helpers/astropy_helpers/sphinx/themes/bootstrap-astropy/globaltoc.html0000600000214200020070000000011112346164025035530 0ustar lbradleySTSCI\science00000000000000

    Table of Contents

    {{ toctree(maxdepth=-1, titles_only=true) }} photutils-0.2.1/astropy_helpers/astropy_helpers/sphinx/themes/bootstrap-astropy/layout.html0000600000214200020070000000655112605531164035115 0ustar lbradleySTSCI\science00000000000000{% extends "basic/layout.html" %} {# Collapsible sidebar script from default/layout.html in Sphinx #} {% set script_files = script_files + ['_static/sidebar.js'] %} {# Add the google webfonts needed for the logo #} {% block extrahead %} {% if not embedded %}{% endif %} {% endblock %} {% block header %}
    {{ theme_logotext1 }}{{ theme_logotext2 }}{{ theme_logotext3 }}
    • Index
    • Modules
    • {% block sidebarsearch %} {% include "searchbox.html" %} {% endblock %}
    {% endblock %} {% block relbar1 %} {% endblock %} {# Silence the bottom relbar. #} {% block relbar2 %}{% endblock %} {%- block footer %}

    {%- if edit_on_github %} {{ edit_on_github_page_message }}   {%- endif %} {%- if show_source and has_source and sourcename %} {{ _('Page Source') }} {%- endif %}   Back to Top

    {%- if show_copyright %} {%- if hasdoc('copyright') %} {% trans path=pathto('copyright'), copyright=copyright|e %}© Copyright {{ copyright }}.{% endtrans %}
    {%- else %} {% trans copyright=copyright|e %}© Copyright {{ copyright }}.{% endtrans %}
    {%- endif %} {%- endif %} {%- if show_sphinx %} {% trans sphinx_version=sphinx_version|e %}Created using Sphinx {{ sphinx_version }}.{% endtrans %}   {%- endif %} {%- if last_updated %} {% trans last_updated=last_updated|e %}Last built {{ last_updated }}.{% endtrans %}
    {%- endif %}

    {%- endblock %} photutils-0.2.1/astropy_helpers/astropy_helpers/sphinx/themes/bootstrap-astropy/localtoc.html0000600000214200020070000000004212346164025035365 0ustar lbradleySTSCI\science00000000000000

    Page Contents

    {{ toc }} photutils-0.2.1/astropy_helpers/astropy_helpers/sphinx/themes/bootstrap-astropy/searchbox.html0000600000214200020070000000042012346164025035543 0ustar lbradleySTSCI\science00000000000000{%- if pagename != "search" %}
    {%- endif %} photutils-0.2.1/astropy_helpers/astropy_helpers/sphinx/themes/bootstrap-astropy/static/0000700000214200020070000000000012646264032034172 5ustar lbradleySTSCI\science00000000000000././@LongLink0000000000000000000000000000015300000000000011214 Lustar 00000000000000photutils-0.2.1/astropy_helpers/astropy_helpers/sphinx/themes/bootstrap-astropy/static/astropy_linkout.svgphotutils-0.2.1/astropy_helpers/astropy_helpers/sphinx/themes/bootstrap-astropy/static/astropy_linko0000600000214200020070000001212112605531164037007 0ustar lbradleySTSCI\science00000000000000 ././@LongLink0000000000000000000000000000015600000000000011217 Lustar 00000000000000photutils-0.2.1/astropy_helpers/astropy_helpers/sphinx/themes/bootstrap-astropy/static/astropy_linkout_20.pngphotutils-0.2.1/astropy_helpers/astropy_helpers/sphinx/themes/bootstrap-astropy/static/astropy_linko0000600000214200020070000000327512346164025037021 0ustar lbradleySTSCI\science00000000000000‰PNG  IHDR[â8A bKGDÿÿÿ ½§“ oFFsvek pHYs × ×B(›x vpAg\@0¢Ð¬IDATXÃå˜iŒ_SÆϘÚ+Új‹fF« BH‘XbOÐέ†ª}‰-Z¤Abû¢$¤Öi…V#¸T•ZCÕ– µIi™ÚU”d¦ª÷ý›;·÷?™)Ó*OrsïyÏsÏûžçžóžs®è!ج’ôLOùÙ`[À–=é`œ3|¼±;»1`{ÛͶﱽÔv]mú«ßØÞX°=˜l¦y’Zjs„á@30ŒlÈ<,éÝ’ÆöÆ @+ð60SÒ϶ûÇG½í‰ñü¡¤mo œ¬‘t—íþÀ%À `¶¤4üÔ pÐX<,’Ô1¦„:`•R~qÂPà` ð.°0kœÐ¨WJéŒs¶@R>)é÷ÎÀ´Ntž$éS`6p6pTØím¢5…—ÿÆHš“s8˜Éã{à@`»¿ ÷J:×v=ð%``/à9`çàœ/iší~À\`ÿbŸ{ƒçœH7KBäÝ€§"Æ“o€f¥´:¡/°hRÊʱ' J™\"ö`ànàÜ*ý[!©ÍöåÀ”ˆÿ `'I­ØÆö¶µ}Ÿí ¶o´Ý9÷#Ûg›Ùþ6ì l²}’í—m¿h[¶›lO·ýeð~ŽòtÛgE;õnÇÛkmϳ=Ëö^ÑÎKQ¿&âš~*¸² Ò NøÑ §ìµNxÊ ×æl30¡L-'ÌwÂ~¥uö ÛOÒ lOŒ˜Ïm)†ÙÞ©`»"×±ÁakÈÙšs\"5äߟ[m,ˆÝfû˜Bý±¹ú 9{ígÃþ[Œþ¼Ø“ªØà„'(Ê8á}'ëðú;aqÑ^{N•:l_q-ãÔHZ"éëx©.„Ü5ÇkŠû×ÀOñ|[ì86—„¤_Y?Ü-éé‚í¸¸ÿB6m‰8×wDqkÚ×… ÚÊ(eY´5$ʯwdz"ðD%¿—iZMh²´1/éѪbÛîmûZÛŸ‘åÒ¸0Çë] ŒV’-Ž_Ù¾9öÕ냲…ª1îK%­)Ôå®AÝðÓBûº08­À9•lî *±íN¶à'’ž M/ÎØÛÛo×;·GcJ=IÏÛ€€þÀeÀ›¶û®§àÕ:T6’܆ò}ÖæÊ³€£œP à„F 7°¸“6J}Kú h,ÌÐa¡S‡ÎŒŠV`¤¤‹%½üXU é[I—»WEÀÿˆÔ°<îM¶‹;¤Á¹çeÝh³1ÏWÊjà% 2úF3;I!±ËF6’Z ¦âÇ¥†ÈcÀrIKªtªÝ›=¢"€¤VIS€rªà·¸°½Y7Å®ï·ÎÈù8/ŠmÀü®4æ„}Õdg‡<¦çÄóhàÁ.4§.p*Úv»ø*žw·}=YJ9ÖÝÙ¼,²=øì”…9ú;À @_`†í¹ÀÊ.þ'IÉöê#{lï |Hv868·Hú¦ðÞÞNRòûï-ÈRãÍ%£öM Þ ûµJÿšQÕÐVCvNé öŒ¶¸&ìk"À“ÉrrÉv$Ä•Ç:ŽŒidi¥8%®WiµU!i­íÑÀcáçÒ\õÀý¹XóÌsÂL²…w7`2°¸o?)8áNàqàÖ.ŠØd{rxS˜yÙ¾ÓÞ¸˜,¡¯î—ôží1À²³ýòàöŽúß‘”æåOtÁ\ V $MSë©A{UÒGeÑFºj&;öö#›IIZg‹dK| ó€=ÉÆJYTM'lE¶»¤”–ÎÔ‹³Äé]ü(¯Hú üMq¨¹h=ÞÛÏ ¯lˆkþ~›<&wmGÿk±pYº™½!üõäÿì%âÿÈ#ÀædëÀX¥·h=…ÿ’ØSß»À3p5™Ø‹óÛĞƟ ½§pÅ%tEXtdate:create2012-10-18T20:57:33+02:00¢p_f%tEXtdate:modify2012-10-18T20:57:33+02:00Ó-çÚtEXtSoftwarewww.inkscape.org›î<IEND®B`‚././@LongLink0000000000000000000000000000015000000000000011211 Lustar 00000000000000photutils-0.2.1/astropy_helpers/astropy_helpers/sphinx/themes/bootstrap-astropy/static/astropy_logo.icophotutils-0.2.1/astropy_helpers/astropy_helpers/sphinx/themes/bootstrap-astropy/static/astropy_logo.0000600000214200020070000010033412605531164036715 0ustar lbradleySTSCI\science00000000000000@@ (@F  (n@ ( –P (¾Y(@€ ÿÿ ÿ* ÿVýy ý›¬±ûÕúûüí÷ùüìýýýíýýýí§ªû× ü«ý‹ýoüKÿ ÿ ÿÿîûHýýÌúìýó ûøûü°µÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ˜Ÿÿÿûþ ûúûöýòúéûÇýÿIóÿ¿ÿ!ýyûÏüðüúÿÿÿÿÿÿ ÿÿ>KÿÿÏÓÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ‡ÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿûúÿðûÚü—û?ã ÿÿý|ûÚýöÿÿÿÿÿÿþÿýÿýÿLYþÿÌÏÿÿûüÿÿÿÿÿÿÿÿÿÿÿÿÿÿþþÿÿerþÿýÿýÿýÿýÿýÿþÿÿÿÿÿÿÿüûûíú½ÿZÿÿüJûÇýöÿÿÿÿþÿýÿýÿýÿ*<þÿ™¡ÿÿêíÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÉÎÿÿ3Eýÿ ýÿýÿýÿýÿýÿýÿýÿýÿþÿÿÿÿÿÿÿÿðûÄüXÿÿü•üêÿÿÿÿþÿýÿýÿýÿ1ýÿ“þÿäèÿÿûûÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿrþÿýÿýÿýÿýÿýÿýÿýÿýÿýÿýÿýÿýÿÿÿÿÿÿÿüïù´ÿ=ÿø$û®ýúÿÿÿÿýÿýÿýÿýÿ.Cþÿ·¿ÿÿùúÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ”Ÿþÿ*ýÿýÿýÿýÿýÿýÿýÿýÿýÿýÿýÿýÿýÿýÿýÿÿÿÿÿÿÿúâû†ÿÿ3üÃüþÿÿýÿýÿýÿýÿýÿ^pþÿÓÙÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ÷øÿÿ…“þÿ+ýÿýÿýÿýÿýÿýÿýÿýÿýÿýÿýÿýÿýÿýÿýÿýÿýÿýÿÿÿÿÿýöü¸ÿ7 ÿ(øÃ!ÿÿ ÿÿ ýÿ ýÿ ýÿýÿýÿsƒþÿåéÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÅÍþÿPfýÿ %ýÿýÿýÿ ýÿ ýÿ ýÿ ýÿýÿýÿýÿýÿýÿýÿýÿýÿýÿýÿýÿýÿýÿþÿÿÿ ÿÿûÙ ÿi#ÿ úº#ÿÿ"ÿÿ"ýÿ"ýÿ"ýÿ ýÿ ýÿy‹ÿÿîðÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿâåþÿu‡ýÿ =ýÿýÿýÿ!ýÿ"ýÿ"ýÿ"ýÿ"ýÿ"ýÿ"ýÿ"ýÿ"ýÿ"ýÿ"ýÿ"ýÿ"ýÿ"ýÿ"ýÿ"ýÿ"ýÿ"ýÿ"ýÿ"ýÿ!ýÿ!ÿÿ!ÿÿ ûìýƒÿÿ$ý›$ýÿ$ÿÿ$ýÿ$ýÿ$ýÿ"ýÿýÿmþÿëîÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿýýÿÿ¦²þÿ8Týÿ%ýÿýÿ!ýÿ$ýÿ$ýÿ$ýÿ$ýÿ$ýÿ#ýÿ#ýÿ#ýÿ"ýÿ"ýÿ"ýÿ"ýÿ#ýÿ#ýÿ#ýÿ$ýÿ$ýÿ$ýÿ$ýÿ$ýÿ$ýÿ#ýÿ#ýÿ$þÿ$ÿÿ#üõ!ü’'ÿ &ÿj'ûñ(ÿÿ&ýÿ&ýÿ&ýÿ&ýÿ!ýÿNiþÿÞãÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿçëþÿmƒýÿ5ýÿ ýÿ ýÿ%ýÿ&ýÿ&ýÿ&ýÿ%ýÿ%ýÿ$ýÿ#ýÿ#ýÿ"ýÿ"ýÿ"ýÿ"ýÿ"ýÿ"ýÿ#ýÿ#ýÿ$ýÿ$ýÿ%ýÿ&ýÿ&ýÿ&ýÿ&ýÿ&ýÿ&ýÿ&þÿ&ÿÿ%ýø&üš3ÿ)ÿ%(ûØ*ÿÿ)ýÿ)ýÿ)ýÿ(ýÿ%ýÿ'IþÿÇÐÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÙßþÿUqýÿ'ýÿ!ýÿ'ýÿ)ýÿ(ýÿ(ýÿ(ýÿ'ýÿ&ýÿ#ýÿ(ýÿ"DþÿPkþÿp†þÿ‡™þÿ’£þÿ‘¢þÿ„˜þÿm„þÿNjþÿ!Cþÿ&ýÿ"ýÿ%ýÿ&ýÿ'ýÿ(ýÿ(ýÿ(ýÿ(ýÿ(ýÿ(ýÿ(ÿÿ&üú'ü˜9ÿ ÿ+ý”*þÿ+ÿÿ*þÿ+þÿ+þÿ)þÿ*þÿ®ÿÿþþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿàåÿÿQoþÿ%þÿ%þÿ+þÿ+þÿ+þÿ+þÿ*þÿ'þÿ$þÿ"Gþÿt‹ÿÿ¶ÂÿÿÔÛÿÿäèÿÿïñÿÿöøÿÿúûÿÿúûÿÿö÷ÿÿîñÿÿãèÿÿÔÛÿÿ¹Åÿÿ}’ÿÿ/Rþÿ'þÿ&þÿ)þÿ)þÿ*þÿ*þÿ*þÿ*þÿ*þÿ*ÿÿ'ûù'ý‰Uª+ÿ;-üæ.ÿÿ-þÿ-þÿ-þÿ,þÿ)þÿVtÿÿêîÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿíñÿÿ]zþÿ(þÿ'þÿ-þÿ-þÿ-þÿ-þÿ,þÿ$þÿFþÿ‰ÿÿÒÚÿÿðóÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿóõÿÿ×Þÿÿ£³ÿÿ?`ÿÿ)þÿ)þÿ,þÿ,þÿ,þÿ,þÿ,þÿ,þÿ.ÿÿ,üñ.ýt@ÿ/ý™/þÿ0ÿÿ0þÿ0þÿ0þÿ-þÿ :þÿ¿Ìÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿz“þÿ1þÿ(þÿ0þÿ/þÿ.þÿ/þÿ,þÿ+þÿZwÿÿÇÑÿÿøúÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÜâÿÿ”§ÿÿ#Lþÿ'þÿ.þÿ/þÿ/þÿ/þÿ/þÿ/þÿ0ÿÿ.üâ-ÿI0ÿ%0ýá2ÿÿ1þÿ1þÿ1þÿ0þÿ/þÿbÿÿðóÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ¯¿þÿHþÿ)þÿ1þÿ2þÿ2þÿ1þÿ.þÿ8þÿx’ÿÿæëÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüýÿÿÄÏÿÿTsÿÿ+þÿ/þÿ1þÿ0þÿ0þÿ0þÿ1ÿÿ1ÿÿ/üÈ2ÿ$@¿3ýn3üø5ÿÿ3þÿ3þÿ3þÿ1þÿ8þÿÀÌÿÿþþÿÿÿÿÿÿÿÿÿÿÿÿÿÿëïÿÿEkþÿ,þÿ2þÿ4þÿ3þÿ4þÿ1þÿ8þÿ€šÿÿñôÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿôöÿÿÕÞÿÿËÕÿÿËÖÿÿ×ßÿÿõöÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿâçÿÿqÿÿ1þÿ0þÿ3þÿ2þÿ2þÿ2þÿ3ÿÿ2þÿ0üŸ@ÿã 2ü¶6üþ6ÿÿ6þÿ6þÿ5þÿ5þÿDlþÿèíÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ”«þÿ @þÿ/þÿ6þÿ5þÿ5þÿ4þÿ0þÿt‘ÿÿñôÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿäéÿÿ—­þÿ\~þÿ?eþÿ1\þÿ,Xþÿ,Xþÿ2]þÿ?fþÿZ}þÿ§þÿÖßÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿïòÿÿu’ÿÿ3þÿ3þÿ5þÿ5þÿ5þÿ5þÿ6ÿÿ4üð4ÿX8ÿ 5ûå:ÿÿ8þÿ8þÿ8þÿ7þÿ7þÿ–®ÿÿûüÿÿÿÿÿÿÿÿÿÿÿÿÿÿðôÿÿ@jþÿ0þÿ8þÿ8þÿ8þÿ8þÿ.þÿRxÿÿæëÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿñóÿÿާþÿ:eþÿEþÿ1þÿ*þÿ-þÿ.þÿ.þÿ-þÿ*þÿ0þÿCþÿ3]þÿj‹þÿËÖþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿíòÿÿlŒÿÿ1þÿ6þÿ8þÿ7þÿ7þÿ8þÿ8ÿÿ5ýÌ5ÿ:ÿO9üô<ÿÿ:þÿ:þÿ:þÿ8þÿ BþÿÏÚÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ®ÁþÿMþÿ3þÿ;þÿ:þÿ;þÿ7þÿOþÿ»ËÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÕÞþÿ^„þÿ@þÿ/þÿ4þÿ9þÿ:þÿ:þÿ:þÿ9þÿ9þÿ9þÿ8þÿ4þÿ.þÿ6þÿ/]þÿ‹¥þÿóõÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿàçÿÿMuÿÿ3þÿ9þÿ9þÿ9þÿ9þÿ;ÿÿ8ûý8ÿÿ<ÿ{;ü÷=ÿÿ<þÿ<þÿ<þÿ;þÿ9hþÿæìÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿcˆþÿ<þÿ:þÿ<þÿ<þÿ<þÿ2þÿx™ÿÿõøÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÒÝþÿOyþÿ6þÿ5þÿ<þÿ=þÿ<þÿ<þÿ<þÿ<þÿ<þÿ<þÿ<þÿ<þÿ<þÿ<þÿ9þÿ2þÿ Aþÿf‹þÿàçÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÅÓÿÿ!Sþÿ9þÿ;þÿ;þÿ;þÿ<þÿ=ÿÿ9üÝ;ÿ'=ý¢?ûý@ÿÿ?þÿ?þÿ=þÿ?þÿkÿÿðôÿÿÿÿÿÿÿÿÿÿÿÿÿÿñôÿÿ7gþÿ5þÿ>þÿ>þÿ>þÿ;þÿMþÿ¾Îÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿêïÿÿc‰þÿ8þÿ9þÿ?þÿ>þÿ>þÿ>þÿ>þÿ>þÿ>þÿ>þÿ>þÿ>þÿ>þÿ>þÿ>þÿ?þÿ>þÿ7þÿ:þÿ[„þÿàèÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüýÿÿ‘¬ÿÿ=þÿ<þÿ>þÿ>þÿ>þÿ@ÿÿ>üþ>ýˆÿAþ¿BÿÿBÿÿAþÿAþÿ?þÿBþÿ•°ÿÿúüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÉ×ÿÿ#[þÿ9þÿAþÿAþÿAþÿ:þÿUÿÿäëÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ”°þÿ Fþÿ9þÿAþÿ@þÿ@þÿ@þÿ>þÿ:þÿ6þÿ5þÿ5þÿ7þÿ;þÿ?þÿ@þÿ@þÿ@þÿ@þÿAþÿ;þÿ=þÿeþÿñõÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿãëÿÿ>oþÿ>þÿ@þÿ@þÿ@þÿAþÿBÿÿ?üÝ<ÿBûÒDÿÿCÿÿCþÿCþÿAþÿDþÿ³Çÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ¢ºþÿTþÿ>þÿCþÿCþÿCþÿ9þÿŒ«ÿÿûýÿÿÿÿÿÿÿÿÿÿÿÿÿÿâêÿÿEvþÿ7þÿCþÿCþÿCþÿ>þÿ4þÿDþÿBsþÿs˜þÿƒ£ÿÿ„£ÿÿjÿÿ0fþÿ>þÿ:þÿBþÿBþÿBþÿBþÿCþÿ;þÿ Fþÿˆ¦þÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüýÿÿ§¾ÿÿCþÿ@þÿBþÿBþÿBþÿDÿÿBûúBýhUÿEûãGÿÿEþÿEþÿEþÿBþÿFþÿÈÖÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ‡¨þÿOþÿAþÿEþÿEþÿDþÿ@þÿ®Äÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ©ÁþÿYþÿ?þÿFþÿCþÿ9þÿ&aþÿ¡ÿÿ¨ÀÿÿÔàÿÿöùÿÿÿÿÿÿÿÿÿÿïóÿÿÈÖÿÿ—³ÿÿ?rÿÿ?þÿBþÿEþÿEþÿEþÿEþÿ=þÿ$_þÿÇÖþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿâêÿÿ4kþÿCþÿDþÿDþÿDþÿDÿÿEýþBüÄ@ÿ FúêJÿÿHþÿHþÿHþÿEþÿIþÿÕáÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿxžþÿMþÿDþÿGþÿGþÿFþÿ Oþÿ¾Ðÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ‚¥þÿIþÿEþÿ?þÿHþÿ_Šÿÿ¿ÑÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÒßÿÿbŽÿÿHþÿEþÿGþÿGþÿGþÿEþÿEþÿ\‰þÿþþÿÿÿÿÿÿÿÿÿÿÿÿÿÿùûÿÿ‰ªÿÿEþÿEþÿGþÿGþÿGþÿIÿÿDûñJÿ4IûåLÿÿJþÿJþÿJþÿGþÿLþÿÙäÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿtœþÿNþÿGþÿJþÿJþÿHþÿZþÿÃÕÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿp™þÿBþÿ=þÿ ]ÿÿЬÿÿêðÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿèïÿÿ]ŒÿÿBþÿIþÿIþÿIþÿJþÿAþÿ `þÿÆ×þÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿËÚÿÿ PþÿGþÿIþÿIþÿIþÿKÿÿHüùJÿxLúàNÿÿLÿÿLþÿLþÿIþÿNþÿÖãÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ{¢þÿ RþÿIþÿLþÿLþÿJþÿ\þÿÃÕÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿrœþÿ;þÿ.hÿÿ¬ÄÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿËÛÿÿ+iÿÿGþÿKþÿKþÿKþÿHþÿNþÿo™þÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿçîÿÿ5pþÿJþÿKþÿKþÿKþÿKÿÿKüþLü¿OûÓPÿÿNÿÿNþÿNþÿLþÿOþÿÈÙÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ°þÿYþÿJþÿNþÿNþÿMþÿRþÿ¼Ðÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ€¦þÿ5nÿÿ®ÈÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿøûÿÿŠ®ÿÿFþÿMþÿNþÿNþÿNþÿFþÿ9uþÿô÷ÿÿÿÿÿÿÿÿÿÿÿÿÿÿðõÿÿnšÿÿMþÿKþÿMþÿMþÿMþÿOÿÿLûéPüºQþÿQÿÿQþÿQþÿOþÿRþÿ±Éÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ¬ÆÿÿbþÿJþÿPþÿPþÿPþÿHþÿ¨ÃÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿºÏÿÿ¹ÐÿÿüýÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÀÕÿÿ\þÿNþÿPþÿPþÿPþÿIþÿ!gþÿÈÙÿÿÿÿÿÿÿÿÿÿÿÿÿÿûýÿÿ™¹ÿÿPþÿNþÿPþÿPþÿPþÿRÿÿPüïRýŸQüüTÿÿSþÿSþÿQþÿTþÿ‘µÿÿùûÿÿÿÿÿÿÿÿÿÿÿÿÿÿÚæÿÿ'mþÿJþÿSþÿSþÿSþÿJþÿ}§ÿÿõøÿÿÿÿÿÿÿÿÿÿÿÿÿÿ÷ùÿÿþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿûüÿÿüýÿÿÿÿÿÿÿÿÿÿÿÿÿÿØäÿÿAÿÿNþÿRþÿRþÿRþÿMþÿ`þÿ›¼þÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿºÐÿÿTþÿPþÿRþÿRþÿRþÿTÿÿPüíVÿ}UüøVÿÿUþÿUþÿSþÿTþÿf™ÿÿïôÿÿÿÿÿÿÿÿÿÿÿÿÿÿûýÿÿF„þÿOþÿTþÿUþÿUþÿQþÿ9{ÿÿØåÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÑàÿÿœ½ÿÿéðÿÿÿÿÿÿÿÿÿÿÿÿÿÿæîÿÿ_“ÿÿNþÿTþÿTþÿTþÿPþÿ Zþÿ~¨þÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÑàÿÿVþÿQþÿTþÿTþÿTþÿVÿÿRüíVÿPWüóYÿÿWþÿWþÿVþÿUþÿ0wþÿåîÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿˆ±þÿ _þÿSþÿWþÿWþÿVþÿXþÿ¡ÁÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿçïÿÿSÿÿ:}þÿÖäÿÿÿÿÿÿÿÿÿÿÿÿÿÿìóÿÿjÿÿPþÿVþÿVþÿVþÿTþÿYþÿjœþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÛçÿÿ ]þÿSþÿVþÿVþÿVþÿXÿÿVüíZÿ"Xúì\ÿÿYþÿYþÿYþÿWþÿ^þÿÃÙÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÜéÿÿ-vþÿQþÿYþÿYþÿYþÿRþÿ;€ÿÿÙæÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿßêÿÿb™ÿÿQþÿ9þÿÛèÿÿÿÿÿÿÿÿÿÿÿÿÿÿëòÿÿhœÿÿSþÿYþÿYþÿYþÿWþÿZþÿb™þÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÞéÿÿeþÿWþÿXþÿXþÿXþÿ[ÿÿXüífÿ XüÇ]ýþ\ÿÿ\þÿ\þÿZþÿZþÿ~¬ÿÿ÷úÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿzªþÿ^þÿWþÿ\þÿ[þÿ[þÿWþÿd›ÿÿêòÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ¿×ÿÿOÿÿXþÿKþÿNŽþÿó÷ÿÿÿÿÿÿÿÿÿÿÿÿÿÿáìÿÿV’ÿÿVþÿ[þÿ[þÿ[þÿYþÿ\þÿeœþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÝéÿÿ dþÿYþÿ[þÿ[þÿ[þÿ^ÿÿ[üífÿ_ý„]üù_ÿÿ^þÿ^þÿ]þÿ\þÿ*xþÿÜèÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿàëÿÿ<„þÿXþÿ]þÿ^þÿ^þÿ\þÿ_þÿdÿÿÓäÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÑâÿÿ‡³ÿÿ)wÿÿTþÿ[þÿYþÿt§þÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÒâÿÿ4þÿYþÿ]þÿ]þÿ]þÿZþÿaþÿr¥þÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÙçÿÿ`þÿZþÿ]þÿ]þÿ]þÿ`ÿÿ]üíÿbÿ<`ûñcÿÿ`þÿ`þÿ`þÿ^þÿ]þÿ˜¿ÿÿûýÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ®ÌþÿoþÿYþÿ`þÿ`þÿ`þÿ]þÿ[þÿBˆÿÿ—¾ÿÿÏáÿÿøúÿÿÿÿÿÿüýÿÿäîÿÿ´Ðÿÿ‹·ÿÿ?‡ÿÿZþÿYþÿ`þÿWþÿ"vþÿ½Õþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ¹Óÿÿeþÿ]þÿ_þÿ_þÿ_þÿ\þÿhþÿеþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÈÜÿÿ`þÿ\þÿ_þÿ_þÿ_þÿbÿÿ]üímíbýÌdýþbþÿbþÿbþÿbþÿaþÿ/€þÿÚèÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ‘»þÿiþÿ[þÿaþÿbþÿbþÿaþÿZþÿ_þÿ;†þÿr¨ÿÿ°ÿÿy¬ÿÿW—þÿoþÿWþÿ[þÿaþÿbþÿ_þÿ]þÿp§þÿøûÿÿÿÿÿÿÿÿÿÿÿÿÿÿùûÿÿ‰·ÿÿYþÿaþÿbþÿbþÿbþÿ]þÿrþÿ¬Ìþÿÿÿÿÿÿÿÿÿÿÿÿÿþÿÿÿ­Ìÿÿbþÿ_þÿaþÿaþÿaþÿdÿÿ_üíUªeýwdüùgÿÿeþÿeþÿeþÿdþÿ`þÿy®ÿÿùûÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿýþÿÿºþÿoþÿ\þÿbþÿdþÿdþÿdþÿcþÿ_þÿZþÿYþÿZþÿ\þÿaþÿdþÿdþÿdþÿaþÿ]þÿGþÿÔäþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿØçÿÿ9‡ÿÿ_þÿdþÿdþÿdþÿdþÿ\þÿ(|þÿÜêÿÿÿÿÿÿÿÿÿÿÿÿÿÿ÷ûÿÿ‰·ÿÿeþÿbþÿdþÿdþÿdþÿgÿÿdüígÿ%füâjÿÿgþÿgþÿgþÿgþÿeþÿpþÿ°Ïÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ Æþÿ3…þÿcþÿ_þÿfþÿgþÿgþÿgþÿfþÿfþÿfþÿfþÿfþÿfþÿfþÿ_þÿcþÿG‘þÿÆÝþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüýÿÿ˜Áÿÿcþÿeþÿfþÿfþÿfþÿeþÿ`þÿGþÿþþÿÿÿÿÿÿÿÿÿÿÿÿÿÿìôÿÿZ›þÿeþÿeþÿfþÿfþÿfþÿiÿÿfüíÿiý—hýýkÿÿiþÿiþÿiþÿhþÿeþÿ5‡þÿÍáÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿËáþÿg¥þÿ'}þÿeþÿ`þÿdþÿfþÿgþÿhþÿhþÿgþÿeþÿaþÿbþÿwþÿj§þÿØèþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÐäÿÿ5‡ÿÿcþÿhþÿhþÿhþÿhþÿdþÿ pþÿ‰¹þÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿàíÿÿ&þÿfþÿgþÿhþÿhþÿhþÿkÿÿhüíjÿ0kúánÿÿkþÿkþÿkþÿkþÿjþÿeþÿN˜ÿÿ×éÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ¹Öþÿi¨þÿ=þÿ|þÿ qþÿhþÿdþÿfþÿlþÿvþÿ0…þÿXžþÿ«Îþÿüýÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿïöÿÿd¦ÿÿdþÿjþÿkþÿkþÿkþÿkþÿdþÿ*„þÿØéÿÿÿÿÿÿÿÿÿÿÿÿÿÿþÿÿÿ¼ØÿÿkþÿhþÿjþÿjþÿjþÿjþÿmÿÿküínýmüþpÿÿnþÿnþÿnþÿnþÿmþÿgþÿSœÿÿÑåÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿáîÿÿ«Ïþÿ‡ºþÿmªþÿ_¤þÿe§þÿx±þÿ˜ÃþÿÊáÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿòøÿÿ|µÿÿnþÿkþÿmþÿmþÿmþÿmþÿjþÿmþÿl«þÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿôùÿÿq®ÿÿlþÿlþÿmþÿmþÿmþÿmþÿpÿÿküïuÿ%mýÔrÿÿpþÿpþÿpþÿpþÿpþÿoþÿiþÿD•ÿÿ·×ÿÿûýÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿìôÿÿ~·ÿÿ tþÿkþÿoþÿoþÿnþÿjþÿkþÿiþÿ.‰þÿÒåÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÙêÿÿ#‚þÿmþÿnþÿoþÿoþÿoþÿoþÿrÿÿoüérÿgpûôuÿÿqþÿrþÿrþÿrþÿrþÿqþÿlþÿþÿÁÿÿáîÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÕèÿÿj¬ÿÿsþÿoþÿqþÿqþÿpþÿsþÿ~þÿtþÿtþÿ¿þÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüýÿÿ•ÄÿÿnþÿoþÿqþÿqþÿqþÿqþÿqÿÿrýþnüÂ`ÿtü«vÿÿuÿÿtþÿtþÿtþÿtþÿtþÿtþÿqþÿsþÿR ÿÿ²Õÿÿãðÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿâïÿÿ§Ïÿÿ:“ÿÿoþÿrþÿtþÿtþÿtþÿmþÿ%ˆþÿ—Æþÿn°þÿb©þÿóøÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÜìÿÿ0þÿrþÿrþÿsþÿsþÿsþÿsþÿuÿÿsüúrýyxÿ1výÓzÿÿwþÿwþÿwþÿwþÿwþÿwþÿvþÿuþÿpþÿ {þÿW¤ÿÿ©ÒÿÿÑæÿÿëôÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿð÷ÿÿÔèÿÿ«ÑÿÿT¢ÿÿxþÿqþÿuþÿuþÿuþÿvþÿsþÿ vþÿp²þÿÿÿÿÿï÷ÿÿåñÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüýÿÿ‰Àÿÿsþÿuþÿvþÿvþÿvþÿvþÿvþÿyÿÿuüéwÿ/xÿ[wûê|ÿÿyþÿxþÿxþÿxþÿxþÿyþÿyþÿxþÿwþÿtþÿvþÿ+þÿh°ÿÿ›Êÿÿ¼ÜÿÿÊãÿÿÒçÿÿÔèÿÿÒèÿÿÍåÿÿÃàÿÿ§Ñÿÿt¶ÿÿ2“þÿwþÿsþÿwþÿxþÿxþÿxþÿxþÿxþÿqþÿ7”þÿÙëÿÿÿÿÿÿÿÿÿÿýÿÿÿýþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÃßÿÿ…þÿvþÿxþÿxþÿwþÿwþÿwþÿyÿÿxÿÿwüª’ÿ|û„xûù~ÿÿ{þÿzþÿzþÿzþÿzþÿzþÿzþÿzþÿzþÿzþÿxþÿwþÿuþÿxþÿ…þÿ)þÿ-’þÿ)þÿŠþÿ|þÿuþÿwþÿxþÿzþÿzþÿzþÿ{þÿ{þÿ{þÿ{þÿvþÿ €þÿ‰ÁþÿþþÿÿÿÿÿÿÿÿÿÿþþÿÿúüÿÿþÿÿÿÿÿÿÿÝíÿÿO¤ÿÿvþÿyþÿyþÿyþÿyþÿyþÿzþÿ|ÿÿwûï|ÿHÿŽÿ {ü—~ýú€ÿÿ}þÿ}þÿ}þÿ}þÿ|þÿ|þÿ|þÿ|þÿ|þÿ|þÿ|þÿ|þÿ{þÿ{þÿ{þÿzþÿ{þÿ{þÿ{þÿ|þÿ|þÿ|þÿ|þÿ|þÿ|þÿ|þÿ|þÿ|þÿ|þÿwþÿP¥þÿôùÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþþÿÿýþÿÿõúÿÿ†Áÿÿyþÿ{þÿ}þÿ|þÿ|þÿ|þÿ|þÿ}ÿÿ}ÿÿzû«’ÿ€ÿ€ý¢‚ýýƒÿÿ€þÿþÿþÿþÿþÿþÿþÿþÿþÿþÿþÿþÿ~þÿ~þÿ~þÿ~þÿ~þÿ~þÿ~þÿ~þÿ~þÿ~þÿ~þÿ~þÿ~þÿ~þÿ~þÿyþÿ!þÿ«ÕþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿëõÿÿÀþÿ„þÿ}þÿ~þÿ~þÿ~þÿ~þÿþÿ‚ÿÿ~ûä}ÿ7„ÿú¨ƒüû…ÿÿ‚ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ€ÿÿ}ÿÿb±ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüþÿÿ¿ßÿÿ/˜ÿÿ€ÿÿ€ÿÿ€ÿÿ€ÿÿ€ÿÿƒÿÿ€ýùý€ÿ€ÿüž…üù‡ÿÿ„ÿÿƒÿÿƒÿÿƒÿÿƒÿÿƒÿÿƒÿÿƒÿÿƒÿÿƒÿÿƒÿÿƒÿÿƒÿÿƒÿÿƒÿÿƒÿÿƒÿÿƒÿÿƒÿÿƒÿÿƒÿÿƒÿÿƒÿÿƒÿÿ‚ÿÿ„ÿÿn¹ÿÿúýÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿòùÿÿÇäÿÿšÎÿÿ; ÿÿƒÿÿƒÿÿƒÿÿƒÿÿ‚ÿÿ…ÿÿ…ÿÿ€ü²ˆÿ’ÿ…ý’„üòŠÿÿ‡ÿÿ…ÿÿ…ÿÿ…ÿÿ…ÿÿ…ÿÿ…ÿÿ…ÿÿ…ÿÿ…ÿÿ…ÿÿ…ÿÿ…ÿÿ…ÿÿ…ÿÿ…ÿÿ…ÿÿ…ÿÿ…ÿÿ…ÿÿƒÿÿ‚ÿÿÿÿ€ÿÿ‚ÿÿ]±ÿÿåóÿÿùýÿÿÿÿÿÿÿÿÿÿàðÿÿ¼àÿÿƒÄÿÿ“ÿÿƒÿÿ„ÿÿ…ÿÿ…ÿÿ…ÿÿ…ÿÿ†ÿÿˆÿÿ‚ýÌ‚ÿ+€ÿ‰ýu‰üáŒÿÿŠÿÿ‡ÿÿ‡ÿÿ‡ÿÿ‡ÿÿ‡ÿÿ‡ÿÿ‡ÿÿ‡ÿÿ‡ÿÿ‡ÿÿ‡ÿÿ‡ÿÿ‡ÿÿ‡ÿÿ‡ÿÿ‡ÿÿ‡ÿÿ‰ÿÿ‘ÿÿ•ÿÿ •ÿÿ%–ÿÿg¸ÿÿËçÿÿ³Ûÿÿ¬ØÿÿÕëÿÿ©ÖÿÿL«ÿÿ‰ÿÿ…ÿÿ†ÿÿ†ÿÿ‡ÿÿ‡ÿÿ‡ÿÿ‡ÿÿ‰ÿÿŒÿÿ†ýÔ‡ÿ@‹üMˆüÈüûŽÿÿ‹ÿÿŠÿÿŠÿÿŠÿÿŠÿÿŠÿÿŠÿÿŠÿÿŠÿÿŠÿÿŠÿÿ‰ÿÿ‰ÿÿ‰ÿÿ‰ÿÿ†ÿÿ•ÿÿxÁÿÿ«Øÿÿ¦ÖÿÿÓêÿÿëöÿÿs¾ÿÿ‰ÿÿ’ÿÿ&›ÿÿˆÿÿˆÿÿˆÿÿˆÿÿ‰ÿÿ‰ÿÿ‰ÿÿ‰ÿÿ‰ÿÿ‹ÿÿŽÿÿ‰ýÔˆÿGŠÿ#Šý™‹üìÿÿÿÿÿÿŒÿÿŒÿÿŒÿÿŒÿÿŒÿÿŒÿÿŒÿÿŒÿÿŒÿÿŒÿÿŒÿÿŒÿÿŠÿÿ•ÿÿV³ÿÿsÀÿÿ]¶ÿÿµÝÿÿ´Ýÿÿ‰ÿÿŠÿÿ‹ÿÿŠÿÿŠÿÿ‹ÿÿ‹ÿÿ‹ÿÿ‹ÿÿ‹ÿÿ‹ÿÿŒÿÿÿÿýþ‰üÆŒÿ<€ÿÿTŽüÇýó‘ÿÿ‘ÿÿÿÿŽÿÿŽÿÿŽÿÿŽÿÿŽÿÿŽÿÿŽÿÿŽÿÿŽÿÿŽÿÿŽÿÿŽÿÿÿÿÿÿ”ÿÿ‘Îÿÿ–Ñÿÿ†ÿÿŽÿÿŽÿÿŽÿÿŽÿÿŽÿÿŽÿÿŽÿÿŽÿÿŽÿÿÿÿ’ÿÿŽýóŽþ­Šÿ%ŒÿÿqŒýÔýõ“ÿÿ”ÿÿ‘ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ‹ÿÿžÿÿ’ÐÿÿsÁÿÿ‹ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ’ÿÿ”ÿÿ’ýûüÜýs€ê €ÿ™ÿ”ÿw‘ýÒ“ÿð“ÿÿ—ÿÿ–ÿÿ”ÿÿ“ÿÿ“ÿÿ’ÿÿ’ÿÿ’ÿÿ’ÿÿ’ÿÿ’ÿÿÿÿœÿÿP´ÿÿ7ªÿÿÿÿ’ÿÿ’ÿÿ’ÿÿ’ÿÿ“ÿÿ•ÿÿ–ÿÿ”ýûüç‘ýœ•ÿ0€ÿªÿ”ÿ˜ÿW“þµ”üè–ýô”ýþ™ÿÿ™ÿÿ˜ÿÿ—ÿÿ–ÿÿ–ÿÿ–ÿÿ•ÿÿ•ÿÿ•ÿÿ–ÿÿ–ÿÿ–ÿÿ—ÿÿ˜ÿÿ™ÿÿ˜ÿÿ”þÿ•ýó’úâ“ýš”ÿ7™ÿÿÿŽÿ šÿ&—ýi˜ü¯–üà˜ýï•ýõ•ýú–ýþ™ÿÿšÿÿ›ÿÿœÿÿ›ÿÿ™ÿÿ™ÿÿ˜ÿÿ—ýû•ý÷™ÿð—úâ—þ°–ÿd‘ÿªÿªÿ™æ ™ÿ›ÿ8™ÿi—ýŽšþ«—üÇ—ûØ—üá—üê•ýè˜ûÚ™ýΘþ¹™ý˜›ÿu˜ÿE›ÿ™ÿ €ÿ( @ ÿüdýŸüÁþþÿÿÿÿÿÿ¢¦ûíþº ýšüW ÿÿ,þ«úûýÿýÿuþÿÿÿÿÿÿÿÿÿ‰þÿýÿýÿýÿúüüÀüJÿÿý‡úûýÿýÿ>Pýÿ½Ãþÿÿÿÿÿÿÿÿÿúúÿÿ&:ýÿýÿýÿýÿýÿýÿýÿýÍüKÿ þºýÿýÿýÿbsþÿýýÿÿÿÿÿÿÿÿÿÿúûÿÿ\nþÿýÿýÿýÿýÿýÿýÿýÿýÿýÿý¦ ÿ+ÿþ»!ýÿ!ýÿ!ýÿŠ™þÿÿÿÿÿÿÿÿÿôöÿÿÈÏÿÿ0Jýÿ ýÿ ýÿ ýÿ ýÿ ýÿ ýÿ ýÿ ýÿ ýÿ ýÿ ýÿüÛÿ+%ý‹%ýÿ%ýÿ%ýÿp…þÿÿÿÿÿÿÿÿÿúûÿÿs‡þÿ(ýÿ%ýÿ%ýÿ%ýÿ%ýÿ%ýÿ%ýÿ%ýÿ%ýÿ%ýÿ%ýÿ%ýÿ$ýÿ$ýÿ$úí"ÿ5+ÿ0*úý*ýÿ*ýÿ>^ýÿüüÿÿÿÿÿÿõ÷ÿÿ@_ýÿ)ýÿ)ýÿ)ýÿ)ýÿ$Gýÿyþÿ¥³þÿ»Æþÿ¯¼þÿ¢þÿPlþÿ 1ýÿ)ýÿ)ýÿ)ýÿ)ýÿ)úð'ÿ..þ¶.þÿ.þÿ0þÿÌÕÿÿÿÿÿÿþþÿÿXvþÿ.þÿ.þÿ.þÿCþÿ²Àÿÿþþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿêîÿÿ{’þÿ3þÿ-þÿ-þÿ-þÿ*üÞ$ÿ3ÿ#3ûþ3þÿ3þÿXyþÿÿÿÿÿÿÿÿÿ¤¶ÿÿ2þÿ2þÿ2þÿ8_þÿìðÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÍ×ÿÿ#Nþÿ2þÿ2þÿ2þÿ2ýž7ÿt7þÿ7þÿ7þÿ·ÇÿÿÿÿÿÿúûÿÿOþÿ7þÿ7þÿOþÿèíÿÿÿÿÿÿÿÿÿÿÓÜÿÿ`‚þÿKþÿ6þÿ =þÿ;eþÿ§ÿÿóöÿÿÿÿÿÿÿÿÿÿàçÿÿJþÿ6þÿ6þÿ6þÿ7ÿO:þ³<þÿ;þÿIþÿúûÿÿÿÿÿÿ¸Èÿÿ;þÿ;þÿ;þÿ¯Âÿÿÿÿÿÿÿÿÿÿ¡·ÿÿ@þÿ;þÿ;þÿ;þÿ;þÿ;þÿ;þÿPþÿÀÏÿÿÿÿÿÿÿÿÿÿÎÙÿÿ@þÿ;þÿ:þÿ:üÛUÿ@üÞ@þÿ@þÿCrþÿÿÿÿÿÿÿÿÿjþÿ@þÿ@þÿ(^þÿýýÿÿÿÿÿÿÇÕÿÿCþÿ?þÿ?þÿ?þÿ?þÿ?þÿ?þÿ?þÿ?þÿ FþÿÅÓÿÿÿÿÿÿÿÿÿÿs–þÿ?þÿ?þÿ?þÿAÿSAûõDþÿDþÿgþÿÿÿÿÿÿÿÿÿAtþÿDþÿDþÿj’þÿÿÿÿÿÿÿÿÿM|þÿDþÿDþÿ7lþÿ­ÂþÿÑÝÿÿÂÒÿÿHyþÿDþÿDþÿDþÿTþÿðôÿÿÿÿÿÿîòÿÿNþÿCþÿCþÿDüÈIûøIþÿIþÿ|¡þÿÿÿÿÿÿÿÿÿ)fþÿIþÿIþÿ°ÿÿÿÿÿÿÿÿÿÿWþÿ Qþÿ¥¿ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿˆªÿÿHþÿHþÿHþÿxžþÿÿÿÿÿÿÿÿÿ\ŠþÿHþÿHþÿHþÿFÿ!MûçMþÿMþÿošþÿÿÿÿÿÿÿÿÿ6sþÿMþÿMþÿ‰­ÿÿÿÿÿÿÿÿÿÿ#eþÿÁÔÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿýþÿÿ8sþÿLþÿLþÿ^þÿýþÿÿÿÿÿÿªÃÿÿLþÿLþÿLþÿMÿcRýÓRþÿRþÿ\þÿÿÿÿÿÿÿÿÿYŽþÿQþÿQþÿh˜þÿÿÿÿÿÿÿÿÿËÜÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþþÿÿþþÿÿÿÿÿÿœ»ÿÿQþÿQþÿQþÿÏÞÿÿÿÿÿÿÛæÿÿQþÿQþÿQþÿOý§Vþ®VþÿVþÿ"mþÿÿÿÿÿÿÿÿÿž¿ÿÿVþÿVþÿcþÿöùÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ³ÿÿãìÿÿÿÿÿÿÂÖÿÿUþÿUþÿUþÿ­ÈÿÿÿÿÿÿöùÿÿUþÿUþÿUþÿSýÏ\ÿl[þÿ[þÿZþÿÜèÿÿÿÿÿÿó÷ÿÿjþÿZþÿZþÿz©þÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ’¹ÿÿ[þÿçïÿÿÿÿÿÿ»ÓÿÿZþÿZþÿZþÿŸÁÿÿÿÿÿÿþþÿÿ]þÿYþÿYþÿWúàaÿ*_þÿ_þÿ_þÿr§þÿÿÿÿÿÿÿÿÿžÂÿÿ_þÿ_þÿ_þÿ€¯þÿýþÿÿÿÿÿÿÿÿÿÿßëÿÿG‹þÿ^þÿ*yþÿÿÿÿÿÿÿÿÿ—½ÿÿ^þÿ^þÿ^þÿ²Îÿÿÿÿÿÿðöÿÿ^þÿ^þÿ^þÿ[ûòÿaýÔcþÿcþÿhþÿáíÿÿÿÿÿÿÿÿÿÿn¦þÿcþÿcþÿcþÿeþÿ({þÿlþÿcþÿcþÿdþÿ±ÏÿÿÿÿÿÿÿÿÿÿA‹þÿcþÿcþÿcþÿÛéÿÿÿÿÿÿÖæÿÿbþÿbþÿbþÿ_ûóiÿ_hþÿhþÿhþÿH“þÿüýÿÿÿÿÿÿÿÿÿÿ•Àÿÿqþÿhþÿgþÿgþÿgþÿgþÿ mþÿŸÆÿÿÿÿÿÿÿÿÿÿÌáÿÿhþÿgþÿgþÿ zþÿÿÿÿÿÿÿÿÿšÃÿÿgþÿgþÿgþÿgüÜfÿkúálþÿlþÿlþÿj©þÿþþÿÿÿÿÿÿÿÿÿÿíõÿÿ“ÁÿÿQ›þÿ8ŒþÿG•þÿ€¶þÿâîÿÿÿÿÿÿÿÿÿÿîõÿÿ#€þÿlþÿlþÿkþÿ‡¹ÿÿÿÿÿÿÿÿÿÿVþÿkþÿkþÿkþÿiþ³pÿ]qþÿqþÿqþÿqþÿNœþÿð÷ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿàîÿÿ7þÿpþÿpþÿpþÿ~þÿñ÷ÿÿÿÿÿÿåðÿÿtþÿpþÿpþÿpþÿoÿwtþ­uþÿuþÿuþÿuþÿ€þÿŽÂÿÿñ÷ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿñ÷ÿÿ“Åÿÿ~þÿuþÿtþÿ yþÿÇàÿÿÉáÿÿÿÿÿÿÿÿÿÿs³þÿtþÿtþÿtþÿtûþvÿ'yÿ{ûçyþÿyþÿyþÿyþÿyþÿ|þÿ@›þÿl²þÿ€¼þÿq´þÿJ þÿ þÿyþÿyþÿyþÿyþÿŽÃþÿÿÿÿÿêôÿÿÿÿÿÿÌäÿÿ|þÿyþÿyþÿyþÿwþ¼}ÿ5~ûô~þÿ~þÿ~þÿ~þÿ~þÿ~þÿ~þÿ~þÿ~þÿ~þÿ}þÿ}þÿ}þÿ}þÿ"ŽþÿäñÿÿÿÿÿÿÿÿÿÿèóÿÿP¥þÿ}þÿ}þÿ}þÿ}þÿ{ÿ<ƒÿD‚üó‚ÿÿ‚ÿÿ‚ÿÿ‚ÿÿ‚ÿÿ‚ÿÿ‚ÿÿ‚ÿÿ‚ÿÿ‚ÿÿ‚ÿÿ‚ÿÿ‚ÿÿŸÐÿÿÿÿÿÿÿÿÿÿýþÿÿÑéÿÿsºÿÿ‚ÿÿ‚ÿÿÿÿý–‰ÿ6…üå‡ÿÿ‡ÿÿ‡ÿÿ‡ÿÿ‡ÿÿ†ÿÿ†ÿÿ†ÿÿ†ÿÿ†ÿÿ†ÿÿŠÿÿœÐÿÿÓêÿÿ¼ßÿÿi¸ÿÿˆÿÿ†ÿÿ†ÿÿ†ÿÿ‡üÇŽÿ ÿ‹þ»‹ÿÿ‹ÿÿ‹ÿÿ‹ÿÿ‹ÿÿ‹ÿÿ‹ÿÿ‹ÿÿ%œÿÿ‘ÍÿÿÊæÿÿ3¢ÿÿŽÿÿ‹ÿÿ‹ÿÿ‹ÿÿŠÿÿŠÿÿŠüÇŽÿÿÿ‘ÿaŽüÞÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ‹ÌÿÿÿÿÿÿÿÿÿÿÿÿŒüþý˜Žÿ €ÿ”ÿ_’ýÔ”ÿÿ”ÿÿ”ÿÿ”ÿÿ”ÿÿ”ÿÿ$£ÿÿ”ÿÿ“ÿÿ“ÿÿ“ÿÿ“þ½“ÿ;•ÿ$—ÿl˜þ°™ýÑ•üæ˜üû˜üé™ýÑ–þ²˜ÿwšÿ&(0 ÿù\ýš&2üÅùùýîÜÞûì$1üÉý¢ÿeÿ1ÿýiýÐÿÿ9Eÿÿ²¸ÿÿÿÿÿÿ¸¿ÿÿ ÿÿÿÿÿÿüðý ûBÿýÿÿÿÿl{ÿÿìïÿÿÿÿÿÿÚÞÿÿ;Oýÿýÿýÿþÿÿÿÿÿüîûÿÿ "ýŸÿÿ ÿÿƒ“þÿÿÿÿÿÿÿÿÿ¡®þÿ)Cýÿýÿýÿýÿýÿýÿýÿ!ÿÿ"ÿÿ þ¾ø&&ýk'üý ÿÿg~ýÿüüÿÿñóÿÿgþÿ#ýÿýÿ#ýÿ-MýÿTnýÿ[týÿGcýÿ<ýÿýÿ!ÿÿ'ÿÿ'ýÐ&ÿ(1ÿ+ûÙ'ÿÿ&Nþÿèìÿÿÿÿÿÿeþÿþÿ!þÿ5Xþÿ­»þÿéíÿÿÿÿÿÿÿÿÿÿþþÿÿÙàÿÿŽ¡þÿEþÿ$ÿÿ.ÿÿ*üÄÿ3ÿd4ÿÿ1ÿÿˆ þÿÿÿÿÿ£µÿÿ1þÿ&þÿMpþÿçìÿÿÿÿÿÿïóÿÿÇÒÿÿÀÌÿÿÒÜÿÿÿÿÿÿÿÿÿÿÓÜÿÿ@eþÿ*ÿÿ5ÿÿ1ýŒÿ8ý¨7ÿÿFþÿÝåÿÿøúÿÿ;gþÿ&þÿ(Xþÿâêÿÿÿÿÿÿ¤¹ÿÿ4\þÿ2þÿ)þÿ @þÿMsþÿ»Ëþÿÿÿÿÿáèÿÿ1^þÿ1ÿÿ8ýó8ÿD>ûÕ;ÿÿ8iþÿÿÿÿÿÈÖÿÿKþÿ2þÿŒ¨þÿÿÿÿÿ¯Ãÿÿ;þÿ,þÿCþÿ Gþÿ9þÿ,þÿFþÿ¬Àÿÿÿÿÿÿ·ÉÿÿEþÿ=ÿÿ>ú¨UÕBúê@ÿÿ[‡þÿÿÿÿÿ¢»ÿÿ>þÿOþÿÅÕÿÿþþÿÿ3jþÿ@þÿ^‰þÿ»ÍþÿÓßÿÿ…¦þÿSþÿ7þÿWþÿÙãÿÿÿÿÿÿOþÿ=ÿÿDüòCú5KùæFÿÿbþÿÿÿÿÿ›¸ÿÿ@þÿ]þÿ×âÿÿõ÷ÿÿ+iþÿš¸ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ¢¾ÿÿJþÿ@þÿo™þÿÿÿÿÿžºÿÿKÿÿLÿÿIýpQýÔNÿÿP‡þÿÿÿÿÿ±ÊÿÿPþÿ WþÿÀÓþÿüýÿÿÁÕÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþþÿÿó÷ÿÿ?|ÿÿ?þÿ3sþÿùûÿÿ×äÿÿ YþÿOÿÿPþ­Vþ±Uÿÿ#nþÿøúÿÿäíÿÿ"nþÿFþÿv¦þÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ¦Äÿÿ¾Ôÿÿÿÿÿÿc—ÿÿDþÿ"mþÿâìÿÿôøÿÿbþÿTÿÿQýÑ]ýv_ÿÿ_ÿÿ¶Ñþÿÿÿÿÿ~­ÿÿQþÿdþÿ©Éþÿÿÿÿÿÿÿÿÿûüÿÿ”»þÿeþÿµÐÿÿÿÿÿÿU’ÿÿLþÿ"rþÿàëÿÿôøÿÿhþÿZÿÿYúâaû:büö^ÿÿGþÿÿÿÿÿôøÿÿO”þÿUþÿdþÿFŽþÿR•þÿ1þÿVþÿBŠþÿøûÿÿåïÿÿ!vþÿUþÿ0€þÿúüÿÿÛéÿÿ jþÿaÿÿ_úèqÿ fü¬mÿÿgþÿ½þÿÿÿÿÿñ÷ÿÿw®ÿÿvþÿbþÿ`þÿhþÿQ—þÿßìÿÿÿÿÿÿ‚µÿÿaþÿaþÿb¢þÿÿÿÿÿ¦ÊÿÿjþÿhÿÿgýÔnûHoýômÿÿtþÿ’Âþÿÿÿÿÿÿÿÿÿàîÿÿ«Ïÿÿ¡ÉÿÿÆßÿÿÿÿÿÿÿÿÿÿ¥Ìþÿ rþÿdþÿrþÿÇßÿÿÿÿÿÿ]£þÿhþÿqÿÿmý©ªÿrý“zÿÿqÿÿtþÿX¤þÿÇàÿÿüþÿÿÿÿÿÿÿÿÿÿÿÿÿÿàîÿÿt´ÿÿ xþÿjþÿQžþÿ±ÓÿÿÿÿÿÿÏåÿÿþÿnÿÿyÿÿtýgózüÈ‚ÿÿwÿÿuþÿ ~þÿ3•þÿ^¬þÿe¯þÿFŸþÿ…þÿvþÿqþÿ‰þÿÙëþÿÿÿÿÿóùÿÿV§ÿÿrþÿÿÿwüÞxÿ ‚ù+ûÕˆÿÿ€ÿÿ}þÿ|þÿ{þÿ{þÿ|þÿ|þÿ|þÿ|ÿÿ„ÂÿÿÿÿÿÿÿÿÿÿÍæÿÿ'’þÿ}ÿÿ„ÿÿ~ýs…ÿ,‡üÄÿÿŠÿÿ†ÿÿ†ÿÿ…ÿÿ…ÿÿ…ÿÿ ‰ÿÿ“ÿÿ§ÖÿÿÑéÿÿ‘Ëÿÿ6ŸÿÿŽÿÿŒÿÿ„ý¨™ÿ ÿŠý™ýô•ÿÿŽÿÿŒÿÿ‹ÿÿŒÿÿ>¨ÿÿžÓÿÿ4£ÿÿ ÿÿ‹ÿÿŒÿÿŽÿÿŠý¦ŒÿüL’ý¨’üøšÿÿ—ÿÿ–ÿÿ”ÿÿ;°ÿÿ™ÿÿ“ÿÿ—ÿÿ”ýÙŽýsŽÿ ™ÿ”ÿ9™ÿq–þ²—ýÓ–üç•üä—ýΕý©™ÿf•ÿ$(  ÿÿÿ* ýmîïý“cmýƒüU#ÿÿÿÿ1ÿ üª üû‘šþÿþþþþ4Eüþüÿüîý• ÿÿ1ÿúá6ýÿßãýýô÷ýüG\üûûûûý ûþüÿ ûí'ûHUÿ'þ¶+ýÿÝâýøÆÒýþ#ýÿ!üþl„üþ§³ýþœªýýKiüú!üþ$üý0üPUÿAÿC$ýÿvýýöùýþ 3üþ DþÿåëþÿúûÿÿÁÎþÿÏÙýþÿÿÿÿÅÐýü;þÿ-üñ>ÿ%>ýˆ4ýÿ×àýü”ªýþ$ýÿÏÚþÿÉ×þÿ4ýÿ"ýÿ"ýÿ RýþáêþÿÄÒýú6ýÿ;ý¨Aý¨Jþÿ÷ùýüRýþTþÿÿÿÿÿ0aþÿIxþÿ¼Îþÿœ¸þÿ Býÿ UýþþþþþW‚þÿ7üöUÿ-Mý RþÿôøýüXˆýþ_þÿöøþÿ´Ëþÿÿÿÿÿûüþÿÿÿÿÿœ»þÿ5ýÿ¾Ïýþ°ÉýüAýÿ Tÿt\ÿtOýÿÈÚýü­ÈýþCýÿ»Òþÿÿÿÿÿÿÿÿÿ¶Ïþÿ¡ÂþÿÐàþÿBýÿ—·ýþÏßýüNýÿYý lÿ-XüöNþÿþþþþKŒýþWýÿWšþÿGþÿ\ýÿÔãþÿ¢ÆþÿIýÿ­Êýþ¿ÖýüVýÿdý¨mý¨dýÿ‰ºýúÿÿÿÿ¡Æýþ@ŽþÿN–þÿÔåþÿíõþÿuþÿdýÿïöýþy°ýü_ýÿoýˆuÿ%uýñmýÿQ¡ýüÕéþÿúýýþùýþÿ´Øþÿþÿ{þÿºÙýþêóýþ}üýqýÿvÿCUÿ|ÿP€ýývýþvýú ‚ýýýþtýþoýþ¬Ôþÿþþþþ¼ýøtþÿ€þ¶Uÿ‡ÿHˆþí‰ÿÿ…þþ…þý ŒþûN©þû–ÎýüZ²ýý‹ÿÿ…þá„ÿªÿŠÿý”ýî‘þÿýþ:ªýþ þÿ†þúþª“ÿÿÿ€ÿÿÿ—ÿ–ÿU—ÿ€ÿˆ™ÿl¤ÿ*ÿÿÿ././@LongLink0000000000000000000000000000015000000000000011211 Lustar 00000000000000photutils-0.2.1/astropy_helpers/astropy_helpers/sphinx/themes/bootstrap-astropy/static/astropy_logo.svgphotutils-0.2.1/astropy_helpers/astropy_helpers/sphinx/themes/bootstrap-astropy/static/astropy_logo.0000600000214200020070000001103212605531164036711 0ustar lbradleySTSCI\science00000000000000 ././@LongLink0000000000000000000000000000015300000000000011214 Lustar 00000000000000photutils-0.2.1/astropy_helpers/astropy_helpers/sphinx/themes/bootstrap-astropy/static/astropy_logo_32.pngphotutils-0.2.1/astropy_helpers/astropy_helpers/sphinx/themes/bootstrap-astropy/static/astropy_logo_0000600000214200020070000000353412346164025037002 0ustar lbradleySTSCI\science00000000000000‰PNG  IHDR szzôsBIT|dˆ pHYsÓÇòŽtEXtSoftwarewww.inkscape.org›î<ÙIDATX…Å—PT×Ç?÷ñc‘P° ˆ „FƒUBìȘ&Ådi”I# ±ÒÄJhC2æÇŒ5ÑÔtw:íÛª5ÑÒSÒÆª©é„Ú¡%¨ZÉF2Vk­JFŒ`ÁŠ(JdÙ÷öÝþqaß., É?½3gæ½sÏïýžûΞº®óÿ\Ñ_ÄÉ•ìÎ#šÅHŠl ø2pèZ€Ý8ØãéÔ¯KL”Wš;†AC°È‹h4¥z>ÕÀ$?ñôé—#¹hJ~‹»œ›´`;&y˜#D²ËÂß b0¨Â¤Åu‹»2RìqKàJr'âã7˜<6.´;`Îã2Ò‹@‹†Ž&°Ìa‹$`›+Æâ1ôWB]Ç, w.rÆM¶|»r€Þh?G6B—m"ù‘GêÕïKàƒ…“œ0º#Ñ&¢: WBÅaˆË°mL6¸pÏ€+àΔƒx¥Áti@D1Çä;«áz§ v³ú7zCýrׇóE9ÎÐäš ‹,“é_Gÿ±hbÞˆy•ˆ;¾Ñ Ðñ!,e÷ÙUÄ—¦AÚlˆO†„©ˆ€-^;V€¬…~ï;MçÅðKxUZùK%:Lü剜"¸ë9äžáT½rÝë†3WCúWaá8úè9ô³`p4XW·;KšxBjó«ËwÙÉ¥„Ö÷á“ýÐÚׇ.WêLDå_e5Êw`ÎDîzFíG;ßz9ì¾?@ÈghI^Ž ÄâUˆ¥›Ô³áƒÆMÈl…+çíãÇÄs%bñZˆK„»Ÿ‚Ão@ûÅ`ó!8¹ò—À¬o‚)Ô!ÔÊpu¹4W›;Uü0ˆ0×i'÷Ý@V— ë\Ð}>üÖßôÁž Èu Àôƒˆï¾ ¦übdëÇ‘‰Yáþ>rµ¡z—c0iØI,\1D‹‰ÜX §)‡Ìùׇˆ×üˆ__…Šm cáB3ì߬|f̃¹ÙI.œ²KŸ;ò“NÖ¤AqÐ!~*Üùr8Þg)ã¬BÄß…¬;!*â'#î©DÔôÁürdÓN;Ql’ à|(€Ùá Xôj®€[Ã`aPy÷ã* ÷ר—¦Ô¥h¹bâO½¶Î 9el¢­ïë 0HÆi¦a29HáReÜÝ 5*Ã@ä)}豄 ¢cU5ö»aÙIr mý0›Jú€nARÂPÊør‡j­&5â“+Þðçõ£AL:éµKðAƒÍ\îÿ´ž eà'_Œ໩âlg'ò›Èm/!7|ü¾p7z‘¯T@ß5å—0 KÕÞ¹Àg†öƒ ú@/fHN|ׯ@b bÁÃÈú8X‹lü,yf} ºÚ ®ú•ˆU; )U1·o»bSµ j€~Ú¦‚aS2!&A”8¼/‡‚û ¿Ž7ªhu¯Ž.@ùó0¿D=¿_oo nIøý/© Ió”è70è¦FÞ§¬&%ÀýÁ¶,Ô*}t â—ƒ{Ë#ÿ$'Ï@ütbÅËʾç?ÈuO„Ú j&Á¡DèºÎK î-T㎉E4| )épá,ò;·Ûí³ôˆµ¿…¨!ÊÎ7ÿ¼Èö3ˆiÙ0ý6X°“Ô¾¹ò8önðôB°ÚSjOEÑšÅNi 0ýÈÚ-ˆg<0c&”T@Ãe]· ùßKˆ» .²ó ;©Þzäæç¡³-Tû³™R[åt:iºÝy±è„·‹,, å4âÑçÝEBÛY8{Z5˜öðîFô÷A¬¦¤ƒÐK]àä?‘úÓð»upíjèLñ©,ñ<«÷…" ^?aReÁ ÀAO/¬YŽØü–±áHKCî}K7ÿÙ¼V='N†´ èhß@$.:4Á}žr½säFp"jÊw^ùÆqo?%Š…føä$¢äâþ2HÍ€÷€°O6àƒžËà75E)iנس\o™FÌ„ë*õj¬þ”î{YU†¬¢üI´¿…ܹ㠦!bò¦¦Qà©Ð[Ç¢&âX¾¶Æ])àWHTÿ]º í…ŸAÖ­Ê`Їu×W ëâXq;¤dÍúgõÚ± "20¼Ö¯Ð·k·að:µobÝ3¹u‹2pÄ!}rô¸nÒ,TjÝäN$9Là¿¡k“{rÀâAMP*a¦Öri.©išÜ[ï—ËÊÎ h“Ш™ì÷¼¨7O$éç0 Ë•Lg§$3ó3Çãÿ¼ G®ÿ.Á½8<ßÇIEND®B`‚././@LongLink0000000000000000000000000000015500000000000011216 Lustar 00000000000000photutils-0.2.1/astropy_helpers/astropy_helpers/sphinx/themes/bootstrap-astropy/static/bootstrap-astropy.cssphotutils-0.2.1/astropy_helpers/astropy_helpers/sphinx/themes/bootstrap-astropy/static/bootstrap-ast0000600000214200020070000002712012606736443036731 0ustar lbradleySTSCI\science00000000000000/*! * Bootstrap v1.4.0 * * Copyright 2011 Twitter, Inc * Licensed under the Apache License v2.0 * http://www.apache.org/licenses/LICENSE-2.0 * * Heavily modified by Kyle Barbary for the AstroPy Project for use with Sphinx. */ @import url("basic.css"); body { background-color: #ffffff; margin: 0; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px; font-weight: normal; line-height: 18px; color: #404040; } /* Hyperlinks ----------------------------------------------------------------*/ a { color: #0069d6; text-decoration: none; line-height: inherit; font-weight: inherit; } a:hover { color: #00438a; text-decoration: underline; } /* Typography ----------------------------------------------------------------*/ h1,h2,h3,h4,h5,h6 { color: #404040; margin: 0.7em 0 0 0; line-height: 1.5em; } h1 { font-size: 24px; margin: 0; } h2 { font-size: 21px; line-height: 1.2em; margin: 1em 0 0.5em 0; border-bottom: 1px solid #404040; } h3 { font-size: 18px; } h4 { font-size: 16px; } h5 { font-size: 14px; } h6 { font-size: 13px; text-transform: uppercase; } p { font-size: 13px; font-weight: normal; line-height: 18px; margin-top: 0px; margin-bottom: 9px; } ul, ol { margin-left: 0; padding: 0 0 0 25px; } ul ul, ul ol, ol ol, ol ul { margin-bottom: 0; } ul { list-style: disc; } ol { list-style: decimal; } li { line-height: 18px; color: #404040; } ul.unstyled { list-style: none; margin-left: 0; } dl { margin-bottom: 18px; } dl dt, dl dd { line-height: 18px; } dl dd { margin-left: 9px; } hr { margin: 20px 0 19px; border: 0; border-bottom: 1px solid #eee; } strong { font-style: inherit; font-weight: bold; } em { font-style: italic; font-weight: inherit; line-height: inherit; } .muted { color: #bfbfbf; } address { display: block; line-height: 18px; margin-bottom: 18px; } code, pre { padding: 0 3px 2px; font-family: monospace; -webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px; } tt { font-family: monospace; } code { padding: 1px 3px; } pre { display: block; padding: 8.5px; margin: 0 0 18px; line-height: 18px; border: 1px solid #ddd; border: 1px solid rgba(0, 0, 0, 0.12); -webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px; white-space: pre; word-wrap: break-word; } img { margin: 9px 0; } /* format inline code with a rounded box */ tt, code { margin: 0 2px; padding: 0 5px; border: 1px solid #ddd; border: 1px solid rgba(0, 0, 0, 0.12); border-radius: 3px; } code.xref, a code { margin: 0; padding: 0 1px 0 1px; background-color: none; border: none; } /* all code has same box background color, even in headers */ h1 tt, h2 tt, h3 tt, h4 tt, h5 tt, h6 tt, h1 code, h2 code, h3 code, h4 code, h5 code, h6 code, pre, code, tt { background-color: #f8f8f8; } /* override box for links & other sphinx-specifc stuff */ tt.xref, a tt, tt.descname, tt.descclassname { padding: 0 1px 0 1px; border: none; } /* override box for related bar at the top of the page */ .related tt { border: none; padding: 0 1px 0 1px; background-color: transparent; font-weight: bold; } th { background-color: #dddddd; } .viewcode-back { font-family: sans-serif; } div.viewcode-block:target { background-color: #f4debf; border-top: 1px solid #ac9; border-bottom: 1px solid #ac9; } table.docutils { border-spacing: 5px; border-collapse: separate; } /* Topbar --------------------------------------------------------------------*/ div.topbar { height: 40px; position: absolute; top: 0; left: 0; right: 0; z-index: 10000; padding: 0px 10px; background-color: #222; background-color: #222222; background-repeat: repeat-x; background-image: -khtml-gradient(linear, left top, left bottom, from(#333333), to(#222222)); background-image: -moz-linear-gradient(top, #333333, #222222); background-image: -ms-linear-gradient(top, #333333, #222222); background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #333333), color-stop(100%, #222222)); background-image: -webkit-linear-gradient(top, #333333, #222222); background-image: -o-linear-gradient(top, #333333, #222222); background-image: linear-gradient(top, #333333, #222222); filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#333333', endColorstr='#222222', GradientType=0); } div.topbar a.brand { font-family: 'Source Sans Pro', sans-serif; font-size: 26px; color: #ffffff; font-weight: 600; text-decoration: none; float: left; display: block; height: 32px; padding: 8px 12px 0px 45px; margin-left: -10px; background: transparent url("astropy_logo_32.png") no-repeat 10px 4px; background-image: url("astropy_logo.svg"), none; background-size: 32px 32px; } #logotext1 { } #logotext2 { font-weight:200; color: #ff5000; } #logotext3 { font-weight:200; } div.topbar .brand:hover, div.topbar ul li a.homelink:hover { background-color: #333; background-color: rgba(255, 255, 255, 0.05); } div.topbar ul { font-size: 110%; list-style: none; margin: 0; padding: 0 0 0 10px; float: right; color: #bfbfbf; text-align: center; text-decoration: none; height: 100%; } div.topbar ul li { float: left; display: inline; height: 30px; margin: 5px; padding: 0px; } div.topbar ul li a { color: #bfbfbf; text-decoration: none; padding: 5px; display: block; height: auto; text-align: center; vertical-align: middle; border-radius: 4px; } div.topbar ul li a:hover { color: #ffffff; text-decoration: none; } div.topbar ul li a.homelink { width: 112px; display: block; height: 20px; padding: 5px 0px; background: transparent url("astropy_linkout_20.png") no-repeat 10px 5px; background-image: url("astropy_linkout.svg"), none; background-size: 91px 20px; } div.topbar form { text-align: left; margin: 0 0 0 5px; position: relative; filter: alpha(opacity=100); -khtml-opacity: 1; -moz-opacity: 1; opacity: 1; } div.topbar input { background-color: #444; background-color: rgba(255, 255, 255, 0.3); font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: normal; font-weight: 13px; line-height: 1; padding: 4px 9px; color: #ffffff; color: rgba(255, 255, 255, 0.75); border: 1px solid #111; -webkit-border-radius: 4px; -moz-border-radius: 4px; border-radius: 4px; -webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1), 0 1px 0px rgba(255, 255, 255, 0.25); -moz-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1), 0 1px 0px rgba(255, 255, 255, 0.25); box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1), 0 1px 0px rgba(255, 255, 255, 0.25); -webkit-transition: none; -moz-transition: none; -ms-transition: none; -o-transition: none; transition: none; } div.topbar input:-moz-placeholder { color: #e6e6e6; } div.topbar input::-webkit-input-placeholder { color: #e6e6e6; } div.topbar input:hover { background-color: #bfbfbf; background-color: rgba(255, 255, 255, 0.5); color: #ffffff; } div.topbar input:focus, div.topbar input.focused { outline: 0; background-color: #ffffff; color: #404040; text-shadow: 0 1px 0 #ffffff; border: 0; padding: 5px 10px; -webkit-box-shadow: 0 0 3px rgba(0, 0, 0, 0.15); -moz-box-shadow: 0 0 3px rgba(0, 0, 0, 0.15); box-shadow: 0 0 3px rgba(0, 0, 0, 0.15); } /* Relation bar (breadcrumbs, prev, next) ------------------------------------*/ div.related { height: 21px; width: auto; margin: 0 10px; position: absolute; top: 42px; clear: both; left: 0; right: 0; z-index: 10000; font-size: 100%; vertical-align: middle; background-color: #fff; border-bottom: 1px solid #bbb; } div.related ul { padding: 0; margin: 0; } /* Footer --------------------------------------------------------------------*/ footer { display: block; margin: 10px 10px 0px; padding: 10px 0 0 0; border-top: 1px solid #bbb; } .pull-right { float: right; width: 30em; text-align: right; } /* Sphinx sidebar ------------------------------------------------------------*/ div.sphinxsidebar { font-size: inherit; border-radius: 3px; background-color: #eee; border: 1px solid #bbb; } div.sphinxsidebarwrapper { padding: 0px 0px 0px 5px; } div.sphinxsidebar h3 { font-family: 'Trebuchet MS', sans-serif; font-size: 1.4em; font-weight: normal; margin: 5px 0px 0px 5px; padding: 0; line-height: 1.6em; } div.sphinxsidebar h4 { font-family: 'Trebuchet MS', sans-serif; font-size: 1.3em; font-weight: normal; margin: 5px 0 0 0; padding: 0; } div.sphinxsidebar p { } div.sphinxsidebar p.topless { margin: 5px 10px 10px 10px; } div.sphinxsidebar ul { margin: 0px 0px 0px 5px; padding: 0; } div.sphinxsidebar ul ul { margin-left: 15px; list-style-type: disc; } /* If showing the global TOC (toctree), color the current page differently */ div.sphinxsidebar a.current { color: #404040; } div.sphinxsidebar a.current:hover { color: #404040; } /* document, documentwrapper, body, bodywrapper ----------------------------- */ div.document { margin-top: 72px; margin-left: 10px; margin-right: 10px; } div.documentwrapper { float: left; width: 100%; } div.body { background-color: #ffffff; padding: 0 0 0px 20px; } div.bodywrapper { margin: 0 0 0 230px; max-width: 55em; } /* Header links ------------------------------------------------------------- */ a.headerlink { font-size: 0.8em; padding: 0 4px 0 4px; text-decoration: none; } a.headerlink:hover { background-color: #0069d6; color: white; text-docoration: none; } /* Admonitions and warnings ------------------------------------------------- */ /* Shared by admonitions and warnings */ div.admonition, div.warning { padding: 0px; border-radius: 3px; -moz-border-radius: 3px; -webkit-border-radius: 3px; } div.admonition p, div.warning p { margin: 0.5em 1em 0.5em 1em; padding: 0; } div.admonition pre, div.warning pre { margin: 0.4em 1em 0.4em 1em; } div.admonition p.admonition-title, div.warning p.admonition-title { margin: 0; padding: 0.1em 0 0.1em 0.5em; color: white; font-weight: bold; font-size: 1.1em; } div.admonition ul, div.admonition ol, div.warning ul, div.warning ol { margin: 0.1em 0.5em 0.5em 3em; padding: 0; } /* Admonitions only */ div.admonition { border: 1px solid #609060; background-color: #e9ffe9; } div.admonition p.admonition-title { background-color: #70A070; } /* Warnings only */ div.warning { border: 1px solid #900000; background-color: #ffe9e9; } div.warning p.admonition-title { background-color: #b04040; } /* Figures ------------------------------------------------------------------ */ .figure.align-center { clear: none; } /* This is a div for containing multiple figures side-by-side, for use with * .. container:: figures */ div.figures { border: 1px solid #CCCCCC; background-color: #F8F8F8; margin: 1em; text-align: center; } div.figures .figure { clear: none; float: none; display: inline-block; border: none; margin-left: 0.5em; margin-right: 0.5em; } .field-list th { white-space: nowrap; } table.field-list { border-spacing: 0px; margin-left: 1px; border-left: 5px solid rgb(238, 238, 238) !important; } table.field-list th.field-name { display: inline-block; padding: 1px 8px 1px 5px; white-space: nowrap; background-color: rgb(238, 238, 238); border-radius: 0 3px 3px 0; -webkit-border-radius: 0 3px 3px 0; } photutils-0.2.1/astropy_helpers/astropy_helpers/sphinx/themes/bootstrap-astropy/static/copybutton.js0000600000214200020070000000467712346164025036754 0ustar lbradleySTSCI\science00000000000000$(document).ready(function() { /* Add a [>>>] button on the top-right corner of code samples to hide * the >>> and ... prompts and the output and thus make the code * copyable. */ var div = $('.highlight-python .highlight,' + '.highlight-python3 .highlight') var pre = div.find('pre'); // get the styles from the current theme pre.parent().parent().css('position', 'relative'); var hide_text = 'Hide the prompts and output'; var show_text = 'Show the prompts and output'; var border_width = pre.css('border-top-width'); var border_style = pre.css('border-top-style'); var border_color = pre.css('border-top-color'); var button_styles = { 'cursor':'pointer', 'position': 'absolute', 'top': '0', 'right': '0', 'border-color': border_color, 'border-style': border_style, 'border-width': border_width, 'color': border_color, 'text-size': '75%', 'font-family': 'monospace', 'padding-left': '0.2em', 'padding-right': '0.2em', 'border-radius': '0 3px 0 0' } // create and add the button to all the code blocks that contain >>> div.each(function(index) { var jthis = $(this); if (jthis.find('.gp').length > 0) { var button = $('>>>'); button.css(button_styles) button.attr('title', hide_text); jthis.prepend(button); } // tracebacks (.gt) contain bare text elements that need to be // wrapped in a span to work with .nextUntil() (see later) jthis.find('pre:has(.gt)').contents().filter(function() { return ((this.nodeType == 3) && (this.data.trim().length > 0)); }).wrap(''); }); // define the behavior of the button when it's clicked $('.copybutton').toggle( function() { var button = $(this); button.parent().find('.go, .gp, .gt').hide(); button.next('pre').find('.gt').nextUntil('.gp, .go').css('visibility', 'hidden'); button.css('text-decoration', 'line-through'); button.attr('title', show_text); }, function() { var button = $(this); button.parent().find('.go, .gp, .gt').show(); button.next('pre').find('.gt').nextUntil('.gp, .go').css('visibility', 'visible'); button.css('text-decoration', 'none'); button.attr('title', hide_text); }); }); photutils-0.2.1/astropy_helpers/astropy_helpers/sphinx/themes/bootstrap-astropy/static/sidebar.js0000600000214200020070000001155312346164025036146 0ustar lbradleySTSCI\science00000000000000/* * sidebar.js * ~~~~~~~~~~ * * This script makes the Sphinx sidebar collapsible. * * .sphinxsidebar contains .sphinxsidebarwrapper. This script adds * in .sphixsidebar, after .sphinxsidebarwrapper, the #sidebarbutton * used to collapse and expand the sidebar. * * When the sidebar is collapsed the .sphinxsidebarwrapper is hidden * and the width of the sidebar and the margin-left of the document * are decreased. When the sidebar is expanded the opposite happens. * This script saves a per-browser/per-session cookie used to * remember the position of the sidebar among the pages. * Once the browser is closed the cookie is deleted and the position * reset to the default (expanded). * * :copyright: Copyright 2007-2011 by the Sphinx team, see AUTHORS. * :license: BSD, see LICENSE for details. * */ $(function() { // global elements used by the functions. // the 'sidebarbutton' element is defined as global after its // creation, in the add_sidebar_button function var bodywrapper = $('.bodywrapper'); var sidebar = $('.sphinxsidebar'); var sidebarwrapper = $('.sphinxsidebarwrapper'); // for some reason, the document has no sidebar; do not run into errors if (!sidebar.length) return; // original margin-left of the bodywrapper and width of the sidebar // with the sidebar expanded var bw_margin_expanded = bodywrapper.css('margin-left'); var ssb_width_expanded = sidebar.width(); // margin-left of the bodywrapper and width of the sidebar // with the sidebar collapsed var bw_margin_collapsed = 12; var ssb_width_collapsed = 12; // custom colors var dark_color = '#404040'; var light_color = '#505050'; function sidebar_is_collapsed() { return sidebarwrapper.is(':not(:visible)'); } function toggle_sidebar() { if (sidebar_is_collapsed()) expand_sidebar(); else collapse_sidebar(); } function collapse_sidebar() { sidebarwrapper.hide(); sidebar.css('width', ssb_width_collapsed); bodywrapper.css('margin-left', bw_margin_collapsed); sidebarbutton.css({ 'margin-left': '-1px', 'height': bodywrapper.height(), 'border-radius': '3px' }); sidebarbutton.find('span').text('»'); sidebarbutton.attr('title', _('Expand sidebar')); document.cookie = 'sidebar=collapsed'; } function expand_sidebar() { bodywrapper.css('margin-left', bw_margin_expanded); sidebar.css('width', ssb_width_expanded); sidebarwrapper.show(); sidebarbutton.css({ 'margin-left': ssb_width_expanded - 12, 'height': bodywrapper.height(), 'border-radius': '0px 3px 3px 0px' }); sidebarbutton.find('span').text('«'); sidebarbutton.attr('title', _('Collapse sidebar')); document.cookie = 'sidebar=expanded'; } function add_sidebar_button() { sidebarwrapper.css({ 'float': 'left', 'margin-right': '0', 'width': ssb_width_expanded - 18 }); // create the button sidebar.append('
    «
    '); var sidebarbutton = $('#sidebarbutton'); // find the height of the viewport to center the '<<' in the page var viewport_height; if (window.innerHeight) viewport_height = window.innerHeight; else viewport_height = $(window).height(); var sidebar_offset = sidebar.offset().top; var sidebar_height = Math.max(bodywrapper.height(), sidebar.height()); sidebarbutton.find('span').css({ 'font-family': '"Lucida Grande",Arial,sans-serif', 'display': 'block', 'top': Math.min(viewport_height/2, sidebar_height/2 + sidebar_offset) - 10, 'width': 12, 'position': 'fixed', 'text-align': 'center' }); sidebarbutton.click(toggle_sidebar); sidebarbutton.attr('title', _('Collapse sidebar')); sidebarbutton.css({ 'color': '#FFFFFF', 'background-color': light_color, 'border': '1px solid ' + light_color, 'border-radius': '0px 3px 3px 0px', 'font-size': '1.2em', 'cursor': 'pointer', 'height': sidebar_height, 'padding-top': '1px', 'margin': '-1px', 'margin-left': ssb_width_expanded - 12 }); sidebarbutton.hover( function () { $(this).css('background-color', dark_color); }, function () { $(this).css('background-color', light_color); } ); } function set_position_from_cookie() { if (!document.cookie) return; var items = document.cookie.split(';'); for(var k=0; k= (3, 3): import importlib importlib.invalidate_caches() @pytest.fixture(scope='function', autouse=True) def reset_setup_helpers(request): """ Saves and restores the global state of the astropy_helpers.setup_helpers module between tests. """ mod = __import__('astropy_helpers.setup_helpers', fromlist=['']) old_state = mod._module_state.copy() def finalizer(old_state=old_state): mod = sys.modules.get('astropy_helpers.setup_helpers') if mod is not None: mod._module_state.update(old_state) request.addfinalizer(finalizer) @pytest.fixture(scope='function', autouse=True) def reset_distutils_log(): """ This is a setup/teardown fixture that ensures the log-level of the distutils log is always set to a default of WARN, since different settings could affect tests that check the contents of stdout. """ from distutils import log log.set_threshold(log.WARN) @pytest.fixture(scope='module', autouse=True) def fix_hide_setuptools(): """ Workaround for https://github.com/astropy/astropy-helpers/issues/124 In setuptools 10.0 run_setup was changed in such a way that it sweeps away the existing setuptools import before running the setup script. In principle this is nice, but in the practice of testing astropy_helpers this is problematic since we're trying to test code that has already been imported during the testing process, and which relies on the setuptools module that was already in use. """ if hasattr(sandbox, 'hide_setuptools'): sandbox.hide_setuptools = lambda: None TEST_PACKAGE_SETUP_PY = """\ #!/usr/bin/env python from setuptools import setup NAME = 'astropy-helpers-test' VERSION = {version!r} setup(name=NAME, version=VERSION, packages=['_astropy_helpers_test_'], zip_safe=False) """ @pytest.fixture def testpackage(tmpdir, version='0.1'): """ This fixture creates a simplified package called _astropy_helpers_test_ used primarily for testing ah_boostrap, but without using the astropy_helpers package directly and getting it confused with the astropy_helpers package already under test. """ source = tmpdir.mkdir('testpkg') with source.as_cwd(): source.mkdir('_astropy_helpers_test_') init = source.join('_astropy_helpers_test_', '__init__.py') init.write('__version__ = {0!r}'.format(version)) setup_py = TEST_PACKAGE_SETUP_PY.format(version=version) source.join('setup.py').write(setup_py) # Make the new test package into a git repo run_cmd('git', ['init']) run_cmd('git', ['add', '--all']) run_cmd('git', ['commit', '-m', 'test package']) return source def cleanup_import(package_name): """Remove all references to package_name from sys.modules""" for k in list(sys.modules): if not isinstance(k, str): # Some things will actually do this =_= continue elif k.startswith('astropy_helpers.tests'): # Don't delete imported test modules or else the tests will break, # badly continue if k == package_name or k.startswith(package_name + '.'): del sys.modules[k] photutils-0.2.1/astropy_helpers/astropy_helpers/tests/coveragerc0000600000214200020070000000110412632702120027562 0ustar lbradleySTSCI\science00000000000000[run] source = astropy_helpers omit = astropy_helpers/commands/_test_compat.py astropy_helpers/compat/* astropy_helpers/*/setup_package.py [report] exclude_lines = # Have to re-enable the standard pragma pragma: no cover # Don't complain about packages we have installed except ImportError # Don't complain if tests don't hit assertions raise AssertionError raise NotImplementedError # Don't complain about script hooks def main\(.*\): # Ignore branches that don't pertain to this version of Python pragma: py{ignore_python_version} photutils-0.2.1/astropy_helpers/astropy_helpers/tests/test_ah_bootstrap.py0000600000214200020070000003434012477406130031636 0ustar lbradleySTSCI\science00000000000000# -*- coding: utf-8 -*- import glob import os import textwrap import sys from distutils.version import StrictVersion import setuptools from setuptools.package_index import PackageIndex import pytest from . import * from ..utils import silence TEST_SETUP_PY = """\ #!/usr/bin/env python from __future__ import print_function import os import sys import ah_bootstrap # reset the name of the package installed by ah_boostrap to # _astropy_helpers_test_--this will prevent any confusion by pkg_resources with # any already installed packages named astropy_helpers # We also disable auto-upgrade by default ah_bootstrap.DIST_NAME = 'astropy-helpers-test' ah_bootstrap.PACKAGE_NAME = '_astropy_helpers_test_' ah_bootstrap.AUTO_UPGRADE = False ah_bootstrap.DOWNLOAD_IF_NEEDED = False try: ah_bootstrap.BOOTSTRAPPER = ah_bootstrap._Bootstrapper.main() ah_bootstrap.use_astropy_helpers({args}) finally: ah_bootstrap.DIST_NAME = 'astropy-helpers' ah_bootstrap.PACKAGE_NAME = 'astropy_helpers' ah_bootstrap.AUTO_UPGRADE = True ah_bootstrap.DOWNLOAD_IF_NEEDED = True # Kind of a hacky way to do this, but this assertion is specifically # for test_check_submodule_no_git # TODO: Rework the tests in this module so that it's easier to test specific # behaviors of ah_bootstrap for each test assert '--no-git' not in sys.argv import _astropy_helpers_test_ filename = os.path.abspath(_astropy_helpers_test_.__file__) filename = filename.replace('.pyc', '.py') # More consistent this way print(filename) """ # The behavior checked in some of the tests depends on the version of # setuptools try: SETUPTOOLS_VERSION = StrictVersion(setuptools.__version__).version except: # Broken setuptools? ¯\_(ツ)_/¯ SETUPTOOLS_VERSION = (0, 0, 0) def test_bootstrap_from_submodule(tmpdir, testpackage, capsys): """ Tests importing _astropy_helpers_test_ from a submodule in a git repository. This tests actually performing a fresh clone of the repository without the submodule initialized, and that importing astropy_helpers in that context works transparently after calling `ah_boostrap.use_astropy_helpers`. """ orig_repo = tmpdir.mkdir('orig') # Ensure ah_bootstrap is imported from the local directory import ah_bootstrap with orig_repo.as_cwd(): run_cmd('git', ['init']) # Write a test setup.py that uses ah_bootstrap; it also ensures that # any previous reference to astropy_helpers is first wiped from # sys.modules orig_repo.join('setup.py').write(TEST_SETUP_PY.format(args='')) run_cmd('git', ['add', 'setup.py']) # Add our own clone of the astropy_helpers repo as a submodule named # astropy_helpers run_cmd('git', ['submodule', 'add', str(testpackage), '_astropy_helpers_test_']) run_cmd('git', ['commit', '-m', 'test repository']) os.chdir(str(tmpdir)) # Creates a clone of our test repo in the directory 'clone' run_cmd('git', ['clone', 'orig', 'clone']) os.chdir('clone') run_setup('setup.py', []) stdout, stderr = capsys.readouterr() path = stdout.strip() # Ensure that the astropy_helpers used by the setup.py is the one that # was imported from git submodule a = os.path.normcase(path) b = os.path.normcase(str(tmpdir.join('clone', '_astropy_helpers_test_', '_astropy_helpers_test_', '__init__.py'))) assert a == b def test_bootstrap_from_submodule_no_locale(tmpdir, testpackage, capsys, monkeypatch): """ Regression test for https://github.com/astropy/astropy/issues/2749 Runs test_bootstrap_from_submodule but with missing locale/language settings. """ for varname in ('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE'): monkeypatch.delenv(varname, raising=False) test_bootstrap_from_submodule(tmpdir, testpackage, capsys) def test_bootstrap_from_submodule_bad_locale(tmpdir, testpackage, capsys, monkeypatch): """ Additional regression test for https://github.com/astropy/astropy/issues/2749 """ for varname in ('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE'): monkeypatch.delenv(varname, raising=False) # Test also with bad LC_CTYPE a la http://bugs.python.org/issue18378 monkeypatch.setenv('LC_CTYPE', 'UTF-8') test_bootstrap_from_submodule(tmpdir, testpackage, capsys) def test_check_submodule_no_git(tmpdir, testpackage): """ Tests that when importing astropy_helpers from a submodule, it is still recognized as a submodule even when using the --no-git option. In particular this ensures that the auto-upgrade feature is not activated. """ orig_repo = tmpdir.mkdir('orig') # Ensure ah_bootstrap is imported from the local directory import ah_bootstrap with orig_repo.as_cwd(): run_cmd('git', ['init']) # Write a test setup.py that uses ah_bootstrap; it also ensures that # any previous reference to astropy_helpers is first wiped from # sys.modules args = 'auto_upgrade=True' orig_repo.join('setup.py').write(TEST_SETUP_PY.format(args=args)) run_cmd('git', ['add', 'setup.py']) # Add our own clone of the astropy_helpers repo as a submodule named # astropy_helpers run_cmd('git', ['submodule', 'add', str(testpackage), '_astropy_helpers_test_']) run_cmd('git', ['commit', '-m', 'test repository']) # Temporarily patch _do_upgrade to fail if called class UpgradeError(Exception): pass def _do_upgrade(*args, **kwargs): raise UpgradeError() orig_do_upgrade = ah_bootstrap._Bootstrapper._do_upgrade ah_bootstrap._Bootstrapper._do_upgrade = _do_upgrade try: run_setup('setup.py', ['--no-git']) except UpgradeError: pytest.fail('Attempted to run auto-upgrade despite importing ' '_astropy_helpers_test_ from a git submodule') finally: ah_bootstrap._Bootstrapper._do_upgrade = orig_do_upgrade # Ensure that the no-git option was in fact set assert not ah_bootstrap.BOOTSTRAPPER.use_git def test_bootstrap_from_directory(tmpdir, testpackage, capsys): """ Tests simply bundling a copy of the astropy_helpers source code in its entirety bundled directly in the source package and not in an archive. """ import ah_bootstrap source = tmpdir.mkdir('source') testpackage.copy(source.join('_astropy_helpers_test_')) with source.as_cwd(): source.join('setup.py').write(TEST_SETUP_PY.format(args='')) run_setup('setup.py', []) stdout, stderr = capsys.readouterr() stdout = stdout.splitlines() if stdout: path = stdout[-1].strip() else: path = '' # Ensure that the astropy_helpers used by the setup.py is the one that # was imported from git submodule a = os.path.normcase(path) b = os.path.normcase(str(source.join('_astropy_helpers_test_', '_astropy_helpers_test_', '__init__.py'))) assert a == b def test_bootstrap_from_archive(tmpdir, testpackage, capsys): """ Tests importing _astropy_helpers_test_ from a .tar.gz source archive shipped alongside the package that uses it. """ orig_repo = tmpdir.mkdir('orig') # Ensure ah_bootstrap is imported from the local directory import ah_bootstrap # Make a source distribution of the test package with silence(): run_setup(str(testpackage.join('setup.py')), ['sdist', '--dist-dir=dist', '--formats=gztar']) dist_dir = testpackage.join('dist') for dist_file in dist_dir.visit('*.tar.gz'): dist_file.copy(orig_repo) with orig_repo.as_cwd(): # Write a test setup.py that uses ah_bootstrap; it also ensures that # any previous reference to astropy_helpers is first wiped from # sys.modules args = 'path={0!r}'.format(os.path.basename(str(dist_file))) orig_repo.join('setup.py').write(TEST_SETUP_PY.format(args=args)) run_setup('setup.py', []) stdout, stderr = capsys.readouterr() path = stdout.splitlines()[-1].strip() # Installation from the .tar.gz should have resulted in a .egg # directory that the _astropy_helpers_test_ package was imported from eggs = _get_local_eggs() assert eggs egg = orig_repo.join(eggs[0]) assert os.path.isdir(str(egg)) a = os.path.normcase(path) b = os.path.normcase(str(egg.join('_astropy_helpers_test_', '__init__.py'))) assert a == b def test_download_if_needed(tmpdir, testpackage, capsys): """ Tests the case where astropy_helpers was not actually included in a package, or is otherwise missing, and we need to "download" it. This does not test actually downloading from the internet--this is normally done through setuptools' easy_install command which can also install from a source archive. From the point of view of ah_boostrap the two actions are equivalent, so we can just as easily simulate this by providing a setup.cfg giving the path to a source archive to "download" (as though it were a URL). """ source = tmpdir.mkdir('source') # Ensure ah_bootstrap is imported from the local directory import ah_bootstrap # Make a source distribution of the test package with silence(): run_setup(str(testpackage.join('setup.py')), ['sdist', '--dist-dir=dist', '--formats=gztar']) dist_dir = testpackage.join('dist') with source.as_cwd(): source.join('setup.py').write(TEST_SETUP_PY.format( args='download_if_needed=True')) source.join('setup.cfg').write(textwrap.dedent("""\ [easy_install] find_links = {find_links} """.format(find_links=str(dist_dir)))) run_setup('setup.py', []) stdout, stderr = capsys.readouterr() # Just take the last line--on Python 2.6 distutils logs warning # messages to stdout instead of stderr, causing them to be mixed up # with our expected output path = stdout.splitlines()[-1].strip() # easy_install should have worked by 'installing' astropy_helpers as a # .egg in the current directory eggs = _get_local_eggs() assert eggs egg = source.join(eggs[0]) assert os.path.isdir(str(egg)) a = os.path.normcase(path) b = os.path.normcase(str(egg.join('_astropy_helpers_test_', '__init__.py'))) assert a == b def test_upgrade(tmpdir, capsys): # Run the testpackage fixture manually, since we use it multiple times in # this test to make different versions of _astropy_helpers_test_ orig_dir = testpackage(tmpdir.mkdir('orig')) # Make a test package that uses _astropy_helpers_test_ source = tmpdir.mkdir('source') dist_dir = source.mkdir('dists') orig_dir.copy(source.join('_astropy_helpers_test_')) with source.as_cwd(): setup_py = TEST_SETUP_PY.format(args='auto_upgrade=True') source.join('setup.py').write(setup_py) # This will be used to later to fake downloading the upgrade package source.join('setup.cfg').write(textwrap.dedent("""\ [easy_install] find_links = {find_links} """.format(find_links=str(dist_dir)))) # Make additional "upgrade" versions of the _astropy_helpers_test_ # package--one of them is version 0.2 and the other is version 0.1.1. The # auto-upgrade should ignore version 0.2 but use version 0.1.1. upgrade_dir_1 = testpackage(tmpdir.mkdir('upgrade_1'), version='0.2') upgrade_dir_2 = testpackage(tmpdir.mkdir('upgrade_2'), version='0.1.1') dists = [] # For each upgrade package go ahead and build a source distribution of it # and copy that source distribution to a dist directory we'll use later to # simulate a 'download' for upgrade_dir in [upgrade_dir_1, upgrade_dir_2]: with silence(): run_setup(str(upgrade_dir.join('setup.py')), ['sdist', '--dist-dir=dist', '--formats=gztar']) dists.append(str(upgrade_dir.join('dist'))) for dist_file in upgrade_dir.visit('*.tar.gz'): dist_file.copy(source.join('dists')) # Monkey with the PackageIndex in ah_bootstrap so that it is initialized # with the test upgrade packages, and so that it does not actually go out # to the internet to look for anything import ah_bootstrap class FakePackageIndex(PackageIndex): def __init__(self, *args, **kwargs): PackageIndex.__init__(self, *args, **kwargs) self.to_scan = dists def find_packages(self, requirement): # no-op pass ah_bootstrap.PackageIndex = FakePackageIndex try: with source.as_cwd(): # Now run the source setup.py; this test is similar to # test_download_if_needed, but we explicitly check that the correct # *version* of _astropy_helpers_test_ was used run_setup('setup.py', []) stdout, stderr = capsys.readouterr() path = stdout.splitlines()[-1].strip() eggs = _get_local_eggs() assert eggs egg = source.join(eggs[0]) assert os.path.isdir(str(egg)) a = os.path.normcase(path) b = os.path.normcase(str(egg.join('_astropy_helpers_test_', '__init__.py'))) assert a == b assert 'astropy_helpers_test-0.1.1-' in str(egg) finally: ah_bootstrap.PackageIndex = PackageIndex def _get_local_eggs(path='.'): """ Helper utility used by some tests to get the list of egg archive files in a local directory. """ if SETUPTOOLS_VERSION[0] >= 7: eggs = glob.glob(os.path.join(path, '.eggs', '*.egg')) else: eggs = glob.glob('*.egg') return eggs photutils-0.2.1/astropy_helpers/astropy_helpers/tests/test_git_helpers.py0000600000214200020070000001627412477406130031464 0ustar lbradleySTSCI\science00000000000000import glob import imp import os import pkgutil import re import sys import tarfile from . import * PY3 = sys.version_info[0] == 3 if PY3: _text_type = str else: _text_type = unicode _DEV_VERSION_RE = re.compile(r'\d+\.\d+(?:\.\d+)?\.dev(\d+)') TEST_VERSION_SETUP_PY = """\ #!/usr/bin/env python from setuptools import setup NAME = '_eva_' VERSION = {version!r} RELEASE = 'dev' not in VERSION from astropy_helpers.git_helpers import get_git_devstr from astropy_helpers.version_helpers import generate_version_py if not RELEASE: VERSION += get_git_devstr(False) generate_version_py(NAME, VERSION, RELEASE, False, uses_git=not RELEASE) setup(name=NAME, version=VERSION, packages=['_eva_']) """ TEST_VERSION_INIT = """\ try: from .version import version as __version__ from .version import githash as __githash__ except ImportError: __version__ = __githash__ = '' """ @pytest.fixture def version_test_package(tmpdir, request): def make_test_package(version='42.42.dev'): test_package = tmpdir.mkdir('test_package') test_package.join('setup.py').write( TEST_VERSION_SETUP_PY.format(version=version)) test_package.mkdir('_eva_').join('__init__.py').write(TEST_VERSION_INIT) with test_package.as_cwd(): run_cmd('git', ['init']) run_cmd('git', ['add', '--all']) run_cmd('git', ['commit', '-m', 'test package']) if '' in sys.path: sys.path.remove('') sys.path.insert(0, '') def finalize(): cleanup_import('_eva_') request.addfinalizer(finalize) return test_package return make_test_package def test_update_git_devstr(version_test_package, capsys): """Tests that the commit number in the package's version string updates after git commits even without re-running setup.py. """ # We have to call version_test_package to actually create the package test_pkg = version_test_package() with test_pkg.as_cwd(): run_setup('setup.py', ['--version']) stdout, stderr = capsys.readouterr() version = stdout.strip() m = _DEV_VERSION_RE.match(version) assert m, ( "Stdout did not match the version string pattern:" "\n\n{0}\n\nStderr:\n\n{1}".format(stdout, stderr)) revcount = int(m.group(1)) import _eva_ assert _eva_.__version__ == version # Make a silly git commit with open('.test', 'w'): pass run_cmd('git', ['add', '.test']) run_cmd('git', ['commit', '-m', 'test']) import _eva_.version imp.reload(_eva_.version) # Previously this checked packagename.__version__, but in order for that to # be updated we also have to re-import _astropy_init which could be tricky. # Checking directly that the packagename.version module was updated is # sufficient: m = _DEV_VERSION_RE.match(_eva_.version.version) assert m assert int(m.group(1)) == revcount + 1 # This doesn't test astropy_helpers.get_helpers.update_git_devstr directly # since a copy of that function is made in packagename.version (so that it # can work without astropy_helpers installed). In order to get test # coverage on the actual astropy_helpers copy of that function just call it # directly and compare to the value in packagename from astropy_helpers.git_helpers import update_git_devstr newversion = update_git_devstr(version, path=str(test_pkg)) assert newversion == _eva_.version.version def test_version_update_in_other_repos(version_test_package, tmpdir): """ Regression test for https://github.com/astropy/astropy-helpers/issues/114 and for https://github.com/astropy/astropy-helpers/issues/107 """ test_pkg = version_test_package() with test_pkg.as_cwd(): run_setup('setup.py', ['build']) # Add the path to the test package to sys.path for now sys.path.insert(0, str(test_pkg)) try: import _eva_ m = _DEV_VERSION_RE.match(_eva_.__version__) assert m correct_revcount = int(m.group(1)) with tmpdir.as_cwd(): testrepo = tmpdir.mkdir('testrepo') testrepo.chdir() # Create an empty git repo run_cmd('git', ['init']) import _eva_.version imp.reload(_eva_.version) m = _DEV_VERSION_RE.match(_eva_.version.version) assert m assert int(m.group(1)) == correct_revcount correct_revcount = int(m.group(1)) # Add several commits--more than the revcount for the _eva_ package for idx in range(correct_revcount + 5): test_filename = '.test' + str(idx) testrepo.ensure(test_filename) run_cmd('git', ['add', test_filename]) run_cmd('git', ['commit', '-m', 'A message']) import _eva_.version imp.reload(_eva_.version) m = _DEV_VERSION_RE.match(_eva_.version.version) assert m assert int(m.group(1)) == correct_revcount correct_revcount = int(m.group(1)) finally: sys.path.remove(str(test_pkg)) @pytest.mark.parametrize('version', ['1.0.dev', '1.0']) def test_installed_git_version(version_test_package, version, tmpdir, capsys): """ Test for https://github.com/astropy/astropy-helpers/issues/87 Ensures that packages installed with astropy_helpers have a correct copy of the git hash of the installed commit. """ # To test this, it should suffice to build a source dist, unpack it # somewhere outside the git repository, and then do a build and import # from the build directory--no need to "install" as such test_pkg = version_test_package(version) with test_pkg.as_cwd(): run_setup('setup.py', ['build']) try: import _eva_ githash = _eva_.__githash__ assert githash and isinstance(githash, _text_type) # Ensure that it does in fact look like a git hash and not some # other arbitrary string assert re.match(r'[0-9a-f]{40}', githash) finally: cleanup_import('_eva_') run_setup('setup.py', ['sdist', '--dist-dir=dist', '--formats=gztar']) tgzs = glob.glob(os.path.join('dist', '*.tar.gz')) assert len(tgzs) == 1 tgz = test_pkg.join(tgzs[0]) build_dir = tmpdir.mkdir('build_dir') tf = tarfile.open(str(tgz), mode='r:gz') tf.extractall(str(build_dir)) with build_dir.as_cwd(): pkg_dir = glob.glob('_eva_-*')[0] os.chdir(pkg_dir) run_setup('setup.py', ['build']) try: import _eva_ loader = pkgutil.get_loader('_eva_') # Ensure we are importing the 'packagename' that was just unpacked # into the build_dir if sys.version_info[:2] != (3, 3): # Skip this test on Python 3.3 wherein the SourceFileLoader # has a bug where get_filename() does not return an absolute # path assert loader.get_filename().startswith(str(build_dir)) assert _eva_.__githash__ == githash finally: cleanup_import('_eva_') photutils-0.2.1/astropy_helpers/astropy_helpers/tests/test_setup_helpers.py0000600000214200020070000003626512632702254032042 0ustar lbradleySTSCI\science00000000000000import contextlib import shutil import stat import sys from textwrap import dedent from setuptools import Distribution from ..setup_helpers import get_package_info, register_commands from ..commands import build_ext from . import * def _extension_test_package(tmpdir, request, extension_type='c'): """Creates a simple test package with an extension module.""" test_pkg = tmpdir.mkdir('test_pkg') test_pkg.mkdir('_eva_').ensure('__init__.py') # TODO: It might be later worth making this particular test package into a # reusable fixture for other build_ext tests if extension_type in ('c', 'both'): # A minimal C extension for testing test_pkg.join('_eva_', 'unit01.c').write(dedent("""\ #include #ifndef PY3K #if PY_MAJOR_VERSION >= 3 #define PY3K 1 #else #define PY3K 0 #endif #endif #if PY3K static struct PyModuleDef moduledef = { PyModuleDef_HEAD_INIT, "unit01", NULL, -1, NULL }; PyMODINIT_FUNC PyInit_unit01(void) { return PyModule_Create(&moduledef); } #else PyMODINIT_FUNC initunit01(void) { Py_InitModule3("unit01", NULL, NULL); } #endif """)) if extension_type in ('pyx', 'both'): # A minimal Cython extension for testing test_pkg.join('_eva_', 'unit02.pyx').write(dedent("""\ print("Hello cruel angel.") """)) if extension_type == 'c': extensions = ['unit01.c'] elif extension_type == 'pyx': extensions = ['unit02.pyx'] elif extension_type == 'both': extensions = ['unit01.c', 'unit02.pyx'] extensions_list = [ "Extension('_eva_.{0}', [join('_eva_', '{1}')])".format( os.path.splitext(extension)[0], extension) for extension in extensions] test_pkg.join('_eva_', 'setup_package.py').write(dedent("""\ from setuptools import Extension from os.path import join def get_extensions(): return [{0}] """.format(', '.join(extensions_list)))) test_pkg.join('setup.py').write(dedent("""\ from os.path import join from setuptools import setup from astropy_helpers.setup_helpers import register_commands from astropy_helpers.setup_helpers import get_package_info from astropy_helpers.version_helpers import generate_version_py NAME = '_eva_' VERSION = '0.1' RELEASE = True cmdclassd = register_commands(NAME, VERSION, RELEASE) generate_version_py(NAME, VERSION, RELEASE, False, False) package_info = get_package_info() setup( name=NAME, version=VERSION, cmdclass=cmdclassd, **package_info ) """)) if '' in sys.path: sys.path.remove('') sys.path.insert(0, '') def finalize(): cleanup_import('_eva_') request.addfinalizer(finalize) return test_pkg @pytest.fixture def extension_test_package(tmpdir, request): return _extension_test_package(tmpdir, request, extension_type='both') @pytest.fixture def c_extension_test_package(tmpdir, request): return _extension_test_package(tmpdir, request, extension_type='c') @pytest.fixture def pyx_extension_test_package(tmpdir, request): return _extension_test_package(tmpdir, request, extension_type='pyx') def test_cython_autoextensions(tmpdir): """ Regression test for https://github.com/astropy/astropy-helpers/pull/19 Ensures that Cython extensions in sub-packages are discovered and built only once. """ # Make a simple test package test_pkg = tmpdir.mkdir('test_pkg') test_pkg.mkdir('yoda').mkdir('luke') test_pkg.ensure('yoda', '__init__.py') test_pkg.ensure('yoda', 'luke', '__init__.py') test_pkg.join('yoda', 'luke', 'dagobah.pyx').write( """def testfunc(): pass""") # Required, currently, for get_package_info to work register_commands('yoda', '0.0', False, srcdir=str(test_pkg)) package_info = get_package_info(str(test_pkg)) assert len(package_info['ext_modules']) == 1 assert package_info['ext_modules'][0].name == 'yoda.luke.dagobah' def test_compiler_module(c_extension_test_package): """ Test ensuring that the compiler module is built and installed for packages that have extension modules. """ test_pkg = c_extension_test_package install_temp = test_pkg.mkdir('install_temp') with test_pkg.as_cwd(): # This is one of the simplest ways to install just a package into a # test directory run_setup('setup.py', ['install', '--single-version-externally-managed', '--install-lib={0}'.format(install_temp), '--record={0}'.format(install_temp.join('record.txt'))]) with install_temp.as_cwd(): import _eva_ # Make sure we imported the _eva_ package from the correct place dirname = os.path.abspath(os.path.dirname(_eva_.__file__)) assert dirname == str(install_temp.join('_eva_')) import _eva_._compiler import _eva_.version assert _eva_.version.compiler == _eva_._compiler.compiler assert _eva_.version.compiler != 'unknown' def test_no_cython_buildext(c_extension_test_package, monkeypatch): """ Regression test for https://github.com/astropy/astropy-helpers/pull/35 This tests the custom build_ext command installed by astropy_helpers when used with a project that has no Cython extensions (but does have one or more normal C extensions). """ test_pkg = c_extension_test_package # In order for this test to test the correct code path we need to fool # build_ext into thinking we don't have Cython installed monkeypatch.setattr(build_ext, 'should_build_with_cython', lambda *args: False) with test_pkg.as_cwd(): run_setup('setup.py', ['build_ext', '--inplace']) sys.path.insert(0, str(test_pkg)) try: import _eva_.unit01 dirname = os.path.abspath(os.path.dirname(_eva_.unit01.__file__)) assert dirname == str(test_pkg.join('_eva_')) finally: sys.path.remove(str(test_pkg)) def test_missing_cython_c_files(pyx_extension_test_package, monkeypatch): """ Regression test for https://github.com/astropy/astropy-helpers/pull/181 Test failure mode when building a package that has Cython modules, but where Cython is not installed and the generated C files are missing. """ test_pkg = pyx_extension_test_package # In order for this test to test the correct code path we need to fool # build_ext into thinking we don't have Cython installed monkeypatch.setattr(build_ext, 'should_build_with_cython', lambda *args: False) with test_pkg.as_cwd(): with pytest.raises(SystemExit) as exc_info: run_setup('setup.py', ['build_ext', '--inplace']) msg = ('Could not find C/C++ file ' '{0}.(c/cpp)'.format('_eva_/unit02'.replace('/', os.sep))) assert msg in str(exc_info.value) @pytest.mark.parametrize('mode', ['cli', 'cli-w', 'direct']) def test_build_sphinx(tmpdir, mode): """ Test for build_sphinx """ import astropy_helpers ah_path = os.path.dirname(astropy_helpers.__file__) test_pkg = tmpdir.mkdir('test_pkg') test_pkg.mkdir('mypackage') test_pkg.join('mypackage').join('__init__.py').write(dedent("""\ def test_function(): pass class A(): pass class B(A): pass """)) docs = test_pkg.mkdir('docs') autosummary = docs.mkdir('_templates').mkdir('autosummary') autosummary.join('base.rst').write('{% extends "autosummary_core/base.rst" %}') autosummary.join('class.rst').write('{% extends "autosummary_core/class.rst" %}') autosummary.join('module.rst').write('{% extends "autosummary_core/module.rst" %}') docs_dir = test_pkg.join('docs') docs_dir.join('conf.py').write(dedent("""\ import sys sys.path.append("../") import warnings with warnings.catch_warnings(): # ignore matplotlib warning warnings.simplefilter("ignore") from astropy_helpers.sphinx.conf import * exclude_patterns.append('_templates') """)) docs_dir.join('index.rst').write(dedent("""\ .. automodapi:: mypackage """)) test_pkg.join('setup.py').write(dedent("""\ from os.path import join from setuptools import setup, Extension from astropy_helpers.setup_helpers import register_commands, get_package_info NAME = 'mypackage' VERSION = 0.1 RELEASE = True cmdclassd = register_commands(NAME, VERSION, RELEASE) setup( name=NAME, version=VERSION, cmdclass=cmdclassd, **get_package_info() ) """)) with test_pkg.as_cwd(): shutil.copytree(ah_path, 'astropy_helpers') if mode == 'cli': run_setup('setup.py', ['build_sphinx']) elif mode == 'cli-w': run_setup('setup.py', ['build_sphinx', '-w']) elif mode == 'direct': # to check coverage with docs_dir.as_cwd(): from sphinx import main try: main(['-b html', '-d _build/doctrees', '.', '_build/html']) except SystemExit as exc: assert exc.code == 0 def test_command_hooks(tmpdir, capsys): """A basic test for pre- and post-command hooks.""" test_pkg = tmpdir.mkdir('test_pkg') test_pkg.mkdir('_welltall_') test_pkg.join('_welltall_', '__init__.py').ensure() # Create a setup_package module with a couple of command hooks in it test_pkg.join('_welltall_', 'setup_package.py').write(dedent("""\ def pre_build_hook(cmd_obj): print('Hello build!') def post_build_hook(cmd_obj): print('Goodbye build!') """)) # A simple setup.py for the test package--running register_commands should # discover and enable the command hooks test_pkg.join('setup.py').write(dedent("""\ from os.path import join from setuptools import setup, Extension from astropy_helpers.setup_helpers import register_commands, get_package_info NAME = '_welltall_' VERSION = 0.1 RELEASE = True cmdclassd = register_commands(NAME, VERSION, RELEASE) setup( name=NAME, version=VERSION, cmdclass=cmdclassd ) """)) with test_pkg.as_cwd(): try: run_setup('setup.py', ['build']) finally: cleanup_import('_welltall_') stdout, stderr = capsys.readouterr() want = dedent("""\ running build running pre_hook from _welltall_.setup_package for build command Hello build! running post_hook from _welltall_.setup_package for build command Goodbye build! """).strip() assert want in stdout def test_adjust_compiler(monkeypatch, tmpdir): """ Regression test for https://github.com/astropy/astropy-helpers/issues/182 """ from distutils import ccompiler, sysconfig class MockLog(object): def __init__(self): self.messages = [] def warn(self, message): self.messages.append(message) good = tmpdir.join('gcc-good') good.write(dedent("""\ #!{python} import sys print('gcc 4.10') sys.exit(0) """.format(python=sys.executable))) good.chmod(stat.S_IRUSR | stat.S_IEXEC) # A "compiler" that reports itself to be a version of Apple's llvm-gcc # which is broken bad = tmpdir.join('gcc-bad') bad.write(dedent("""\ #!{python} import sys print('i686-apple-darwin-llvm-gcc-4.2') sys.exit(0) """.format(python=sys.executable))) bad.chmod(stat.S_IRUSR | stat.S_IEXEC) # A "compiler" that doesn't even know its identity (this reproduces the bug # in #182) ugly = tmpdir.join('gcc-ugly') ugly.write(dedent("""\ #!{python} import sys sys.exit(1) """.format(python=sys.executable))) ugly.chmod(stat.S_IRUSR | stat.S_IEXEC) # Scripts with shebang lines don't work implicitly in Windows when passed # to subprocess.Popen, so... if 'win' in sys.platform: good = ' '.join((sys.executable, str(good))) bad = ' '.join((sys.executable, str(bad))) ugly = ' '.join((sys.executable, str(ugly))) dist = Distribution({}) cmd_cls = build_ext.generate_build_ext_command('astropy', False) cmd = cmd_cls(dist) adjust_compiler = cmd._adjust_compiler @contextlib.contextmanager def test_setup(): log = MockLog() monkeypatch.setattr(build_ext, 'log', log) yield log monkeypatch.undo() @contextlib.contextmanager def compiler_setter_with_environ(compiler): monkeypatch.setenv('CC', compiler) with test_setup() as log: yield log monkeypatch.undo() @contextlib.contextmanager def compiler_setter_with_sysconfig(compiler): monkeypatch.setattr(ccompiler, 'get_default_compiler', lambda: 'unix') monkeypatch.setattr(sysconfig, 'get_config_var', lambda v: compiler) old_cc = os.environ.get('CC') if old_cc is not None: del os.environ['CC'] with test_setup() as log: yield log monkeypatch.undo() monkeypatch.undo() monkeypatch.undo() if old_cc is not None: os.environ['CC'] = old_cc compiler_setters = (compiler_setter_with_environ, compiler_setter_with_sysconfig) for compiler_setter in compiler_setters: with compiler_setter(str(good)): # Should have no side-effects adjust_compiler() with compiler_setter(str(ugly)): # Should just pass without complaint, since we can't determine # anything about the compiler anyways adjust_compiler() # In the following tests we check the log messages just to ensure that the # failures occur on the correct code paths for these cases with compiler_setter_with_environ(str(bad)) as log: with pytest.raises(SystemExit): adjust_compiler() assert len(log.messages) == 1 assert 'will fail to compile' in log.messages[0] with compiler_setter_with_sysconfig(str(bad)): adjust_compiler() assert 'CC' in os.environ and os.environ['CC'] == 'clang' with compiler_setter_with_environ('bogus') as log: with pytest.raises(SystemExit): # Missing compiler? adjust_compiler() assert len(log.messages) == 1 assert 'cannot be found or executed' in log.messages[0] with compiler_setter_with_sysconfig('bogus') as log: with pytest.raises(SystemExit): # Missing compiler? adjust_compiler() assert len(log.messages) == 1 assert 'The C compiler used to compile Python' in log.messages[0] photutils-0.2.1/astropy_helpers/astropy_helpers/tests/test_utils.py0000600000214200020070000000135712632702254030312 0ustar lbradleySTSCI\science00000000000000import os from ..utils import find_data_files def test_find_data_files(tmpdir): data = tmpdir.mkdir('data') sub1 = data.mkdir('sub1') sub2 = data.mkdir('sub2') sub3 = sub1.mkdir('sub3') for directory in (data, sub1, sub2, sub3): filename = directory.join('data.dat').strpath with open(filename, 'w') as f: f.write('test') filenames = find_data_files(data.strpath, '**/*.dat') filenames = sorted(os.path.relpath(x, data.strpath) for x in filenames) assert filenames[0] == os.path.join('data.dat') assert filenames[1] == os.path.join('sub1', 'data.dat') assert filenames[2] == os.path.join('sub1', 'sub3', 'data.dat') assert filenames[3] == os.path.join('sub2', 'data.dat') photutils-0.2.1/astropy_helpers/astropy_helpers/utils.py0000600000214200020070000006646212632702254026121 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst from __future__ import absolute_import, unicode_literals import contextlib import functools import imp import inspect import os import sys import glob import textwrap import types import warnings try: from importlib import machinery as import_machinery # Python 3.2 does not have SourceLoader if not hasattr(import_machinery, 'SourceLoader'): import_machinery = None except ImportError: import_machinery = None # Python 3.3's importlib caches filesystem reads for faster imports in the # general case. But sometimes it's necessary to manually invalidate those # caches so that the import system can pick up new generated files. See # https://github.com/astropy/astropy/issues/820 if sys.version_info[:2] >= (3, 3): from importlib import invalidate_caches else: invalidate_caches = lambda: None # Python 2/3 compatibility if sys.version_info[0] < 3: string_types = (str, unicode) else: string_types = (str,) # Note: The following Warning subclasses are simply copies of the Warnings in # Astropy of the same names. class AstropyWarning(Warning): """ The base warning class from which all Astropy warnings should inherit. Any warning inheriting from this class is handled by the Astropy logger. """ class AstropyDeprecationWarning(AstropyWarning): """ A warning class to indicate a deprecated feature. """ class AstropyPendingDeprecationWarning(PendingDeprecationWarning, AstropyWarning): """ A warning class to indicate a soon-to-be deprecated feature. """ def _get_platlib_dir(cmd): """ Given a build command, return the name of the appropriate platform-specific build subdirectory directory (e.g. build/lib.linux-x86_64-2.7) """ plat_specifier = '.{0}-{1}'.format(cmd.plat_name, sys.version[0:3]) return os.path.join(cmd.build_base, 'lib' + plat_specifier) def get_numpy_include_path(): """ Gets the path to the numpy headers. """ # We need to go through this nonsense in case setuptools # downloaded and installed Numpy for us as part of the build or # install, since Numpy may still think it's in "setup mode", when # in fact we're ready to use it to build astropy now. if sys.version_info[0] >= 3: import builtins if hasattr(builtins, '__NUMPY_SETUP__'): del builtins.__NUMPY_SETUP__ import imp import numpy imp.reload(numpy) else: import __builtin__ if hasattr(__builtin__, '__NUMPY_SETUP__'): del __builtin__.__NUMPY_SETUP__ import numpy reload(numpy) try: numpy_include = numpy.get_include() except AttributeError: numpy_include = numpy.get_numpy_include() return numpy_include class _DummyFile(object): """A noop writeable object.""" errors = '' # Required for Python 3.x def write(self, s): pass def flush(self): pass @contextlib.contextmanager def silence(): """A context manager that silences sys.stdout and sys.stderr.""" old_stdout = sys.stdout old_stderr = sys.stderr sys.stdout = _DummyFile() sys.stderr = _DummyFile() exception_occurred = False try: yield except: exception_occurred = True # Go ahead and clean up so that exception handling can work normally sys.stdout = old_stdout sys.stderr = old_stderr raise if not exception_occurred: sys.stdout = old_stdout sys.stderr = old_stderr if sys.platform == 'win32': import ctypes def _has_hidden_attribute(filepath): """ Returns True if the given filepath has the hidden attribute on MS-Windows. Based on a post here: http://stackoverflow.com/questions/284115/cross-platform-hidden-file-detection """ if isinstance(filepath, bytes): filepath = filepath.decode(sys.getfilesystemencoding()) try: attrs = ctypes.windll.kernel32.GetFileAttributesW(filepath) assert attrs != -1 result = bool(attrs & 2) except (AttributeError, AssertionError): result = False return result else: def _has_hidden_attribute(filepath): return False def is_path_hidden(filepath): """ Determines if a given file or directory is hidden. Parameters ---------- filepath : str The path to a file or directory Returns ------- hidden : bool Returns `True` if the file is hidden """ name = os.path.basename(os.path.abspath(filepath)) if isinstance(name, bytes): is_dotted = name.startswith(b'.') else: is_dotted = name.startswith('.') return is_dotted or _has_hidden_attribute(filepath) def walk_skip_hidden(top, onerror=None, followlinks=False): """ A wrapper for `os.walk` that skips hidden files and directories. This function does not have the parameter `topdown` from `os.walk`: the directories must always be recursed top-down when using this function. See also -------- os.walk : For a description of the parameters """ for root, dirs, files in os.walk( top, topdown=True, onerror=onerror, followlinks=followlinks): # These lists must be updated in-place so os.walk will skip # hidden directories dirs[:] = [d for d in dirs if not is_path_hidden(d)] files[:] = [f for f in files if not is_path_hidden(f)] yield root, dirs, files def write_if_different(filename, data): """Write `data` to `filename`, if the content of the file is different. Parameters ---------- filename : str The file name to be written to. data : bytes The data to be written to `filename`. """ assert isinstance(data, bytes) if os.path.exists(filename): with open(filename, 'rb') as fd: original_data = fd.read() else: original_data = None if original_data != data: with open(filename, 'wb') as fd: fd.write(data) def import_file(filename, name=None): """ Imports a module from a single file as if it doesn't belong to a particular package. The returned module will have the optional ``name`` if given, or else a name generated from the filename. """ # Specifying a traditional dot-separated fully qualified name here # results in a number of "Parent module 'astropy' not found while # handling absolute import" warnings. Using the same name, the # namespaces of the modules get merged together. So, this # generates an underscore-separated name which is more likely to # be unique, and it doesn't really matter because the name isn't # used directly here anyway. mode = 'U' if sys.version_info[0] < 3 else 'r' if name is None: basename = os.path.splitext(filename)[0] name = '_'.join(os.path.relpath(basename).split(os.sep)[1:]) if import_machinery: loader = import_machinery.SourceFileLoader(name, filename) mod = loader.load_module() else: with open(filename, mode) as fd: mod = imp.load_module(name, fd, filename, ('.py', mode, 1)) return mod def resolve_name(name): """Resolve a name like ``module.object`` to an object and return it. Raise `ImportError` if the module or name is not found. """ parts = name.split('.') cursor = len(parts) - 1 module_name = parts[:cursor] attr_name = parts[-1] while cursor > 0: try: ret = __import__('.'.join(module_name), fromlist=[attr_name]) break except ImportError: if cursor == 0: raise cursor -= 1 module_name = parts[:cursor] attr_name = parts[cursor] ret = '' for part in parts[cursor:]: try: ret = getattr(ret, part) except AttributeError: raise ImportError(name) return ret if sys.version_info[0] >= 3: def iteritems(dictionary): return dictionary.items() else: def iteritems(dictionary): return dictionary.iteritems() def extends_doc(extended_func): """ A function decorator for use when wrapping an existing function but adding additional functionality. This copies the docstring from the original function, and appends to it (along with a newline) the docstring of the wrapper function. Example ------- >>> def foo(): ... '''Hello.''' ... >>> @extends_doc(foo) ... def bar(): ... '''Goodbye.''' ... >>> print(bar.__doc__) Hello. Goodbye. """ def decorator(func): if not (extended_func.__doc__ is None or func.__doc__ is None): func.__doc__ = '\n\n'.join([extended_func.__doc__.rstrip('\n'), func.__doc__.lstrip('\n')]) return func return decorator # Duplicated from astropy.utils.decorators.deprecated # When fixing issues in this function fix them in astropy first, then # port the fixes over to astropy-helpers def deprecated(since, message='', name='', alternative='', pending=False, obj_type=None): """ Used to mark a function or class as deprecated. To mark an attribute as deprecated, use `deprecated_attribute`. Parameters ------------ since : str The release at which this API became deprecated. This is required. message : str, optional Override the default deprecation message. The format specifier ``func`` may be used for the name of the function, and ``alternative`` may be used in the deprecation message to insert the name of an alternative to the deprecated function. ``obj_type`` may be used to insert a friendly name for the type of object being deprecated. name : str, optional The name of the deprecated function or class; if not provided the name is automatically determined from the passed in function or class, though this is useful in the case of renamed functions, where the new function is just assigned to the name of the deprecated function. For example:: def new_function(): ... oldFunction = new_function alternative : str, optional An alternative function or class name that the user may use in place of the deprecated object. The deprecation warning will tell the user about this alternative if provided. pending : bool, optional If True, uses a AstropyPendingDeprecationWarning instead of a AstropyDeprecationWarning. obj_type : str, optional The type of this object, if the automatically determined one needs to be overridden. """ method_types = (classmethod, staticmethod, types.MethodType) def deprecate_doc(old_doc, message): """ Returns a given docstring with a deprecation message prepended to it. """ if not old_doc: old_doc = '' old_doc = textwrap.dedent(old_doc).strip('\n') new_doc = (('\n.. deprecated:: %(since)s' '\n %(message)s\n\n' % {'since': since, 'message': message.strip()}) + old_doc) if not old_doc: # This is to prevent a spurious 'unexpected unindent' warning from # docutils when the original docstring was blank. new_doc += r'\ ' return new_doc def get_function(func): """ Given a function or classmethod (or other function wrapper type), get the function object. """ if isinstance(func, method_types): try: func = func.__func__ except AttributeError: # classmethods in Python2.6 and below lack the __func__ # attribute so we need to hack around to get it method = func.__get__(None, object) if isinstance(method, types.FunctionType): # For staticmethods anyways the wrapped object is just a # plain function (not a bound method or anything like that) func = method elif hasattr(method, '__func__'): func = method.__func__ elif hasattr(method, 'im_func'): func = method.im_func else: # Nothing we can do really... just return the original # classmethod, etc. return func return func def deprecate_function(func, message): """ Returns a wrapped function that displays an ``AstropyDeprecationWarning`` when it is called. """ if isinstance(func, method_types): func_wrapper = type(func) else: func_wrapper = lambda f: f func = get_function(func) def deprecated_func(*args, **kwargs): if pending: category = AstropyPendingDeprecationWarning else: category = AstropyDeprecationWarning warnings.warn(message, category, stacklevel=2) return func(*args, **kwargs) # If this is an extension function, we can't call # functools.wraps on it, but we normally don't care. # This crazy way to get the type of a wrapper descriptor is # straight out of the Python 3.3 inspect module docs. if type(func) != type(str.__dict__['__add__']): deprecated_func = functools.wraps(func)(deprecated_func) deprecated_func.__doc__ = deprecate_doc( deprecated_func.__doc__, message) return func_wrapper(deprecated_func) def deprecate_class(cls, message): """ Returns a wrapper class with the docstrings updated and an __init__ function that will raise an ``AstropyDeprectationWarning`` warning when called. """ # Creates a new class with the same name and bases as the # original class, but updates the dictionary with a new # docstring and a wrapped __init__ method. __module__ needs # to be manually copied over, since otherwise it will be set # to *this* module (astropy.utils.misc). # This approach seems to make Sphinx happy (the new class # looks enough like the original class), and works with # extension classes (which functools.wraps does not, since # it tries to modify the original class). # We need to add a custom pickler or you'll get # Can't pickle : it's not found as ... # errors. Picklability is required for any class that is # documented by Sphinx. members = cls.__dict__.copy() members.update({ '__doc__': deprecate_doc(cls.__doc__, message), '__init__': deprecate_function(get_function(cls.__init__), message), }) return type(cls.__name__, cls.__bases__, members) def deprecate(obj, message=message, name=name, alternative=alternative, pending=pending): if obj_type is None: if isinstance(obj, type): obj_type_name = 'class' elif inspect.isfunction(obj): obj_type_name = 'function' elif inspect.ismethod(obj) or isinstance(obj, method_types): obj_type_name = 'method' else: obj_type_name = 'object' else: obj_type_name = obj_type if not name: name = get_function(obj).__name__ altmessage = '' if not message or type(message) == type(deprecate): if pending: message = ('The %(func)s %(obj_type)s will be deprecated in a ' 'future version.') else: message = ('The %(func)s %(obj_type)s is deprecated and may ' 'be removed in a future version.') if alternative: altmessage = '\n Use %s instead.' % alternative message = ((message % { 'func': name, 'name': name, 'alternative': alternative, 'obj_type': obj_type_name}) + altmessage) if isinstance(obj, type): return deprecate_class(obj, message) else: return deprecate_function(obj, message) if type(message) == type(deprecate): return deprecate(message) return deprecate def deprecated_attribute(name, since, message=None, alternative=None, pending=False): """ Used to mark a public attribute as deprecated. This creates a property that will warn when the given attribute name is accessed. To prevent the warning (i.e. for internal code), use the private name for the attribute by prepending an underscore (i.e. ``self._name``). Parameters ---------- name : str The name of the deprecated attribute. since : str The release at which this API became deprecated. This is required. message : str, optional Override the default deprecation message. The format specifier ``name`` may be used for the name of the attribute, and ``alternative`` may be used in the deprecation message to insert the name of an alternative to the deprecated function. alternative : str, optional An alternative attribute that the user may use in place of the deprecated attribute. The deprecation warning will tell the user about this alternative if provided. pending : bool, optional If True, uses a AstropyPendingDeprecationWarning instead of a AstropyDeprecationWarning. Examples -------- :: class MyClass: # Mark the old_name as deprecated old_name = misc.deprecated_attribute('old_name', '0.1') def method(self): self._old_name = 42 """ private_name = '_' + name @deprecated(since, name=name, obj_type='attribute') def get(self): return getattr(self, private_name) @deprecated(since, name=name, obj_type='attribute') def set(self, val): setattr(self, private_name, val) @deprecated(since, name=name, obj_type='attribute') def delete(self): delattr(self, private_name) return property(get, set, delete) def minversion(module, version, inclusive=True, version_path='__version__'): """ Returns `True` if the specified Python module satisfies a minimum version requirement, and `False` if not. By default this uses `pkg_resources.parse_version` to do the version comparison if available. Otherwise it falls back on `distutils.version.LooseVersion`. Parameters ---------- module : module or `str` An imported module of which to check the version, or the name of that module (in which case an import of that module is attempted-- if this fails `False` is returned). version : `str` The version as a string that this module must have at a minimum (e.g. ``'0.12'``). inclusive : `bool` The specified version meets the requirement inclusively (i.e. ``>=``) as opposed to strictly greater than (default: `True`). version_path : `str` A dotted attribute path to follow in the module for the version. Defaults to just ``'__version__'``, which should work for most Python modules. Examples -------- >>> import astropy >>> minversion(astropy, '0.4.4') True """ if isinstance(module, types.ModuleType): module_name = module.__name__ elif isinstance(module, string_types): module_name = module try: module = resolve_name(module_name) except ImportError: return False else: raise ValueError('module argument must be an actual imported ' 'module, or the import name of the module; ' 'got {0!r}'.format(module)) if '.' not in version_path: have_version = getattr(module, version_path) else: have_version = resolve_name('.'.join([module.__name__, version_path])) try: from pkg_resources import parse_version except ImportError: from distutils.version import LooseVersion as parse_version if inclusive: return parse_version(have_version) >= parse_version(version) else: return parse_version(have_version) > parse_version(version) # Copy of the classproperty decorator from astropy.utils.decorators class classproperty(property): """ Similar to `property`, but allows class-level properties. That is, a property whose getter is like a `classmethod`. The wrapped method may explicitly use the `classmethod` decorator (which must become before this decorator), or the `classmethod` may be omitted (it is implicit through use of this decorator). .. note:: classproperty only works for *read-only* properties. It does not currently allow writeable/deleteable properties, due to subtleties of how Python descriptors work. In order to implement such properties on a class a metaclass for that class must be implemented. Parameters ---------- fget : callable The function that computes the value of this property (in particular, the function when this is used as a decorator) a la `property`. doc : str, optional The docstring for the property--by default inherited from the getter function. lazy : bool, optional If True, caches the value returned by the first call to the getter function, so that it is only called once (used for lazy evaluation of an attribute). This is analogous to `lazyproperty`. The ``lazy`` argument can also be used when `classproperty` is used as a decorator (see the third example below). When used in the decorator syntax this *must* be passed in as a keyword argument. Examples -------- :: >>> class Foo(object): ... _bar_internal = 1 ... @classproperty ... def bar(cls): ... return cls._bar_internal + 1 ... >>> Foo.bar 2 >>> foo_instance = Foo() >>> foo_instance.bar 2 >>> foo_instance._bar_internal = 2 >>> foo_instance.bar # Ignores instance attributes 2 As previously noted, a `classproperty` is limited to implementing read-only attributes:: >>> class Foo(object): ... _bar_internal = 1 ... @classproperty ... def bar(cls): ... return cls._bar_internal ... @bar.setter ... def bar(cls, value): ... cls._bar_internal = value ... Traceback (most recent call last): ... NotImplementedError: classproperty can only be read-only; use a metaclass to implement modifiable class-level properties When the ``lazy`` option is used, the getter is only called once:: >>> class Foo(object): ... @classproperty(lazy=True) ... def bar(cls): ... print("Performing complicated calculation") ... return 1 ... >>> Foo.bar Performing complicated calculation 1 >>> Foo.bar 1 If a subclass inherits a lazy `classproperty` the property is still re-evaluated for the subclass:: >>> class FooSub(Foo): ... pass ... >>> FooSub.bar Performing complicated calculation 1 >>> FooSub.bar 1 """ def __new__(cls, fget=None, doc=None, lazy=False): if fget is None: # Being used as a decorator--return a wrapper that implements # decorator syntax def wrapper(func): return cls(func, lazy=lazy) return wrapper return super(classproperty, cls).__new__(cls) def __init__(self, fget, doc=None, lazy=False): self._lazy = lazy if lazy: self._cache = {} fget = self._wrap_fget(fget) super(classproperty, self).__init__(fget=fget, doc=doc) # There is a buglet in Python where self.__doc__ doesn't # get set properly on instances of property subclasses if # the doc argument was used rather than taking the docstring # from fget if doc is not None: self.__doc__ = doc def __get__(self, obj, objtype=None): if self._lazy and objtype in self._cache: return self._cache[objtype] if objtype is not None: # The base property.__get__ will just return self here; # instead we pass objtype through to the original wrapped # function (which takes the class as its sole argument) val = self.fget.__wrapped__(objtype) else: val = super(classproperty, self).__get__(obj, objtype=objtype) if self._lazy: if objtype is None: objtype = obj.__class__ self._cache[objtype] = val return val def getter(self, fget): return super(classproperty, self).getter(self._wrap_fget(fget)) def setter(self, fset): raise NotImplementedError( "classproperty can only be read-only; use a metaclass to " "implement modifiable class-level properties") def deleter(self, fdel): raise NotImplementedError( "classproperty can only be read-only; use a metaclass to " "implement modifiable class-level properties") @staticmethod def _wrap_fget(orig_fget): if isinstance(orig_fget, classmethod): orig_fget = orig_fget.__func__ # Using stock functools.wraps instead of the fancier version # found later in this module, which is overkill for this purpose @functools.wraps(orig_fget) def fget(obj): return orig_fget(obj.__class__) # Set the __wrapped__ attribute manually for support on Python 2 fget.__wrapped__ = orig_fget return fget def find_data_files(package, pattern): """ Include files matching ``pattern`` inside ``package``. Parameters ---------- package : str The package inside which to look for data files pattern : str Pattern (glob-style) to match for the data files (e.g. ``*.dat``). This supports the Python 3.5 ``**``recursive syntax. For example, ``**/*.fits`` matches all files ending with ``.fits`` recursively. Only one instance of ``**`` can be included in the pattern. """ if sys.version_info[:2] >= (3, 5): return glob.glob(os.path.join(package, pattern), recursive=True) else: if '**' in pattern: start, end = pattern.split('**') if end.startswith(('/', os.sep)): end = end[1:] matches = glob.glob(os.path.join(package, start, end)) for root, dirs, files in os.walk(os.path.join(package, start)): for dirname in dirs: matches += glob.glob(os.path.join(root, dirname, end)) return matches else: return glob.glob(os.path.join(package, pattern)) photutils-0.2.1/astropy_helpers/astropy_helpers/version.py0000600000214200020070000001242012464174242026432 0ustar lbradleySTSCI\science00000000000000# Autogenerated by Astropy-affiliated package astropy_helpers's setup.py on 2015-02-03 11:34:42.123563 import locale import os import subprocess import warnings def _decode_stdio(stream): try: stdio_encoding = locale.getdefaultlocale()[1] or 'utf-8' except ValueError: stdio_encoding = 'utf-8' try: text = stream.decode(stdio_encoding) except UnicodeDecodeError: # Final fallback text = stream.decode('latin1') return text def update_git_devstr(version, path=None): """ Updates the git revision string if and only if the path is being imported directly from a git working copy. This ensures that the revision number in the version string is accurate. """ try: # Quick way to determine if we're in git or not - returns '' if not devstr = get_git_devstr(sha=True, show_warning=False, path=path) except OSError: return version if not devstr: # Probably not in git so just pass silently return version if 'dev' in version: # update to the current git revision version_base = version.split('.dev', 1)[0] devstr = get_git_devstr(sha=False, show_warning=False, path=path) return version_base + '.dev' + devstr else: #otherwise it's already the true/release version return version def get_git_devstr(sha=False, show_warning=True, path=None): """ Determines the number of revisions in this repository. Parameters ---------- sha : bool If True, the full SHA1 hash will be returned. Otherwise, the total count of commits in the repository will be used as a "revision number". show_warning : bool If True, issue a warning if git returns an error code, otherwise errors pass silently. path : str or None If a string, specifies the directory to look in to find the git repository. If `None`, the current working directory is used. If given a filename it uses the directory containing that file. Returns ------- devversion : str Either a string with the revision number (if `sha` is False), the SHA1 hash of the current commit (if `sha` is True), or an empty string if git version info could not be identified. """ if path is None: path = os.getcwd() if not os.path.isdir(path): path = os.path.abspath(os.path.dirname(path)) if not os.path.exists(os.path.join(path, '.git')): return '' if sha: # Faster for getting just the hash of HEAD cmd = ['rev-parse', 'HEAD'] else: cmd = ['rev-list', '--count', 'HEAD'] def run_git(cmd): try: p = subprocess.Popen(['git'] + cmd, cwd=path, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE) stdout, stderr = p.communicate() except OSError as e: if show_warning: warnings.warn('Error running git: ' + str(e)) return (None, '', '') if p.returncode == 128: if show_warning: warnings.warn('No git repository present at {0!r}! Using ' 'default dev version.'.format(path)) return (p.returncode, '', '') if p.returncode == 129: if show_warning: warnings.warn('Your git looks old (does it support {0}?); ' 'consider upgrading to v1.7.2 or ' 'later.'.format(cmd[0])) return (p.returncode, stdout, stderr) elif p.returncode != 0: if show_warning: warnings.warn('Git failed while determining revision ' 'count: {0}'.format(_decode_stdio(stderr))) return (p.returncode, stdout, stderr) return p.returncode, stdout, stderr returncode, stdout, stderr = run_git(cmd) if not sha and returncode == 129: # git returns 129 if a command option failed to parse; in # particular this could happen in git versions older than 1.7.2 # where the --count option is not supported # Also use --abbrev-commit and --abbrev=0 to display the minimum # number of characters needed per-commit (rather than the full hash) cmd = ['rev-list', '--abbrev-commit', '--abbrev=0', 'HEAD'] returncode, stdout, stderr = run_git(cmd) # Fall back on the old method of getting all revisions and counting # the lines if returncode == 0: return str(stdout.count(b'\n')) else: return '' elif sha: return _decode_stdio(stdout)[:40] else: return _decode_stdio(stdout).strip() _last_generated_version = '0.4.4' _last_githash = u'ca3953a76d40fd16a0fe5a01b76ee526bb9a69b1' version = update_git_devstr(_last_generated_version) githash = get_git_devstr(sha=True, show_warning=False, path=__file__) or _last_githash major = 0 minor = 4 bugfix = 4 release = True debug = False try: from ._compiler import compiler except ImportError: compiler = "unknown" try: from .cython_version import cython_version except ImportError: cython_version = "unknown" photutils-0.2.1/astropy_helpers/astropy_helpers/version_helpers.py0000600000214200020070000002264412477406130030163 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst """ Utilities for generating the version string for Astropy (or an affiliated package) and the version.py module, which contains version info for the package. Within the generated astropy.version module, the `major`, `minor`, and `bugfix` variables hold the respective parts of the version number (bugfix is '0' if absent). The `release` variable is True if this is a release, and False if this is a development version of astropy. For the actual version string, use:: from astropy.version import version or:: from astropy import __version__ """ from __future__ import division import datetime import imp import os import pkgutil import sys from distutils import log import pkg_resources from . import git_helpers from .distutils_helpers import is_distutils_display_option from .utils import invalidate_caches PY3 = sys.version_info[0] == 3 def _version_split(version): """ Split a version string into major, minor, and bugfix numbers. If any of those numbers are missing the default is zero. Any pre/post release modifiers are ignored. Examples ======== >>> _version_split('1.2.3') (1, 2, 3) >>> _version_split('1.2') (1, 2, 0) >>> _version_split('1.2rc1') (1, 2, 0) >>> _version_split('1') (1, 0, 0) >>> _version_split('') (0, 0, 0) """ parsed_version = pkg_resources.parse_version(version) if hasattr(parsed_version, 'base_version'): # New version parsing for setuptools >= 8.0 if parsed_version.base_version: parts = [int(part) for part in parsed_version.base_version.split('.')] else: parts = [] else: parts = [] for part in parsed_version: if part.startswith('*'): # Ignore any .dev, a, b, rc, etc. break parts.append(int(part)) if len(parts) < 3: parts += [0] * (3 - len(parts)) # In principle a version could have more parts (like 1.2.3.4) but we only # support .. return tuple(parts[:3]) # This is used by setup.py to create a new version.py - see that file for # details. Note that the imports have to be absolute, since this is also used # by affiliated packages. _FROZEN_VERSION_PY_TEMPLATE = """ # Autogenerated by {packagetitle}'s setup.py on {timestamp!s} from __future__ import unicode_literals import datetime {header} major = {major} minor = {minor} bugfix = {bugfix} release = {rel} timestamp = {timestamp!r} debug = {debug} try: from ._compiler import compiler except ImportError: compiler = "unknown" try: from .cython_version import cython_version except ImportError: cython_version = "unknown" """[1:] _FROZEN_VERSION_PY_WITH_GIT_HEADER = """ {git_helpers} _packagename = "{packagename}" _last_generated_version = "{verstr}" _last_githash = "{githash}" # Determine where the source code for this module # lives. If __file__ is not a filesystem path then # it is assumed not to live in a git repo at all. if _get_repo_path(__file__, levels=len(_packagename.split('.'))): version = update_git_devstr(_last_generated_version, path=__file__) githash = get_git_devstr(sha=True, show_warning=False, path=__file__) or _last_githash else: # The file does not appear to live in a git repo so don't bother # invoking git version = _last_generated_version githash = _last_githash """[1:] _FROZEN_VERSION_PY_STATIC_HEADER = """ version = "{verstr}" githash = "{githash}" """[1:] def _get_version_py_str(packagename, version, githash, release, debug, uses_git=True): timestamp = datetime.datetime.now() major, minor, bugfix = _version_split(version) if packagename.lower() == 'astropy': packagetitle = 'Astropy' else: packagetitle = 'Astropy-affiliated package ' + packagename header = '' if uses_git: header = _generate_git_header(packagename, version, githash) elif not githash: # _generate_git_header will already generate a new git has for us, but # for creating a new version.py for a release (even if uses_git=False) # we still need to get the githash to include in the version.py # See https://github.com/astropy/astropy-helpers/issues/141 githash = git_helpers.get_git_devstr(sha=True, show_warning=True) if not header: # If _generate_git_header fails it returns an empty string header = _FROZEN_VERSION_PY_STATIC_HEADER.format(verstr=version, githash=githash) return _FROZEN_VERSION_PY_TEMPLATE.format(packagetitle=packagetitle, timestamp=timestamp, header=header, major=major, minor=minor, bugfix=bugfix, rel=release, debug=debug) def _generate_git_header(packagename, version, githash): """ Generates a header to the version.py module that includes utilities for probing the git repository for updates (to the current git hash, etc.) These utilities should only be available in development versions, and not in release builds. If this fails for any reason an empty string is returned. """ loader = pkgutil.get_loader(git_helpers) source = loader.get_source(git_helpers.__name__) or '' source_lines = source.splitlines() if not source_lines: log.warn('Cannot get source code for astropy_helpers.git_helpers; ' 'git support disabled.') return '' idx = 0 for idx, line in enumerate(source_lines): if line.startswith('# BEGIN'): break git_helpers_py = '\n'.join(source_lines[idx + 1:]) if PY3: verstr = version else: # In Python 2 don't pass in a unicode string; otherwise verstr will # be represented with u'' syntax which breaks on Python 3.x with x # < 3. This is only an issue when developing on multiple Python # versions at once verstr = version.encode('utf8') new_githash = git_helpers.get_git_devstr(sha=True, show_warning=False) if new_githash: githash = new_githash return _FROZEN_VERSION_PY_WITH_GIT_HEADER.format( git_helpers=git_helpers_py, packagename=packagename, verstr=verstr, githash=githash) def generate_version_py(packagename, version, release=None, debug=None, uses_git=True): """Regenerate the version.py module if necessary.""" try: version_module = get_pkg_version_module(packagename) try: last_generated_version = version_module._last_generated_version except AttributeError: last_generated_version = version_module.version try: last_githash = version_module._last_githash except AttributeError: last_githash = version_module.githash current_release = version_module.release current_debug = version_module.debug except ImportError: version_module = None last_generated_version = None last_githash = None current_release = None current_debug = None if release is None: # Keep whatever the current value is, if it exists release = bool(current_release) if debug is None: # Likewise, keep whatever the current value is, if it exists debug = bool(current_debug) version_py = os.path.join(packagename, 'version.py') if (last_generated_version != version or current_release != release or current_debug != debug): if '-q' not in sys.argv and '--quiet' not in sys.argv: log.set_threshold(log.INFO) if is_distutils_display_option(): # Always silence unnecessary log messages when display options are # being used log.set_threshold(log.WARN) log.info('Freezing version number to {0}'.format(version_py)) with open(version_py, 'w') as f: # This overwrites the actual version.py f.write(_get_version_py_str(packagename, version, last_githash, release, debug, uses_git=uses_git)) invalidate_caches() if version_module: imp.reload(version_module) def get_pkg_version_module(packagename, fromlist=None): """Returns the package's .version module generated by `astropy_helpers.version_helpers.generate_version_py`. Raises an ImportError if the version module is not found. If ``fromlist`` is an iterable, return a tuple of the members of the version module corresponding to the member names given in ``fromlist``. Raises an `AttributeError` if any of these module members are not found. """ if not fromlist: # Due to a historical quirk of Python's import implementation, # __import__ will not return submodules of a package if 'fromlist' is # empty. # TODO: For Python 3.1 and up it may be preferable to use importlib # instead of the __import__ builtin return __import__(packagename + '.version', fromlist=['']) else: mod = __import__(packagename + '.version', fromlist=fromlist) return tuple(getattr(mod, member) for member in fromlist) photutils-0.2.1/astropy_helpers/astropy_helpers.egg-info/0000700000214200020070000000000012646264032026063 5ustar lbradleySTSCI\science00000000000000photutils-0.2.1/astropy_helpers/astropy_helpers.egg-info/dependency_links.txt0000600000214200020070000000000112464174242032134 0ustar lbradleySTSCI\science00000000000000 photutils-0.2.1/astropy_helpers/astropy_helpers.egg-info/not-zip-safe0000600000214200020070000000000112464174242030314 0ustar lbradleySTSCI\science00000000000000 photutils-0.2.1/astropy_helpers/astropy_helpers.egg-info/PKG-INFO0000600000214200020070000000543112464174242027166 0ustar lbradleySTSCI\science00000000000000Metadata-Version: 1.1 Name: astropy-helpers Version: 0.4.4 Summary: Utilities for building and installing Astropy, Astropy affiliated packages, and their respective documentation. Home-page: http://astropy.org Author: The Astropy Developers Author-email: astropy.team@gmail.com License: BSD Download-URL: http://pypi.python.org/packages/source/a/astropy-helpers/astropy-helpers-0.4.4.tar.gz Description: astropy-helpers =============== This project provides a Python package, ``astropy_helpers``, which includes many build, installation, and documentation-related tools used by the Astropy project, but packaged separately for use by other projects that wish to leverage this work. The motivation behind this package and details of its implementation are in the accepted `Astropy Proposal for Enhancement (APE) 4 `_. ``astropy_helpers`` includes a special "bootstrap" module called ``ah_bootstrap.py`` which is intended to be used by a project's setup.py in order to ensure that the ``astropy_helpers`` package is available for build/installation. This is similar to the ``ez_setup.py`` module that is shipped with some projects to bootstrap `setuptools `_. As described in APE4, the version numbers for ``astropy_helpers`` follow the corresponding major/minor version of the `astropy core package `_, but with an independent sequence of micro (bugfix) version numbers. Hence, the initial release is 0.4, in parallel with Astropy v0.4, which will be the first version of Astropy to use ``astropy-helpers``. For examples of how to implement ``astropy-helpers`` in a project, see the ``setup.py`` and ``setup.cfg`` files of the `Affiliated package template `_. .. image:: https://travis-ci.org/astropy/astropy-helpers.png :target: https://travis-ci.org/astropy/astropy-helpers .. image:: https://coveralls.io/repos/astropy/astropy-helpers/badge.png :target: https://coveralls.io/r/astropy/astropy-helpers Platform: UNKNOWN Classifier: Development Status :: 5 - Production/Stable Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: BSD License Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 3 Classifier: Topic :: Software Development :: Build Tools Classifier: Topic :: Software Development :: Libraries :: Python Modules Classifier: Topic :: System :: Archiving :: Packaging photutils-0.2.1/astropy_helpers/astropy_helpers.egg-info/SOURCES.txt0000600000214200020070000000540512464174242027756 0ustar lbradleySTSCI\science00000000000000CHANGES.rst LICENSE.rst MANIFEST.in README.rst ah_bootstrap.py ez_setup.py setup.cfg setup.py astropy_helpers/__init__.py astropy_helpers/git_helpers.py astropy_helpers/setup_helpers.py astropy_helpers/test_helpers.py astropy_helpers/utils.py astropy_helpers/version.py astropy_helpers/version_helpers.py astropy_helpers.egg-info/PKG-INFO astropy_helpers.egg-info/SOURCES.txt astropy_helpers.egg-info/dependency_links.txt astropy_helpers.egg-info/not-zip-safe astropy_helpers.egg-info/top_level.txt astropy_helpers/compat/__init__.py astropy_helpers/compat/subprocess.py astropy_helpers/compat/_subprocess_py2/__init__.py astropy_helpers/sphinx/__init__.py astropy_helpers/sphinx/conf.py astropy_helpers/sphinx/setup_package.py astropy_helpers/sphinx/ext/__init__.py astropy_helpers/sphinx/ext/astropyautosummary.py astropy_helpers/sphinx/ext/automodapi.py astropy_helpers/sphinx/ext/automodsumm.py astropy_helpers/sphinx/ext/changelog_links.py astropy_helpers/sphinx/ext/comment_eater.py astropy_helpers/sphinx/ext/compiler_unparse.py astropy_helpers/sphinx/ext/docscrape.py astropy_helpers/sphinx/ext/docscrape_sphinx.py astropy_helpers/sphinx/ext/doctest.py astropy_helpers/sphinx/ext/edit_on_github.py astropy_helpers/sphinx/ext/numpydoc.py astropy_helpers/sphinx/ext/phantom_import.py astropy_helpers/sphinx/ext/smart_resolver.py astropy_helpers/sphinx/ext/tocdepthfix.py astropy_helpers/sphinx/ext/traitsdoc.py astropy_helpers/sphinx/ext/utils.py astropy_helpers/sphinx/ext/viewcode.py astropy_helpers/sphinx/ext/templates/autosummary_core/base.rst astropy_helpers/sphinx/ext/templates/autosummary_core/class.rst astropy_helpers/sphinx/ext/templates/autosummary_core/module.rst astropy_helpers/sphinx/ext/tests/__init__.py astropy_helpers/sphinx/ext/tests/test_automodapi.py astropy_helpers/sphinx/ext/tests/test_automodsumm.py astropy_helpers/sphinx/ext/tests/test_docscrape.py astropy_helpers/sphinx/ext/tests/test_utils.py astropy_helpers/sphinx/local/python3links.inv astropy_helpers/sphinx/themes/bootstrap-astropy/globaltoc.html astropy_helpers/sphinx/themes/bootstrap-astropy/layout.html astropy_helpers/sphinx/themes/bootstrap-astropy/localtoc.html astropy_helpers/sphinx/themes/bootstrap-astropy/searchbox.html astropy_helpers/sphinx/themes/bootstrap-astropy/theme.conf astropy_helpers/sphinx/themes/bootstrap-astropy/static/astropy_linkout_20.png astropy_helpers/sphinx/themes/bootstrap-astropy/static/astropy_logo.ico astropy_helpers/sphinx/themes/bootstrap-astropy/static/astropy_logo_32.png astropy_helpers/sphinx/themes/bootstrap-astropy/static/bootstrap-astropy.css astropy_helpers/sphinx/themes/bootstrap-astropy/static/copybutton.js astropy_helpers/sphinx/themes/bootstrap-astropy/static/sidebar.js astropy_helpers/src/__init__.py astropy_helpers/src/compiler.c astropy_helpers/src/setup_package.pyphotutils-0.2.1/astropy_helpers/astropy_helpers.egg-info/top_level.txt0000600000214200020070000000002012464174242030610 0ustar lbradleySTSCI\science00000000000000astropy_helpers photutils-0.2.1/astropy_helpers/CHANGES.rst0000600000214200020070000003126512640232360022752 0ustar lbradleySTSCI\science00000000000000astropy-helpers Changelog ========================= 1.1.1 (2015-12-23) ------------------ - Fixed crash in build with ``AttributeError: cython_create_listing`` with older versions of setuptools. [#209] 1.1 (2015-12-10) ---------------- - The original ``AstropyTest`` class in ``astropy_helpers``, which implements the ``setup.py test`` command, is deprecated in favor of moving the implementation of that command closer to the actual Astropy test runner in ``astropy.tests``. Now a dummy ``test`` command is provided solely for informing users that they need ``astropy`` installed to run the tests (however, the previous, now deprecated implementation is still provided and continues to work with older versions of Astropy). See the related issue for more details. [#184] - Added a useful new utility function to ``astropy_helpers.utils`` called ``find_data_files``. This is similar to the ``find_packages`` function in setuptools in that it can be used to search a package for data files (matching a pattern) that can be passed to the ``package_data`` argument for ``setup()``. See the docstring to ``astropy_helpers.utils.find_data_files`` for more details. [#42] - The ``astropy_helpers`` module now sets the global ``_ASTROPY_SETUP_`` flag upon import (from within a ``setup.py``) script, so it's not necessary to have this in the ``setup.py`` script explicitly. If in doubt though, there's no harm in setting it twice. Putting it in ``astropy_helpers`` just ensures that any other imports that occur during build will have this flag set. [#191] - It is now possible to use Cython as a ``setup_requires`` build requirement, and still build Cython extensions even if Cython wasn't available at the beginning of the build processes (that is, is automatically downloaded via setuptools' processing of ``setup_requires``). [#185] - Moves the ``adjust_compiler`` check into the ``build_ext`` command itself, so it's only used when actually building extension modules. This also deprecates the stand-alone ``adjust_compiler`` function. [#76] - When running the ``build_sphinx`` / ``build_docs`` command with the ``-w`` option, the output from Sphinx is streamed as it runs instead of silently buffering until the doc build is complete. [#197] 1.0.6 (2015-12-04) ------------------ - Fixed bug where running ``./setup.py build_sphinx`` could return successfully even when the build was not successful (and should have returned a non-zero error code). [#199] 1.0.5 (2015-10-02) ------------------ - Fixed a regression in the ``./setup.py test`` command that was introduced in v1.0.4. 1.0.4 (2015-10-02) ------------------ - Fixed issue with the sphinx documentation css where the line numbers for code blocks were not aligned with the code. [#179] - Fixed crash that could occur when trying to build Cython extension modules when Cython isn't installed. Normally this still results in a failed build, but was supposed to provide a useful error message rather than crash outright (this was a regression introduced in v1.0.3). [#181] - Fixed a crash that could occur on Python 3 when a working C compiler isn't found. [#182] - Quieted warnings about deprecated Numpy API in Cython extensions, when building Cython extensions against Numpy >= 1.7. [#183] - Improved support for py.test >= 2.7--running the ``./setup.py test`` command now copies all doc pages into the temporary test directory as well, so that all test files have a "common root directory". [#189] 1.0.3 (2015-07-22) ------------------ - Added workaround for sphinx-doc/sphinx#1843, a but in Sphinx which prevented descriptor classes with a custom metaclass from being documented correctly. [#158] - Added an alias for the ``./setup.py build_sphinx`` command as ``./setup.py build_docs`` which, to a new contributor, should hopefully be less cryptic. [#161] - The fonts in graphviz diagrams now match the font of the HTML content. [#169] - When the documentation is built on readthedocs.org, MathJax will be used for math rendering. When built elsewhere, the "pngmath" extension is still used for math rendering. [#170] - Fix crash when importing astropy_helpers when running with ``python -OO`` [#171] - The ``build`` and ``build_ext`` stages now correctly recognize the presence of C++ files in Cython extensions (previously only vanilla C worked). [#173] 1.0.2 (2015-04-02) ------------------ - Various fixes enabling the astropy-helpers Sphinx build command and Sphinx extensions to work with Sphinx 1.3. [#148] - More improvement to the ability to handle multiple versions of astropy-helpers being imported in the same Python interpreter session in the (somewhat rare) case of nested installs. [#147] - To better support high resolution displays, use SVG for the astropy logo and linkout image, falling back to PNGs for browsers that support it. [#150, #151] - Improve ``setup_helpers.get_compiler_version`` to work with more compilers, and to return more info. This will help fix builds of Astropy on less common compilers, like Sun C. [#153] 1.0.1 (2015-03-04) ------------------ - Released in concert with v0.4.8 to address the same issues. - Improved the ``ah_bootstrap`` script's ability to override existing installations of astropy-helpers with new versions in the context of installing multiple packages simultaneously within the same Python interpreter (e.g. when one package has in its ``setup_requires`` another package that uses a different version of astropy-helpers. [#144] - Added a workaround to an issue in matplotlib that can, in rare cases, lead to a crash when installing packages that import matplotlib at build time. [#144] 0.4.8 (2015-03-04) ------------------ - Improved the ``ah_bootstrap`` script's ability to override existing installations of astropy-helpers with new versions in the context of installing multiple packages simultaneously within the same Python interpreter (e.g. when one package has in its ``setup_requires`` another package that uses a different version of astropy-helpers. [#144] - Added a workaround to an issue in matplotlib that can, in rare cases, lead to a crash when installing packages that import matplotlib at build time. [#144] 1.0 (2015-02-17) ---------------- - Added new pre-/post-command hook points for ``setup.py`` commands. Now any package can define code to run before and/or after any ``setup.py`` command without having to manually subclass that command by adding ``pre__hook`` and ``post__hook`` callables to the package's ``setup_package.py`` module. See the PR for more details. [#112] - The following objects in the ``astropy_helpers.setup_helpers`` module have been relocated: - ``get_dummy_distribution``, ``get_distutils_*``, ``get_compiler_option``, ``add_command_option``, ``is_distutils_display_option`` -> ``astropy_helpers.distutils_helpers`` - ``should_build_with_cython``, ``generate_build_ext_command`` -> ``astropy_helpers.commands.build_ext`` - ``AstropyBuildPy`` -> ``astropy_helpers.commands.build_py`` - ``AstropyBuildSphinx`` -> ``astropy_helpers.commands.build_sphinx`` - ``AstropyInstall`` -> ``astropy_helpers.commands.install`` - ``AstropyInstallLib`` -> ``astropy_helpers.commands.install_lib`` - ``AstropyRegister`` -> ``astropy_helpers.commands.register`` - ``get_pkg_version_module`` -> ``astropy_helpers.version_helpers`` - ``write_if_different``, ``import_file``, ``get_numpy_include_path`` -> ``astropy_helpers.utils`` All of these are "soft" deprecations in the sense that they are still importable from ``astropy_helpers.setup_helpers`` for now, and there is no (easy) way to produce deprecation warnings when importing these objects from ``setup_helpers`` rather than directly from the modules they are defined in. But please consider updating any imports to these objects. [#110] - Use of the ``astropy.sphinx.ext.astropyautosummary`` extension is deprecated for use with Sphinx < 1.2. Instead it should suffice to remove this extension for the ``extensions`` list in your ``conf.py`` and add the stock ``sphinx.ext.autosummary`` instead. [#131] 0.4.7 (2015-02-17) ------------------ - Fixed incorrect/missing git hash being added to the generated ``version.py`` when creating a release. [#141] 0.4.6 (2015-02-16) ------------------ - Fixed problems related to the automatically generated _compiler module not being created properly. [#139] 0.4.5 (2015-02-11) ------------------ - Fixed an issue where ah_bootstrap.py could blow up when astropy_helper's version number is 1.0. - Added a workaround for documentation of properties in the rare case where the class's metaclass has a property of the same name. [#130] - Fixed an issue on Python 3 where importing a package using astropy-helper's generated version.py module would crash when the current working directory is an empty git repository. [#114] - Fixed an issue where the "revision count" appended to .dev versions by the generated version.py did not accurately reflect the revision count for the package it belongs to, and could be invalid if the current working directory is an unrelated git repository. [#107] - Likewise, fixed a confusing warning message that could occur in the same circumstances as the above issue. [#121] 0.4.4 (2014-12-31) ------------------ - More improvements for building the documentation using Python 3.x. [#100] - Additional minor fixes to Python 3 support. [#115] - Updates to support new test features in Astropy [#92, #106] 0.4.3 (2014-10-22) ------------------ - The generated ``version.py`` file now preserves the git hash of installed copies of the package as well as when building a source distribution. That is, the git hash of the changeset that was installed/released is preserved. [#87] - In smart resolver add resolution for class links when they exist in the intersphinx inventory, but not the mapping of the current package (e.g. when an affiliated package uses an astropy core class of which "actual" and "documented" location differs) [#88] - Fixed a bug that could occur when running ``setup.py`` for the first time in a repository that uses astropy-helpers as a submodule: ``AttributeError: 'NoneType' object has no attribute 'mkdtemp'`` [#89] - Fixed a bug where optional arguments to the ``doctest-skip`` Sphinx directive were sometimes being left in the generated documentation output. [#90] - Improved support for building the documentation using Python 3.x. [#96] - Avoid error message if .git directory is not present. [#91] 0.4.2 (2014-08-09) ------------------ - Fixed some CSS issues in generated API docs. [#69] - Fixed the warning message that could be displayed when generating a version number with some older versions of git. [#77] - Fixed automodsumm to work with new versions of Sphinx (>= 1.2.2). [#80] 0.4.1 (2014-08-08) ------------------ - Fixed git revision count on systems with git versions older than v1.7.2. [#70] - Fixed display of warning text when running a git command fails (previously the output of stderr was not being decoded properly). [#70] - The ``--offline`` flag to ``setup.py`` understood by ``ah_bootstrap.py`` now also prevents git from going online to fetch submodule updates. [#67] - The Sphinx extension for converting issue numbers to links in the changelog now supports working on arbitrary pages via a new ``conf.py`` setting: ``changelog_links_docpattern``. By default it affects the ``changelog`` and ``whatsnew`` pages in one's Sphinx docs. [#61] - Fixed crash that could result from users with missing/misconfigured locale settings. [#58] - The font used for code examples in the docs is now the system-defined ``monospace`` font, rather than ``Minaco``, which is not available on all platforms. [#50] 0.4 (2014-07-15) ---------------- - Initial release of astropy-helpers. See `APE4 `_ for details of the motivation and design of this package. - The ``astropy_helpers`` package replaces the following modules in the ``astropy`` package: - ``astropy.setup_helpers`` -> ``astropy_helpers.setup_helpers`` - ``astropy.version_helpers`` -> ``astropy_helpers.version_helpers`` - ``astropy.sphinx`` - > ``astropy_helpers.sphinx`` These modules should be considered deprecated in ``astropy``, and any new, non-critical changes to those modules will be made in ``astropy_helpers`` instead. Affiliated packages wishing to make use those modules (as in the Astropy package-template) should use the versions from ``astropy_helpers`` instead, and include the ``ah_bootstrap.py`` script in their project, for bootstrapping the ``astropy_helpers`` package in their setup.py script. photutils-0.2.1/astropy_helpers/CONTRIBUTING.md0000600000214200020070000000216512361365073023406 0ustar lbradleySTSCI\science00000000000000Contributing to astropy-helpers =============================== The guidelines for contributing to ``astropy-helpers`` are generally the same as the [contributing guidelines for the astropy core package](http://github.com/astropy/astropy/blob/master/CONTRIBUTING.md). Basically, report relevant issues in the ``astropy-helpers`` issue tracker, and we welcome pull requests that broadly follow the [Astropy coding guidelines](http://docs.astropy.org/en/latest/development/codeguide.html). The key subtlety lies in understanding the relationship between ``astropy`` and ``astropy-helpers``. This package contains the build, installation, and documentation tools used by astropy. It also includes support for the ``setup.py test`` command, though Astropy is still required for this to function (it does not currently include the full Astropy test runner). So issues or improvements to that functionality should be addressed in this package. Any other aspect of the [astropy core package](http://github.com/astropy/astropy) (or any other package that uses ``astropy-helpers``) should be addressed in the github repository for that package. photutils-0.2.1/astropy_helpers/ez_setup.py0000600000214200020070000002757312346164025023374 0ustar lbradleySTSCI\science00000000000000#!python """Bootstrap setuptools installation If you want to use setuptools in your package's setup.py, just include this file in the same directory with it, and add this to the top of your setup.py:: from ez_setup import use_setuptools use_setuptools() If you want to require a specific version of setuptools, set a download mirror, or use an alternate download directory, you can do so by supplying the appropriate options to ``use_setuptools()``. This file can also be run as a script to install or upgrade setuptools. """ import os import shutil import sys import tempfile import tarfile import optparse import subprocess import platform from distutils import log try: from site import USER_SITE except ImportError: USER_SITE = None DEFAULT_VERSION = "1.4.2" DEFAULT_URL = "https://pypi.python.org/packages/source/s/setuptools/" def _python_cmd(*args): args = (sys.executable,) + args return subprocess.call(args) == 0 def _check_call_py24(cmd, *args, **kwargs): res = subprocess.call(cmd, *args, **kwargs) class CalledProcessError(Exception): pass if not res == 0: msg = "Command '%s' return non-zero exit status %d" % (cmd, res) raise CalledProcessError(msg) vars(subprocess).setdefault('check_call', _check_call_py24) def _install(tarball, install_args=()): # extracting the tarball tmpdir = tempfile.mkdtemp() log.warn('Extracting in %s', tmpdir) old_wd = os.getcwd() try: os.chdir(tmpdir) tar = tarfile.open(tarball) _extractall(tar) tar.close() # going in the directory subdir = os.path.join(tmpdir, os.listdir(tmpdir)[0]) os.chdir(subdir) log.warn('Now working in %s', subdir) # installing log.warn('Installing Setuptools') if not _python_cmd('setup.py', 'install', *install_args): log.warn('Something went wrong during the installation.') log.warn('See the error message above.') # exitcode will be 2 return 2 finally: os.chdir(old_wd) shutil.rmtree(tmpdir) def _build_egg(egg, tarball, to_dir): # extracting the tarball tmpdir = tempfile.mkdtemp() log.warn('Extracting in %s', tmpdir) old_wd = os.getcwd() try: os.chdir(tmpdir) tar = tarfile.open(tarball) _extractall(tar) tar.close() # going in the directory subdir = os.path.join(tmpdir, os.listdir(tmpdir)[0]) os.chdir(subdir) log.warn('Now working in %s', subdir) # building an egg log.warn('Building a Setuptools egg in %s', to_dir) _python_cmd('setup.py', '-q', 'bdist_egg', '--dist-dir', to_dir) finally: os.chdir(old_wd) shutil.rmtree(tmpdir) # returning the result log.warn(egg) if not os.path.exists(egg): raise IOError('Could not build the egg.') def _do_download(version, download_base, to_dir, download_delay): egg = os.path.join(to_dir, 'setuptools-%s-py%d.%d.egg' % (version, sys.version_info[0], sys.version_info[1])) if not os.path.exists(egg): tarball = download_setuptools(version, download_base, to_dir, download_delay) _build_egg(egg, tarball, to_dir) sys.path.insert(0, egg) # Remove previously-imported pkg_resources if present (see # https://bitbucket.org/pypa/setuptools/pull-request/7/ for details). if 'pkg_resources' in sys.modules: del sys.modules['pkg_resources'] import setuptools setuptools.bootstrap_install_from = egg def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir, download_delay=15): # making sure we use the absolute path to_dir = os.path.abspath(to_dir) was_imported = 'pkg_resources' in sys.modules or \ 'setuptools' in sys.modules try: import pkg_resources except ImportError: return _do_download(version, download_base, to_dir, download_delay) try: pkg_resources.require("setuptools>=" + version) return except pkg_resources.VersionConflict: e = sys.exc_info()[1] if was_imported: sys.stderr.write( "The required version of setuptools (>=%s) is not available,\n" "and can't be installed while this script is running. Please\n" "install a more recent version first, using\n" "'easy_install -U setuptools'." "\n\n(Currently using %r)\n" % (version, e.args[0])) sys.exit(2) else: del pkg_resources, sys.modules['pkg_resources'] # reload ok return _do_download(version, download_base, to_dir, download_delay) except pkg_resources.DistributionNotFound: return _do_download(version, download_base, to_dir, download_delay) def _clean_check(cmd, target): """ Run the command to download target. If the command fails, clean up before re-raising the error. """ try: subprocess.check_call(cmd) except subprocess.CalledProcessError: if os.access(target, os.F_OK): os.unlink(target) raise def download_file_powershell(url, target): """ Download the file at url to target using Powershell (which will validate trust). Raise an exception if the command cannot complete. """ target = os.path.abspath(target) cmd = [ 'powershell', '-Command', "(new-object System.Net.WebClient).DownloadFile(%(url)r, %(target)r)" % vars(), ] _clean_check(cmd, target) def has_powershell(): if platform.system() != 'Windows': return False cmd = ['powershell', '-Command', 'echo test'] devnull = open(os.path.devnull, 'wb') try: try: subprocess.check_call(cmd, stdout=devnull, stderr=devnull) except: return False finally: devnull.close() return True download_file_powershell.viable = has_powershell def download_file_curl(url, target): cmd = ['curl', url, '--silent', '--output', target] _clean_check(cmd, target) def has_curl(): cmd = ['curl', '--version'] devnull = open(os.path.devnull, 'wb') try: try: subprocess.check_call(cmd, stdout=devnull, stderr=devnull) except: return False finally: devnull.close() return True download_file_curl.viable = has_curl def download_file_wget(url, target): cmd = ['wget', url, '--quiet', '--output-document', target] _clean_check(cmd, target) def has_wget(): cmd = ['wget', '--version'] devnull = open(os.path.devnull, 'wb') try: try: subprocess.check_call(cmd, stdout=devnull, stderr=devnull) except: return False finally: devnull.close() return True download_file_wget.viable = has_wget def download_file_insecure(url, target): """ Use Python to download the file, even though it cannot authenticate the connection. """ try: from urllib.request import urlopen except ImportError: from urllib2 import urlopen src = dst = None try: src = urlopen(url) # Read/write all in one block, so we don't create a corrupt file # if the download is interrupted. data = src.read() dst = open(target, "wb") dst.write(data) finally: if src: src.close() if dst: dst.close() download_file_insecure.viable = lambda: True def get_best_downloader(): downloaders = [ download_file_powershell, download_file_curl, download_file_wget, download_file_insecure, ] for dl in downloaders: if dl.viable(): return dl def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir, delay=15, downloader_factory=get_best_downloader): """Download setuptools from a specified location and return its filename `version` should be a valid setuptools version number that is available as an egg for download under the `download_base` URL (which should end with a '/'). `to_dir` is the directory where the egg will be downloaded. `delay` is the number of seconds to pause before an actual download attempt. ``downloader_factory`` should be a function taking no arguments and returning a function for downloading a URL to a target. """ # making sure we use the absolute path to_dir = os.path.abspath(to_dir) tgz_name = "setuptools-%s.tar.gz" % version url = download_base + tgz_name saveto = os.path.join(to_dir, tgz_name) if not os.path.exists(saveto): # Avoid repeated downloads log.warn("Downloading %s", url) downloader = downloader_factory() downloader(url, saveto) return os.path.realpath(saveto) def _extractall(self, path=".", members=None): """Extract all members from the archive to the current working directory and set owner, modification time and permissions on directories afterwards. `path' specifies a different directory to extract to. `members' is optional and must be a subset of the list returned by getmembers(). """ import copy import operator from tarfile import ExtractError directories = [] if members is None: members = self for tarinfo in members: if tarinfo.isdir(): # Extract directories with a safe mode. directories.append(tarinfo) tarinfo = copy.copy(tarinfo) tarinfo.mode = 448 # decimal for oct 0700 self.extract(tarinfo, path) # Reverse sort directories. if sys.version_info < (2, 4): def sorter(dir1, dir2): return cmp(dir1.name, dir2.name) directories.sort(sorter) directories.reverse() else: directories.sort(key=operator.attrgetter('name'), reverse=True) # Set correct owner, mtime and filemode on directories. for tarinfo in directories: dirpath = os.path.join(path, tarinfo.name) try: self.chown(tarinfo, dirpath) self.utime(tarinfo, dirpath) self.chmod(tarinfo, dirpath) except ExtractError: e = sys.exc_info()[1] if self.errorlevel > 1: raise else: self._dbg(1, "tarfile: %s" % e) def _build_install_args(options): """ Build the arguments to 'python setup.py install' on the setuptools package """ install_args = [] if options.user_install: if sys.version_info < (2, 6): log.warn("--user requires Python 2.6 or later") raise SystemExit(1) install_args.append('--user') return install_args def _parse_args(): """ Parse the command line for options """ parser = optparse.OptionParser() parser.add_option( '--user', dest='user_install', action='store_true', default=False, help='install in user site package (requires Python 2.6 or later)') parser.add_option( '--download-base', dest='download_base', metavar="URL", default=DEFAULT_URL, help='alternative URL from where to download the setuptools package') parser.add_option( '--insecure', dest='downloader_factory', action='store_const', const=lambda: download_file_insecure, default=get_best_downloader, help='Use internal, non-validating downloader' ) options, args = parser.parse_args() # positional arguments are ignored return options def main(version=DEFAULT_VERSION): """Install or upgrade setuptools and EasyInstall""" options = _parse_args() tarball = download_setuptools(download_base=options.download_base, downloader_factory=options.downloader_factory) return _install(tarball, _build_install_args(options)) if __name__ == '__main__': sys.exit(main()) photutils-0.2.1/astropy_helpers/LICENSE.rst0000600000214200020070000000272312361365073022771 0ustar lbradleySTSCI\science00000000000000Copyright (c) 2014, Astropy Developers All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the Astropy Team nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. photutils-0.2.1/astropy_helpers/licenses/0000700000214200020070000000000012646264032022753 5ustar lbradleySTSCI\science00000000000000photutils-0.2.1/astropy_helpers/licenses/LICENSE_COPYBUTTON.rst0000600000214200020070000000471112346164025026360 0ustar lbradleySTSCI\science00000000000000Copyright 2014 Python Software Foundation License: PSF PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2 -------------------------------------------- . 1. This LICENSE AGREEMENT is between the Python Software Foundation ("PSF"), and the Individual or Organization ("Licensee") accessing and otherwise using this software ("Python") in source or binary form and its associated documentation. . 2. Subject to the terms and conditions of this License Agreement, PSF hereby grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce, analyze, test, perform and/or display publicly, prepare derivative works, distribute, and otherwise use Python alone or in any derivative version, provided, however, that PSF's License Agreement and PSF's notice of copyright, i.e., "Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Python Software Foundation; All Rights Reserved" are retained in Python alone or in any derivative version prepared by Licensee. . 3. In the event Licensee prepares a derivative work that is based on or incorporates Python or any part thereof, and wants to make the derivative work available to others as provided herein, then Licensee hereby agrees to include in any such work a brief summary of the changes made to Python. . 4. PSF is making Python available to Licensee on an "AS IS" basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON WILL NOT INFRINGE ANY THIRD PARTY RIGHTS. . 5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON, OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. . 6. This License Agreement will automatically terminate upon a material breach of its terms and conditions. . 7. Nothing in this License Agreement shall be deemed to create any relationship of agency, partnership, or joint venture between PSF and Licensee. This License Agreement does not grant permission to use PSF trademarks or trade name in a trademark sense to endorse or promote products or services of Licensee, or any third party. . 8. By copying, installing or otherwise using Python, Licensee agrees to be bound by the terms and conditions of this License Agreement. photutils-0.2.1/astropy_helpers/licenses/LICENSE_NUMPYDOC.rst0000600000214200020070000001350712346164025026113 0ustar lbradleySTSCI\science00000000000000------------------------------------------------------------------------------- The files - numpydoc.py - docscrape.py - docscrape_sphinx.py - phantom_import.py have the following license: Copyright (C) 2008 Stefan van der Walt , Pauli Virtanen Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ------------------------------------------------------------------------------- The files - compiler_unparse.py - comment_eater.py - traitsdoc.py have the following license: This software is OSI Certified Open Source Software. OSI Certified is a certification mark of the Open Source Initiative. Copyright (c) 2006, Enthought, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Enthought, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ------------------------------------------------------------------------------- The file - plot_directive.py originates from Matplotlib (http://matplotlib.sf.net/) which has the following license: Copyright (c) 2002-2008 John D. Hunter; All Rights Reserved. 1. This LICENSE AGREEMENT is between John D. Hunter (“JDHâ€), and the Individual or Organization (“Licenseeâ€) accessing and otherwise using matplotlib software in source or binary form and its associated documentation. 2. Subject to the terms and conditions of this License Agreement, JDH hereby grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce, analyze, test, perform and/or display publicly, prepare derivative works, distribute, and otherwise use matplotlib 0.98.3 alone or in any derivative version, provided, however, that JDH’s License Agreement and JDH’s notice of copyright, i.e., “Copyright (c) 2002-2008 John D. Hunter; All Rights Reserved†are retained in matplotlib 0.98.3 alone or in any derivative version prepared by Licensee. 3. In the event Licensee prepares a derivative work that is based on or incorporates matplotlib 0.98.3 or any part thereof, and wants to make the derivative work available to others as provided herein, then Licensee hereby agrees to include in any such work a brief summary of the changes made to matplotlib 0.98.3. 4. JDH is making matplotlib 0.98.3 available to Licensee on an “AS IS†basis. JDH MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, JDH MAKES NO AND DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF MATPLOTLIB 0.98.3 WILL NOT INFRINGE ANY THIRD PARTY RIGHTS. 5. JDH SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF MATPLOTLIB 0.98.3 FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING MATPLOTLIB 0.98.3, OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. 6. This License Agreement will automatically terminate upon a material breach of its terms and conditions. 7. Nothing in this License Agreement shall be deemed to create any relationship of agency, partnership, or joint venture between JDH and Licensee. This License Agreement does not grant permission to use JDH trademarks or trade name in a trademark sense to endorse or promote products or services of Licensee, or any third party. 8. By copying, installing or otherwise using matplotlib 0.98.3, Licensee agrees to be bound by the terms and conditions of this License Agreement. photutils-0.2.1/astropy_helpers/MANIFEST.in0000600000214200020070000000024312346164025022703 0ustar lbradleySTSCI\science00000000000000include README.rst include CHANGES.rst include LICENSE.rst include ez_setup.py include ah_bootstrap.py exclude *.pyc *.o prune build prune astropy_helpers/tests photutils-0.2.1/astropy_helpers/README.rst0000600000214200020070000000323112457734703022645 0ustar lbradleySTSCI\science00000000000000astropy-helpers =============== This project provides a Python package, ``astropy_helpers``, which includes many build, installation, and documentation-related tools used by the Astropy project, but packaged separately for use by other projects that wish to leverage this work. The motivation behind this package and details of its implementation are in the accepted `Astropy Proposal for Enhancement (APE) 4 `_. ``astropy_helpers`` includes a special "bootstrap" module called ``ah_bootstrap.py`` which is intended to be used by a project's setup.py in order to ensure that the ``astropy_helpers`` package is available for build/installation. This is similar to the ``ez_setup.py`` module that is shipped with some projects to bootstrap `setuptools `_. As described in APE4, the version numbers for ``astropy_helpers`` follow the corresponding major/minor version of the `astropy core package `_, but with an independent sequence of micro (bugfix) version numbers. Hence, the initial release is 0.4, in parallel with Astropy v0.4, which will be the first version of Astropy to use ``astropy-helpers``. For examples of how to implement ``astropy-helpers`` in a project, see the ``setup.py`` and ``setup.cfg`` files of the `Affiliated package template `_. .. image:: https://travis-ci.org/astropy/astropy-helpers.png :target: https://travis-ci.org/astropy/astropy-helpers .. image:: https://coveralls.io/repos/astropy/astropy-helpers/badge.png :target: https://coveralls.io/r/astropy/astropy-helpers photutils-0.2.1/astropy_helpers/setup.cfg0000600000214200020070000000014612346164025022770 0ustar lbradleySTSCI\science00000000000000[pytest] norecursedirs = .tox astropy_helpers/tests/package_template python_functions = test_ photutils-0.2.1/astropy_helpers/setup.py0000700000214200020070000000402312640232360022653 0ustar lbradleySTSCI\science00000000000000#!/usr/bin/env python # Licensed under a 3-clause BSD style license - see LICENSE.rst import ah_bootstrap import pkg_resources from setuptools import setup from astropy_helpers.setup_helpers import register_commands, get_package_info from astropy_helpers.version_helpers import generate_version_py NAME = 'astropy_helpers' VERSION = '1.1.1' RELEASE = 'dev' not in VERSION DOWNLOAD_BASE_URL = 'http://pypi.python.org/packages/source/a/astropy-helpers' generate_version_py(NAME, VERSION, RELEASE, False, uses_git=not RELEASE) # Use the updated version including the git rev count from astropy_helpers.version import version as VERSION cmdclass = register_commands(NAME, VERSION, RELEASE) # This package actually doesn't use the Astropy test command del cmdclass['test'] setup( name=pkg_resources.safe_name(NAME), # astropy_helpers -> astropy-helpers version=VERSION, description='Utilities for building and installing Astropy, Astropy ' 'affiliated packages, and their respective documentation.', author='The Astropy Developers', author_email='astropy.team@gmail.com', license='BSD', url='http://astropy.org', long_description=open('README.rst').read(), download_url='{0}/astropy-helpers-{1}.tar.gz'.format(DOWNLOAD_BASE_URL, VERSION), classifiers=[ 'Development Status :: 5 - Production/Stable', 'Intended Audience :: Developers', 'Framework :: Setuptools Plugin', 'Framework :: Sphinx :: Extension', 'Framework :: Sphinx :: Theme', 'License :: OSI Approved :: BSD License', 'Operating System :: OS Independent', 'Programming Language :: Python', 'Programming Language :: Python :: 3', 'Topic :: Software Development :: Build Tools', 'Topic :: Software Development :: Libraries :: Python Modules', 'Topic :: System :: Archiving :: Packaging' ], cmdclass=cmdclass, zip_safe=False, **get_package_info(exclude=['astropy_helpers.tests']) ) photutils-0.2.1/astropy_helpers/tox.ini0000600000214200020070000000045012477406130022461 0ustar lbradleySTSCI\science00000000000000[tox] envlist = py26,py27,py32,py33,py34 [testenv] deps = pytest numpy Cython Sphinx==1.2.3 # Note: Sphinx is required to run the sphinx.ext tests commands = py.test {posargs} sitepackages = False [testenv:py32] deps = pygments<=1.9 Jinja2<2.7 {[testenv]deps} photutils-0.2.1/cextern/0000700000214200020070000000000012646264032017373 5ustar lbradleySTSCI\science00000000000000photutils-0.2.1/cextern/README.rst0000600000214200020070000000054212345377273021075 0ustar lbradleySTSCI\science00000000000000External Packages/Libraries =========================== This directory contains C extensions included with the package. Note that only C extensions should be included in this directory - pure Cython code should be placed in the package source tree, and wrapper Cython code for C libraries included here should be in the packagename/wrappers directory. photutils-0.2.1/CHANGES.rst0000600000214200020070000000652212646263745017546 0ustar lbradleySTSCI\science000000000000000.2.1 (2016-01-15) ------------------ Bug Fixes ^^^^^^^^^ - ``photutils.segmentation`` - Fixed issue where ``SegmentationImage`` slices were not being updated. [#317] - ``photutils.background`` - Added more robust version checking of Astropy. [#318] - ``photutils.detection`` - Added more robust version checking of Astropy. [#318] - ``photutils.segmentation`` - Added more robust version checking of scikit-image. [#318] 0.2 (2015-12-31) ---------------- General ^^^^^^^ - Photutils has the following requirements: - Python 2.7 or 3.3 or later - Numpy 1.6 or later - Astropy v1.0 or later New Features ^^^^^^^^^^^^ - ``photutils.detection`` - ``find_peaks`` now returns an Astropy Table containing the (x, y) positions and peak values. [#240] - ``find_peaks`` has new ``mask``, ``error``, ``wcs`` and ``subpixel`` precision options. [#244] - ``detect_sources`` will now issue a warning if the filter kernel is not normalized to 1. [#298] - Added new ``deblend_sources`` function, an experimental source deblender. [#314] - ``photutils.morphology`` - Added new ``GaussianConst2D`` (2D Gaussian plus a constant) model. [#244] - Added new ``marginalize_data2d`` function. [#244] - Added new ``cutout_footprint`` function. [#244] - ``photutils.segmentation`` - Added new ``SegmentationImage`` class. [#306] - Added new ``check_label``, ``keep_labels``, and ``outline_segments`` methods for modifying ``SegmentationImage``. [#306] - ``photutils.utils`` - Added new ``random_cmap`` function to generate a colormap comprised of random colors. [#299] - Added new ``ShepardIDWInterpolator`` class to perform Inverse Distance Weighted (IDW) interpolation. [#307] - The ``interpolate_masked_data`` function can now interpolate higher-dimensional data. [#310] API changes ^^^^^^^^^^^ - ``photutils.segmentation`` - The ``relabel_sequential``, ``relabel_segments``, ``remove_segments``, ``remove_border_segments``, and ``remove_masked_segments`` functions are now ``SegmentationImage`` methods (with slightly different names). [#306] - The ``SegmentProperties`` class has been renamed to ``SourceProperties``. Likewise the ``segment_properties`` function has been renamed to ``source_properties``. [#306] - The ``segment_sum`` and ``segment_sum_err`` attributes have been renamed to ``source_sum`` and ``source_sum_err``, respectively. [#306] - The ``background_atcentroid`` attribute has been renamed to ``background_at_centroid``. [#306] Bug Fixes ^^^^^^^^^ - ``photutils.aperture_photometry`` - Fixed an issue where ``np.nan`` or ``np.inf`` were not properly masked. [#267] - ``photutils.geometry`` - ``overlap_area_triangle_unit_circle`` handles correctly a corner case in some i386 systems where the area of the aperture was not computed correctly. [#242] - ``rectangular_overlap_grid`` and ``elliptical_overlap_grid`` fixes to normalization of subsampled pixels. [#265] - ``overlap_area_triangle_unit_circle`` handles correctly the case where a line segment intersects at a triangle vertex. [#277] Other Changes and Additions ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - Updated astropy-helpers to v1.1. [#302] 0.1 (2014-12-22) ---------------- Photutils 0.1 was released on December 22, 2014. It requires Astropy version 0.4 or later. photutils-0.2.1/docs/0000700000214200020070000000000012646264032016653 5ustar lbradleySTSCI\science00000000000000photutils-0.2.1/docs/_static/0000700000214200020070000000000012646264032020301 5ustar lbradleySTSCI\science00000000000000photutils-0.2.1/docs/_static/favicon.ico0000600000214200020070000003535612444404542022436 0ustar lbradleySTSCI\science00000000000000 h6  ¨ž00 ¨%F(  ¨o1‘xm²t,G®p(¦m.ª¤l,£¢j*z h)1’\ ¨o/©q4.­p*É¡k1ÿšj9þ¥k*ÿ¢j)ÿŸh)ÿf'üšc&»—a%4‘[¦o35«o*ô–lFÿtfýŽjNübOüœe)üœd&ü™c'þ—a$ÿ–_!ÿ”]s“Y¡m6©o-Ìžg,ÿ‘ymúͪƒÿÑ­‚ÿ¢ƒiÿƒ]>ÿbÿ–^ÿ•^üŽ\%û[$ÿY{ŽX¤l-Z¥l*ÿ—e0üŽp\ÿÓ±‡ÿؽžÿ±“vÿ€]Aÿ’a+ÿƒePÿZÿuWDþmTJüˆUÿ‰TI¡i* žg*ÿ¢g#üƒ`Eÿ‹iNÿ¡}Zÿ‹{{ÿŠVÿ†eJÿƒ€”ÿ}R)ÿ†hQÿ“sTüqP6ÿˆQÍOGWf(½že$ÿ^.ýŽ^-ÿ…[4ÿ}Y<ÿŠVÿ“ZÿŠXÿƒT#ÿ…TÿsT?ÿ¡xGÿs\Qý~KÿNTœd%µ’]%ÿ„uuýngÿ“Zÿ‘[ÿ‚fUÿ\;ÿŠTÿ‰Uÿ‚QÿpUEÿÁ£ÿƒoeürEÿ~K¢Ÿd‰U/ÿº´³ü’‚|ÿˆQÿ}U2ÿ™’šÿnhÿƒOÿƒOÿ‚JÿlQ@ÿƯ•ÿxgýhAÿ{H ÌŸ`>ƒX/þ„|„þ|_Jÿ‹Uÿ‰TÿzT3ÿ}R&ÿ‚MÿzW6ÿr\OÿfI6ÿždÿ}[:ýeC&ÿwDÓY»yQ-ÿ†Sü‰TÿzO#ÿzN!ÿ€NÿxGÿvwÿykkÿg?ÿz`Mÿš|]ýgI0ÿq=¸‰U7ŠUüˆSþpM0ýzbSÿ„l[ÿjQDÿgI5ÿnEÿsB ÿuC ÿaG8ÿubZücA#ÿq<q…Q€Qg„PÿkK2ü`Gû¼—iÿ¦‚ÿdJÿeG2ÿtC ÿqA ÿj?ûU:+ÿh< Ün;ƒP~La}JùeG2ÿpZOþ–~jü˜yYü\HDük?üm> ýk<ÿk;üh:E€NyH)zF ¯h?úeF-ÿdJ8ÿd=ÿl=þh;ÿf9Óc9 :h:M}G H*s<sn9 m<ªg:‘f9Nb5g:øÿàÀ€€€€Ààðøÿ( @ ªq0©o.«q1©p/&¨o.>§n-G¦m-A¥l,-¤l,›d&›d&ªp/ªp/¬s1ªq0S©p/©¨o/Þ¨n.ø§n-ÿ¦m-ÿ¥l,ÿ¤k+û¢j+ç¡i*¾ h)|Ÿg(*—a$—`$ªp/©o/«q0Yªp0ߨo1ÿªo,þªn)ÿ§m+ÿ£l.ÿ¤k,þ£j+þ¢i*ÿ¡i*ÿ h)ÿŸg(ÿf(ýœe'½›d&A˜a$”^"ªp/ªq0 ªp/©©p0ÿªo,þ¯q&ü l6û—j?ýŸk3þªl!ÿ£j*ÿ i+ÿ h)ÿŸg(þžf(üœe'û›d&þ›d&ÿ™c%ÿ˜b$°—`$“]!ªp/ªp/ ªp/Ĩo0ÿªn*ú£m2ým]fÿncrÿragÿj_pÿsclÿ h)ÿ¡g&ÿf)ÿe'ÿœe'ÿ›d&ÿšc%ÿ™b%ü˜a$ü—`$ÿ•_#ð”^"S[ ¥m-©o/±¨o.ÿ¨n,ù¥n1ÿaZsÿ¬œ–ÿ³|=ÿ«o)ÿ«r0ÿ}[Dÿe_xÿŸf%ÿœe'ÿ›d&ÿšc&ÿ™b%ÿ˜a$ÿ—`$ÿ–`#ÿ”_"û“^"ý’]!ÿ‘\ yŽY¨n.¨n.q§n.ÿ¤m/ú®n$ÿq]_ÿ™„{ÿÙ²€ÿ¹’gÿÊ­Žÿʯ’ÿËœ`ÿvZMÿv`]ÿ¢dÿ˜b'ÿ˜b$ÿ—a$ÿ–`#ÿ•_"ÿ”^"ÿ’]"ÿ“\ý’\û[ ÿZŒX§n-¦m-ë¥l,ÿ¤k,þ¤m.ÿfXdÿÅ¡xÿ¸bÿѶ—ÿɪˆÿ¶_ÿË®ÿ¬„ZÿbUcÿœc"ÿ—a%ÿ•`%ÿ–`"ÿ“^#ÿ“]!ÿ’]!ÿ“\ÿ[$ÿ‹Z$þ‘YûŒXÿŒWjŠW¥l,u¥l,ÿ£k+û£j)ÿžj2ÿiW\ÿÄžsÿ»•lÿÕ¾£ÿøôðÿØÃ«ÿ®‚Qÿ¾yÿcQYÿ˜b&ÿ•_$ÿ™_ÿ’_'ÿ–^ÿ’\ÿ‘[ÿ‹Z%ÿ\WpÿXWvÿ€W1þŽWþ‰Vü‰U<‰U¤k+Ç£j+ÿ¡i*ý h+ÿ¤h$ÿg]oÿk7ÿÓ¸šÿÀžyÿÈ©‡ÿ»™sÿ»“eÿ¯”{ÿ_Q]ÿ›aÿ—_ÿvXDÿ`d‰ÿgYbÿŽYÿ•ZÿmXSÿoRBÿ…OÿTTvÿŠUüˆTÿ‡SуQ‡T¢j+$¢j*ô¡i*ÿ h)þg*ÿ¤gÿbOÿhZfÿ©jÿ¾–fÿ³‰XÿµˆRÿìÕ·ÿc\rÿ[>ÿ˜^ÿ‘^%ÿab„ÿãÆ ÿ‚˜ÿuVAÿ™[ÿ`QXÿŒmQÿ³ƒFÿgPHÿhSOÿSû„Rÿ„Qx„R¡i*L h)ÿŸg)þžf(ÿe'ÿ™d*ÿŸdÿr__ÿe[lÿV-ÿ‡V#ÿ™}hÿjj‡ÿoWNÿ™^ÿ\#ÿ”\ÿgW[ÿ|}™ÿdazÿ„V%ÿ‘Wÿ`Uaÿ¦‹rÿ°Š_ÿ£YÿQI`ÿ†SþƒPÿ‚Pç€NŸg)gžf(ÿf'üœe'ÿšd'ÿ¡dÿžcÿbÿ„_@ÿk]fÿh\jÿfV[ÿ€W2ÿ—^ÿ[!ÿZÿŽZÿŽXÿwU;ÿ…U#ÿ‹VÿŒUÿ_TbÿW-ÿzAÿ¶_ÿcWcÿpN3ÿ†Oû€NÿMif'qœe'ÿ›d&üšc&ÿc ÿv\Rÿv\Qÿ˜`!ÿ™_ÿ›_ÿ—^ÿ˜^ÿ•]ÿ”]ÿZÿYÿŒXÿ‹WÿXÿŠVÿ†TÿŒTÿ^R^ÿyO&ÿ£zKÿ¯‰[ÿ…naÿYHKÿ‡O ü}Mÿ}L¾›d&i›d&ÿ˜b'üŸcÿo[ZÿrciÿlamÿxZIÿ˜^ÿ\$ÿ\"ÿ‘[ÿŽ[#ÿ}]Eÿ‹Y#ÿŽXÿŠWÿ‰VÿˆUÿ‡Tÿ…Sÿ‹Sÿ^MRÿ_Dÿ·–nÿ¸›{ÿŸ^ÿPGYÿNþ|Kÿ{JòzI"™c%O˜b%ÿšb!þŽ_/ÿ`ZrÿDz“ÿ¢ƒÿcRXÿ˜^ÿŽ["ÿZÿ‰X$ÿUOgÿwoÿTOiÿ‚T%ÿŠUÿ‡Tÿ†Sÿ…RÿƒQÿ‰QÿaKEÿzcVÿ­†WÿÒ²ÿ°cÿSJYÿvK ÿ|JýyIÿyHU˜a$*–`%øœaÿuWFþswÿçãÚÿ¨œ—ÿbPUÿ•\ÿŒY"ÿ–\ÿnZXÿ€ÿûá·ÿ—†€ÿgW\ÿWÿ„Rÿ„RÿƒQÿPÿ†OÿjK6ÿkZ\ÿ¹–kÿáÙÒÿµ‘eÿ]NRÿjI/ÿ}H üwGÿwG˜b%“_%Õ›`ÿkSMý’…ƒÿëèàÿ”‡„ÿePOÿ•[ÿŠX!ÿXÿvW@ÿfbyÿÄ«ÿjezÿnSCÿŠSÿƒQÿ‚PÿPÿ„PÿƒNÿsL&ÿ[Q`ÿ¶”jÿÌ»ªÿª„VÿgRJÿ_G=ÿ|FüuFÿuEš‘]%•™^ÿiRNû~zÿÒ¾žÿgatÿxU8ÿXÿŠVÿ‰UÿŒUÿiOCÿ[XsÿeNFÿ‡Qÿ‚PÿOÿƒOÿƒM ÿlF%ÿxKÿLÿOI^ÿ¥†dÿ±•vÿ²‘hÿfH2ÿYHJÿ{EüsDÿsC£Ž\$?”\ÿ|X:ýb[pÿze\ÿ[SfÿWÿ‰Vÿ‰Uÿ‡Tÿ…SÿŠSÿŒVÿ‰Qÿ‚Pÿ€OÿƒOÿwJÿRQoÿqtŽÿQSvÿJ ÿQCLÿwkÿvKÿ‡Y"ÿfC$ÿVJSÿxCüqCÿqB ™‡TY Å‘YÿpUHübRYÿŠWÿŠUÿˆTÿ†Sÿ†RÿˆRÿ‡Rÿ„Qÿ€OÿNÿ€Nÿ|KÿUUsÿÀ»¹ÿµ°®ÿNMiÿHÿaD2ÿg^lÿ¦Rÿm9ÿxdÿRHTÿvAüoAÿo@ {ŒXXM‹WÿWüWÿˆUÿ‡Tÿ…Sÿ‰RÿƒRÿtO.ÿmG%ÿvKÿƒOÿ„M ÿLÿoH%ÿV]…ÿ€“ÿMNpÿrEÿzG ÿuHÿFB]ÿž|Yÿ©‰bÿ´«¨ÿJ=FÿvBþm@ ÿn? L‰U‰V«‡Uÿ†Tû†Sÿ„RÿˆQÿqQ9ÿPMjÿ_S]ÿyv‹ÿd`vÿMEXÿ]LMÿxLÿ‚IÿiG+ÿ_@+ÿyF ÿxF ÿsEÿzDÿTFLÿ]F>ÿ§|Eÿ‰xqÿN?Eþs?ÿk> çl= ‡TˆU†Så…Rÿ„Rý„QÿPÿQNjÿ€Rÿ³Œ]ÿ¡vAÿ™l8ÿ‡_3ÿiRGÿFC_ÿ^JFÿ€Gÿ{H ÿuFÿtDÿsDÿsC ÿpBÿCFlÿj6ÿQ>CÿXB:üp=ÿj=  …R…RC„Qü‚Pþ‚Oý€OÿQLdÿ‡Vÿª‹iÿ€S!ÿ¾¨ÿµ™yÿ°Œ_ÿžvGÿRFPÿRIWÿxEÿsDÿrC ÿqB ÿpAÿr@ÿcA'ÿDGlÿIE^ÿj= ýj<ÿi< 8„Q‚OYNÿNý„M ügNBÿOGZÿšj0ÿ±’mÿıÿßÔÈÿ½§ÿ›ySÿ¦zBÿNBMÿ\G@ÿvBÿpBÿpA ÿo@ ÿm? ÿo=ÿh>ÿi< új;ÿh;›i;‚OMT~Lø|KÿJû_LJþIE^ÿ|W1ÿ uAÿ¦Uÿ¤‚[ÿl:ÿ«ŒgÿxIÿJE\ÿsAÿn@ ÿn? ÿm> ÿl= ÿj= ÿj;úi;ÿg:Ôh9f9€N|K4{JÜyIÿ~GükJ.ûJF`þNBNÿlQ?ÿ£Œvÿ»¦‘ÿŽkDÿRACÿQEQÿr?ÿl? ÿl> ÿk= ÿj<ýi;úg:ÿf9àf9#g9~LzI xH“vGüyEÿyEþfG.ûUHQüVRiþXWpþE?TÿRDIÿn? ÿl> þk= þj<üi;ûh:ýg9ÿf9Æe8f9|KyHvE,sD§rC÷uBÿvAþq>ÿl<ÿq@ÿr=þk= ÿj< ÿi;ÿh:þg:ÿf9ìe8sc6m@ f9yIyHpAqB oAlm@³m@ ám? øk= ÿi= ÿi<ÿh;úg:ãf9´f8ce7f9f9vEuEk= k= 'j<=i;Fh;@g:+e9 h:f9e8ÿÿÿÿÿ€?ÿþÿøÿðÿààÀÀ€€€€€€€€€€ÀÀààðøüþÿÿ€ÿàÿüÿÿÿÿÿ(0` $«q0ªp/ªo.¶v.Ÿg)Ÿg)žf(«q0ªq0©o.ªp/ªp/U©o/ˆ¨o.­¨n.ŧn-Ѧm-Ô¦m-Ï¥l,Á¤k,¨£k+ƒ¢j+S¢i* ¨q6œe'œd'ªq0ªq/«r1ªq0gªp/Īp/ù©o/ÿ¨o.ÿ§n.ÿ§m-ÿ¦m-ÿ¥l,ÿ¤l,ÿ¤k,ÿ£k+ÿ¢j+ÿ¢i*ÿ¡i*ú h)ÍŸg)~Ÿg('™c%™b%ªp/¬r1«q0tªq0éªp/ÿ©o/þ¨o.ÿ§n.ü§m.û¦m-ü¥l,ü¥l,ý¤k,ý£k+ý¢j+ü¢i*û¡i*û h)ü h)ÿŸg)ÿžg(ÿžf(ûe'·œd'B—a$–`#ªp/«q09ªq0תp/ÿ©o/þ¨o/ü¥n1ü§n-þ©n*ÿ§m+ÿ£l.ÿ£k.ÿ£k+ÿ£j+ÿ¢j*ÿ¡i*ÿ¡i*ÿ h)ÿŸg)ÿžg(þžf(üf'ûœe'þœd'ÿ›d&ÿšc&¿™b%4—`#”_"©p/ªq0mªp/ý©p/ÿ©o.û¦n1ý¬o'ÿ±p ÿ¥m.ÿœk8ÿŸk2ÿ«l"ÿ¬lÿ¡j,ÿ¡i+ÿ¡i*ÿ h)ÿŸg)ÿŸg(ÿžf(ÿf(ÿœe'ÿœd'ÿ›d&ÿšc&üšc%ü™b%ÿ˜b$þ—a$’–`# “^!©o/ªp/ƒªp/ÿ©o/û¨o.ü¥n0ÿ±o ÿ“kHÿ\^…ÿT^“ÿW_ÿU^’ÿU^‘ÿxcaÿ¨j ÿ¢i(ÿŸh*ÿŸg(ÿžf(ÿf(ÿe'ÿœe'ÿ›d&ÿ›d&ÿšc%ÿ™b%ÿ˜b%ÿ˜a$ü—a$ü–`#ÿ•_#Ú”_"4’]!©o.©p/x©o/ÿ¨o.ú¨n.þ¥m0ÿ°n ÿsepÿHV•ÿŠo`ÿ¢m2ÿ¦l(ÿ¢h'ÿ’hAÿ^`†ÿP\“ÿ g(ÿ g&ÿf(ÿe'ÿœe'ÿ›d&ÿ›d&ÿšc&ÿ™b%ÿ™b%ÿ˜a$ÿ—a$ÿ–`#ÿ–`#þ•_#û”^"ÿ”^"ú“]!_\ Z©o.©o/P©o.ÿ¨n.ü§n-þ¤m0ÿ¯n ÿxfkÿLS†ÿÍ iÿëÓ³ÿ›^ÿœc"ÿ£m1ÿž`ÿ©b ÿubeÿM[•ÿ£gÿ›e(ÿœd'ÿ›d&ÿšc&ÿ™c%ÿ™b%ÿ˜b$ÿ—a$ÿ—`$ÿ–`#ÿ•_#ÿ”_"ÿ”^"ÿ“^!ü’]!ü’\ ÿ‘\ |Z¨o.¨o.¨o.æ§n.ÿ¦m-ý¥m-ÿ¨m)ÿ›k:ÿGX™ÿ³~?ÿîâÕÿ¢n3ÿ·Œ[ÿæ×ÆÿäÔÃÿãÓÁÿ²Œcÿ§_ÿ`_ÿm^hÿ¥eÿ™c(ÿšc%ÿ™b%ÿ˜b%ÿ˜a$ÿ—`$ÿ–`#ÿ•_#ÿ•_"ÿ”^"ÿ“^!ÿ“]!ÿ’\!ÿ‘\ þ[ û[ÿZƒX§n.§n.›§m-ÿ¦m-û¥l,ÿ£k/ÿ®mÿndvÿmVUÿݹŒÿÁ {ÿ¨u:ÿíâÖÿ­}Gÿœc#ÿ¯Nÿìâ×ÿº‘bÿŽZ$ÿO\”ÿc!ÿ˜b&ÿ˜b%ÿ˜a$ÿ—a$ÿ–`#ÿ–`#ÿ•_"ÿ”^"ÿ“^!ÿ“]!ÿ’] ÿ\"ÿ‘\ÿ[ÿŽZ!þZûŽYÿYwŒW§m-§m-0¦m-û¦m-ÿ¥l,ÿ¤k,ÿ¢k.ÿªk!ÿ\`Šÿ‰]4ÿáɬÿ¬|GÿͰÿá{ÿÁžvÿìáÔÿª{Fÿ¥s;ÿäØÊÿŸcÿTZ‡ÿŒa7ÿ›b ÿ—a$ÿ–`#ÿ–`#ÿ”_$ÿ“_$ÿ”^"ÿ“]!ÿ’]!ÿ’\ ÿ\!ÿ”[ÿZ ÿŽZ ÿ”ZÿŒY þXüŒXÿ‹WXŠV¦m-¦m-™¥l,ÿ¤k,û£k+ÿ£j+ÿ¡j,ÿ§j#ÿZ_ŒÿŒ[)ÿÜħÿ³ˆYÿº“gÿþþýÿÿÿÿÿ÷óîÿãÔÃÿ”ZÿÛʸÿ²~AÿTTxÿ†`@ÿ›aÿ•`$ÿ•_#ÿ“^#ÿ›aÿ›`ÿ‘\!ÿ‘\!ÿ‘\ ÿ[!ÿ“[ÿ‚Y4ÿDU”ÿBT–ÿsWFÿ“Xÿ‰Wþ‹WÿŠVò‰U,‰U¥l,¤l,ê¤k+ÿ£k+þ¢j+ÿ¢i*ÿŸi,ÿ¨iÿ[_ˆÿ†[6ÿ½‘]ÿäÖÅÿ–\ÿȪˆÿÈ©‡ÿ´‹]ÿáоÿ‘VÿÛÉ·ÿ°~EÿNRÿ‹`5ÿ˜`ÿ”_#ÿ”^"ÿ˜^ÿz_Qÿy_Rÿ–]ÿ‘\ÿ[ ÿŽZ!ÿ–ZÿHUŒÿuWDÿŒYÿ;SŸÿzV7ÿVÿˆVü‰UÿˆTƃO¤k+P£k+ÿ¢j+ü¢i*ÿ¡i*ÿ h)ÿžg+ÿ©hÿl_lÿmamÿ¢^ ÿ˱–ÿçÙÊÿº”iÿ¼˜oÿëàÓÿ®ƒSÿše+ÿçÖÁÿa6ÿKWŽÿš`ÿ“^$ÿ’]"ÿ˜^ÿNNsÿWa”ÿXb“ÿKMtÿ”[ÿY ÿYÿƒX.ÿLU‡ÿVÿŒQ ÿ}W6ÿ@S•ÿŽUÿ‡Uÿ‡Tû‡Sÿ†Sy†S¢j+¢j*ÿ¡i*û¡i*ÿ h)ÿŸg)ÿžg)ÿŸf&ÿ˜e.ÿEYŸÿ›e)ÿ˜[ÿ¯‡[ÿзœÿзœÿ£r<ÿ¡q<ÿøøûÿÌ`ÿMNuÿo]^ÿœ_ÿ‘]%ÿ™_ÿ}_KÿWb”ÿà™ÿâÄ›ÿYb’ÿx]Mÿ”[ÿ’YÿrWHÿSQpÿ—\ÿ—oFÿŽNÿRTwÿcSWÿT ÿ…Sþ…Rÿ…Rñ„Q"…R¡i*Á¡i*ÿ h)üŸg)ÿŸg(ÿžf(ÿf'ÿ›e)ÿ¤eÿx_WÿGY›ÿe%ÿž[ ÿ’UÿTÿ”[ÿѱ‰ÿêÍ¥ÿe_uÿNV†ÿ›_ÿ‘]#ÿ‘\"ÿ—^ÿ~^GÿQ^•ÿع‘ÿÚ»“ÿR^“ÿy[Hÿ‘Zÿ’XÿgUVÿ\SfÿË©|ÿÉ´ÿ³eÿvJÿCT‘ÿŠSÿ„Rÿ„QûƒQÿƒP˜ƒQ¡i*  h)àŸh)ÿŸg(ýžf(ÿf(ÿe'ÿœe'ÿ›d&ÿ˜c)ÿ£dÿu^YÿCXŸÿp^`ÿb7ÿ”`'ÿšn@ÿ…k[ÿCIyÿRW€ÿ˜^ÿ’\ ÿ‘\ ÿ[ ÿŽZ!ÿ•[ÿRNjÿP^–ÿQ^–ÿOLlÿ‘XÿˆV ÿ“Xÿ\LSÿwuÿÁšjÿu;ÿư™ÿ£q3ÿEJuÿnRBÿ‰Qÿ‚Pþ‚Pÿ‚OõO%OŸh)Ÿg)ñžf(ÿžf(þe'ÿœe'ÿ›d&ÿšd'ÿ˜c(ÿ˜b(ÿ–b(ÿ bÿŽ`1ÿ^ZuÿNXŒÿNXŒÿKU‰ÿRVÿz]Mÿ›^ÿ‘\ ÿ\ ÿ[ÿZÿŽZÿŽZÿ“Yÿ|\Cÿ{[Dÿ‘WÿŠWÿˆVÿ‘V ÿ_R]ÿbWeÿ’XÿNÿ•j;ÿȨ€ÿbH<ÿPRvÿ‹Pÿ€OÿOû€Nÿ€N†€Nžf((žf(øf'ÿœe'þœd'ÿ›d&ÿ™c'ÿ›c#ÿ¢cÿ¡cÿ™a!ÿ”`'ÿ˜`ÿŸ`ÿ™_ÿ’^#ÿ•^ÿœ^ÿ˜]ÿ\#ÿ\!ÿZÿZÿŽYÿYÿXÿŠWÿ‘Yÿ‘YÿˆUÿ‰Vÿ‡UÿT ÿbSZÿ[Q`ÿR ÿ€Nÿw?ÿ¿¤†ÿd7ÿ?KÿPÿNÿ€NýMÿ~MÜ|Kf'*œe'úœd'ÿ›d&þšc&ÿ™c'ÿœc ÿ”a,ÿY[€ÿWZ‚ÿ‘_+ÿ˜`ÿ”_$ÿ’^%ÿ’^#ÿ“] ÿ‘\!ÿ\#ÿ["ÿŽ["ÿŽ\$ÿY ÿŽYÿXÿŒXÿ‹Wÿ‹Wÿ‰Vÿ‰VÿˆUÿˆTÿ†TÿS ÿfRPÿXSkÿ‡Jÿ°’qÿ¶˜wÿ¡}Wÿ²ˆUÿCDhÿmP>ÿ„M ÿ~Mÿ~Lý}Lÿ}KCœd'$›d&ö›d&ÿšc%þ™b%ÿ™b#ÿ—a&ÿCWœÿrZRÿnZZÿKWÿš_ÿ’^#ÿ“]!ÿ’]!ÿ‘\ ÿ‘\ÿ[!ÿ‘Zÿ™]ÿœd ÿ”XÿŒXÿ‹Wÿ‹WÿŠVÿ‰Vÿ‰UÿˆTÿ‡Tÿ†Sÿ…Sÿ‹RÿlRCÿNNoÿ“\ÿ¼¤‰ÿ²“qÿ²•vÿ¹”dÿYHJÿWPdÿ†Lÿ|Lÿ}Kû|Kÿ{J‰›d&šc&ë™b%ÿ™b%þ–a'ÿ¡bÿXY|ÿl^fÿ¼™iÿ²†NÿPT€ÿ€\@ÿ—]ÿ‘\!ÿ‘\ ÿ[ÿZ!ÿ’Zÿ†Y+ÿWY~ÿT`”ÿdV^ÿXÿŠWÿŠVÿ‰UÿˆUÿ‡Tÿ‡Sÿ†Sÿ…Rÿ„RÿˆQÿtQ3ÿEJuÿšh-ÿ°’rÿ–l>ÿϽ©ÿ¸—qÿuS7ÿFMzÿƒK ÿ{Kÿ{Jü{JÿzIÛd&™b%טb$ÿ—a$ý™a!ÿŽ`1ÿGS‹ÿª†[ÿÇÎÙÿÁ­‘ÿaYnÿnYVÿ™]ÿ[!ÿ[ÿŽZÿYÿˆX%ÿ8KŽÿm[[ÿ¤ŒxÿACjÿUSqÿU ÿ†TÿˆTÿ‡Tÿ†Sÿ…Rÿ…Rÿ„QÿƒQÿ„Pÿ}P"ÿ@J|ÿ•i5ÿ¯mÿ» ‚ÿêâÙÿ´—wÿ‹`0ÿ>I|ÿzKÿ{JÿzIþyIÿyHéxG˜a$µ—a$ÿ•`%ü`ÿq[Xÿ`YpÿÄ­ŽÿÝâëÿȵšÿc[oÿkXXÿ˜\ÿŽZ!ÿŽZÿŒZ!ÿ™]ÿa[pÿmeuÿѨpÿìâ×ÿ¯BÿK]›ÿ‚Y2ÿ‹Vÿ†Tÿ†Sÿ…Rÿ„QÿƒQÿƒPÿ‚PÿOÿƒOÿAK}ÿ‡a:ÿ³“nÿů–ÿòíçÿ±•vÿšl4ÿ@EpÿmK0ÿ}I ÿxHÿxHÿwGþwG4–`#ƒ–`#ÿ“_%ûž`ÿ^WnÿuddÿÑŲÿêïöÿÄ®ÿYWsÿrXMÿ•[ÿY ÿYÿ‹Y"ÿš`ÿ_]{ÿ…xzÿâÈ¥ÿõöùÿÈ¡oÿXd—ÿ]@ÿŒWÿ…Sÿ…Rÿ„QÿƒPÿ‚Pÿ‚OÿOÿNÿ‡MÿIMtÿqVCÿ¸–mÿí•ÿïèâÿ¨Šiÿ£v>ÿGB[ÿ_LIÿ~GÿwGÿwGývFÿvFQ•_#G”_"ÿ’^$ýœ_ÿVUvÿ€kaÿÒÉ»ÿÝáæÿ²•rÿLQ~ÿY4ÿYÿŒXÿŒXÿŠWÿUÿxT6ÿ4Fˆÿ‰_5ÿáwÿU>;ÿCPˆÿ‰Q ÿƒQÿ„QÿƒQÿ‚Pÿ‚OÿOÿNÿ~Nÿ}Mÿ†LÿXN]ÿXJSÿ¹”eÿ»£‰ÿÒÁ®ÿ{Uÿ¥zEÿP@DÿSL^ÿFÿuFÿvFýuEÿtEd”^"“^!è‘]$ÿ›^þVTtÿ~g]ÿÈÁ¶ÿÉÆÃÿŽpVÿFQ†ÿ“Zÿ‹Xÿ‹Wÿ‹WÿŠVÿˆVÿUÿmTJÿEW˜ÿPbŸÿHRƒÿ‚S!ÿ†RÿƒQÿƒPÿ‚PÿOÿNÿ„NÿˆNÿ‡MÿLÿK ÿjN<ÿBCfÿ²‹[ÿ®’tÿ«kÿ¦‡dÿœq<ÿZ@3ÿJKmÿ}EÿtEÿtEütDÿsDm‘\ ’\ ¢\#ÿš\üaWgÿhX^ÿ¸™nÿ´ZÿPS|ÿhVXÿ“Xÿ‰WÿŠVÿ‰Vÿ‰UÿˆTÿ†TÿŒSÿŠVÿ‰^1ÿŠP ÿ…Qÿ‚Pÿ‚Pÿ‚OÿOÿNÿˆNÿpL+ÿKGbÿBJxÿjL7ÿ€J ÿyLÿ8BuÿzQÿ¤ƒ^ÿ«Œjÿȵ ÿ|I ÿdE,ÿCJvÿ{DÿsDÿsDürC ÿrC i[\ D[ ÿ’Zý„Y0ÿ>S›ÿ„X-ÿ]TgÿHSˆÿ‘Wÿ‰VÿŠVÿ‰UÿˆUÿ‡Tÿ‡Sÿ†Sÿ„Rÿ…Rÿ‡TÿPÿ‚Pÿ‚OÿOÿ€NÿNÿ†M ÿQI]ÿ?U›ÿ‚™ÿ|qtÿ9J‰ÿ{JÿIÿCIsÿpVEÿ¿¢ÿr@ ÿzKÿwCÿrQ3ÿ?IzÿxDÿrCÿrC ýqB ÿqB YZÇY ÿ“YýsWGÿDT‘ÿVUsÿŒWÿ‹Vÿ‰UÿˆUÿˆTÿ‡Sÿ†Sÿ…Rÿ„RÿƒQÿƒQÿƒQÿ‚OÿOÿ€Nÿ€Nÿ~Mÿ†MÿRK`ÿQf¦ÿϱÿìܾÿƒ|ƒÿ@GuÿI ÿ~Hÿ[LQÿE?UÿÀžsÿŠd:ÿn<ÿzIÿ‡jOÿ=I~ÿvBÿqBÿqB ÿpA ÿo@ ?YYVXÿ‹XüXÿ‘Wÿ’WÿŠVÿˆUÿˆTÿ‡Tÿ†Sÿ…SÿƒRÿ…Qÿ‡Qÿ†Pÿ„PÿOÿOÿNÿMÿ~Mÿ€LÿtL%ÿ=NŒÿÁ¤yÿÖ˹ÿ€“ÿ2K–ÿsIÿzH ÿxGÿrHÿ5C|ÿ‘h8ÿ»¤‹ÿ]%ÿìÿ¯Ÿ“ÿ5>pÿuCÿpAþo@ ÿo@ ðn@ ‰V‹WÁ‹Wÿ‰VüˆVÿ‡UÿˆTÿ‡Tÿ†Sÿ†Sÿ„Rÿ†QÿŒQ ÿPÿvR2ÿtP1ÿwM$ÿ€Nÿ‡Mÿ†Mÿ~Lÿ{Lÿ~KÿuK ÿ;N‘ÿ^bƒÿFW“ÿ ÿl> ‘ˆUˆUŠˆTÿ‡Sû†Sÿ…Rÿ…Rÿ„Qÿ„Qÿ‚Pÿÿk> ýl> ÿk= D†SŠU†SdžSÿ…Rü„QÿƒQÿ‚Pÿ‰P ÿdOLÿRQnÿ‡DÿŸ|Wÿ»¢‡ÿ~Oÿ{IÿšrEÿ¡vCÿ“_ÿsA ÿLCSÿ7O™ÿaI>ÿFÿtGÿvFÿuEÿuEÿtDÿsCÿrC ÿqCÿtAÿfB#ÿ1J–ÿqBÿ~>ÿ?EpÿUB?ÿq=ýj= ÿj<Ôj< …R…R#„Qé„QÿƒPý‚PÿOÿ†O ÿgOCÿNQvÿ~@ÿªmÿžyRÿj1ÿ¼£‡ÿ°”sÿ¢\ÿ¯”wÿ»¢…ÿ›k.ÿi; ÿ9M‘ÿQI\ÿ}EÿsEÿtDÿsDÿsC ÿrC ÿqB ÿqA ÿnAÿu?ÿTCFÿ4H‹ÿJDYÿ6G‡ÿm=ÿj= ûj<ÿi<ki<„QƒQ=‚P÷‚OÿOý€NÿNÿ‚Mÿ;O“ÿqJ&ÿ‡Rÿȶ£ÿ‡Y&ÿ°“rÿÝÐÂÿØÉ¹ÿ¿§ÿ”nCÿº¤Œÿ¯lÿv;ÿÿ]@-ÿED`ÿg=ÿl<ýi< ÿi;Ôi;h;ƒPOJ€Nù€NÿMü~Mÿ‚L ÿlL4ÿ6OœÿuDÿŽ[#ÿ¯šÿ©‹hÿ¾¦‹ÿÖȸÿÞÒÅÿ̹¥ÿn:ÿ¶‚ÿ¡€Zÿo9ÿ5L•ÿjDÿtBÿqB ÿpA ÿo@ ÿo@ ÿn? ÿm? ÿm> ÿk> ÿn<ÿr;ÿk<ÿi;üh;ÿh:Jh:OMDMó~Lÿ}Lû{KÿƒJÿeK=ÿ5OžÿdD.ÿFÿ§„[ÿ±—|ÿ«oÿ­‘qÿ²—yÿsC ÿo>ÿº¤Žÿw@ÿSGPÿLG\ÿx@ÿnAÿo@ ÿn? ÿn? ÿm> ÿl> ÿk= ÿk<ÿi< ÿh< ÿh;úh:ÿg:Œh:€N~L/}KÞ|Kÿ|JûyJý€IÿoI%ÿ:MÿGKrÿg<ÿ}Dÿ\!ÿŠ_.ÿˆ`2ÿvIÿœ|Yÿ´…ÿv9ÿXFGÿGFdÿw?ÿm@ÿn? ÿm> ÿl> ÿl= ÿk= ÿj<ÿi<ÿi;ÿh:úg:ÿg9²i9i;~M|K{J°zIÿyIýwHû{G þ}FÿWIOÿ;NÿAHuÿdSSÿŠlNÿÙɶÿæ×Âÿµ•mÿwFÿ^A-ÿ1J–ÿdA!ÿp?ÿm? ÿl> ÿl= ÿk= ÿj<ÿj<ÿi;ÿh:ýg:úg9ÿf9¹e8 f9}L{JyHcxGîwGÿvFýuFû|EþwD ÿ^F;ÿEHlÿ;I‚ÿ9F}ÿIWŽÿ8@pÿ7E~ÿ:HÿaA)ÿq>ÿl> ÿl> ÿk= ÿj<ÿj<ÿi;ÿh;þh:ûg:ýf9ÿf8Ÿf7i=f9|KzIwGvF˜uEùuEÿsDþsDüxCüzBþtBÿkBÿb>ÿdC&ÿjAÿt>ÿp>ÿk> ÿl= ÿk= ÿj<ÿi;ÿi;ýh:ûg:ýf9ÿf8ðe8bf9f9yIvFtE%tD–sC ïrC ÿpBþoBÿoA ýq@ ûr@ûq?ün>ýk> ýk= ýk=üj<üi<ûi;ûh:þg:ÿf9ÿf9÷e8™e8f9f8wGwGqB qC qB dpA ¸o@ ño@ ÿn? ÿm? ÿl> ÿl= ÿk= ÿj<ÿi<ÿi;ÿh:ÿg:ÿg9þf9Öf8€e8f9f8uEtDn@ n? Cm> tl> k= ºj<Ëj<Òi;Ñi;Çh:³g:‘g9bf9+d8f8e8rC qB qB g:f9e8ÿÿÿÿÿÿÿÿÿÿÿøÿÿÿàÿÿÿ€ÿÿÿüÿüÿøÿðÿàÿàÀ?ÀÀ€€€€€€€€€€€ÀÀÀààððøøüþÿÿ€ÿÀÿàÿð?ÿüÿþÿÿÿ€ÿÿÿðÿÿÿÿÿÿÿÿÿÿÿÿphotutils-0.2.1/docs/_static/photutils.css0000600000214200020070000000040112634600603023036 0ustar lbradleySTSCI\science00000000000000 @import url("bootstrap-astropy.css"); div.topbar a.brand { background: transparent url("photutils_logo-32x32.png") no-repeat 8px 3px; background-image: url("photutils_logo.svg"), none; background-size: 32px 32px; } #logotext1 { color: #e8f2fc; } photutils-0.2.1/docs/_static/photutils_banner-475x120.png0000600000214200020070000005045312444404542025326 0ustar lbradleySTSCI\science00000000000000‰PNG  IHDRÛxº…XÀtEXtSoftwareAdobe ImageReadyqÉe<PÍIDATxÚì]`UúÿfÓ„E^Xè+MITä°&6ÄFâY°œ³œå¼$÷·ßiÀV’xŠŠ%ÁÆY *EQ U9–* B =;ÿ÷½}3ûfvfwf[xLvgwöÍ›yoÞïý¾÷"Dˆ!B"*±âKâø[ÒAüïª_:×%îˆ!B„ V¤£í‚“ϼ=h*y›F´S|ïÄ}Y–uGËʶ«¾+ÇOÉÞò¾’¼© û Ë_¬]Jˆ!B„U`Û.ý'ÂtŠ(¸‚œÎ!'ÿVùW‹¾ú2è"ðR.'à+±!B„9òÀ¶}ÆLd¨ÓÈÛtÀz©E°ôè*{¤˜òZÖ¸B¯!B„Ø9ò5€U¦Ý`m€=+AuAÈLð¨ˆÃ–a)‡ªæÙà}I¨›£,‰“ò³•¾@\uŸä‹;&DH«[Y¶m³Ú¬T‡³ÿŠë¬Ù¤)fàº+mIRAN’$XJì¿–›jàŽÄZPÆ·žc-”ãùwÀ•<Ÿ+ÓZ˜ ¬¸¥"²_7úFÝYt£*ж#”“M€­!BÂ*޶Vá”sîJM9ûNZÒ²[H@-ÑÌóE7Â!X*€éK‰"qûÊ5åp“(mìX+ehêBË!“)ì  ‹ÀëÝPˆ!BŽli3Ì6eâ]hÜ”GÙ‰$1†*)ŠZ/ÐÉvªì%¥F Õ˵ǖ=û¤˜™d?™.a¹ù¢; "¤­Šœ Ùà]ª©Ê LÜ•6¶'ÞN^ȲUQYt:Еչ C¤jÙZ9²Ête™®œGÕœ9tËE·"DHÚ" ¶ügÅpsÄÝñH«U#;Ïý[ªóÜ{Š"-&[:¨°&é̺ STõmDTËËÑ(Ÿ¹‰{ë£ZÆw8#\,TËB„iƒŒ6Ûà«löÖ¶ÎI÷:“þ–O°h  l-@yaK’´@æK)‚ ë=Ì|=7XàVAw&ù³ŠnšèžB„i2!ÈïŽ*iUjäNº×e‹dÊòŒÖa¨)jXÆý©–;Ju0"æw³†Çì%ûõpFÌÃó¯i>Ö’íë¦^ðAã¨r'èÖs#©ZVÊ¡û©¤d¹¹+^*ÝTˆ!B؆²“ïs2ã§™Ôh‰âŽ?ã'ÿ ;Üñ;\û+œO¶á޽ô˜µîc ˜v%`ÚæÖŸ•JñøAAûxÒWð|ògðzÃ`¸§öLº‘[Ï•¹µfïÚ28ÑU(nôM#W¼˜+ºª#Y'å/†®YuŸäKâNÙÑ’K*‹ˆ[FÌËöóÖ¶ÇL¾°"tá‘yÐÆ?èzÊkl„`yUì:¸%îè+UÁ6¹#|Ôt¼Þé|˜¿³TÊ Ð±}"ŒØ†ìç“×¾Ý9ï.—®£ÅØ8P-ë‚ØMt—Àq›aò¡K Pw±mD¥ ˆaný¬B®!Ë…™pp…¡#YRÅ-ˆˆðþåårpê ·8Bà.ÀÖ6О÷@> ¥±ž¡Ò}IXI9%˜ý̳ßÇQ ÷Æ-¥@[Eõ£æãanc&¬!Lße \uzOض{?̽{ Ü$õüU‡j጑ǑïÀšM;U Ãr^o6 „Û½‹Ú¿ Cªs Š°a-C Ì"lªåìø17áN®Hv D€­Ö&huLwIX´[;Òùü¿£µm)A¡toä'/ ¤¬0Ëí먂¿Å"È®¥,öÖ†ó(“E T0ïªI§À׫…oVo‚ñ#¶=`8Û×?]IAö‚qÃàÖKϤìö–'Þ€JÀ XbYç¾ –µžHú n®™¨c¨Ñr¢û8kÄû–%º­!BZ!à pmM`ÛåüÓŒ,¦À!Y]‡Õ‚.‚ìô˜•„i&Âmdç7÷Æ"VVuH9ó?ý^ïoÖÀ^}»u¢À;ÿ“•ô'¾ú a·d¿ æÞ3®úÇ< È!à>R?OÄIÛĪEÐeÌÞ€-g†[DØ­P) 9b$qR~º¸ áÕÐJ$ª®?].x0›Çb#NÉÔ=G2uóAc§% E0=ö{x¾ùTH«»…ío9>¾¬ )ÿ#»¥ ̹ }½z3\•WLYîðãzù¸çlsw¤ë¸¡ûçz™»nN¨sÉõë*„*å"Ñu…bA„ÏþÑÆl½ð3 a+TªçEå€-Žo‰ùŽý –ºû„†ëa›œâ»žËÊp¶K„ázÀ°=¡#y‚ë³-[OÁÖÈUUÍøÝã†ÃÚM»4uQP°£Ô@˜n|p¡ j™îÍK–¿ Ô6Bû"D€­´y4”—ÄÀCæÔŠ5®Ì?iÃ-JðlÌ05f <Ñ|<ÞtŸÈNU-wl—çÓ³ÆS EAðÄ ?{ô–‹`né7pßÜ÷ ýs˜”AÞPïlÅ]¨u„~,Š{sEò*D7"Ø—!G9Øv½(¿ˆI6‡Ž`tééLX®êàÕØ·a˜´®mº >n>A)AKÙé™ãè†ò1a¯¿ö9|³f3NPmêÄ“aÎ]WP†‹L–B:|\ÇEKeü³%VAõªø ðaÓqÞ¥Sh5©üJ àŽ"€+,”…´eé(n¶!­‡Ñ2+bH Y®t ½¸ñZX'wÕ?¡œ?f(<û×KéûçË–Âó¥K¡ê°`Ç }»9©Ae¥x=êaP?ãû1Âz€é1\V!\'Æ·ÔM­AWè kÌÂ×?W’LËHÅü¸äa0%¤-‹P# `4Ð^\àÍ!˪ñ“UÐ}Öñh›ÐB7Ž{ÖsŸÍ½¦žsÙeðÄë_@%Ùñ`§gŽ¥êd3©:T/ßà5X"uA¶‹|F~ x -áÄrXëî ¯7ƒp§ò3fa ¸³ÆN/©_ö|¹èÎañFÈ!r¦ÿˆ\Bްí–ùÏ"‚Ù\¤'  «³˜,ý W:VÃ_š/‚õrwàƒY Úxá£×CŽ×>ô:|¼lƒÊrÿóàÕ~ëUu¸®ùç«ô#J=2ýB¸jâÉp5Z\ßåUÔ÷Å-£1•Ç×\繄֛ʯ(aÜôQõKŸo•êdæÚ›”\” ®;¯&[YÝ'ù­^%N®'•¼d’m$xœøŒU²kQ@»œ\Oy+©o:«oÇ&¬¾•l[ÝBu  D€­} ý?£5\‹år¹Rlò fÑjᙘ÷á÷éð¦<’‹å)ãÂhh/¾÷X·ù7Z&6)êd3ŵÜÇ^ûÂk05°' +ËÔ½è¶Ä 83n'ý^ðpÍ©Ø2ÌHwKqýÒ¹®05§ÓãXÂe» ëOpÀÏd ›Ó˜.›xApk‹©l1ƒ]OE„ëêýWÚÁ1›”WÎ& ¡‚n8|Ãí0à%! ¼ú‰f\#– Äà|)ÃHdsõã&5úöO#Ç/¶Y½«‘¡ôe[½†Y¼wÓô-=)Àßás<Ç?r–ƨ°-ÚLÏÅ z(v˜?™î•R¼(†jHòYÏ½çª xó‹U°l­‹oîàZ,2Ý¥k·hز‚K㇤ `9=v%<ÿ%Ú[ë'³ŸNågtý%'»Þlÿ8¥zx­~0=âöÄÕpaÜf]ue àV2'EÓXj‚n g} ,®XV:)3«%Y.9?j òÂP¨‹Iy‘\¦®/‚ðÆNgíÐj&?Q+ÍÖr¾Tý3˜ó,±ÙWÚ “U&8é!<Ïø¬’²fÀ ¨U Øö¸äazb/CU¢Ûݾd‚Їl‹äA@ÂrútuÒí…÷Wø°åE+~"@|,yævxã‹ ˜VRëcØb@w7bU5¯%`|ÛSïÀŸýjV.ïí#ñ_PVûxã8xŒlzëgSЕeŸD fë¹f`92æwXÔþ=ØêN1ÕSið üñkõƒà¿)¥ð@òwðpíiØrvâø[ ê¾™ãŠâ ¡°©"á.*'Š*ÁJvM8ˆ•Bx-eiLpRö¨pƒ)³1ÚH‰2ùɈ4;"$ l¶Ð)(¯ вä‘fðÜÏ#e";Î! [1°íqé#JR§¯ZØèú³(Т¬‡î\Œ`(î:Û÷T‚Þ?wûž*ȸcÜ|Ñ7¼?^*Y.2^´VþxùOêz-ç0KËïØÏÅ}¡®i¸„fò‚(ø&Jàüs•º‡¢ZÆP˜?vò¡K š%SÀÃ1{Ñsui„áVב,¯?¶LÕ‡ÑÊ›ÆT¬¥Ù¬-¨†uE‰áV°kZ ‘ ¶Êô°h "8Ñ1›,¬ŠòäGHàÉa¹ŸöJÓkw¢ä:’nÚ"€E†ZfÏ`Ï›S÷\/&ß瘩ÝC[ÉÃhSõja­ñ“¤2I¿Á,€‰¬î¥k]ÔÐéÊsFÁ‹ï/÷aËÂi‘6º”ì-Y[gXv„:ø[ì74©†¼¨ñ|x9†j=a}(ªeÌ(ÔÏQíIã‡@« fñl}ÜŸô-\¿…2ÝlYa·ÑR÷­ŠÒyö‚g¨Ù>®…ÎC\ Ñ÷SÅÉÀmy!;ö¡ `HgýCH¶…uÔ­2ÑÕOVr¬î~c:A$4y:m’bXh(!%"èyÙ£äDR¦&¬¾¤†äg $>%.Ï€¤°„;ÀÃ^'K ËyñýðÐ ‚›ƒ•$É´bû$'@½—€lEÂ\˜³nk¼.l¸š¦ê“Ô2ì'JPÀ%90/ÇóçŒØpuü˜^{®šP-™‹ŸÐ8.ˆß &É ØåѺ8£Är¢-NÆ #-ÙQºža`µÁm… pE0 !mIôö$ŽVVº•Ìhn§-Èòg,4Øö¼ì1ò I…> ¢$; »àÄ2è7IË Ëù×›KàÅ<€ûÃË3áî©0nx*ÛúÓ }g5µáê‡1ޑɮJ˜76ûBó©0ªþVxÓ=@W—ð€.— Èh@þ<Ÿô)|Ø8nþ² á÷gÆî ”HÝ­¬“»˜š¦<5/éÌëHl¦hg†01¨àÚ£œ :A±êP®Aˆ(³ÚtÝÇYŒ©†¤Y Û(ÚåþŽ ZLÆvª÷Öªs9u)Ç$Ý|ŒÖseøL†Ïa|ïëdž?×0 ë¹þUË÷Ç/§ëµ÷Ö§ûÍ4â¸Þ°vË>z,ª›qm׿®œ–tÆm©µ_?çja€¥¦ñuŸä» ÀBñM·Yn¡?UM„Ï»|×±ðPýœj³<¼ÅA­‘:ÌJ{€IàÆRgØpe½8˱&ŸO°Ñ lÔ­\@Œ?«ò@àht–Øöºâñ|2¶§ù‚¥Ð5 fÁ¯çJ°z'þø?ø¾—¶À¿å xOÅ÷ö½•ðà+Ÿè¢P©sjè4VrÁy1©JÕÆKå~4"Õî0¯ÅjÀ’£ÿ`ö×sÑúùÖøaNÃI4_®d²ž‹Á7.?ùu'-»_ÌAr|Š•T~عò[ Sã@žh=Ã(cÁìø`¦"P›Óˆ ÈæM¸=Ÿ©uí€Õ„`Àìû¬“ºçhº…kÉ`Ïà }¢Ó¯‘ïóM&ùVÁÖ¬ !B,>k¼”D»¶Á¶÷O ÈæÉÏPuÆOf Ð"Ë}KËȳ~,†ÙR)ÞE°”ì¯'@¼”Ž|Š=€>r%ô‘*aì†aÒnÕªy©œ ÿrO€Ý'ÀvÙ©‚1‡ú† ÕË t¯Žó„™œÓx’¦.˜yèüqà_·càµO¾ƒ ÇPM¼Ö4 gÄ›z[‰Buq €-¸YvŒ˜”ÑØÆ&€L‹»µ4qà®%‡‹ÜdEl¯yr¡/ôzÐE×$ð¾Y\dÙ£Äx.¤Kš¦§uƒ­¢¾òF\ò’e–ktÑXj†| ü2`2ücɽÁ×»$ß(UR"uÚFõM9 –‹@ ªE/•°~¼c;(á™ÖÊ]¡JN t5®BdÿÖø`~ãPO™¬Œá{Á9p·íÙ÷M›Dý…?\º–²\½U€ÐiÉgþ%µæ«g¢Õ©f‘:(—#¸l°BdSÎ[&S㉠,†s# ¶`/ÀF™ åÚ£ƒ‰€uKó´Ð6bGZܶÀØöžò¯luV­€%ˆèzØòv¹¼H öE£!¦Zïû`RùéÁr˜c/Mï×WªŽÀíÏ7J˜òñ4‘¼Fµlƒ-_»ž”] sšNVkôéÞ >~òVê 0<æwvÉ’®…xëge_š¥~²¿(6;à©ks ´œ,ŒÐŒÛŽ•ùl?kÌ–µ`ÝR9n Ò¥" Z¥è€-¹ÑÕ ˜{ŠèjG|I‡§^p ‡«P° «­‹Aã¥Eò‰Ðбœ›Ö¦Œ?zN‡‡ÜWt¾¾?þ_ê‰:E˜¦ÐE¶Œiû0ö²â*tË%gPC¨[þõT³ô(ãG¤¯#Èw’Xüº I-Ô¡B; ©ks…A=©p†é6Ž ™õ³û0Û¦¶Aˆ¶¶3äÌ誖-mß©O:=³jIÃHMƒYØb¹áÝÀl8òÜ¢í“âàøaÔ€®>¢\2î˜4v8¼}Üõpcò p^Üfx?~¾p-úçÞÿ# žACB"­iŸ ÷];æ¾÷5¬Ý´K-?G2ʇËÖy¯A³`F Û¦ÀÖæš_k¾6;`m‰ 2²UæXV h_,Æt!md"ÏRa4+`‘ÙJ3ÉÀíÔ”¸~XnXA±åð©–¹O„)ÒjWÃo•µàFPLiÇõégŽ™cO€äácáö”› oÌ!¸uººpuó¢>œó ‹½ìùî–¬ñôõ±×>ó‰B¥¨‘1¾3Oñ×è'‚”æÛ¥ÏHocE¹Õ™eîQ¶6YíÂp]mWê(DHÔ„E‰Ò-Ù„ÝE«Á¶ïUO9ɘ=Ã,úàZQÏP-²ÜÄ„¸A“Öãší?jÞ÷ÀZ×>¨:\ 1±1ÐýØÎ0ü¸Þ0é”ÐkäÉpK» ¯£šF¦ …jxÌ^ªFƹ ã¾êÜS`né7Pù(T¸n{þ]ÏSÕ22^gû$-pKF ËÝ+ûƒykW[°#”gd*³hN€DG!­Ur &¸«Xé–[ Y-HN/fø] ÔAnÓ§° ñyºå7½½å¾ê\ÓõÜð©–c¡¬çzÞUA\×|œëÞ·î}>­ØËÖo‡-;öÂÁC‡!6†€î1)pêñÝÁÑo0<“A“ô“ª¹¾ ‹éûÖº»Â6èH?¼`ìPšÍˆæÕ5 ý8ÿÓï)ð~³f“~*bûÙ‡å¶5°ÝjãØ£i`·ÜŽÈŽ´5õ"$ÊìVIÚPi0Ž`Æž"–Õ§eÀ–ŒØÓTàT­Ê ÞjaAÃøsó×°ÞÑ V8Â$÷zXÞð\Þü}dUË ëÉÐøÉÿz®—宓»Ã_ÜÃ%?ÀÍ¿ý¾ú~#|üÝ/°jãVعgÔÖÕCûÄXH=¶ÌKÔ ScÖø€%_´`~£y¸zï¦VûѲõ°]Mý§7ƒb,÷0§¢ ´ Û¯=vT°GS\Þ–1;à-˜­¶¸.ƒ¯³É¶Š1ÝìpPùõ³íwõ¬lPÒçñ¸Q/5CŠ\ã Œ¥0ö\ÊtŸjz‹¶ æ_¿Ú0ùçò¡ããT¬ñ›Êϯ¯—å¾%„íÍN(·à´}[ ïÐe°`Ï8¡WGèÑ)b ‹Þ[U MÍnXä>ÆIÛ||k•`ÃòRw?zÎŒ5f\óÏÿLå§`§Ç ìæÏmkLC$& lËÅ­"Ä?à ňg…`ìÛF\Ë-$ÇáZïìP[ Y­lrž÷§Ë¿Âh÷¯0%á6¨–’!†|ŒZ\7é c'Ñcž$€»Ãq ,—³0]¿¡4É °Œ‰q@\L y×hÜöAÃFžÕ|<-¿ój^„®0çXx-aÄ’ ®ªi¨;D`XH¾n<;EV‹VÈërþØ¡”±~´lO³ A÷›Õ›i9Øèk«þ @þ\oÀ!B„Â.ÍcKÀc$cà–tÍ‚1²\dÂèWì/^P`›zÍìTZÅðÉt/oZ Pu3ãЧSôp&¡ú&ؼ÷0Ì®™cÜ›àÉÆ·`lÂý|ÁÒ ©º úÁD¡"ûtsB%…lÙ?èʺL>Û¡d¹¯ƒ±°î–—ÀÓÍÿªº$XÝèqC{èq/¸Og_†z¾ƒ1›8 «ýxÙz5‚TJûD¸jâÉôØùŸþà laPŽG ¯ %F³ò\£,ÔzB„b º¨ *g)ø”¬WNÍR!c»ÅäµÄnÖ X?¬v†Ì€MG=èŽnþæÅI­z MÜú› ‡ë›aŦýðý–J¸Sž ‹êŸ¤jeT/›w8TËÝi’â=`¤”?¶¬É•cÈ–õ,7ËÝ&:+m…¾l‚ó±ûDxÃ=’†p4b¨˜uh˜´wŸáeºlo{êz,æà}ÿ‰©±ʰ=à¶'ß6NäÀ@ùË*ı\‘oTˆ!Büƒ.2W´VÎÅõZðøŒ›iQØ.‚mUÐõ£F–2%l2ŸÆŽ®/ÊÐA®…Þò~Âl{C)Ð…€ï¼Ø3!…€óåÍ+!(ÿ\ £Í>¾ …Ý„AÏì} îû¹ äàOò†¨„~ôõÖ[?cö ­4Ÿ®Ræøá`Ýæß`ûžJê?;=s<_¶ÖnÞ /÷¬á' «·8F¡ ï â-K’äC’À×]¨õ‹&î:ŠÆ«×š*†K!BÂÃvÉ–O6dG˜ËŒÁb(ãÅ܆ Á– ÐÓŒýju Ë@×k;&ÇBÚÄÄHNN‚”vIp\÷пk2ÔÇ·ƒwbO…Iîu¾Á,ÐÕ H5qÂ$ñï4¿Ÿ6? WÈ?Bs—~3pŒ…-0O~>s?K€ø·ÐAW_ýÝ PÆ8i+³Bö|‚Ìv-[T'wl—/”-SÝ|0!Áø‘4A1” DÕr¢ß$ºÙ ¤ì¸* °ئ‹6r”oÙÐe¨¿ è¦\3?Ûtc¿Zt½Xã€øXÄÆÆ@bB´KN&[tII‚]ÛCJb|3Îm^GÝ„¼˜|* ¤ñvó‹ÐÀe17Á蘿AÙIwÃú³îƒswÀé1wÓcßu¿Lט¡š³e C !ô£“Lp½ÖÃl=eášìÒµ.úÁåž«ÏV*2^,ñg˜’óê³ðÃrÛ–Ø ¶(Nb$Dˆ—í"èÇ@­\‘™®ØœöúÕ¦ñ€cÌB2À@]oâã!))‰²ÛöÉ Ð³S]Çý.Öx´¼ Âúñ•¦Wi@scgÀ ‡‡NÙF èNÜÇÀeŽa»Ô æ¹_o±T~Ø¥òz¹;-§o7'e²ë6ïVY.ÊÔ‰'⣧.}U,ѼõT~ZÐm3b•EU†1Ø~[–Œ¬e¹¼D¯"¤5‚n9c¹F©ûfZe¶é¾¡A›ó´ã–š™å/†2Dv‹€‹¯Û'À±) P“LÝ„†ºw‚¿ÐV@w˜¼ ÆÈ›!7æ ¨¦4˜ßï >0 ç1ÐçX'ý¨ZJ‚?;®¥ìÕÌÑMåçy‡*dŒFU%%Òý¾]=Çë¶üÃö¤À‹‚¯ãF 0KyaµAäÏm3ƒadvR´mÁ/ì´ãÅal“T`+’9š·Œ£Q¦ïó[L8.Iª[Ëe‚já¦fjÜÐìv{7.–mBBÔÎ`=ÃAî ŒCC*õ»á¼S!¥Çù†óOQËDf»Àq2L!`ÝT~°¤`‹þ¸¬ŒqÃû3VK´«¶=¨ëÆËÁ€Ãj*?ßµå6!v@báÑô`3Æh'‘{¸\¾ìL€«r4nŽîc§Ñscäú“Ήī×Ç3ÈëqcâÞë›Cum446CssuŠ! 7.¦b¡Sr$°E¦‰VÉ<Ȝϫ‘{Nb| Ä8ô€nÎöôøŒÝÛ`O—S û¤“à´A½aˆTh°ÅmÉê-dsAüú-Ðû—· ëíL¿ß_] MÍôýẓ`,ÔúQuñ±î*4TÚMýp=åH4L#u,¡Åq°•ôȬd¶)ª4uñ f¡úç¶!Àe *[ ì~¥Ìâ=Röâ0œs†cK"ÝGZhé UÀŠ?€‹A1*t ‘~™íq9s„E¥ú°7¦»ÃÑ»wBc³ön„ÚúFhhh„úúhjj¢Çà:nÌøØø–0Û!TÌ3K_–‹1Ž‘·#mùí€Ç@×Nía`ÏcÈ÷±rlw3¤ MíªZ^†¦vƒSNì }ºv„Ž„ãoñ}Â(;&{Ô·íãÉyÈvÕ2Æ2ƀ롻Êt‡õïËÖmSKa TÕ2?éQŒ¬üe2a¹KÚHŸÍ³q¬+BiìZ»Øaóy¡²[òûl@6‰è¹Ø ñÙL Àl¥4Fg=¬SÌBe€ŒR}{<Œnúþã> öj€ªšF¨«¯‡ÚÚZp'$–ë¦Ç£µ2%§\Ju³x˸¿®±‰‹Å@Þ¯¶#Ü0ù$øóyžp‡Ë7l‡ü’/aýqR~órhzÀg?lò–©¾ø·¬Bųî@A1†V‹²”®£Ëvj­¡õ‚Öʼ´H ý8̱—~¾ª‘õÁ,¼uñ(|ã$GABÔ3m²ÚÙGãÓLÀ¬ŒÜ+—ÅÁ?•M`rƒllÓÂ(´I¹‰Vz44hq*딀¸lLÜH??BZ…œh:t¬*I’ÀËý6æx8½ùp`Ùw°öT×AM]=Ô°EÀmlj·ÛíeÅ\9æÇúua_÷œÂå]ÐÐowü^ù¯.V‹/ @»Áµ—þ]„®pÿŸ8††5•_à`„ÅÂnØNÍêØa©°nËnkn®tÝ '¬ƒY`?s‹cS¦[…ŽVDçô u%ÆUÁ¯ø(~¨ l;“±Ó`€v± ¥MìØ´(ÞgW ¦a†4… 䈇v°—úI:£%%ð½è~{]ƒ=§q ¨i‚M{j`ÿÁ:8|¸†nõx›šš¡¡Éí±VÖŒß`’©Õò'Ža°ÁÑ^n,Ö÷Wk\x«aýÖßU¬*hþ€¾_à8lçÏåá^gü¤e©Æªå>R%[ p©>\gØÛöVª®@ë™eºŽ=°Nîf1˜…wÀj銳]LéB;ªKÆhí ê”A†Wy´>°äÚ‹Áž/k‘Àå€Ö¸Û&6UÏ©¤~3[lÓÃ}´‹!zjjÁ #'iú5rª @wGLgø,n$\Úø-Ô5ɰåZØþÚš:ÊnQ¥\ߨë›àÊÐQ5Ž ‚åê@÷θ©Ð[> æÒWüð«5[aÍfê6Eªƒ§šÀåîï!?öB8(%é"Q™³Âfµ< öÀ2T!¸áþ²uÚöØNÀדрªª¦N½š –‚Y¨•¨¬üä1W;„[è¦ùc³d+%oKm8 ÏϵmÕ0îâmâd ¼Å&ÐVÀ µMìh_ .3¶ Uô¶‡³9 d,ð¨°s!TôQ«õÄê˜f*pAí=ã6[Ó”µÖ¸ÊJççl¯yz6ÿ»«Ž…õ»A—ñÐ|¹mÕ5ÂÞêÆnjL…ªgœe¶Ï¯ç²7ÔgwJü­ðRCü·á)Êvã×ÿí÷õ€ü¦/àòæïé¡o;NVáÑ›Ê/ø„õV×sÑ¿·JÄY]kÙò:¶¦Œ‚»lÝV¸{ªÇ5ˆÏl€îC˜¾O3!ð“lž[Ïm #"']Ta"8V°­ŠuÈ´fò¹G3«åØ ®Ý"ÃͶñ3df«Øš/‚$cBÌ-' —´ÐæùpÑJº„õ­JÖ§R•k!ß Ñ` ï¿–œ†¡øÂ‘DÜh+#Á:MÖžÃr mIXB\ªÊŠÄº;+?3ÐR¶dŒNÕæ•U†o™a-oŒCGtx7~4ÜQ÷‹© ý`šUÈæz.þÃ`ÁÅ[ÖÀ§áz®«å>l ¤Ì–n\—G˜¬jü4 ;U!ÿ÷ÛŸa8Z7yËnõxýkµuQÙ«õõTåGÀÃBAE¨MA*£6Ü“Ÿ‚0_G8Ö'gÔ©(À%¿Ég@›ÊõëH°,½Ì6Ð6MÖÏF}ŠÚ–„2qâ€V/ËÌÚÔáÅÿn>F Ëïÿ­Ý4Øéè Ï~5í QuÔ `pó¸£îc(NÈÿ BÝý‡jáõÇ•‚Hågå]t9ÒN$<ïÑ÷kx‚W$Á]WN @»ªjêaìðT ¼Ô?˜•9Yú–É©`%•Ÿ®~û=­A¸,‚³òŒ£,á€]ÀÅ{Ô?ŠZŒ‚­2qÈ c‘©¡J±õ=#–‚€‹ )=À`œŠ2ÙÐè,O,IyD×m žÏlVÿTêW#6Ih5`èž\®‰HÉг…µ‘å¾BŽÍÄûg´~5p:)P×ben UÌ»ô(©TÕ ×tø+¼v°^?TïÅ¡–ʧ7ý²ë¿¤ïŸN8¼K¿ÞÐt3~òœÖâz.·FÙHÀ}oåaŽêÉêÚ'+<Àš°çwáXÏE[j‰¬«Ë²õ[á®)gÂ?æ%Âì¿\D¿yð•OéQ¸vKÕÉìcž÷KÕ~ ® °ýdaü,f!Îs¹`´–ï?Þ£Qh&G 8hçD2«ª¥É5P0 S‘80‡hd°žEV4ìË6(ÕÊz#@” l0O3™@f1Œ–ä°ú:uõß –suïÈêÎˬô°2ðjÚRR…­W`žY mXF~SÎ&<úç#•[…lïÇj®ÏWrí8Òà>jÆ+÷)V«‡ôððÇþâ$óVËÕR2\”ò×Kê—ÑWd»Å gÁÓ‰ç{ÏdoÙty°ÔF³’LÀòp]£—Ìše8AWÖ˜>i&ÚøÆžß¼µx ÜxÁé°ñµ»©Ô%þªkêèõÖþþÊ'^V ?ÓõÚÊz-·Ùè–EyÀŸEÊrÖqÓC(ª’±'áâc¿ rI”„¡ ôíƒÛ¬hL|8À-„Ð-t'@Ö‚ÉšÃ@Õh"cÇpcZF²"àË«0tR\n0òi·bd®8ÛÁÈlØ:9-A¹U­Á\Ôy`l$˜Ê¶L›u, åÔÄj0‚±ZÕÅLjåZÝâij(ÀªÀ¦à’E¶ìµ8¶Çr×7A»„ØlÙ:è¶OŒ‡C˜¨@ò^£Or3–+ór¯Õrõáz8çΗ`XÿnÔõ§Š©½'>RÚ%ÂòuÛÔ{0VrÁ"yŠÛú$Jâ}¢òâú㣇*Z`°§j_æ¯9ì­›á,²$Zƒú®VÎ`½¦Að–Ç.6ÐG»=à–û­Öu ê…Œu§Úüy[Ì`ÏMê?ŠÕ?Ýæ}„¬7Z…›ôƒ´ Ê£Rf£2!8WÄJ®]-Ý#uéqÐMóÒ=3¼˜Æ±IYEX$ïQ²&ž±öçrepÇêÊ‘õuãÀ²]bœ‡Ýrqe],d ^iN¨­]»„8OV “k4,‡ã÷˰z@žã|]]4?R7ëö‹(Ÿý×é~¹VJOA¶<Á e(,W}?k߇ÿÒú¬[%“2ÒØ€Ÿfò€—3µÍôP~a¡ÒËSXŒÓD½éb «¼µ$z`ë®™\ýSý¨ùúG $˜U±¿~­¨–œË¢¬2¶SÿtÀR꾄ս¢•Ô9ŸÕ9U×gCVɳû}l$+?ÍB+³«Z5Â_o0 Ó•%-Xš2T£€ ñϵ–m¯ç$NðÏ–ý³ÜDÛúÆ ÖsQªYÂx½ŠÚ(•ßäÓO€¿õ•w_ú‰º ý«uãË0f¹ èJ%­áa¶H(Þ²m ÌÀËÚhýqp›­(r 6Û¯Ûbý™š6¿-߇œ$#Ð尜ղxËfIëµ<\›Ø[FM}“íÐf®B•Ô}ýsu•Mµ©«Ð”Œ‘T…Œë¹J]Æ’ Ô"Z ©üt~¾û>ügT¤0&*"Dˆ#Rb9`¨ô·®õ\#¦Ë§òÃŽhÁŒ 7o§¯;¤Î°Óq >µ"æxO*9ø(TælYËt{vN-»+M¬Ÿ ؼOl Õg @‹ë¹ø›¾Òø“üäÀUÀ‡m ˜´ÞS·–`µipt&s"Dˆ{`ûÓ 9ƒ§±q=< ë?ô£²zËûáŽÚàœÆ ®ü⧘>`ñýt{7ÿÙ ;<àK>7n4ŧC5$…º&ÆOÇ÷î K×oókýìOµì\sW¡±CúÂØ¡ýàÒ·^WÁüOÀTÈÒ`f„¬1~Ò…~ä&’T)Ýéç„"¤uƒ­<€te?®B Ð`¹p>px\Ò°œº=“t0å‰ŸÌ gD…l÷Ò†o!§a1ÝŠâ3`vÂdKë¹Fî9¸8–‹`žÛô œÛ¼z/Üwà_îóbΠ¯v\…ð `±â¹épYþ|XŽÀ­Ý;§œA?_¾~«ºž;Ž Á0ôöÏrË~_Xò "DHk}н -誫£¾ë¹Šië¹ç4¬†Å•P•1FŸJïø0'œ ;c:›–Ó§Kú‚‡’.ƒ þ Åhp?<ü8 qïM¢GˆB… é—Ö?Dö•Ø3á‡ëæÃKÝ®¡©ßj˜ëÉ$d)ô#—†ð÷*º MíúT~7ž*ŒÚþQô¹ú›að %Ûé$îzü§òãÖs D—"DˆV¶¨†”$}°|°`üdt‘ÉÎ94—ÆT¾¸ãß¡4a¬Îˆ tûNÔz›½phÙ‰çÁ…íï£ûókž&€»3¤Ð/ÕσÒ109ñN˜w& š|),ízMrP; žl|Ƹ7yËÑÞ<^?À݉°ÖíXOÑ€åÐþÝàÎ+΀—?Z \{Ô2n”—ѤË¥þvóçï]˜ç]Zˆ!BZ?³]Â@"ºYõËá±CÅðLò…poûl šÞrÀÔjùÛŸwÑ­º¶^¿7æ“íÜ“ÀGg¸ªÝ ª~ž_3†4ï *ÞòeÍ+éÚñM ×ÃAR§¡ýºB»Äx¸`ô‰ôw³âÎ…Žp}ó×`%Á®¹v„ZºÿÔ;K¡÷±á†ó<€;´Wx'ÿ*ØNï“o/Uãw„:ø“¼^vŒµ”´žgòä¥Dtg!B„i¢_³eÌH5¸ñì)á®çòyo}×sOkÜH€¶ž%@ûlÒ…>q’­øçîÜw²\…íâ~ѧ«ážO“áù𠏶»—‚°‘űYèÇÑÍ¿ÂWÉ£ Ó€Á0ºwg¸þO£< þ%¸ñ¼“aÓo`óoûaïÃê±mJ]%d£˜%_Â'+1CûÀÛåkaAù:Ð[?_.ÿ@Xíxja-ÙKXŸ+º²!B„´°]?纊¡·¾ZI†p§ž¡Úg¹Zн½æ}úûû;\ïëºÂîiƒzðëL@ÎxT}¼q—Æ=ç¡7—’ãzªÇÜ‘y*\ýø.8H@ꞤkáƒC¥߻q§ûøÕÖ54«Œ´¦¾þø¹¾ûy'ô«OÑKÞ†ô•ýéºðŒKN‡ËÎBYé?_[Ÿ~¿ ®oZ3¥$xiÑ~Â6z™m®ûS C]±a;ݼ—âeÜ—»€>òXs²—¹ðÏe [¼»ôA—èÊB„ÒFÀ–üådÏ”#4b¹vA·§ûw¸®ös¸mµ#Y•-#hN;{\wÎ0@ùËE'CuM”|¾ž^ø=¨ûÁ3ä}uM=<0uU'_:þDx÷›ðSlx/~4ÜQÿ1¼K^­†~ü,v\߸„ª“Wì;f¿÷-ÛyŸTÀ§?l†¨%ßŸÆ W ¾¯®WµŒ¾Â( Û¥N~]…Rä:(hþ²Úx¬ªD˜Ê¯R–$Áj…"¤•‹Ãà³%À;yßj ŒQy ¼¤nìŒé¥Iã|ÊLXlÙ?.Û/:‰-ª‰K—ýž}ÿGúºóƒôsÝ÷ó/ƒ ¡HŠ(þl-¼·ôPòÙ»½øTµ\Lç×ÛýœÛ¸Ú0ô£>ñ=eбÇÓèT/Ô½L­šwì;Hѯܸ“úÞþ»þ ¸³â&Y ý¸Üq-w(ì è*tƒ{)Ý*æ0L|/qÚ¾€‚Ýï= üj…"¤­1[ Ã2c"]ŽYy˜!cº:#óõ\/sˬ[ _$Œâ’Í{ÊÜçxõÎó YØ÷ÀªÂÊÍwÜ?e æ¹·O‚kžø@]ÏEÐ6q]»Ò· ]¿Eã¨ocO€‰MkhÒzÓT~:–;=éx¡öeø¨æ ¼ÇÁŽg7ÂÌëáÔÚïè÷W&ÞNËö2Kÿ¡78zÂh÷&øÄ1Ì4ñýPyüµù3ȹÈÃ†ÍØ²/Ë­øí½DÎW!B„i‹ÌvÝs׸ÈK…¾Ì ‚`¹½›ÿ€^Íû 4q<ðÜ2¥]<<{ë9hÞþdý_)”.ÿÅÐ?·”0Økÿõ!ýè´{Àé'öT™º}‡kº€ÖɽTÿÜÏ ÈžC˜m c¦+é2àº-Z'‡2³Vžý`aÄ[U°D Ì€zåÆßT°DŸX…¡z%ØÝf.,”Öø‰ã÷6X®ÿ\Эرàa},Dˆ!mTbý}¹ö™©ÅÃïx#dHµAJ50ò¬6nŒï½ª÷ÑDñ™E¯¤G[òÿgfŒ„k¹ƒúv¦ªâiO."Œ÷8í„îtÝöÛ»á;¨*Þ“Šj¹tÙ/P]Û¨&ÜäÉo‹VÉæñ–e¿ë¹õÚ‘3Ä …Êîz®™®.ÉA%¹±v*¤Åä /t’—4²U~ðÁGصe“—T`­ýúŽä¶8ªÁ–aZùS$ƒ¤ ì7˜5Üû9®Ÿ‡6ü_$žì±fk²¢sÔr$([þ+dŽ9î¿ü4˜öÔ)!#ÓÕà ³~~4û ÊjQå¬O)ÓXAC7‚.˜…ov"Ðd²jµ.ÐÕ'JÐ%' €œ±ý­»…µ¯–܃Ç:ýˆ˜ø1ÐZÌ®M }Z!ÚBH‹€í𧧏ãdüO“%›q’É߃Ždø’€lfÍ7ôYùË^ú»Sï¦úÚ¢<÷Ñj8;­/œJ@ø™[΂ûK¾¡@ª·Ü›üæ´Ö(÷E݇øç4¬‚ÏãG¸Ð˜±Üp®ìë*¤€®¬³’Ìr³¶½qWE ÎØ·°ÝYd&œÅÁ¬ˆ¼d³]œ…w 㬥‚”yÄNBȵÊ&_U2@(!×_,†° %›õ%­,ÑÆBZl2à ½8Øä_& xz5ÿAc$ïÚˆî ¶×f †ÇÞYI¿kÿaxìí•ððuãàì‘}áó‡/ƒRÂvWþo7MF€V̰È(”Ñ.ø>¯Øæ%Øä_VÝRz®’¤sü‚¥mÐ5p⸲O&ŸUË9ÛÞøkyˆí›É^]ì}4“drïd`É$GY˜fõÀfõåGÁ3Z Û Ô%ÒÉ=Fî©`7ÁÉö:»LÚZe“sã³–NÎ/!Ø|ò’‡c¹¦¨–ÀvÍÓW–˜ñæ,‚3­³PA—¼_˜|&ÜZ] ·|èt¤9­¢™áÚ³CÙŠMêš­çý¸c)¸bð %/h<õ(ZT1KººÜ^ó|AXí.G Ðù]™s6YÏžj63Úi hK°“‘ΖuVXn†ŽÇÅ@ƒ¥±#¤½òMþb6g ö”89)ÚXHka¶êì+“`A*AÊ,˜…&@ùîqç50ûB(#À»2a¬üu|¹f;œ5¢çž ,eî>2ÞKù°Û>p"²Y€Q02²Ü/“ÝAUÏÞ5c…¡Þvø‹ùºŽwÛ fYÕ² Е ÐÎh™ ™à,ry |+,þ>]aÅäAwÙ<ýÅìgKØ"ç8_:ÇÄËÆÁ©§ñ,—|®¼§*ev͸©Æ#œL…žY³Iª–Œ¥ÁWÎTëZ!•EwÀf׊Ïc)»×ÅmŸÊß í¦LÂ9!³[£6 p¼º´ ¶ìsÀ~ô½ ÔÆ!Þ³Pžm¿m6—w”ºµWϰ÷‹u£ÏD¸ú•-õÀÈo¥Ët¶¥‰8dݾ:(qFU³ÿx N­ÿ &u›EóÚvHŠƒ¢ ƒí»xþåÅrÊj•£› <;‡¹t><Ûîbx6ù"mÊl’ü R‹Ù!ƒÝ÷LV?ýu™¶»g38¦§Lvr”AF.ÝïKÙyñ¾Íâú€­º°~PÈM¸LÛ™;G!xí”ö›mÄ î›^4×fr_ÊÙuV˜”™ËŽ)å®»“PØmcýgì|ú{†ŸgÓê5)êã ÛØÄ W_Ý8“ÎÞ;õÏ›ócésiÒo\ìø2Ýy I¤Ò_X{”±q«”+3‹Ý·tvoË ê1“Õ£À¬ÿ9ì à«gO)Gëä`ƒYü½ÓtØs,ÌÛ÷0¤¸kàPm#äÌþŒlÏÎíáÝû. ~¶š\®\9š9‚¤ Ú?¨y;¼zà ø.~a¸#%ú@ÙKNp(¦™O¾ŸÀž‘¾žì¾d°ørVŸÅ¬õ7¸-†÷#\ml YººW°û¥Y²±{MÊ=%ßå±ý|“Irª“Ã2·²ºúéçý¹öÁߌduœ¦ƒð»~ìÞf2ðS¤” xf^ÆîC!+«œ•cØæãF…®~DÙýÈ&¯¹ºçEY²+÷§–wÕ$r%R!£R|äd†º1>.ïö(}ÿÎÞûᬺ¨ÛÎŒ—Àãïþ`›-ßvh!xœ2ÚiÇü 9Úùa¨’Žû†[ôV;–k1•ùCºp-7x¡,ä™26ãËô3ã\hÐY\ÜÃmE…œ©?7zžõ2bxJ}ËCd*ëtŽ-óê ö°Îæ®Õ‡ ê“\ŽUb·xýeV×yq‚¡ÛJb”rþž€K9ÇöyÉãîS¥~½0@²Ù@Va,6ë’fÄ฾˜©زٹ&%úY ÉãØœQýqK5Ñ~¸ ‹;mÌI…þsî~9ÃxMfl6žÌ2Yþ©dÀ”j2ÎèûØj?cÐVýuq¶Åzµ>+Ÿí4“ó’“g „›TÁ˜æW[Lo\=kJåÈ™ 2h‡d§7.ƒd‰åîŠ=þÜõïpKÕ»ÔhjeÂ`˜›r ¬Œ VÙrfí7pëÁRH‘kà¹ö™tó2I_÷/C ‚åFÀ?—W†“–-¯Þ ãE…¬g°eÜ ±8BçUU㜧RÇ|ùsç€wýt›—°‡(”{Sn2k5šð¿ÉãT‚vÏ—ªpíæê€u†Ñ gaðçôb³Ù97áQfñéþT”vݱ¸52e-ËÊä+P]\è–ëuEÕï£Z5Qç:uÇ¥ºõÃ|ƒ?£þá ²ÏÚjã(_“?õv…‰ö ’=Çé¬M]k”:TùQë+ÇÙ:¿«Y¬­fè&ÓØWv°õî p¥Å4œvóÞ$ ô‰N×Á—ɧPÐ÷ûÄ1ð‚ïÏq}éú®RΠ†­pbãV8µág8›°áî(Ks:dQõ1˜Ö0Ë®5ëç‚-¯þ%?w»ñç4oU%lW.Ö©™Ì¬ªJf*ÇJN-•Æ6Tæ„Á7 ðf«R¥c»•hËø‰ ÙÇ2ä»2¾d±Ýl ˜ÉM¬–0¶^jÀðƒàëÚ8+”º0™Í&…ì·ÊÄň‘¥s»Ì0?;vîKZ¸ÎI?Ö]“Ý2#ñ Oà&*ya“ˆbÆØ©%§BHbC99Ü ÆpÉ(9ƒI6ÿ}ÂÂr‡@Ϧßᚃ‹à”úŸàšCÿ5='1,†~ÜÉùÑŒfЕý†~TtÓ~Y.æ£ÍÚôêmåì às꽊Ùhí4Ô‡ÚicðÓ0k¨eŒ5Í`/–‡FýÃáž`À°ÓÀP »çÉ©Âx)â®5"çk¬X…â¹ôkJ>ªCýg6ÀËÍPÚ ×nuÆQ¶ê¢0 ææ’§<+™J¯Ì@ûöˆh6ïK›ˆK¡k*·p‘ºO ÏŠà„üL g0­œÑ²YøÁVÜ´Ü‹˜û†èdΠH g¾Éæ‘Õ"ÓU\|ÛÁ}ØsŒ§ÛÅÃ`Um4Çí„4 fÁù ›øç†¨Z.'edm*¾5b>™àUš­¥éŒ ÂÉny Í2ðiÅz‹?fÍÔ79äØÕ3§ª\7)уÄ4ÝÃlGÒÁ»æ«°Û Âf+9C©i¹Ð€ÙLiÕ8ï)®Ó¥ÛPUR eà˜ËÚ<T¹‚­ ëÊàUþí»¸þ‰ˆhî‹¢j] mGÂ}MJ¤ù™´§El]Üs5°e}¿¼FhÓX_XG8*PQxEÁ¢ Iâolhyo1ÁJÂzé–8vÅk»}]ŒÜsôTawª$Ÿæ͈$Ðr3@ç[È1ÜH0j0bŒl0Vú‡j¤…Æ Ì²Õ õF?Æ^`æJÝ02O!WźØÃcy"BÀ[IÕh £†RL…¬SEMü¨cŽB£{hbXR¡ `sX+ ±.Š&ƒ®y2㸠“6t× '?·¬€SOÕ?,¬Ïµ2 öš\F}µA1k³™eæ³ïÊè•Ò‹bð™mCUîâ44¡²['»NËjòØp]9ÜÊ´Ü·p #‘³eÀ,9UW!¿ Õ[ކjÙo926‚”ûkñôh °Rià Œ­‘RK½0EI嘭?·‘…ÜŒ7“û]&3«çE(ƒ;`ÅÜ€‘­XO’W;±N VqÅLš­ÒŒ}²`<¨2 Í“ ,Šà"É^J•Á€õ‡lvMN]?@«×‹Áëg©ø!¦‚×÷vT€ÉKs³ÈÔ©“mÕ…Ñ—Òè•ëÚ7‹µasç˜ÍÊMUž«æ‚6ÓØdl1Wv:7AÍjKI0B¸¦rÖfE¬8ÁëÒÇk6úq}{×ÎY¼&\?Åò±-fk©%«Æz”è–8–°ºå±1P±)â~r÷n¶•ß9Ây* /¯$̤ ó°ò‰Ö-&›·Ì‚d˦u‘B`º†l)ë×¢é¸Ehu*ä@3­2ŽQ„[…¼ÄÂyéCÉüó”àŠÿ)à"Ã`FcÀvÓl<(XF0V¡—ƒÎgÏ€! ÿ,Z/ÆW6¸g˜¹q › ‘1JãÈÅÚb1x£óµi¼¿³8vªø[V‚u‹é\v|çºe«.L‹ L´ò 6LW) œÂ(v?Ó•¼‘Ȇ8󔲕Éਖbp æš””ƒé\;frm ÐHÿHOHX3¸IR‡BðÆe×÷³bÖ•{¬†o¶nòP"fGX.†OæRáÊÚhA†~ŒX9ºï Ë0ÙXIþÎþå•›òAH0ì8•c´|=Ó9•¯+ÈsZŽéŠá¥2¦ñ¨„qsYQ ³ðŒ“c³¢pÓ8•¬ËÆïB¾ŸÁÖ…±„l£šõ‹B6Șí{Ý£Qv >k¶®)P;¶†Ô—vêŽ8Ê\xÆ\Áè‚-ºùžÙƒì”u±‡[t–a'ÙtqÖ8ë/ß(½ƒm¿ÅYt‰—Ÿ£l’…ñ›³ÙĽÀ_Üc!B¢ØoW1À¶Ìà‘®TEáåù•TìQçr8/…fD¥)4±«F³ “jŸdûÍ@+Äh©ß°Ú€’éÇPKQõ•‹Û$¤m>cѶr!G5)0a¹¨¾Àu‚t­jÙCmªeßL>.ò§„¼›µñ¥À f«?ÖÉ‚Z`GV›eb©,Ô„È^‹XÅ?\‰—‹’#rº iÁ>ª`W*Û|bŠ·*°Õî4¯ÕrÀ2„r8ÀÅ äç¯,E€­¿cóÙƒé"[®`µ–³lϘ ‰N¤¸jÍ>RÖK…´y°EYhu¶ÅÁ–ÝTÏŒVžF0.5Ú k±Œ ‹…²Ÿ^ȼ!B„±-Rk©HZî‚t‚qèF‘ ªUj8@7¨2h,WRFÙOÏg €"Dˆ!GØò2ræ\|FÚ> ¾:½v–[IÙ+W(ß0÷ºrÑ-„"Dȶ¾àûV*e»2à~2e¾²Ç¯Ê:è–³Ö*™îË®õÏ]+˜«!B„`kUFÜñFšìaÁ®µÏL *Dˆ!B„"Dˆ!Gƒü¿F®ÕTBIˆIEND®B`‚photutils-0.2.1/docs/_static/photutils_banner.pdf0000600000214200020070000006065312646242520024366 0ustar lbradleySTSCI\science00000000000000%PDF-1.5 %µí®û 3 0 obj << /Length 4 0 R /Filter /FlateDecode >> stream xœå}Ë®$IrÝ>¾" rÂßî[‚€ZŒ´ÐBЂH©Y nIh΂óù²sŽ™GܼÅ⨵$=uÍ3Âææöv‹ßß”Ö3ÏõHé|–•?©¬gÏé1ÛsŽa`~®Rµ?Ky¤³>KœŸg¯×c´çèùq|ËÏ|¦GéÏtæÇ·ô\«>~ìx¸åf«Ï6u<Ïšù™ÒxÌþl³>Êùgá,f;ìÑæÓ*Ík5Ÿ«Ùï¥>WÊ÷Y¿ß²’ÿöøßÇùÌ#ŸÖõiÿûvAÏUû˜ÓzLϳÍñxý8þôçãŸþòøÓ_¾·Ç_¾>Òÿû/ÿé¡_›ò9Ï´ÿzœ°ÿþùøïÿÃú:ÿó¨ÿüøÝžæ8ø‡ˆKm劾k{f{qg-ÓæVÏgoù±Ê3¯ñ(ÓPRËV ~«ÝræçœÅWË3ÛŠ³?×ÙG¶5ð<ףæf8ÍxüÄŸ5M cÿoÏõ‘s=O[ïã¿>b…ÿòOØ”56åT:ÛmàÛ“jTÛ·Òµù¨¶›Ãµ.SÂäl%6¼íL¯ùxõÌABè¶öãD¿Ã L­aäŽõ® ¦ (MÂDB#'Ѐ-3Û€ teÓ>5®M‘ó­špdz÷ùßãóO ”·µþví³ÑG)˨þ_­íì¿>~µ§¶]FÞs~pëm ±l¹6Ðß0€‘”ÍÉHmj€aLÁàldÂzÜoL›EýÛ0²é†›8Ï®uh$þŒ$Øk‰pþo§ñW›TŸgê8Z‰7æ– Ïöʶìk£²ci„Q:—œçnØCv`rµc‡SZö·w’eYÕg­ mõÌ:ã€LqvqD“팽:2Àõ,´m Ë%ÀìÔœ³ž‹:ØÉfuV £Æl†'ˆ5Ùæžg¦ó×ܧƒß÷üït2àVlDpM;ãÆY+–“6øâ2sÀÇ#ÛÙ)ûeA ¸ÒŸ¶X¶^šéY×îÒ¡—xDƒÏÇß¼fŠ“zŸ÷Å®¸öšÏÖméÙÉ¿Ã{{¹³ ¶Ù±œÆz ÎÆÀl6XØ=ãjÆ/—í&˜ %–½šŒes³ý8}ýw0ÂjÔ?‰+7vMYÈŽm}3?F›5¡TMÌØ‹í48ɰ7æÛ›ßFá: «¶G†mÈOcéݤŸÍüD;ì¹fÄ4AqU›5Hï`‹1[!Ø^o†¾Ö(ÐÑ}çãŸàŸA‡ƒUw ;#¶vÌ}%6†êÙ6w ä\l-ù”¬²¹ʺwoÈÉYK]ZjNz~¯Ý~¦qˆ(Þ±õ‡x/Tm°GdݨÚNv>Ÿà1ã4È~µÆ~mãBHÛžƒìûýõ?̾ ‰ÃD‘u”H¡¶ß¡ ÜÕàe#^ã°o;GÉ6ÍvÉÿÀ®ùkqi6¨NÆ…ìÜþöm[­'tЧLÑ×ÁRöþ}Í4lY¿dßë|dCMËÚ¢e:d–@3'ÁN¦oƒ¬NêQî ÷48C0ñl=wò0CEªE-ƨ{€oö*„„Zè%Ö»€fH;x"ŒðÐ`ÒÕ é?›Ð°1Á9å›qç^fÿÄ·M–ŒFÅÔÿø.2¼ }¨ú.‚˜ ËdäÚ›MÓÒ:N+ ðRènxˆ¿TÉϯ:ä¿H¡õL¯B 3YæãúÏ>'¾šŸgÌÃû¶†¯\½÷õ·±u°˜b´Z«àvx(Ü»ôF0ˆl²uã¯ùP¼ŒK7PÇÂ&?FyV¨Ô¦,Û¡·®ÊԣˠIþ¿$Æ~mñ“ÒÐð!?%µS¡ð¨Ð)ŽwÍÓ€œ³‘²Mú{iYL5>™³& …ÀxK§–Æ £€²*´{°QÄÅfd ¬·†Ÿƒ‡àÉçM¤Ýv Y &7N) ÅŒ#›{)އn‡Èp¸š˜z“üy¡šú§•ÿ¤ ÷Žª?ÌÙ±%cÑÖ„>l– -QSc!¿?¨ÏäBÓ#åä Ó0B“„Üý­‹?ÌÜÙ3H~ÒªÃdL\OZ)} ŽÝ)YØPþÇûF¾YCÔàr©XžýEC ÿJ! ÁÈ>ÑSÞc°¡¥òÿÄåAHÀ«QaJ#ÎÈZÁÂA–yŠÕUiÍÐ ›|i§±#ÓN ”〞¦×›†oÕU;-äH^¤L;ö‰–0´ÿ¾?‚ynLlRƒÃI¶†²JæÏ0zì´7šòo¦úÿVѱD04ÖD@ X`¥Æ¯V£Éoë;×™ÑK~t·=̾¯F9öϬõÀÔZ‘‚؆ÔH˜7Ö°örü5¬ËJ©ÑÚï‹",Aã1Ó¨ÚD¯‘µ@<6Xº‰Ò’úãmæ:Èo‹qR(u¤NRø¤5(–¼cå› í eÏpQ@Ùjp-UãSߌ@²1(›`5ÍâçZ‚}3 kjéÃOz}8˜Õýäóh°]5%vñm“&®—w 5âIåB#óW“þšVÇ{ìI!_Ö„üþøÓ_:=N¿ÿ?Þ2ղԲŜ зA 8~PÔ!ì„Oh«m‡€±/:&Œžý3änö·ý³±ùEþào/´ç½÷ýû÷ã}üß~Eì¿Ö¹»u`ÿê0Úø¦tˆA–‘s,I5 è‚‚ºSÎýj@ì÷ ¬ëÞßl^Fï×!3Æ|Xoð)ù«Ÿæû’Ö_@ld’ïð¯¦Tî­4¶¨¶ò¶™C}À¯–q<†fTí7lÞ˜ôTãbú2žß§TžÃ;¸0Ýfå[p›²C ~ÿ~¼Oáë~þbæ“Ö>¸í‡Ã+Ñö›F5™¾MðTŸŠC´’áò|ôÏèU‡¼ã׆}Žþ*¸ñ™¢cA`S>®ÿsÔ«ŸgŒ}|_ƒXTÊe I+¬Ì¢­rýñßF& €è"‡l CÊo±\Ó¨³A²°aß =ìTñ×Ã@³Bl2ƒšž ‚޳\ésÓ«¦»“µGǀȲc\X–šÒà‹éñy¾dNo+Iÿ‡^þŸ¿ƒžÀ^ºJƒï[’ªþ/ÿ‹¡…ß¶÷¦à¬Å²6KmÝxÎ-®ð×Tê=ÁwoTZ5B£kñ›‰ÔœÚm´ç•4„~=•éOÚšfy­ü6H»9Ñ«N´-qÖ‚=5ÜÃL66äaQ¾h²RŠ735è0ÛǶ¼~m`Ð s‚iY ioMòK-8‹³70q5Lj0°¾* «îq Ó}ÖiÜ!›Mt7wô'¸FW$jᓹ=Ó91#È,v)ØÞ0&²Ú8nôíAªÐl·æR%W¾2“B*ù™àx¯¨]Ó”6!Ý×R¨7¤I«l 8j†ÜÊ…èJSv©)™mªûeêG{ö\3=ð\$†Œyh£æÏ£Áæ]ô3ù_¦‡½'¸ìL.j¢þ4ÙmêX „«¤œY¹t_,|!Ð- ±G²ÃÔŒé@§J…n,“qTÔ Ú í•)I 'SÆ«)ãf<0ö Ú#ÜjðLÄöuwî^¦ Êú’ €c²¸e¼+ö­tøg9ÓÑ%ƒTmŒI­Ùž„7¶#˜4Ø4ex%;GCD¦C}æ`…ú©Á'vÕžª4½TJëâÄÁ) æCü>2¹öRýV8°q/tö"âðo@:¬N_¶­ðÑùzà¤E› ãÑh4»€|GíoG>W”²­•jlN™':Z>®³¹Î‘½…lÀE…6sdcœ0$à‚±©gãf œúbç3›²ãþîÖéJ$!ºtP¶÷ÍF=âDç<è‘¿}6!¥3îOëB, gèÊ;"c<¤e¯ÔD7Žâa#Ó3)LȰxáãj€ª¬•hË&~Þ[p®ëœä\¡•Rõi¶†¥0²b ò°ã&ÄÙë1wc§«bóÂó´aŽ`ŽÅÏpK#vRŸcMÙ6vì·d„mÒœ/Æöl•^LFQ 7[ÿ+Û›ZßÙÈÁçµ¹ÉY»Yq†÷œF?™µÁ•ì2˜ù‘a1´tc÷¦¯ÐÕ!ƒµÎ‹vFã7ê¤ÐK¤dã¡P3w¶å4­¯1¦|1l˜UŒÇeJÆÉþ´l•¼X¨m,7ÔÑ`ÍÝöù“½xBf" †¶hvзáu5Øâ )éuH•dÜÞ»gÈkéq ßäÚs£x{îðJR‹¯ìz-þ€L:=ÆÎ1Økã2…qEq±âhh‡âwß¿xÛ7øêÝI Fw ÑäŽMB×ìÄbu¢ÀXºèFŒÓ¯wlò¼~&0VNÇ(ó:Ñ`¢¼É‚š â‹}0M¢cƒº“kØ=pßcè&SÕú l9jU^Iü>³Œm*(&~õ…¶öøP'LˆÙ¸ Éf¥¶sÄëÆæêŠîÁWJ×ãr‹‡K“C~Ž=yd˾ºx@‹ß¯;r®îy>ºcöðɽ¡þ§»ñÛQ’Q#F0Ô b¡yEÃÇnab-qô·òkz7BK½»°g¬)+¡ç'-×kŒ£ä¯-ÇmxëK41æwDƒkA%7òh€Ë8„YŠ9Ft¨œ Ž{C)†ÍFMî‚b²¡ò­ ÅÇF€n:·aç« Èô3xÌs dBÇUH­ ²ª!ê–:˜¦± e¦´5LͯJ©ìÈ2ÁH‡ŽALoo•³˜l¤Z$ª¼ðÛ—´ÄèÔ€K‚jÒ™8…¸_ÇíäV°1ÎèENÚH|¡ ¿D56J*‚œ£„³Ú–?¨f’ž`P£Dÿ /Ðq ÀwôøF|o~³ÚJ Y#õÈêój»åc· ei] 8äHh€~°ƒÐËËH3ã–ÅÖFj|¼ÃðË4Wñ0Ø{°w ŸÃ´‘ø=l‚Å«2`{]6\1CDÏTuËžj9Òl’ëàGÑp[ÞìÒ3¾´le¤›©«Ÿ[΋È?®v,f¤@#*0|ÅDkFV…vÝ„+i)Œ— G}_ŒëÑA\œëZE¦Í±0òBÒÙu”^9D&2o2UTH«œ÷¶ãL#ö(ð€ÜiYûWÊøí¨§{`lr¬²©3£ác7à­Ò™m…¸Þš7ô¢eÁ]ÞUÙ°@@_áë;ƒ`"_[4òq{kÏ%:âTåÞÐé׈£KÍè´"΃´$#èH/¶ uÊö~€Ð’@×­˜t4CÒ£q$HÝ5eÒ䯪ð鈪—÷^¥ˆ Ä5 ì2'¦š3Ã2ƒÑ,äípš"K1ŸâJ“ š=ml CÜÎYLnA²Är*¶ñk`Þæª_ð5­»åcÅp$?ˆõ§ƒ9¸*ücÈ/i›`±¦DýbñA85WðJ€«æLTBðÚp­*1t1€5 qTDç»2$Sjö!ìYq " é¬EŽwC*@Ø|HÁ²ã Œ$“Ë?s7dÌ™È7ÚP‡©Øò—s`G£(Ð…x–§½lèÚ-µÐWÁì7ÐC©<±˜ež¹Z*„g14{ Pgp.&’7l‡lÄ+jYŒr{f3!ßùª1Š5Lš1Œ<°qÍÒà¹ðu8Œè;n0ÿñêa1/÷6ÒxaakËöY·†½ÝâK.6*|¶0‹ã†O÷ÝmtÞî›aã.Û~°¨#7Æâ-›ÕÇK7Óôk?FàÀ°ÒèX-Ì{N<ñÑò±[:×÷†“‘ÇJcâØ,2­Ü8”‚Ü6Ç€I‘ÊfP©Î âq†Vhù` }¼Q©jQ^£¿F¯8ÊäÎ#¤Õ8äÇ¡qäÇú1‡ÝAQtÅJ0΃X™˜ Ϥ«V{þ›)@)jÛ¹eåØàV+¾ÿç¶ðu\ܶÁ1|UÈ.Db ¬ÃžƒmW3i‘hÙ3L¬M¦çkp1UøÌùlBÄ`eFñ´ç—‚ ûw%ãB[Ã5‹|À“ yÍømC^eQrøå© O82¡r8¸Å¯«aRè€qârX2{ƒ?–É ÏË5I-Æ_½)5Éc «…»oQ»Å|‘#°ƒ¬…%ƒ'×7@+¦KBfZ´ÕªdãAc'v æ¸ôøÉ”!3Áé.‘L3ÍÄP ËÜÀ%¡5©pdˆ-æJLd÷6¤‹AÇ‚/ÛÖÌ¢ ¯v]ʱàFC\['ˆüTÄMšm$6´+¯_i»H¢?AèXpK1Ñ_à¶þvC¡šKÊB˜ •ý3㣇º0¦ù&1¬B™Ë6yhŒðÑä³éNBö¤f¶ˆá FB9D©’´—²˜z’ç‘K€3ÿ\ ”¬’¹y• kÇ”áOÈË´;' ‰æªU£ï$D… ¼ $V%!à\BŽ"„gÍ!üD¢HìBJÈ̼›à¦`îø?ˆyakŠ3Ã+_夣#ʆi#P.øE *hêØ "+$ìGYTý"ÓS™f fD÷3Mo,C؇謷p¤ yÌ^܈„­ë´º*Cät+à¢É”yŽ“pê ÙÖrøBiP™Œ.g(ãæ†³}7œL8pq5€Ïçp:(F‚Ùœ…&ÊE$¶$2I¸’»¨pbœj©¼fÑB ¦-²NFû²µ-)lÍ7«ó3ùq@1쇛 ‚Ó…„VÐ&ÒìEÚ‹äÒÈ0¦ÓŠ Sq¤YÈxwv„§•P ëç³9NêÚt Ÿ#F!€ç;œî@‡ ¬dOqDsKÄÞ1ÜB ¥R‹ SÓÙ§|‰§Ø%E:!.0ÚZèRÈÈ¥AÛ6Ú¦ÓKžÝõí9ÀÎPž5&2Ç>#%8‹=éþòÔà[®£ñ%ä7•yÀ[’|ÿ*ë~CžB²_ÿ@þ¨_%É'Õølƒ}@£ yDÆMýïP,K&Ë̸²Q f0èÜü®î¼1‰ºS¥½ " v¥2åI½[Cõ†ãC—æJºÞ8©ÊïþLwî$÷ŠùäÅí×lÂp¦ùrìù<ºò3³TÞÌA`ˆa;ÙÆË!Fá°Bûh ®&iš‰×xeYLktºÌ‘`*ÅÉÕJ¼?uãY¿›Á Miôc*„‰Þi;#Çfc°“`M™0à`èùuoȦÜ0E£„yˆÑñáFp!_fh8¾&µ?N®“‹NŸ=ò"æ /“ø@Ŧ1'–×Z¯Žx¦’ì›6ä… XP…Èäe(÷`ÕíŸê«o`‰h‡‡SnÀWŒ;àpD ­¦H\ÙÉÂ"d.ê@!n œB\áö@#Ãáä‘8„ðjÒ•Á gtöº ­7€05ít@UÂl –æˆD˜;| 8¸×†œо³)iƒ7Þ ³pìßóÀŠ™qbÆy_ã=¿få%g¦æT17Þý˜I‡ygÉï<Ì™nžõØxš)šÝ sãê¯=@ö–äóƒWÍffîd  '¬g^ ç´Ìëg˜)\+Cr€Ê¢Ôœ"È®¢,mÜÁ^e®7°ŸÅéÂàâÆÛ'Y³IŠ¡Îp=/)ðÊá2@LP#COǕϪô@¢ÈH´x±ä›d¥:„äÇgPBâŠçí€_ŸŸ<Ú$Ïéée‹÷Êh¤ †¬=ÉÈêÜR†“âó™§¢ì ®2í7í¶µé!‘[¬€t±Á¿!Æ5½Ì“Ô99ÃÙFBƒYŒ€)H¨ :wfö˸%Cêôî-û×5¼²© ‚&Ëk‹kÁæÁ·—ƒ–Áô‘&©Éœ´‰Ra¼có4rq'ÅE ®9ÚÉQr«§C!Í×am?•±x éÊa!1‘§, –²ŸóÙ8[R®G0áЇ|2©yUƒï_ˆÉäfÍæ™2˳ÁóôW}]ùÃ{©’ƒÈÂ*ò¢6òÁì=Òâ—†xe!øÅxÇ~úšÀúyMu7 N€?µ£iôø ä…•>?=àh!ý,ÝL Ûêq0¤¤Ë½˜]b”¨)© ~ çbÏè-QÒ™¯§JŸ¢ÀHdÆØÄü®åù J¤ôù 6ð|É—²i€ÙJëF#°æ†Ã#—Ô58 :)P‹,ÎÅÎÉžÓ )UÅ&à“‚D¡ :]¸›c)yw„ÞŽ»%Ki—•)ŽLJÑã¨ó!ßô8¯ÛG |'7£ÀUyDEF€fÝR\mú€vü]0$ñ­a°l JàAM ò Û=Ekô½'ÔL(ümòvò’¨(Ëp-!«vË:$šöˆ5ÈìÀ ˜ÒË™2º™é@ãTt<”O¦ûº5O@±/ŸÀ!5µéý“±NÀ8a?Šœòú†ƒ¾èwÞ©8úŠ…gV­y+´˜àö%wL? ä™áš‚€˜ñ<#!¡ ú.ÝÔ·}C.¥.Ògà.C­AöáÉ ;g°?ÎKk¡&Ÿºñ-}RЬB…/# ­')1LŠ9u±zQÛ˜ -£ìôK aÎMÔw žBT;«j·_ …ý;b°)ûõtÒßµµûñÓøI>Õ˜âŠ}\³7¹]˜ŒËKbåZ<3¡þ^È¡y8±k9f ó¯ ž;²]Êsôž”ÎúÚ£#ƒJML†ÕìÁ¦fããJ ,Öî!.Ç åÚìBΩðV¡PÜ:O Üo{ã GlÝ~]{{uï{ã;eÄìœr4ûÃ)M:Wçtkwº¼#² ܳÇã3Í3ù ³Ù{ñã±á©$G¤Po~òhô|ÒÅZ‘J…å䡼ù„Ó¸(:mk7ÓtUðu‚Süyfe#¤ÅkxìœVù¸É(ņë ÞÍÌì9vïà)±Íô‚ÀßöÔ JC#&ðµ—vì´ôýºP³{wÄiôÖ˜›Àãñ5í żVŸý–H4L²ë¦m£öÁ; y¢ÌpX‡ùøÔ€Œw¸fx‹ XͽúBŽ èS"…y\Sžs%ÉÚ`¬·‹“¡cøÝW‚^ Jæ 7˜_Çõ@§FËþ˜TŽˆIUYèÊǶnPå`%û"[sPHõîõÈ”Ÿ%] Ì`àmÿá·0Mê.Ž˜‡.ÖãØ±‚ZgêÅVOÑÀbgJ±ÃB¨'Uš0]ÓÖ¡?1'ZpètÕŠ©Ð +7¦ l^L‰)“ýµ>…÷$&$ˆCçý/ضEK.¼M8•6©-šèm)É]R°{°¥*_ æ@; ÐP&uv%þdZ‡YhF–=—’xq¡^Cþæb¹RŸèÃÀz=œ8 Š1ªñºjLrèÌÏ‚n»ºï¹C§ÆtHšä]ÖÓð[?¤'Ùf̤ñ5iÛoð¢6ÐÒl§ Z@÷â`k<ÿ¿ƒ©I$Ó¹JºU9Ù\`¯½Õ*B6’»M‰ µˆB+~p›ªHŠ:å8FpÝžÍ!|FñkæõÓ¬,ÞTRO’„LVÍ4¦m:S—L‹û8~F?¦N•S9ºOÖ'è7 éËö©L Fð÷lÎ|´Â%÷ ÄW1,®@ZÉŠ'û¯EAHZ+€èWC “~µ\*#5dý… «ä$å"†ÀÅŠ¥;+JÓÅ1û+,cp㘘+“Ê®bÆi”4&÷+JTwáœY;ñ !ÈȽ†›AÐÙ šá‚J“SÉÓGº™7lZ÷]ôý©žßm¼.Í(&»èJ?öb<èZ\×ÑõL5°x¸Qñ #¿1VGÞÈöiÀŸt师,Ìq×åzÂæ1+’\n%ÊÛL‰Oä;£~^\Áå¢Ûþ•";SCœ>Œ(fúe<À L3~F¬ or'¤žJÂþLÆÿ^l0£¨HÚ1¬¼Œ@wµp[EÊÔ€« tÑ-ÖÎÊÍ3ór;)3s‡—xG MXm‹þªŒŒ0•“+ë1!23‡¦±&Ú©Ë9n¸ÿ ôvr€³ÉFëºÀsH‹–ª}‰×•±»»Ïq'+†Ïb±š¿4ªbúIålxÏcÒwמåÊ£‡·‹áž%D]"?æ}­Àì)í10/Ï»ª†ÝàVá±wï2Ñ Š¬`¾#q?++yo¢š:'-s=Q¯©Å‚ ½“… ,€‡4ø.7HüúólèÌLÒë,·»Gîn×ñ"jf¹JÞñùJ—"Ã`Ð1ûéŽÔ5|=?]³1s$Û¥ŠþÇn˜ºœÄ|2LƒQ‚•â s_÷™à,'#ιËGŸ˜¦€ $Ôâ"‚yk tBÚ–*ÜByí¼L´h>eÞ-Ô½ƒŒîÓýqM*_V?€']îÀå'ç¥"ЏÍ2Ì–pa@v<Â>!š„Z×¥÷íWÁëem<`4^1¢paOG%0Ý )Ó•q¼ý ¼(ÕZXâ|‚*o•Äóœ‰Ú:o]Ûƒ„ Lž;x=8Ù¾ÕXÍ£SqêÜ…Ú¿/]8Do8¤¸~+CÎn4xÚà ËIGn x:©ÞG´ÄqãM¢Y>Á̲҅^50õj˜ L_Ü.J˜JR˜¤Uë2GöH&Ü™`(@À¥fxsgç¨&?–[òðŽ$Ö`ò¡íYyÁDZ ÛÏçG·œÖ…v*Îr5Вﺎ–HGe ÔªD\áP$ݦÅÐX+sÃZe¡±ò´Úõ{'á“,4<^Ø< GLVYæÜûɉÔý¼¯ˆÕª&ånX¬oÆ‚{׃-Sœ £ ?ÿ]µ8®[”#Ô²&78£—×¥¨O Åî> éûXär™Ì"êôëéÈ*ºzEŒdâ¨w}¼íÄO7ÇX Ó=W„Hm¿¼ GIºäþº˜.E&åÖ#B°­l÷"k°A«ç£¡µÐß3£|3ì`†Ãx•ßÊÛ™ sÀôÀ >¸ÑãÜN¤¹ÞŽõt·püÌ»P—Í”*uVãz g« =8#¢Ò››ü‘Åí¹Dz|Ò«§ªsl©ò#Åë†âyÈ—Àð],zI¤MUm&Ëå䙜5âuÁr±XdRÆï¨&YMèd¨.òŽ—ha÷JÞ.§²ê)ÔÞüÎÄ{SÁt »ƒnè“lu+F¾‚šh¨ …ƒnòAŠhcÛSÐk7IÉéñ6ȸ§Ýû@pøN•)–3 >ÏÂ+H@Î5Íßä³gÑæ³™ÁN)VÇŒØa] kAÞ9lÜ‘‡W–•ƒd$Ï]Ø«ô»GFq¹ äMJr”Ã)£Œn‰Pø8­mf‹Ò×ç÷«X}}JmV 8Æ.iƒ:U†×SÄD¶Wu¦ˆ>rç0×’73Gä¹”·gþÇþÝpSÇå³Jºzg ޶GÇÆ±FõÃïé›û²Ž—ëÌ%QÞÅ+ʸ²KÈl(^´õ›÷¨Jû+"ÃzçN¿ñÖ¯í¬ð˼gùôÉ' kf–ŸŸ·”7H‘1w°EÒb‡Q3^yßdyñÌ(ÖpÁåt&jo˜…ÿŽH9ñ9tš Ä£š÷Mÿ¼[ÙòzË[×F׊ƒm´œ§¤‡k£™ÕFZ¡Öé_¡ŽxnåÇ‘:zkà]W€ŠEAXpcë£h¡ŽI}ç˜>ZN•üÛ )n @æÒºB uĶBŠ›Î¬i-…´°:i0¿ÂÐ@½˜#”ddñ'飉­¢!—k2ªÕ"u” lÓÍ—ê^ê(ÒœÏê(;È)ÔQô^ûŽgœŽgRŽÎÉfÏÅ)™K“³Zb‹˜ºÔSàu*¨¢4dAô¨—6ZNe¤º6 °Ë…6ºÁÐF½áØ„ÇZþ“‡òɆœ>7xq*8Ã1aj9RFyG½_º(7KÊggáã ˆ;Õ#r~øÞ¿ÆçsÏxÇ’­Ž"RœÛVGã|P=oˆ7U‘´=Ò¥ñÜ Žbtr ©£œÌœ—>ІūdÒG9ÿš‚bu§ôMqD4x(H¿£ük¨£€Ì0¹©£Ä¥|½ƒ›/³×ÕÑ8¡[Ý [ÅœÕQ ÐÚÖGÉJ¿ôQž±ŒB‘t}0݈¡bõÈbw}`QÕK裓~=Y¼P´õÑkê£o[ñÓÝAI„¾K`äÇãÖ`Ê ÁÉ{1*‡;R,N¯\€kÐûò+ót½µÊ»÷‰VÇ%r•JÝ¿*{eÑó‚IUºç~`ñÑÅ~Ö3õ5ýO“¥_„¡3ãNp.á©;à1DÕˆÖÕŒ³_þI»†@ROÖ0»+ÅÏÎT ö&Á‚¼g€ ¬¿!ÂÉ…`ŠjøqCöVÚ\chú¼ü¨)à/Rp{¡éƒðAêé–7s ^–8þ<YEë&·Ëöê:L¶;n?Ó>›»¹Äêgˆæ ºDƒ „xx$H8Œ ¿®H‡k™ºçY®u_•É:x¾õxÖãÈg? -/i0$¼ 6U(¹¨ °@öˆ´H€¬E×T}Yϳ|fã <®f«2°Ie¼=øQ?Ho0ž!o Å^–;+qÑÀÌÚÊ|5ÇÁ©æ)‚K—h÷‰á}€'å"êʱ3ÊÐɈN‰èûÉû¯œ÷H©«"qkÓc€Añºií yL2Dõõg÷UwnRµ“¤r†“ <ˆGˆ”¿6ªC¸(êŸê˜zV«r¢, BÆ ¼´;í±3^r%bÈýpyXɲ,ùçV•è¨}2íä×7™'1Øã^põCüjî€ÒãV–¢„/à**Š”ô5¢qJgpS(#w*9`— ¸5Ïã[(ÈKxW£‘¹®ÓÎÄJŸËz*ù@((Ä„`ø­Ôï³xî[~§>GSY‚ËÔ• *ZÁÅw±7nïì×M¾x‡ýÞ½K‘¾J`rÇ^sß ñxfR¤¯[¬á†–øV ng ­šÍ í-\%Ú•&{Öt‘ø¶«º¾¿w½Kõ’øD2?¥"SÖ³¾<·Ý3ÑU©äwfàÜ8”<–§ÎtÓµXÏt,»F¹-x£.³?w&>ÀGËS½¥.<¸g=¶ƒÅ»xãPþß’= Ìe4n‡Þ¼Ç¨üÅÌÿÙY!&ðT cfI\÷Eƒ #¸”¸zŠ”+€¸ŠïÉÏ/V*;«.ÿÛ(½2RøK6Å釬¤\TÅ´GÄg î|}ů¶‚Nš|8èHßGRâZÉž¦©†Èúî¹0)YâLþJ*^yÐt‘ÊéHõä Zß0‡Õw·øL¡{«o{¸¤HìGª ¾É>VñO4°$©· ¯— ´*س¼œœEŽ¥y>øÀTBX©þöTíÔh]YûÊ&Ãl"MÔsuO’&Ò_\, ZÄÙ=Íò¦WÞ›¼©…‰UÛ< õNåç¢îãJà%õëR`y8¦g 1?<ð¦ºÒVCÏÁr®Ã(oêÛÙä FÑ É|?»A¹]@ ¿!ÍÝi‘8/t!Ëñ`FV%‚\¥ŠŸ™[çÐÕt|ãg«ÂËOä1ÚS=¥·0mQAêÓÑéWÈz%žw#°«or¡8Êf´ré‰^~²+Ó‹åÌÃ3NýîI•Èrã¹ÉQsü]ÆððET]"mü"Ï, W !=PH_î2ªté4Æ"p+\7ÀU4lÝã]7Ž[‹\©×;ï ÛãW‹égø¸¿‘â6Ç[ƒBsW·‰y§~Ü[”ÃÙö‹WUK•ã¦l§IÕ§yp᤭^ŒLÐP qéà‹ Š—ÿ®²²äÛuc%Tä-ƒšïŠ|æUßš¥|¬rù"go¸óà}¯±ýHž¾‰;Á*ÄB¥¥\P„JûýrÓãÂS=šÊîñþ~„JÑ@œ3TŠ"}nSbšpߪ›Må+%âL9E7q‡œ£~9¥[÷ì“xÝ–"‹ºˆfÄð3üáœÚŠd˜¹9%–†ë­ÉBÅ‹ïoÄ ‡®Qo(Ħè"±*ð¸Y<ŒÎ_w{0zßQ§Ý£R‡Ï.‚V1ûKdùâ<è+÷˜X`F\þpTεCrÙŽùKŠøÎìß¹oÇõz w›Kßø=¾¨bÏÎ]²1û#Èj/OTç«¢¼°ãDØs 'jÇg‚Òô±ï3 ör~J¾„ÔÀìyÑtë-ëÎŽG{¹¼V"ÚËZ”=_Á^àƒoìXÇö\Y )Õ »*:¡hoáGXw0wïF{KÛ©¥h8 ¿Q¯×{¼ÝIÕD°Y³* ÀÙNLüÞ„¯N×céóŽz§¼T/Ü-Çê¡¿÷Ïa-O½áùèqî}@ö}2G„ýc¶;î«ñ¤X«§.®œƒ@–'%.#(b/¯þc¯÷ø¢„=;QÊmö¤¤ÛòTMx/^”xÃ(uãNtˆõ½ýŠôM t–£ÚU8P¯6›TD&Òaª 1w}3ýS?¬›f»j»N© -*wU³ŸNZÖ/6 I³ßj² ¥Í~=àuX­ lÕ¨æ¯×-|cË(ø\†Ç=Uâ #Æ[ƒCṡëú8oC pˆï¾IÔe”ÂOxŒ¥Áƒ‚±R'èõaä¸Cé ‘œ"H¼Ò„"Xí [ÇÑF]Ñ÷÷³½ô{á;ǹð›9óÊq.^OËÊTÞ¸ç8£20¿7½sœËÔG1=Ç ê¤zŽsÁá|¥8&,D†3 ºüCØP‡çyF†sÁêU#Ã`öê<ü°÷6:v‹2œ÷ë^‰;º g?2œcrIWcîžßÌ•õùÍ\·{Àt•rá9ðöZw«Ê_ÞXüæ2U¦pç7GÃÞ[mÜqß]Ô0Sª­r}ËÔçj½S*9Ò›1ßSÕw”ÞŒ”:Ь6,׿·¼%jB³øÖ¦¤TBR¢á¨Œß^×oÝ7~bøÆ•O ú[ ƒFõµ=CÒW–†F÷u'÷M^’ Úà†>•˜E¬:¼U‹Ý ƒ&^w½0zß*»~„N“s?f¿M‚Xœ› ±ò¨…,ÌÜ.†êÜ" ̺Á˜ßMìL\ Û¯Ÿrcíî}ãc|§Š˜ˆ&НMT±:§¹X»“ä…'Ù@žúظýLñ*Ø­›·C0£ËÞb‚ïš “CkÇzŒpWë¹¾¶BçˆräÛ¢AÙ •ׯ¶Epæy³hXK~l‹¦ú'¦ÝbÙÛ «¥—Ë¢Áö ÔÛHO¾w^Yåm^#¿^s«JöØöLet¯nÚ½ðÔî¨wÂËÛž¸Ò6i¼Naéßñª+çÑõVÞ}äÈXöi¹æÓÞ¦A,ËM‡X´Ži½‡€’ì „ºÙ²9O˜5±!ûwm×±_ç†^fMlxŒîässr¹æ.rÚf“[˜5AŽfœ\sNÌŽVAÇ/éßä‚ßÃvÿßVð× ùw`ͪഠ|T@åЦÙ·fOÁøÒp½3"mò­Ã÷wöD¼,q®{ƒræðí‚“õ UW•Îh]wñmÚ !©šýf¬|ò•vÒº\ô5÷ðF á¨ºí¬Ã¶øsSòwâ5^4x+¬!ܲîÁ)Ÿ"<8¹å,šscÀ ¢3îb+{éC®­+û ÌmPÕ¢šu*87Ô´qçÜÙCŠñ{Uú“2½*=ï3Ôê²jR"Õ[<•ÊÎ:Ë Ïž£ÀÇ‹ YŒ×ñ+ öˆX?Ñ÷= }”‚ŸSSbf çrnp¸»øøþ•JA¸óÆSŒn‡àÍúþKÈe^m±w ;:hkÙJ)ôqe¶ßÔèQk«3%…¾}×·×Ý?‹¯/¸¾A}į‡:S”=p©3¥í"þÎ/²×ë=й:S†ò~}ø©â£>5e3ÞfŽòë¸V¶Âò¦:ƒÏAçË? ¸ÔK©§âªŽT7–„Èõ×C"{ï—ÄöÑÃ?ë³Ûßg©3¾¸P|åûÓ=òÝ?ë¸Ûúˆc6ˆÞ1 ß™ý;÷í¸^×Î^êŒoü?…v¥Ù‘hn“'M{uNs¡ÎD¶T÷™…Ì÷©_JAÙUy¨4øÂC¥ ^Ž›Êáx •ÄÑK0Ÿ­Ñø¶xû¶_/Ê\¹ºßuÁ5¼ˆbOND£ÉNdc\‹#É]KIÞp#’ݸKÛš"fÓgcê'gÀäB-qAXî¾Ê/ÔßT ·ÐáYç½5GwñlÀÌ•'¤"Ɇº'¤Ö©ð´E¶+ª-“€ûŠJ‚Nàü¸öEàŒœìì°:²ª<îAð³±5ÒÃ*JE«ÒÃzEéa¾ß€ÄRg7=U€ß ÁEJÙ³R9ükžÐÝMn¡ {†XÀž"F0E†ûRpQbÀ£WÎUFZæNõjAm}è–g¤ˆ³EYZ•¿ûGd]&Û¸ës(—0¯ŸÓSñ]~¼mxáàHC§'ˆ³Òƒ!f׺2İ<ž4Ï«£ÄŒRýõÙ"CŒÛ¦ë,þµ2T„¯QlOÕUÃq>¯»·/®´Ž±óê—ìͱ«Øç¥9öŠ,Üú$àéaNß·ô0€s×HSTéaq~vzXœ¯HÛçÑuÇÏÇS_ )b‚‘ï´”Vù!úéaÜÝ8wepð³‚JéJÚéÕwÏ”„€RrÐàUöâw¯FõK‘Î[‚ K^WDĈO©!´C@‡©\ bD¯ÌC&ˆ>¥D!A f™ÙH#þ•uɯF%ˆÕÞ#?w'ˆ}A¾06Å–¶çdèë‚—Ç"¶ïdL5¶.‚[Úä|ÛU‚bëó+¼ß˜.p¾4\žeOCðå7qØÝ&óô´}æ ¯`W!´°4ž»MP¡Û«p€Ò£¾÷&]Ö^¸ÿÜXuÙ½&*­póšÌ9 %ø—¾Âm‚µ•p›øã«ÊDs·Éô{bî6™ÛqA· ÆÓ53w› ’ƒê#Aµ;ø§}°ù§ë½ïâP¿ŸQÃP UŸ¡p$®ÆŠK÷t› åA†ÛßLHw· 꾫’ Ý&(”_‰+ºMPìÀ3bW<ž®ò*Aá6 0Ü&ß¿R¨-¢¡µÞ´ã©šè7zÚå¿•¶€†¢Tí« žÇ€¯1›S.ˆ©O4î<|¥KáwZ ËS¾\º®…@â;eÙ?vß1cµ }rkùg"‹?ß¾ƒ¸—âéêKÅvãGÑ”oá\feiCJb¨^IÜ“ö¬ºJb@ qœR̕ŀ…/%€øGÚV8q6§®¹~nFüRY Ѱ/ߨ›âõ¾u¶›ø¤3^:yYÎvs1Ëž М?{/4¿Ê×Tç .¾Tb·UqI ðh~ï&dŽÒΤåDŠß‡n4¬} PNÄä_„dzøIå$;jMùS2‚x1¯cêª>/æwW‡xåBr€Ô8§ÌÕï êC÷/Gå‡&—®£ðë¢M_0ó’ÅÉg©ºbçÕ¹ÊÏ•í A%€~ûT¾ ƹ·|°%>¹‚Ï…¡~y!U ÝU1¿9bBøˆã)5AóÅ'ÕxM#îmð‹zº.¨ã3fõîGgL±Ó½YµÐç•)Ë8CL)I“ˆ5%æ¥T\NÞ-9ˆ#~E‰Q^ŽÖ§É–îã-qClïDWÁ’C{òjÒñrò@Ã(ú„$Â:ªKéGQ¥”Ç;SúU·q â¶éëDÓ/×èÇØýV~(lJ·_úžöäç#ÈßÈoÇŸÿ í¼Å­ endstream endobj 4 0 obj 15625 endobj 2 0 obj << /ExtGState << /a0 << /CA 1 /ca 1 >> /s6 6 0 R /s8 8 0 R /s10 10 0 R /s12 12 0 R >> /Shading << /sh5 5 0 R >> /XObject << /x7 7 0 R /x9 9 0 R /x11 11 0 R /x13 13 0 R /x14 14 0 R /x15 15 0 R >> >> endobj 16 0 obj << /Type /Page /Parent 1 0 R /MediaBox [ 0 0 512 132.915924 ] /Contents 3 0 R /Group << /Type /Group /S /Transparency /I true /CS /DeviceRGB >> /Resources 2 0 R >> endobj 17 0 obj << /Type /XObject /Length 47 /Filter /FlateDecode /Subtype /Form /BBox [ 41 52.915924 73 85.915924 ] /Group << /Type /Group /S /Transparency /I true /CS /DeviceRGB >> /Resources << /ExtGState << /a0 << /CA 0.19 /ca 0.19 >> >> >> >> stream xœ3P0¢týD…ôb.CS#=KCSK#c#cc…¢T…4.¯Ù˜ endstream endobj 7 0 obj << /Type /XObject /Length 48 /Filter /FlateDecode /Subtype /Form /BBox [ 41 52.915924 73 85.915924 ] /Group << /Type /Group /S /Transparency /I true /CS /DeviceRGB >> /Resources << /ExtGState << /a0 << /CA 1 /ca 1 >> >> /XObject << /x18 18 0 R >> >> >> stream xœ+ä2T0B©k g`ab`nj©œË¥Ÿh ^¬ _ah¡à’ÏȽ & endstream endobj 19 0 obj << /Type /Mask /S /Alpha /G 17 0 R >> endobj 6 0 obj << /Type /ExtGState /SMask 19 0 R /ca 1 /CA 1 /AIS false >> endobj 20 0 obj << /Type /XObject /Length 47 /Filter /FlateDecode /Subtype /Form /BBox [ 46 57.915924 68 80.915924 ] /Group << /Type /Group /S /Transparency /I true /CS /DeviceRGB >> /Resources << /ExtGState << /a0 << /CA 0.595 /ca 0.595 >> >> >> >> stream xœ3P0¢týD…ôb.3Ss=KCSK####c…¢T…4.°  endstream endobj 9 0 obj << /Type /XObject /Length 48 /Filter /FlateDecode /Subtype /Form /BBox [ 46 57.915924 68 80.915924 ] /Group << /Type /Group /S /Transparency /I true /CS /DeviceRGB >> /Resources << /ExtGState << /a0 << /CA 1 /ca 1 >> >> /XObject << /x21 21 0 R >> >> >> stream xœ+ä2T0B©k g`ab`nj©œË¥Ÿh ^¬ _ad¨à’Ïȼô endstream endobj 22 0 obj << /Type /Mask /S /Alpha /G 20 0 R >> endobj 8 0 obj << /Type /ExtGState /SMask 22 0 R /ca 1 /CA 1 /AIS false >> endobj 23 0 obj << /Type /XObject /Length 47 /Filter /FlateDecode /Subtype /Form /BBox [ 65 31.915924 91 56.915924 ] /Group << /Type /Group /S /Transparency /I true /CS /DeviceRGB >> /Resources << /ExtGState << /a0 << /CA 0.19 /ca 0.19 >> >> >> >> stream xœ3P0¢týD…ôb.3ScC=KCSK##3#S…¢T…4.°JŸ endstream endobj 11 0 obj << /Type /XObject /Length 48 /Filter /FlateDecode /Subtype /Form /BBox [ 65 31.915924 91 56.915924 ] /Group << /Type /Group /S /Transparency /I true /CS /DeviceRGB >> /Resources << /ExtGState << /a0 << /CA 1 /ca 1 >> >> /XObject << /x24 24 0 R >> >> >> stream xœ+ä2T0B©k g`ab`nj©œË¥Ÿh ^¬ _ad¢à’ÏȽ # endstream endobj 25 0 obj << /Type /Mask /S /Alpha /G 23 0 R >> endobj 10 0 obj << /Type /ExtGState /SMask 25 0 R /ca 1 /CA 1 /AIS false >> endobj 26 0 obj << /Type /XObject /Length 47 /Filter /FlateDecode /Subtype /Form /BBox [ 69 35.915924 87 52.915924 ] /Group << /Type /Group /S /Transparency /I true /CS /DeviceRGB >> /Resources << /ExtGState << /a0 << /CA 0.595 /ca 0.595 >> >> >> >> stream xœ3P0¢týD…ôb.3KcS=KCSK#C Cs…¢T…4.±© endstream endobj 13 0 obj << /Type /XObject /Length 48 /Filter /FlateDecode /Subtype /Form /BBox [ 69 35.915924 87 52.915924 ] /Group << /Type /Group /S /Transparency /I true /CS /DeviceRGB >> /Resources << /ExtGState << /a0 << /CA 1 /ca 1 >> >> /XObject << /x27 27 0 R >> >> >> stream xœ+ä2T0B©k g`ab`nj©œË¥Ÿh ^¬ _ad®à’ÏȽ & endstream endobj 28 0 obj << /Type /Mask /S /Alpha /G 26 0 R >> endobj 12 0 obj << /Type /ExtGState /SMask 28 0 R /ca 1 /CA 1 /AIS false >> endobj 29 0 obj << /FunctionType 2 /Domain [ 0 1 ] /C0 [ 0.188235 0.443137 0.670588 ] /C1 [ 0.0196078 0.219608 0.396078 ] /N 1 >> endobj 5 0 obj << /ShadingType 2 /ColorSpace /DeviceRGB /Coords [ 121.590797 450.859406 367.959412 24.1366 ] /Domain [ 0 1 ] /Extend [ true true ] /Function 29 0 R >> endobj 30 0 obj << /Length 31 0 R /Filter /FlateDecode /Type /XObject /Subtype /Image /Width 19 /Height 18 /ColorSpace /DeviceGray /Interpolate true /BitsPerComponent 8 >> stream xœc`À1DXyÄØ9Q„™$=’œ5XBæ«.ž?;+Þ„&Äî¾ýûïßïnÏŽ–`‚kœùñï¿¿>ï)Ôƒ©ã=ôùï¿ÿÿ¾]o2ေHä\ýúÿÿÿߟvËB-aTÉ;õý/Pì÷…"I˜qÊé›>ýüÿïß·ÍœP1ž€ §?}ÿóóRªÜOšÑ“.^º¹6^áf6-ó¬Âp5d¯1ròJ ³(8»‘E endstream endobj 31 0 obj 185 endobj 14 0 obj << /Length 32 0 R /Filter /FlateDecode /Type /XObject /Subtype /Image /Width 19 /Height 18 /ColorSpace /DeviceGray /Interpolate true /BitsPerComponent 8 /SMask 30 0 R >> stream xœÁ ‚@EýÉþÇ/h´h%´›y:øP0ÑPH©Ål¢o°ˆ#há].÷<žeMËŠ¬ó2ì(Ð0ð’/r(Dä!#1ˆÒ¼,$r:hd»<«Î][J€™f„bÙ)ukdì;ºFDV÷çý$£­>ȺWêzLÁ5sdE{éš½Œ6Yr!U!ãYƒ³åˆ)Fœ˜KÞ^Â(§cëÓ$~³‰ù›xi endstream endobj 32 0 obj 180 endobj 33 0 obj << /Length 34 0 R /Filter /FlateDecode /Type /XObject /Subtype /Image /Width 19 /Height 33 /ColorSpace /DeviceGray /Interpolate true /BitsPerComponent 8 >> stream xœc`ÀјعؘPDXøä´äùX5ñGåÆ˜‰"‰±©æ¬Û³¶ÎN˜nÇü{¯ªµà‡Y¢œwèÓŸ/¶eª°ÁôôÞúùÿßó]xaB¦+^ÿýÿïß÷óù2P—°ZoÿôïÿÿÿžÌ²å˜Æé¾ ,ô÷ÞD)ˆ2nÏ­ŸABÿ~\kÑ€¸ËiÛW°Ðß7+MX!Ž0Ùúÿÿë>°a¬¦‹_þ }?ž&ö›aßÝ_`¡Ÿ—kTÁ†±¨–_þ ù÷û~:X£h̰Ðÿ¿/gjC¬ätÙúá/HèÏó¹æì`!vãI÷~Ýÿl®5ÄJyÇ¿@„æ™AƒQÀmÐãÿÿýy>SŒÌJuW¾ÿû÷ÿ÷ Vhà ù-}øóß¿¯Ç •`À¡™·ãÅŸ¯Ö‹Â⎉߲îàƒGg[Œ8q+dW½|ÍD_qx$"jí"ωãâr¢ì¨©€‰™•…yª»_ endstream endobj 34 0 obj 381 endobj 15 0 obj << /Length 35 0 R /Filter /FlateDecode /Type /XObject /Subtype /Image /Width 19 /Height 33 /ColorSpace /DeviceGray /Interpolate true /BitsPerComponent 8 /SMask 33 0 R >> stream xœ’IRÂ@…¹¤÷á î²bßU¡çt:&LA4&R(Pê "&a¥ÿò«×ÿð^×jÿ®œ( ~F̶q`ž" ¢œè$œ1‚¯@Eê3!uÎÈ«N„ê¦m:W+Ù^$Ý^àšR+ÔáV0Ež›‡ NÏâБèðPéîI˜B-eœ~¼\eÉ +x‰ —þ4]¿fOÃJ¹þôq»{ºíKÞ*ÛwtoºÚ}®ï#›“b ‹³í׿aäpX43¡æŽ–o›lìjô¢0 P;Lž·ïéÄÒ"½iúò¼»“]"á çiš 4Ê-šÜêÇÉ|9‚•'å-¢;Ñä&¾¶x§º1Ó ‡¡'Tþ0*-¯çw­ì©5ÐÞXË’ ³« ʸ.‚¿ÉåïSÂðè~‘ ¦¤Ý> stream xœ]± €0 {Oñ;ÁN2#ÐÀþ„H ¡¯^§¿ßIQsÌèFÁ|R¯¬^ØÌÙÔkÕ±ÂKa‘³hë–>œ mM/Nr+ó·ÎÆ[³¿|ù½O4П@ ö endstream endobj 37 0 obj 101 endobj 36 0 obj << /ExtGState << /a0 << /CA 1 /ca 1 >> >> >> endobj 21 0 obj << /Length 39 0 R /Filter /FlateDecode /Type /XObject /Subtype /Form /BBox [ 46 58 68 81 ] /Resources 38 0 R >> stream xœ]» Ã@ C{MÁ hù>’nŒŒ&va¶÷ŒK‚°"yÈŒžsÁôT,—cJÖh†Õ¨‘`A׌ Õ©%££ô™3jûšòf®´Ù‡Ê½~Vxý¿}ÉCnåcØ endstream endobj 39 0 obj 102 endobj 38 0 obj << /ExtGState << /a0 << /CA 1 /ca 1 >> >> >> endobj 24 0 obj << /Length 41 0 R /Filter /FlateDecode /Type /XObject /Subtype /Form /BBox [ 65 32 91 57 ] /Resources 40 0 R >> stream xœeŽ;€0 C÷œÂ'é'M{ ŽÀB`î/Q¨òYϲ³“í£b˜õ¤¤\BDŒœD±ÁŒMÂí};+,³“‚à9¶Øãե΋°Ï z z@YœïšØòÃß/¿féÃ"= endstream endobj 41 0 obj 105 endobj 40 0 obj << /ExtGState << /a0 << /CA 1 /ca 1 >> >> >> endobj 27 0 obj << /Length 43 0 R /Filter /FlateDecode /Type /XObject /Subtype /Form /BBox [ 69 36 87 53 ] /Resources 42 0 R >> stream xœeŽ1Ã0 w½‚/`­J¶ägô ]šíäÿ@ÒÂ…‡Bq AqÅç¶—{Á²KëÌRáÎvÊ´8Ù˜¡x!’Z:¬ÑÊàôœ~6º:dÌ@¥¹Ï‚ze×/?ÿù7á!79’Î"o endstream endobj 43 0 obj 106 endobj 42 0 obj << /ExtGState << /a0 << /CA 1 /ca 1 >> >> >> endobj 1 0 obj << /Type /Pages /Kids [ 16 0 R ] /Count 1 >> endobj 44 0 obj << /Creator (cairo 1.14.0 (http://cairographics.org)) /Producer (cairo 1.14.0 (http://cairographics.org)) >> endobj 45 0 obj << /Type /Catalog /Pages 1 0 R >> endobj xref 0 46 0000000000 65535 f 0000023749 00000 n 0000015741 00000 n 0000000015 00000 n 0000015717 00000 n 0000020004 00000 n 0000017040 00000 n 0000016587 00000 n 0000017951 00000 n 0000017498 00000 n 0000018861 00000 n 0000018407 00000 n 0000019774 00000 n 0000019320 00000 n 0000020650 00000 n 0000021702 00000 n 0000015996 00000 n 0000016218 00000 n 0000022307 00000 n 0000016980 00000 n 0000017127 00000 n 0000022665 00000 n 0000017891 00000 n 0000018038 00000 n 0000023024 00000 n 0000018801 00000 n 0000018949 00000 n 0000023386 00000 n 0000019714 00000 n 0000019862 00000 n 0000020228 00000 n 0000020627 00000 n 0000021061 00000 n 0000021084 00000 n 0000021679 00000 n 0000022284 00000 n 0000022592 00000 n 0000022569 00000 n 0000022951 00000 n 0000022928 00000 n 0000023313 00000 n 0000023290 00000 n 0000023676 00000 n 0000023653 00000 n 0000023815 00000 n 0000023943 00000 n trailer << /Size 46 /Root 45 0 R /Info 44 0 R >> startxref 23996 %%EOF photutils-0.2.1/docs/_static/photutils_banner.svg0000600000214200020070000012633012646242520024407 0ustar lbradleySTSCI\science00000000000000 photutils logoimage/svg+xmlphotutils logoLarry Bradley photutils-0.2.1/docs/_static/photutils_banner_original.svg0000600000214200020070000003743612646242520026303 0ustar lbradleySTSCI\science00000000000000 photutils logoimage/svg+xmlphotutils logoLarry Bradleyphot utils An Astropy Package for Photometry photutils-0.2.1/docs/_static/photutils_logo-32x32.png0000600000214200020070000000407112444404542024643 0ustar lbradleySTSCI\science00000000000000‰PNG  IHDR szzôtEXtSoftwareAdobe ImageReadyqÉe<ÛIDATxÚ¤W PT×þÎaaewwQpäµ ò¨ƒ©±¶¤˜„Ñ’¦Ð´3u™Nf´“Nb§í$ÓÎ$mÆ´i’JÓv:MšJ§6ŽŽŒB4JRÌ¡€°°,( ¸¼–ǽýï¹û¸ ¤ÑÊðï½÷<þÇ÷?Îùîá/jçadXeY¢/²¬ýØç.ÿÖ~'<ØÝ ¹¿¶Œ„|‹Hyn„ìTÂ7f§G=}ürþÊëö{VÀøÀ3ÕÄô9­PU ¤úŽÀ{-®%EÜw­@ìÞcVâð±)Ó2/ë‚[Ž€qU$Ü“1~q!ù3•¡7=w‘-ZþaÿKx\ù³Õ`ìÏŒ± EW#ób¿®)|)_ªÀ‡j¾­Í£ ý·nã‹:'º¤5ª]ŒÑ¿úï@$M 3\_ø¨ãsˆÿÚs'Iãj¿ÙlÙ¸…FnGIÎ&¸§<ÂúÓM­(ÍMÅ¥ëÝ„J7Nϧ.±^Ò¸Kâ†]s¼&Э$<ᡫ–ÌHð̘DkÊ^”oJÄW‹2‰¶Âvc,wÃ-¬o•Ö‘±\$Õ<™ƒib†A6ÑûIúÈ_щûr„;*PôTÀœx[PaÆ©K6Ü_Ž÷.·ãüG]ðÎ/ÂûïsÂ=ÍR’r¨ðC%›Ã£ú.äêF`“â•ÉDe[ßBsKI¼PYzID¯BL…‘ÉŠ*¦ÕQÈIKÂ÷_>%"Ü,ßF ëƒ ëÐ(Yˆ¯o­õïUè±ðœðZ‘Ç‘6…¾ÅeÝÓôSÉ•/öÒ†K#8KÂŒ‰oó:ª=ÑF8zz) "ÑD‚…Ÿ¡‰xM”ò~ôIä¡4/ §ó .Î'Óeò˜üây‘ãøŠÜ¯2k—“Ð&¯W… û‹eªë¸,üü¢ñCŒ7ap`œË `âs°ìÞ [·¹›7 ‘¾ÕìàÊö2%bRõ²‰qþ4çY¸‰Jùcšç" ÄýÄ©™ãDýºì<øMl~ð ª"ÚĸÉ'lbzŽa7”ªÊ7ðf)"có¾r€T:`Ä,òùë P:qí<9˜ÏœeHKŽÃØ„'˜ãDÍ3±ˆ¶Áz6 ׈ŸÈ ØÍ{ ´ö AŽÆë7 ÷ŒÂ£ï¬@€´Q­'_;,%8\± ±ñkEdsŸ?ÅÌŽ‡×Œ¢}ËúÝT:ŽÚbð§Å¼à>¢òâl‚?׸o,ˆO«~Ußêƒúð0¤lHÂdæ.d“BèiÞŒq)¶=\%2ÂÂÆU8y!Ó(ìGçgO–cÂãEn˜ «q§²‡q+÷Yà [ ÓX¦<3H4EÃÀfã(}Ìñ&ìKÆÞÊJeY°÷@%*¶¬FjRÅD„ˆ •T^FÊýI…ª’>”aá“@¬¹m*ó§½¢@‘û ÎÜ‹›î™€%Þ ƒcSxut¾Ýùs¼ÓÛ‚¶†³xƒ—*gŒH·`T3(‡ £IN…¡µO~}‡@Ì(uSj‹R¢Ñ§ lƒ2øZt^¸ ƒäAO˜ÚyeÇÉð2 ÐD\ÔíG.ìõ×…Œ²W/ň½yF¸ÃĽjuUôûе>Vèjø,HŒÊN4uñªŸ‚i#¨Õî ñ£ßMÚ TàWçÚìð÷Ð7î±÷~ÚÀù²<çè· CgãJjîY´a‡ÔMÏV‘S³ó¡u€öÄ›V•¨–î3׺`I0Á⺎÷ÙV­±õE5C ‹2¶c± {>Á¹+:Œ¹0?ø8jbû±è F?Ñ—¥6¼çÁw¤FŸ1*RÅÙ)ÈN]ׄP\Ë›è¸8Žia‹z|ùý§ÁÉ .±áTd ÓE$;G§ñë_€³êqŠæ8Ì„¯‚‰î% X¿q†h=Î^ÑÁ5> ãŒm}#4v&¨¨)1á‹‘º[õÏÚÅ-ë{¸Mƒ&íA²o¦çbËp¬²Ÿ:FÅx 1û´D ¶ëqV—+Î\À£ÑhjëÇYž-ÎŒ­„Ò8ôTõbñÄÂ%ʘºi>èÝÚ÷„ÂG2 «öe=ÈÛq®uÞÄöoGù}iÂÂSt!Ógw7œÞxjð¯Çü‡ ÎW$~OªUCs0`†Uz\ëº%”8ï™ÃÕÿ â/lÄßš:‘ì;Tü¨OÏRV¹(ãï†eâF$Õ ¼}´N{g핃 u|IJ6·t¢¢h³PBñeEqºˆæê©éÊžIÆÒ”¤®zŠ68þòLÍÒ˜.x;eµ´ºŒTÞ¨ p!z;ªœÿÂäh":œ³¨¿rCX#Mcß| ÞŠÚ­Zå³N^v|€ŠÀ#«yíç6&yGÞ¶Òã 2ùo´»fš… *,Šp…é9}~èÝ+4%Bñ~¼ç­ÃÏßqgd­}ǪÞZeëŠMäÏh>¤ŽHiÍ触ûäS wÝ’&zQZ±•„.·^ZÒÊÇ;ßønÝ=7§¤ˆrG¤žgërÈV+mW=Ñß;^«©¿›f÷Ž›SŠ“Pb9öÖÙÿßÿ¿ æ(HU¿Ž’ŠIEND®B`‚photutils-0.2.1/docs/_static/photutils_logo.svg0000600000214200020070000003625212634600603024102 0ustar lbradleySTSCI\science00000000000000 photutils logoimage/svg+xmlphotutils logoLarry Bradleyphotutils-0.2.1/docs/_templates/0000700000214200020070000000000012646264032021010 5ustar lbradleySTSCI\science00000000000000photutils-0.2.1/docs/_templates/autosummary/0000700000214200020070000000000012646264032023376 5ustar lbradleySTSCI\science00000000000000photutils-0.2.1/docs/_templates/autosummary/base.rst0000600000214200020070000000037212345377273025056 0ustar lbradleySTSCI\science00000000000000{% extends "autosummary_core/base.rst" %} {# The template this is inherited from is in astropy/sphinx/ext/templates/autosummary_core. If you want to modify this template, it is strongly recommended that you still inherit from the astropy template. #}photutils-0.2.1/docs/_templates/autosummary/class.rst0000600000214200020070000000037312345377273025252 0ustar lbradleySTSCI\science00000000000000{% extends "autosummary_core/class.rst" %} {# The template this is inherited from is in astropy/sphinx/ext/templates/autosummary_core. If you want to modify this template, it is strongly recommended that you still inherit from the astropy template. #}photutils-0.2.1/docs/_templates/autosummary/module.rst0000600000214200020070000000037412345377273025433 0ustar lbradleySTSCI\science00000000000000{% extends "autosummary_core/module.rst" %} {# The template this is inherited from is in astropy/sphinx/ext/templates/autosummary_core. If you want to modify this template, it is strongly recommended that you still inherit from the astropy template. #}photutils-0.2.1/docs/changelog.rst0000600000214200020070000000011312627615324021334 0ustar lbradleySTSCI\science00000000000000.. _changelog: ********* Changelog ********* .. include:: ../CHANGES.rst photutils-0.2.1/docs/conf.py0000600000214200020070000001630212634600603020151 0ustar lbradleySTSCI\science00000000000000# -*- coding: utf-8 -*- # Licensed under a 3-clause BSD style license - see LICENSE.rst # # Astropy documentation build configuration file. # # This file is execfile()d with the current directory set to its containing dir. # # Note that not all possible configuration values are present in this file. # # All configuration values have a default. Some values are defined in # the global Astropy configuration which is loaded here before anything else. # See astropy.sphinx.conf for which values are set there. # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. # sys.path.insert(0, os.path.abspath('..')) # IMPORTANT: the above commented section was generated by sphinx-quickstart, but # is *NOT* appropriate for astropy or Astropy affiliated packages. It is left # commented out with this explanation to make it clear why this should not be # done. If the sys.path entry above is added, when the astropy.sphinx.conf # import occurs, it will import the *source* version of astropy instead of the # version installed (if invoked as "make html" or directly with sphinx), or the # version in the build directory (if "python setup.py build_sphinx" is used). # Thus, any C-extensions that are needed to build the documentation will *not* # be accessible, and the documentation will not build correctly. import datetime import os import sys try: import astropy_helpers except ImportError: # Building from inside the docs/ directory? if os.path.basename(os.getcwd()) == 'docs': a_h_path = os.path.abspath(os.path.join('..', 'astropy_helpers')) if os.path.isdir(a_h_path): sys.path.insert(1, a_h_path) # Load all of the global Astropy configuration from astropy_helpers.sphinx.conf import * from astropy.extern import six # Get configuration information from setup.cfg from distutils import config conf = config.ConfigParser() conf.read([os.path.join(os.path.dirname(__file__), '..', 'setup.cfg')]) setup_cfg = dict(conf.items('metadata')) # -- General configuration ---------------------------------------------------- # If your documentation needs a minimal Sphinx version, state it here. #needs_sphinx = '1.1' # We don't have references to `h5py` ... no need to load the intersphinx mapping file. del intersphinx_mapping['h5py'] # We currently want to link to the latest development version of the astropy docs, # so we override the `intersphinx_mapping` entry pointing to the stable docs version # that is listed in `astropy/sphinx/conf.py`. intersphinx_mapping['astropy'] = ('http://docs.astropy.org/en/latest/', None) # Extend astropy intersphinx_mapping with packages we use here intersphinx_mapping['skimage'] = ('http://scikit-image.org/docs/stable/', None) # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. exclude_patterns.append('_templates') # This is added to the end of RST files - a good place to put substitutions to # be used globally. rst_epilog += """ .. _Photutils: high-level_API.html """ # -- Project information ------------------------------------------------------ # This does not *have* to match the package name, but typically does project = setup_cfg['package_name'] author = setup_cfg['author'] copyright = '{0}, {1}'.format( datetime.datetime.now().year, setup_cfg['author']) # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. __import__(setup_cfg['package_name']) package = sys.modules[setup_cfg['package_name']] # The short X.Y version. version = package.__version__.split('-', 1)[0] # The full version, including alpha/beta/rc tags. release = package.__version__ # -- Options for HTML output --------------------------------------------------- # A NOTE ON HTML THEMES # The global astropy configuration uses a custom theme, 'bootstrap-astropy', # which is installed along with astropy. A different theme can be used or # the options for this theme can be modified by overriding some of the # variables set in the global configuration. The variables set in the # global configuration are listed below, commented out. html_theme_options = { 'logotext1': 'phot', # white, semi-bold 'logotext2': 'utils', # orange, light 'logotext3': '' # white, light } # Add any paths that contain custom themes here, relative to this directory. # To use a different custom theme, add the directory containing the theme. #html_theme_path = [] # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. To override the custom theme, set this to the # name of a builtin theme or the name of a custom theme in html_theme_path. #html_theme = None # Custom sidebar templates, maps document names to template names. #html_sidebars = {} # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. from os.path import join html_favicon = join('_static', 'favicon.ico') # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. #html_last_updated_fmt = '' # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". html_title = '{0} v{1}'.format(project, release) # Output file base name for HTML help builder. htmlhelp_basename = project + 'doc' # Static files to copy after template files html_static_path = ['_static'] html_style = 'photutils.css' # -- Options for LaTeX output -------------------------------------------------- # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass [howto/manual]). latex_documents = [('index', project + '.tex', project + u' Documentation', author, 'manual')] latex_logo = '_static/photutils_banner.pdf' # -- Options for manual page output -------------------------------------------- # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [('index', project.lower(), project + u' Documentation', [author], 1)] ## -- Options for the edit_on_github extension ---------------------------------------- if eval(setup_cfg.get('edit_on_github')): extensions += ['astropy.sphinx.ext.edit_on_github'] versionmod = __import__(setup_cfg['package_name'] + '.version') edit_on_github_project = setup_cfg['github_project'] if versionmod.release: edit_on_github_branch = "v" + versionmod.version else: edit_on_github_branch = "master" edit_on_github_source_root = "" edit_on_github_doc_root = "docs" github_issues_url = 'https://github.com/astropy/photutils/issues/' autodoc_docstring_signature = True nitpicky = True nitpick_ignore = [] for line in open('nitpick-exceptions'): if line.strip() == "" or line.startswith("#"): continue dtype, target = line.split(None, 1) target = target.strip() nitpick_ignore.append((dtype, six.u(target))) photutils-0.2.1/docs/index.rst0000600000214200020070000000653612634600603020523 0ustar lbradleySTSCI\science00000000000000 .. the "raw" directive below is used to hide the title in favor of just the logo being visible .. raw:: html ********* Photutils ********* .. raw:: html .. only:: latex .. image:: _static/photutils_banner.pdf Photutils at a Glance ===================== **Photutils** is an in-development `affiliated package `_ of `Astropy`_ to provide tools for detecting and performing photometry of astronomical sources. It is an open source (BSD licensed) Python package. Bug reports, comments, and help with development are very welcome. .. toctree:: :maxdepth: 2 photutils/install.rst photutils/overview.rst photutils/getting_started.rst changelog .. note:: Photutils is still under development and has not seen widespread use yet. We will change its API if we find that something can be improved. User Documentation ================== .. toctree:: :maxdepth: 1 photutils/background.rst photutils/detection.rst photutils/aperture.rst photutils/psf.rst photutils/segmentation.rst photutils/morphology.rst photutils/geometry.rst photutils/datasets.rst photutils/utils.rst photutils/high-level_API.rst Reporting Issues ================ If you have found a bug in Photutils please report it by creating a new issue on the `Photutils GitHub issue tracker `_. Please include an example that demonstrates the issue that will allow the developers to reproduce and fix the problem. You may be asked to also provide information about your operating system and a full Python stack trace. The developers will walk you through obtaining a stack trace if it is necessary. Photutils uses a package of utilities called `astropy-helpers `_ during building and installation. If you have any build or installation issue mentioning the ``astropy_helpers`` or ``ah_bootstrap`` modules please send a report to the `astropy-helpers issue tracker `_. If you are unsure, then it's fine to report to the main Photutils issue tracker. Contributing ============ Like the `Astropy`_ project, Photutils is made both by and for its users. We accept contributions at all levels, spanning the gamut from fixing a typo in the documentation to developing a major new feature. We welcome contributors who will abide by the `Python Software Foundation Code of Conduct `_. Photutils follows the same workflow and coding guidelines as `Astropy`_. The following pages will help you get started with contributing fixes, code, or documentation (no git or GitHub experience necessary): * `How to make a code contribution `_ * `Coding Guidelines `_ * `Try the development version `_ * `Developer Documentation `_ photutils-0.2.1/docs/make.bat0000600000214200020070000001064112345377273020274 0ustar lbradleySTSCI\science00000000000000@ECHO OFF REM Command file for Sphinx documentation if "%SPHINXBUILD%" == "" ( set SPHINXBUILD=sphinx-build ) set BUILDDIR=_build set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . if NOT "%PAPER%" == "" ( set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% ) if "%1" == "" goto help if "%1" == "help" ( :help echo.Please use `make ^` where ^ is one of echo. html to make standalone HTML files echo. dirhtml to make HTML files named index.html in directories echo. singlehtml to make a single large HTML file echo. pickle to make pickle files echo. json to make JSON files echo. htmlhelp to make HTML files and a HTML help project echo. qthelp to make HTML files and a qthelp project echo. devhelp to make HTML files and a Devhelp project echo. epub to make an epub echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter echo. text to make text files echo. man to make manual pages echo. changes to make an overview over all changed/added/deprecated items echo. linkcheck to check all external links for integrity echo. doctest to run all doctests embedded in the documentation if enabled goto end ) if "%1" == "clean" ( for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i del /q /s %BUILDDIR%\* goto end ) if "%1" == "html" ( %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html if errorlevel 1 exit /b 1 echo. echo.Build finished. The HTML pages are in %BUILDDIR%/html. goto end ) if "%1" == "dirhtml" ( %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml if errorlevel 1 exit /b 1 echo. echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. goto end ) if "%1" == "singlehtml" ( %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml if errorlevel 1 exit /b 1 echo. echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. goto end ) if "%1" == "pickle" ( %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can process the pickle files. goto end ) if "%1" == "json" ( %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can process the JSON files. goto end ) if "%1" == "htmlhelp" ( %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can run HTML Help Workshop with the ^ .hhp project file in %BUILDDIR%/htmlhelp. goto end ) if "%1" == "qthelp" ( %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can run "qcollectiongenerator" with the ^ .qhcp project file in %BUILDDIR%/qthelp, like this: echo.^> qcollectiongenerator %BUILDDIR%\qthelp\Astropy.qhcp echo.To view the help file: echo.^> assistant -collectionFile %BUILDDIR%\qthelp\Astropy.ghc goto end ) if "%1" == "devhelp" ( %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp if errorlevel 1 exit /b 1 echo. echo.Build finished. goto end ) if "%1" == "epub" ( %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub if errorlevel 1 exit /b 1 echo. echo.Build finished. The epub file is in %BUILDDIR%/epub. goto end ) if "%1" == "latex" ( %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex if errorlevel 1 exit /b 1 echo. echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. goto end ) if "%1" == "text" ( %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text if errorlevel 1 exit /b 1 echo. echo.Build finished. The text files are in %BUILDDIR%/text. goto end ) if "%1" == "man" ( %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man if errorlevel 1 exit /b 1 echo. echo.Build finished. The manual pages are in %BUILDDIR%/man. goto end ) if "%1" == "changes" ( %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes if errorlevel 1 exit /b 1 echo. echo.The overview file is in %BUILDDIR%/changes. goto end ) if "%1" == "linkcheck" ( %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck if errorlevel 1 exit /b 1 echo. echo.Link check complete; look for any errors in the above output ^ or in %BUILDDIR%/linkcheck/output.txt. goto end ) if "%1" == "doctest" ( %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest if errorlevel 1 exit /b 1 echo. echo.Testing of doctests in the sources finished, look at the ^ results in %BUILDDIR%/doctest/output.txt. goto end ) :end photutils-0.2.1/docs/Makefile0000600000214200020070000001116412345377273020330 0ustar lbradleySTSCI\science00000000000000# Makefile for Sphinx documentation # # You can set these variables from the command line. SPHINXOPTS = SPHINXBUILD = sphinx-build PAPER = BUILDDIR = _build # Internal variables. PAPEROPT_a4 = -D latex_paper_size=a4 PAPEROPT_letter = -D latex_paper_size=letter ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest #This is needed with git because git doesn't create a dir if it's empty $(shell [ -d "_static" ] || mkdir -p _static) help: @echo "Please use \`make ' where is one of" @echo " html to make standalone HTML files" @echo " dirhtml to make HTML files named index.html in directories" @echo " singlehtml to make a single large HTML file" @echo " pickle to make pickle files" @echo " json to make JSON files" @echo " htmlhelp to make HTML files and a HTML help project" @echo " qthelp to make HTML files and a qthelp project" @echo " devhelp to make HTML files and a Devhelp project" @echo " epub to make an epub" @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" @echo " latexpdf to make LaTeX files and run them through pdflatex" @echo " text to make text files" @echo " man to make manual pages" @echo " changes to make an overview of all changed/added/deprecated items" @echo " linkcheck to check all external links for integrity" @echo " doctest to run all doctests embedded in the documentation (if enabled)" clean: -rm -rf $(BUILDDIR) -rm -rf api html: $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." dirhtml: $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." singlehtml: $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml @echo @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." pickle: $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle @echo @echo "Build finished; now you can process the pickle files." json: $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json @echo @echo "Build finished; now you can process the JSON files." htmlhelp: $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp @echo @echo "Build finished; now you can run HTML Help Workshop with the" \ ".hhp project file in $(BUILDDIR)/htmlhelp." qthelp: $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp @echo @echo "Build finished; now you can run "qcollectiongenerator" with the" \ ".qhcp project file in $(BUILDDIR)/qthelp, like this:" @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/Astropy.qhcp" @echo "To view the help file:" @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/Astropy.qhc" devhelp: $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp @echo @echo "Build finished." @echo "To view the help file:" @echo "# mkdir -p $$HOME/.local/share/devhelp/Astropy" @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/Astropy" @echo "# devhelp" epub: $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub @echo @echo "Build finished. The epub file is in $(BUILDDIR)/epub." latex: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." @echo "Run \`make' in that directory to run these through (pdf)latex" \ "(use \`make latexpdf' here to do that automatically)." latexpdf: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo "Running LaTeX files through pdflatex..." make -C $(BUILDDIR)/latex all-pdf @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." text: $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text @echo @echo "Build finished. The text files are in $(BUILDDIR)/text." man: $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man @echo @echo "Build finished. The manual pages are in $(BUILDDIR)/man." changes: $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes @echo @echo "The overview file is in $(BUILDDIR)/changes." linkcheck: $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck @echo @echo "Link check complete; look for any errors in the above output " \ "or in $(BUILDDIR)/linkcheck/output.txt." doctest: $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest @echo "Testing of doctests in the sources finished, look at the " \ "results in $(BUILDDIR)/doctest/output.txt." photutils-0.2.1/docs/nitpick-exceptions0000600000214200020070000000010412627615324022416 0ustar lbradleySTSCI\science00000000000000# photutils.morphology py:class photutils.morphology.CompoundModel1 photutils-0.2.1/docs/photutils/0000700000214200020070000000000012646264032020706 5ustar lbradleySTSCI\science00000000000000photutils-0.2.1/docs/photutils/aperture.rst0000600000214200020070000004524712634600603023300 0ustar lbradleySTSCI\science00000000000000Aperture Photometry =================== .. currentmodule:: photutils Introduction ------------ In Photutils, the :func:`~photutils.aperture_photometry` function is the main tool to perform aperture photometry on an astronomical image for a given set of apertures. The aperture shapes that are currently provided are: * Circle * Circular annulus * Ellipse * Elliptical annulus * Rectangle * Rectangular annulus The positions can be input either as pixel coordinates or sky coordinates, provided that the data is specified with a WCS transformation. Users can also create their own custom apertures (see :ref:`custom-apertures`). .. _creating-aperture-objects: Creating Aperture Objects ------------------------- The first step in performing aperture photometry is to create an aperture object. An aperture object is defined by a position (or a list of positions) and parameters that define its size and possibly, orientation (e.g., an elliptical aperture). We start with an example of creating a circular aperture in pixel coordinates using the :class:`~photutils.CircularAperture` class:: >>> from photutils import CircularAperture >>> positions = [(30., 30.), (40., 40.)] >>> apertures = CircularAperture(positions, r=3.) The positions should be either a single tuple of ``(x, y)``, a list of ``(x, y)`` tuples, or an array with shape ``Nx2``, where ``N`` is the number of positions. In the above example, there are two sources located at pixel coordinates ``(30, 30)`` and ``(40, 40)``, and the apertures have a radius of 3 pixels. Creating an aperture object in celestial coordinates is similar. One first uses the :class:`~astropy.coordinates.SkyCoord` class to define celestial coordinates and then the :class:`~photutils.SkyCircularAperture` class to define the aperture object:: >>> from astropy import units as u >>> from astropy.coordinates import SkyCoord >>> from photutils import SkyCircularAperture >>> positions = SkyCoord(l=[1.2, 2.3] * u.deg, b=[0.1, 0.2] * u.deg, ... frame='galactic') >>> apertures = SkyCircularAperture(positions, r=4. * u.arcsec) .. note:: At this time, apertures are not defined completely in celestial coordinates. They simply use celestial coordinates to define the central position, and the remaining parameters are converted to pixels using the pixel scale of the image at the central position. Projection distortions are not taken into account. If the apertures were defined completely in celestial coordinates, their shapes would not be preserved when converting to pixel coordinates. Performing Aperture Photometry ------------------------------ After the aperture object is created, we can then carry out the photometry using the :func:`~photutils.aperture_photometry` function. We start by defining the apertures as described above: >>> positions = [(30., 30.), (40., 40.)] >>> apertures = CircularAperture(positions, r=3.) and then we call the :func:`~photutils.aperture_photometry` function with the data and the apertures:: >>> import numpy as np >>> from photutils import aperture_photometry >>> data = np.ones((100, 100)) >>> phot_table = aperture_photometry(data, apertures) >>> print(phot_table) aperture_sum xcenter ycenter pix pix ------------- ------- ------- 28.2743338823 30.0 30.0 28.2743338823 40.0 40.0 This function returns the results of the photometry in an Astropy `~astropy.table.Table`. In this example, the table has three columns, named ``'aperture_sum'``, ``'xcenter'``, and ``'ycenter'``. Since all the data values are 1.0, the aperture sums are equal to the area of a circle with a radius of 3:: >>> print(np.pi * 3. ** 2) # doctest: +FLOAT_CMP 28.2743338823 Aperture and Pixel Overlap -------------------------- The overlap of the apertures with the data pixels can be handled in different ways. For the default method (``method='exact'``), the exact intersection of the aperture with each pixel is calculated. The other options, ``'center'`` and ``'subpixel'``, are faster, but with the expense of less precision. For ``'center'``, a pixel is considered to be entirely in or out of the aperture depending on whether its center is in or out of the aperture. For ``'subpixel'``, pixels are divided into a number of subpixels, which are in or out of the aperture based on their centers. This example uses the ``'subpixel'`` method where pixels are resampled by a factor of 5 in each dimension:: >>> phot_table = aperture_photometry(data, apertures, ... method='subpixel', subpixels=5) >>> print(phot_table['aperture_sum']) aperture_sum ------------ 27.96 27.96 Note that the results differ from the true value of 28.274333 (see above). For the ``'subpixel'`` method, the default value is ``subpixels=5``, meaning that each pixel is equally divided into 25 smaller pixels (this is the method and subsampling factor used in SourceExtractor_.). The precision can be increased by increasing ``subpixels``, but note that computation time will be increased. Multiple Apertures at Each Position ----------------------------------- While the `~photutils.Aperture` objects support multiple positions, they currently must have a fixed size and orientation (e.g., defined by radius for a circular aperture, or axes lengths and orientation for an elliptical aperture). To perform photometry in multiple apertures at each position, one may loop over different aperture size and orientation parameters. Suppose that we wish to use three circular apertures, with radii of 3, 4, and 5 pixels, on each source:: >>> radii = [3., 4., 5.] >>> flux = [] >>> for radius in radii: ... flux.append(aperture_photometry(data, CircularAperture(positions, radius))) We now have three separate tables containing the photometry results, one for each aperture. One may use `~astropy.table.hstack` to stack them into one `~astropy.table.Table`:: >>> from astropy.table import hstack >>> phot_table = hstack(flux) >>> print(phot_table['aperture_sum_1', 'aperture_sum_2', 'aperture_sum_3']) # doctest: +FLOAT_CMP aperture_sum_1 aperture_sum_2 aperture_sum_3 -------------- -------------- -------------- 28.2743338823 50.2654824574 78.5398163397 28.2743338823 50.2654824574 78.5398163397 Other apertures have multiple parameters specifying the aperture size and orientation. For example, for elliptical apertures, one must specify ``a``, ``b``, and ``theta``:: >>> from photutils import EllipticalAperture >>> a = 5. >>> b = 3. >>> theta = np.pi / 4. >>> apertures = EllipticalAperture(positions, a, b, theta) >>> phot_table = aperture_photometry(data, apertures) >>> print(phot_table['aperture_sum']) # doctest: +FLOAT_CMP aperture_sum ------------- 47.1238898038 47.1238898038 Again, for multiple apertures one should loop over them:: >>> a = [5., 6., 7., 8.] >>> b = [3., 4., 5., 6.] >>> theta = np.pi / 4. >>> flux = [] >>> for index in range(len(a)): ... flux.append(aperture_photometry( ... data, EllipticalAperture(positions, a[index], b[index], theta))) >>> phot_table = hstack(flux) >>> print(phot_table['aperture_sum_1', 'aperture_sum_2', ... 'aperture_sum_3', 'aperture_sum_4']) # doctest: +FLOAT_CMP aperture_sum_1 aperture_sum_2 aperture_sum_3 aperture_sum_4 -------------- -------------- -------------- -------------- 47.1238898038 75.3982236862 109.955742876 150.796447372 47.1238898038 75.3982236862 109.955742876 150.796447372 Background Subtraction ---------------------- :func:`aperture_photometry` assumes that the data have been background-subtracted. Global Background Subtraction ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ If ``bkg`` is an array representing the background of the data (determined by `~photutils.background.Background` or an external function), simply do:: >>> phot_table = aperture_photometry(data - bkg, apertures) # doctest: +SKIP Local Background Subtraction ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Suppose we want to perform the photometry in a circular aperture with a radius of 3 pixels and estimate the local background level around each source with a circular annulus of inner radius 6 pixels and outer radius 8 pixels. We start by defining the apertures:: >>> from photutils import CircularAnnulus >>> apertures = CircularAperture(positions, r=3) >>> annulus_apertures = CircularAnnulus(positions, r_in=6., r_out=8.) We then compute the aperture sum in both apertures and combine the two tables:: >>> rawflux_table = aperture_photometry(data, apertures) >>> bkgflux_table = aperture_photometry(data, annulus_apertures) >>> phot_table = hstack([rawflux_table, bkgflux_table], table_names=['raw', 'bkg']) To calculate the mean local background within the circular annulus aperture, we need to divide its sum by its area, which can be calculated using the :meth:`~photutils.CircularAnnulus.area` method:: >>> bkg_mean = phot_table['aperture_sum_bkg'] / annulus_apertures.area() The background sum within the circular aperture is then the mean local background times the circular aperture area:: >>> bkg_sum = bkg_mean * apertures.area() >>> final_sum = phot_table['aperture_sum_raw'] - bkg_sum >>> phot_table['residual_aperture_sum'] = final_sum >>> print(phot_table['residual_aperture_sum']) # doctest: +FLOAT_CMP residual_aperture_sum --------------------- -3.5527136788e-15 -3.5527136788e-15 The result here should be zero because all of the data values are 1.0 (the small difference from 0.0 is due to numerical precision). .. _error_estimation: Error Estimation ---------------- If and only if the ``error`` keyword is input to :func:`aperture_photometry`, the returned table will include a ``'aperture_sum_err'`` column in addition to ``'aperture_sum'``. ``'aperture_sum_err'`` provides the propagated uncertainty associated with ``'aperture_sum'``. For example, suppose we have previously calculated the error on each pixel's value and saved it in the array ``data_error``:: >>> data_error = 0.1 * data # (100 x 100 array) >>> phot_table = aperture_photometry(data, apertures, error=data_error) >>> print(phot_table) # doctest: +FLOAT_CMP aperture_sum aperture_sum_err xcenter ycenter pix pix ------------- ---------------- ------- ------- 28.2743338823 0.531736155272 30.0 30.0 28.2743338823 0.531736155272 40.0 40.0 ``'aperture_sum_err'`` values are given by .. math:: \Delta F = \sqrt{ \sum_{i \in A} \sigma_i^2} where :math:`\sigma` is the given error array and the sum is over pixels in the aperture :math:`A`. In the example above, it is assumed that the ``error`` keyword specifies the *full* error (either it includes Poisson noise due to individual sources or such noise is irrelevant). However, it is often the case that one has previously calculated a smooth "background error" array which by design doesn't include increased noise on bright pixels. In such a case, we wish to explicitly include Poisson noise from the sources. Specifying the ``effective_gain`` keyword does this. For example, suppose we have a function ``background()`` that calculates the position-dependent background level and variance of our data:: >>> effective_gain = 1.5 >>> sky_level, sky_sigma = background(data) # function returns two arrays # doctest: +SKIP >>> phot_table = aperture_photometry(data - sky_level, apertures, ... error=sky_sigma, ... effective_gain=effective_gain) # doctest: +SKIP In this case, and indeed whenever ``effective_gain`` is not `None`, then ``'aperture_sum_err'`` is given by .. math:: \Delta F = \sqrt{\sum_{i \in A} (\sigma_i^2 + f_i / g_i)} where :math:`f_i` is the value of the data (``data - sky_level`` in this case) at each pixel and :math:`g_i` is the value of the ``effective_gain`` at each pixel. .. note:: In cases where the ``error`` and ``effective_gain`` arrays are slowly varying across the image, it is not necessary to sum the error from every pixel in the aperture individually. Instead, we can approximate the error as being roughly constant across the aperture and simply take the value of :math:`\sigma` at the center of the aperture. This can be done by setting the keyword ``pixelwise_errors=False``. This saves some computation time. In this case the flux error is .. math:: \Delta F = \sqrt{A \sigma^2 + F / g} where :math:`\sigma` and :math:`g` are the ``error`` and ``effective_gain`` at the center of the aperture, :math:`A` is the area of the aperture, and :math:`F` is the *total* flux in the aperture. Pixel Masking ------------- Pixels can be ignored/excluded (e.g., bad pixels) from the aperture photometry by providing an image mask via the ``mask`` keyword:: >>> data = np.ones((5, 5)) >>> aperture = CircularAperture((2, 2), 2.) >>> mask = np.zeros_like(data, dtype=bool) >>> data[2, 2] = 100. # bad pixel >>> mask[2, 2] = True >>> t1 = aperture_photometry(data, aperture, mask=mask) >>> print(t1['aperture_sum']) aperture_sum ------------- 11.5663706144 The result is very different if a ``mask`` image is not provided:: >>> t2 = aperture_photometry(data, aperture) >>> print(t2['aperture_sum']) aperture_sum ------------- 111.566370614 Aperture Photometry Using Sky Coordinates ----------------------------------------- As mentioned in :ref:`creating-aperture-objects`, performing photometry using apertures defined in celestial coordinates simply requires defining a 'sky' aperture using a :class:`~astropy.coordinates.SkyCoord` object. We show here an example of photometry on real data in celestial coordinates. We start by loading a Spitzer 4.5 micron image of a region of the Galactic plane:: >>> from photutils import datasets >>> hdu = datasets.load_spitzer_image() # doctest: +REMOTE_DATA >>> catalog = datasets.load_spitzer_catalog() # doctest: +REMOTE_DATA The catalog contains (among other things) the Galactic coordinates of the sources in the image as well as the PSF-fitted fluxes from the official Spitzer data reduction. We define the apertures positions based on the existing catalog positions:: >>> positions = SkyCoord(catalog['l'], catalog['b'], frame='galactic') # doctest: +REMOTE_DATA >>> apertures = SkyCircularAperture(positions, r=4.8 * u.arcsec) # doctest: +REMOTE_DATA >>> phot_table = aperture_photometry(hdu, apertures) # doctest: +REMOTE_DATA The ``hdu`` object is a FITS HDU that contains, in addition to the data, a header describing the WCS of the image (including the coordinate frame of the image and the projection from celestial to pixel coordinates). The `~photutils.aperture_photometry` function uses this information to automatically convert the apertures defined in celestial coordinates into pixel coordinates. The Spitzer catalog also contains the official fluxes for the sources that we can compare to our fluxes. The Spitzer catalog units are mJy while the data are in units of MJy/sr, so we have to do the conversion before comparing the results. The image data has a pixel scale of 1.2 arcsec / pixel. >>> import astropy.units as u >>> factor = (1.2 * u.arcsec) ** 2 / u.pixel >>> fluxes_catalog = catalog['f4_5'] # doctest: +REMOTE_DATA >>> converted_aperture_sum = (phot_table['aperture_sum'] * ... factor).to(u.mJy / u.pixel) # doctest: +REMOTE_DATA Finally, we can plot the comparison: .. doctest-skip:: >>> import matplotlib.pylab as plt >>> plt.scatter(fluxes_catalog, converted_aperture_sum.value) >>> plt.xlabel('Spitzer catalog fluxes ') >>> plt.ylabel('Aperture photometry fluxes') .. plot:: from astropy import units as u from astropy.coordinates import SkyCoord from photutils import aperture_photometry, SkyCircularAperture # Load dataset from photutils import datasets hdu = datasets.load_spitzer_image() catalog = datasets.load_spitzer_catalog() # Set up apertures positions = SkyCoord(catalog['l'], catalog['b'], frame='galactic') apertures = SkyCircularAperture(positions, r=4.8 * u.arcsec) phot_table = aperture_photometry(hdu, apertures) # Convert to correct units factor = (1.2 * u.arcsec) ** 2 / u.pixel fluxes_catalog = catalog['f4_5'] converted_aperture_sum = (phot_table['aperture_sum'] * factor).to(u.mJy / u.pixel) # Plot import matplotlib.pylab as plt plt.scatter(fluxes_catalog, converted_aperture_sum.value) plt.xlabel('Spitzer catalog fluxes ') plt.ylabel('Aperture photometry fluxes') plt.plot([40, 100, 450],[40, 100, 450], color='black', lw=2) Despite using different methods, the two catalogs are in good agreement. The aperture photometry fluxes are based on a circular aperture with a radius of 4.8 arcsec. The Spitzer catalog fluxes were computed using PSF photometry. Therefore, differences are expected between the two measurements. .. _custom-apertures: Defining Your Own Custom Apertures ---------------------------------- The photometry function :func:`~photutils.aperture_photometry` can perform aperture photometry in arbitrary apertures. This function accepts `Aperture`-derived objects, such as `~photutils.CircularAperture`. This makes it simple to extend functionality: a new type of aperture photometry simply requires the definition of a new `~photutils.Aperture` subclass. All `~photutils.PixelAperture` subclasses must implement three methods, ``do_photometry(data)``, ``area()``, and ``plot()``. `~photutils.SkyAperture` subclasses must implement only ``do_photometry(data)`` and ``plot()``. * ``do_photometry(data)``: A method to sum the pixel values within the defined aperture. * ``area()``: A method to return the area (pixels**2) of the aperture. * ``plot()``: A method to plot the aperture on a `matplotlib`_ Axes instance. Note that all x and y coordinates refer to the fast and slow (second and first) axis of the data array respectively. See :ref:`coordinate-conventions`. .. _matplotlib: http://matplotlib.org See Also -------- 1. `IRAF's APPHOT specification [PDF]`_ (Sec. 3.3.5.8 - 3.3.5.9) 2. `SourceExtractor Manual [PDF]`_ (Sec. 9.4 p. 36) .. _SourceExtractor: http://www.astromatic.net/software/sextractor .. _SourceExtractor Manual [PDF]: https://www.astromatic.net/pubsvn/software/sextractor/trunk/doc/sextractor.pdf .. _IRAF's APPHOT specification [PDF]: http://iraf.net/irafdocs/apspec.pdf Reference/API ------------- .. automodapi:: photutils.aperture_core :no-heading: photutils-0.2.1/docs/photutils/background.rst0000600000214200020070000004077712634600603023573 0ustar lbradleySTSCI\science00000000000000Background and Background Noise Estimation ========================================== Introduction ------------ To accurately measure the photometry and morphological properties of astronomical sources, one requires an accurate estimate of the background, which can be from both the sky and the detector. Similarly, having an accurate estimate of the background rms noise is important for determining the significance of source detections and for estimating photometric errors. Unfortunately, accurate background and background noise estimation is a difficult task. Further, because astronomical images can cover a wide variety of scenes, there is not a single background estimation method that will always be applicable. Photutils provides some tools for estimating the background and background noise in your data, but ultimately you have the flexibility of determining the background most appropriate for your data. Scalar Background Level and Noise Estimation -------------------------------------------- Simple Statistics ^^^^^^^^^^^^^^^^^ If the background level and noise are relatively constant across an image, the simplest way to estimate these values is to derive scalar values for these quantities using simple approximations. Of course, when computing the image statistics one must take into account the astronomical sources present in the images, which add a positive tail to the distribution of pixel intensities. For example, one may consider using the image median as the background level and the image standard deviation as the 1-sigma background noise, but the resulting values are obviously biased by the presence of real sources. A slightly better method involves using statistics that are robust against the presence of outliers, such as the biweight location for the background level and biweight midvariance or `median absolute deviation (MAD) `_ for the background noise estimation. However, for most astronomical scenes these methods will also be biased by the presence of astronomical sources in the image. As an example, we load a synthetic image comprised of 100 sources with a Gaussian-distributed background whose mean is 5 and standard deviation is 2:: >>> from photutils.datasets import make_100gaussians_image >>> data = make_100gaussians_image() Let's plot the image: .. doctest-skip:: >>> from astropy.visualization import SqrtStretch >>> from astropy.visualization.mpl_normalize import ImageNormalize >>> import matplotlib.pylab as plt >>> norm = ImageNormalize(stretch=SqrtStretch()) >>> plt.imshow(data, origin='lower', cmap='Greys_r', norm=norm) .. plot:: from photutils.datasets import make_100gaussians_image from astropy.visualization import SqrtStretch from astropy.visualization.mpl_normalize import ImageNormalize import matplotlib.pylab as plt data = make_100gaussians_image() norm = ImageNormalize(stretch=SqrtStretch()) plt.imshow(data, origin='lower', cmap='Greys_r', norm=norm) The image median and biweight location are both larger than the true background level of 5:: >>> import numpy as np >>> from astropy.stats import biweight_location >>> print(np.median(data)) 5.2255295184 >>> print(biweight_location(data)) 5.1867597555 Similarly, using the biweight midvariance and median absolute deviation to estimate the background noise level give values that are larger than the true value of 2:: >>> from astropy.stats import biweight_midvariance, mad_std >>> print(biweight_midvariance(data)) 2.22011175104 >>> print(mad_std(data)) # doctest: +FLOAT_CMP 2.1443728009 Sigma-Clipped Statistics ^^^^^^^^^^^^^^^^^^^^^^^^ The most widely used technique to remove the sources from the image statistics is called sigma clipping. Briefly, pixels that are above or below a specified sigma level from the median are discarded and the statistics are recalculated. The procedure is typically repeated over a number of iterations or until convergence is reached. This method provides a better estimate of the background and background noise levels:: >>> from astropy.stats import sigma_clipped_stats >>> mean, median, std = sigma_clipped_stats(data, sigma=3.0, iters=5) >>> print((mean, median, std)) # doctest: +FLOAT_CMP (5.1991386516217908, 5.1555874333582912, 2.0942752121329691) Masking Sources ^^^^^^^^^^^^^^^ An even better method is to exclude the sources in the image by masking them. Of course, this technique requires one to `identify the sources in the data `_, which in turn depends on the background and background noise. Therefore, this method for estimating the background and background rms requires an iterative procedure. We start by using the sigma-clipped statistics as the first estimate of the background and noise levels for the source detection. Here we use a aggressive 2-sigma detection threshold to maximize the source detections: .. doctest-requires:: scipy >>> from astropy.convolution import Gaussian2DKernel >>> from photutils.detection import detect_sources >>> threshold = median + (std * 2.) >>> segm_img = detect_sources(data, threshold, npixels=5) >>> mask = segm_img.data.astype(np.bool) # turn segm_img into a mask >>> mean, median, std = sigma_clipped_stats(data, sigma=3.0, mask=mask) >>> print((mean, median, std)) # doctest: +FLOAT_CMP (5.12349231659, 5.11792609168, 2.00503461917) To ensure that we are completely masking the extended regions of detected sources, we can dilate the source mask (NOTE: this requires `scipy`_): .. doctest-requires:: scipy >>> from scipy.ndimage import binary_dilation >>> selem = np.ones((5, 5)) # dilate using a 5x5 box >>> mask2 = binary_dilation(mask, selem) >>> mean, median, std = sigma_clipped_stats(data, sigma=3.0, mask=mask2) >>> print((mean, median, std)) # doctest: +FLOAT_CMP (5.02603895921, 5.02341384438, 1.97423026273) Of course, the source detection and masking procedure can be iterated further. Even with one iteration we are within ~%1 of the true values. .. _scipy: http://www.scipy.org/ 2D Background Level and Noise Estimation --------------------------------------------- If the background or the background noise varies across the image, then you will generally want to generate a 2D image of the background and background rms (or compute these values locally). This can be accomplished by applying the above techniques to subregions of the image. A common procedure is to use sigma-clipped statistics in each mesh of a grid that covers the input data to create a low-resolution background map. The final background or background rms map is then generated using spline interpolation of the low-resolution map. In Photutils, the :class:`~photutils.background.Background` class can be used to estimate a 2D background and background rms noise in an astronomical image. `~photutils.background.Background` requires the shape of the box (``box_shape``) in which to estimate the background. Selecting the box size requires some care by the user. The box size should generally be larger than the typical size of sources in the image, but small enough to encapsulate any background variations. For best results, the box shape should also be chosen so that the data are covered by an integer number of boxes in both dimensions. The background level in each of the meshes is based on sigma-clipped statistics, where the sigma-clipping is controlled controlled by the ``sigmaclip_sigma`` and the ``sigclip_iters`` input parameters. The background level in each mesh is estimated using one of several defined methods or by using a custom method (see :ref:`background_methods` below). The background rms in each mesh is estimated by the sigma-clipped standard deviation. After the background has been determined in each of the boxes, the low-resolution background can be median filtered (``filter_shape``) to suppress local under- or overestimations (e.g., due to bright galaxies in a particular box). Likewise, the median filter can be applied only to those boxes which are above a specified threshold (``filter_threshold``). The low-resolution background maps are resized to the original data size using spline interpolation of the requested order (``interp_order``). The default is ``interp_order=3``, which is bicubic spline interpolation. For this example, we will add a strong background gradient to the image:: >>> ny, nx = data.shape >>> y, x = np.mgrid[:ny, :nx] >>> gradient = x * y / 2000. >>> data2 = data + gradient >>> plt.imshow(data2, origin='lower', cmap='Greys_r') # doctest: +SKIP .. plot:: from photutils.datasets import make_100gaussians_image import matplotlib.pylab as plt data = make_100gaussians_image() ny, nx = data.shape y, x = np.mgrid[:ny, :nx] gradient = x * y / 2000. data2 = data + gradient plt.imshow(data2, origin='lower', cmap='Greys_r') We start by creating a `~photutils.background.Background` object using a box shape of 50x50, a 3x3 median filter, and the "median" background method, which estimates the background using the sigma-clipped median in each box: .. doctest-requires:: scipy >>> from photutils.background import Background >>> bkg = Background(data2, (50, 50), filter_shape=(3, 3), method='median') The 2D background map and background rms maps are retrieved using the ``background`` and ``background_rms`` attributes, respectively. The low-resolution versions of these maps are the ``background_low_res`` and ``background_rms_low_res`` attributes, respectively. The global median value of the low-resolution background and background rms maps is provided with the ``background_median`` and ``background_rms_median`` attributes, respectively: .. doctest-requires:: scipy >>> print(bkg.background_median) 19.2448529312 >>> print(bkg.background_rms_median) 3.09090781196 Let's plot the background map: .. doctest-skip:: >>> plt.imshow(bkg.background, origin='lower', cmap='Greys_r') .. plot:: from photutils.datasets import make_100gaussians_image from photutils.background import Background import matplotlib.pylab as plt data = make_100gaussians_image() ny, nx = data.shape y, x = np.mgrid[:ny, :nx] gradient = x * y / 2000. data2 = data + gradient bkg = Background(data2, (50, 50), filter_shape=(3, 3), method='median') plt.imshow(bkg.background, origin='lower', cmap='Greys_r') .. _background_methods: Background Methods ^^^^^^^^^^^^^^^^^^ The background level in each of the background meshes can by estimated using one of several defined methods or by using a custom method. For all methods, the statistics are calculated from the sigma-clipped data values in each mesh. The defined methods are ``'mean'``, ``'median'``, ``'sextractor'``, and ``'mode_estimate'``. ``'mean'`` and ``'median'`` are simply the sigma-clipped mean and median, respectively, in each background mesh. For ``'sextractor'``, the background in each mesh is ``(2.5 * median) - (1.5 * mean)``. However, if ``(mean - median) / std > 0.3`` then the ``median`` is used instead (despite what the `SExtractor `_ User's Manual says, this is the method it always uses). For ``'mode_estimate'``, the background is ``(3 * median) - (2 * mean)``. A custom calculation can also be defined for the background level by setting ``method='custom'`` and inputing a custom function to the ``backfunc`` parameter. The custom function must must take in a 3D `~numpy.ma.MaskedArray` of size ``MxNxZ``, where the ``Z`` axis (axis=2) contains the sigma-clipped pixels in each background mesh, and outputs a 2D `~numpy.ndarray` low-resolution background map of size ``MxN``. We demonstrate this capability using a custom function that is simply the median of the sigma-clipped data in each mesh (this is the same calculation used by ``method='median'``). We start by defining the custom function:: >>> def backfunc(data): ... z = np.ma.median(data, axis=2) ... return np.ma.filled(z, np.ma.median(z)) Now we can pass the function to the `~photutils.background.Background` class: .. doctest-requires:: scipy >>> bkg = Background(data, (50, 50), filter_shape=(3, 3), ... method='custom', backfunc=backfunc) >>> back = bkg.background Masking ^^^^^^^ Masks can also be input into `~photutils.background.Background`. As described above, this can be employed to mask sources in the image to estimate the background with an iterative procedure. Additionally, input masks are often necessary if your data array includes regions without data coverage (e.g., from a rotated image or an image from a mosaic). Otherwise the data values in the regions without coverage (e.g., usually zeros) will adversely contribute to the background statistics. Let's create such an image (this requires `scipy`_) and plot it: .. doctest-requires:: scipy >>> from scipy.ndimage import rotate >>> data3 = rotate(data2, -45.) >>> norm = ImageNormalize(stretch=SqrtStretch()) # doctest: +SKIP >>> plt.imshow(data3, origin='lower', cmap='Greys_r', norm=norm) # doctest: +SKIP .. plot:: from photutils.datasets import make_100gaussians_image from scipy.ndimage.interpolation import rotate from astropy.visualization import SqrtStretch from astropy.visualization.mpl_normalize import ImageNormalize import matplotlib.pylab as plt data = make_100gaussians_image() ny, nx = data.shape y, x = np.mgrid[:ny, :nx] gradient = x * y / 2000. data2 = data + gradient data3 = rotate(data2, -45.) norm = ImageNormalize(stretch=SqrtStretch()) plt.imshow(data3, origin='lower', cmap='Greys_r', norm=norm) Now we create a coverage mask and input it into `~photutils.background.Background` to exclude the regions where we have no data. For real data, one can usually create a coverage mask from a weight or rms image. For this example we also use a smaller box size to help capture the strong gradient in the background: .. doctest-requires:: scipy >>> mask = (data3 == 0) >>> bkg3 = Background(data3, (25, 25), filter_shape=(3, 3), mask=mask) Masks are never applied to the returned background map because the input ``mask`` can represent either a coverage mask or a source mask, or a combination of both. We need to manually apply the coverage mask to the returned background map: .. doctest-requires:: scipy >>> back3 = bkg3.background * ~mask >>> norm = ImageNormalize(stretch=SqrtStretch()) # doctest: +SKIP >>> plt.imshow(back3, origin='lower', cmap='Greys_r', norm=norm) # doctest: +SKIP .. plot:: from photutils.datasets import make_100gaussians_image from photutils.background import Background from scipy.ndimage.interpolation import rotate from astropy.visualization import SqrtStretch from astropy.visualization.mpl_normalize import ImageNormalize import matplotlib.pylab as plt data = make_100gaussians_image() ny, nx = data.shape y, x = np.mgrid[:ny, :nx] gradient = x * y / 2000. data2 = data + gradient data3 = rotate(data2, -45.) mask = (data3 == 0) bkg3 = Background(data3, (25, 25), filter_shape=(3, 3), mask=mask) back3 = bkg3.background * ~mask norm = ImageNormalize(stretch=SqrtStretch()) plt.imshow(back3, origin='lower', cmap='Greys_r', norm=norm) Finally, let's subtract the background from the image and plot it: .. doctest-skip:: >>> norm = ImageNormalize(stretch=SqrtStretch()) >>> plt.imshow(data3 - back3, origin='lower', cmap='Greys_r', norm=norm) .. plot:: from photutils.datasets import make_100gaussians_image from photutils.background import Background from scipy.ndimage.interpolation import rotate import matplotlib.pylab as plt from astropy.visualization import SqrtStretch from astropy.visualization.mpl_normalize import ImageNormalize data = make_100gaussians_image() ny, nx = data.shape y, x = np.mgrid[:ny, :nx] gradient = x * y / 2000. data2 = data + gradient data3 = rotate(data2, -45.) mask = (data3 == 0) bkg3 = Background(data3, (25, 25), filter_shape=(3, 3), mask=mask) back3 = bkg3.background * ~mask norm = ImageNormalize(stretch=SqrtStretch()) plt.imshow(data3 - back3, origin='lower', cmap='Greys_r', norm=norm) While there are some residuals around the image edges (due to the bicubic spline interpolation), the overall result is respectable, especially given the strong background gradient that was present in the data. Reference/API ------------- .. automodapi:: photutils.background :no-heading: photutils-0.2.1/docs/photutils/datasets.rst0000600000214200020070000000356612634600603023257 0ustar lbradleySTSCI\science00000000000000.. _datasets: Datasets (`photutils.datasets`) =============================== .. currentmodule:: photutils.datasets Introduction ------------ `photutils.datasets` gives easy access to a few example datasets (mostly images, but also e.g. source catalogs or PSF models). This is useful for the Photutils documentation, tests, and benchmarks, but also for users that would like to try out Photutils functions or implement new methods for Photutils or their own scripts. Functions that start with ``load_*`` load data files from disk. Very small data files are bundled in the Photutils code repository and are guaranteed to be available. Mid-sized data files are currently available from a separate `photutils-datasets`_ repository and loaded into the Astropy cache on the user's machine on first load. Functions that start with ``make_*`` generate simple simulated data (e.g. Gaussian sources on flat background with Poisson or Gaussian noise). Note that there are other tools like `skymaker`_ that can simulate much more realistic astronomical images. Getting Started --------------- To load an example image with `~photutils.datasets.load_star_image`:: >>> from photutils import datasets >>> hdu = datasets.load_star_image() # doctest: +REMOTE_DATA >>> print(hdu.data.shape) # doctest: +REMOTE_DATA (1059, 1059) ``hdu`` is an `astropy.io.fits.ImageHDU` object and ``hdu.data`` is a `numpy.array` object that you can analyse with Photutils. Let's plot the image: .. plot:: :include-source: from photutils import datasets hdu = datasets.load_star_image() plt.imshow(hdu.data, origin='lower', cmap='gray') plt.tight_layout() plt.show() Reference/API ------------- .. automodapi:: photutils.datasets :no-heading: .. _photutils-datasets: https://github.com/astropy/photutils-datasets/ .. _skymaker: http://www.astromatic.net/software/skymaker photutils-0.2.1/docs/photutils/detection.rst0000600000214200020070000003566212641136622023432 0ustar lbradleySTSCI\science00000000000000Source Detection and Extraction =============================== Introduction ------------ One generally needs to identify astronomical sources in their data before they can perform photometry or morphological measurements. This procedure is referred to as source detection or source extraction. Photutils provides two functions designed specifically to detect point-like (stellar) sources in an astronomical image. Photutils also provides a general-use function to detect sources (both point-like and extended) in an image using a process called `image segmentation`_ in the `computer vision `_ field. Detecting Stars --------------- Photutils includes two widely-used tools that are used to detect stars in an image, `DAOFIND`_ and IRAF's `starfind`_. :func:`~photutils.daofind` is an implementation of the `DAOFIND`_ algorithm (`Stetson 1987, PASP 99, 191 `_). It searches images for local density maxima that have a peak amplitude greater than a specified threshold (the threshold is applied to a convolved image) and have a size and shape similar to a defined 2D Gaussian kernel. :func:`~photutils.daofind` also provides an estimate of the objects' roundness and sharpness, whose lower and upper bounds can be specified. :func:`~photutils.irafstarfind` is an implementation of IRAF's `starfind`_ algorithm. It is similar to :func:`~photutils.daofind`, but it always uses a 2D circular Gaussian kernel, while :func:`~photutils.daofind` can use an elliptical Gaussian kernel. :func:`~photutils.irafstarfind` is also different in that it calculates the objects' centroid, roundness, and sharpness using image moments. As an example, let's load an image from the bundled datasets and select a subset of the image. We will estimate the background and background noise using sigma-clipped statistics:: >>> from photutils import datasets >>> from astropy.stats import sigma_clipped_stats >>> hdu = datasets.load_star_image() # doctest: +REMOTE_DATA Downloading ... >>> data = hdu.data[0:400, 0:400] # doctest: +REMOTE_DATA >>> mean, median, std = sigma_clipped_stats(data, sigma=3.0, iters=5) # doctest: +REMOTE_DATA >>> print(mean, median, std) # doctest: +REMOTE_DATA (3667.7792400186008, 3649.0, 204.27923665845705) Now we will subtract the background and use :func:`~photutils.daofind` to find the stars in the image that have FWHMs of around 3 pixels and have peaks approximately 5-sigma above the background: .. doctest-requires:: scipy, skimage >>> from photutils import daofind >>> sources = daofind(data - median, fwhm=3.0, threshold=5.*std) # doctest: +REMOTE_DATA >>> print(sources) # doctest: +REMOTE_DATA id xcentroid ycentroid ... peak flux mag --- ------------- ------------- ... ------ ------------- --------------- 1 144.247567164 6.37979042704 ... 6903.0 5.70143033038 -1.88995955438 2 208.669068628 6.82058053777 ... 7896.0 6.72306730455 -2.06891864748 3 216.926136655 6.5775933198 ... 2195.0 1.66737467591 -0.555083002864 4 351.625190383 8.5459013233 ... 6977.0 5.90092548147 -1.92730032571 5 377.519909958 12.0655009987 ... 1260.0 1.11856203781 -0.121650189969 ... ... ... ... ... ... ... 281 268.049236979 397.925371446 ... 9299.0 6.22022587541 -1.98451538884 282 268.475068392 398.020998272 ... 8754.0 6.05079160593 -1.95453048936 283 299.80943822 398.027911813 ... 8890.0 6.11853416663 -1.96661847383 284 315.689448343 398.70251891 ... 6485.0 5.55471107793 -1.86165368631 285 360.437243037 398.698539555 ... 8079.0 5.26549321379 -1.80359764345 Length = 285 rows Let's plot the image and mark the location of detected sources: .. doctest-skip:: >>> from photutils import CircularAperture >>> from astropy.visualization import SqrtStretch >>> from astropy.visualization.mpl_normalize import ImageNormalize >>> import matplotlib.pylab as plt >>> positions = (sources['xcentroid'], sources['ycentroid']) >>> apertures = CircularAperture(positions, r=4.) >>> norm = ImageNormalize(stretch=SqrtStretch()) >>> plt.imshow(data, cmap='Greys', origin='lower', norm=norm) >>> apertures.plot(color='blue', lw=1.5, alpha=0.5) .. plot:: from astropy.stats import sigma_clipped_stats from photutils import datasets, daofind, CircularAperture from astropy.visualization import SqrtStretch from astropy.visualization.mpl_normalize import ImageNormalize import matplotlib.pylab as plt hdu = datasets.load_star_image() data = hdu.data[0:400, 0:400] mean, median, std = sigma_clipped_stats(data, sigma=3.0) sources = daofind(data - median, fwhm=3.0, threshold=5.*std) positions = (sources['xcentroid'], sources['ycentroid']) apertures = CircularAperture(positions, r=4.) norm = ImageNormalize(stretch=SqrtStretch()) plt.imshow(data, cmap='Greys', origin='lower', norm=norm) apertures.plot(color='blue', lw=1.5, alpha=0.5) .. _source_extraction: Source Extraction Using Image Segmentation ------------------------------------------ Photutils also provides tools to detect astronomical sources using `image segmentation`_, which is a process of assigning a label to every pixel in an image such that pixels with the same label are part of the same source. The segmentation procedure implemented in Photutils is called the threshold method, where detected sources must have a minimum number of connected pixels that are each greater than a specified threshold value in an image. The threshold level is usually defined at some multiple of the background standard deviation (sigma) above the background. The image can also be filtered before thresholding to smooth the noise and maximize the detectability of objects with a shape similar to the filter kernel. In Photutils, source extraction is performed using the :func:`~photutils.detection.detect_sources` function. The :func:`~photutils.detection.detect_threshold` tool is a convenience function to generate a 2D detection threshold image using simple sigma-clipped statistics to estimate the background and background rms. For this example, let's detect sources in a synthetic image provided by the `datasets `_ module:: >>> from photutils.datasets import make_100gaussians_image >>> data = make_100gaussians_image() We will use :func:`~photutils.detection.detect_threshold` to produce a detection threshold image. :func:`~photutils.detection.detect_threshold` will estimate the background and background rms using sigma-clipped statistics if they are not input. The threshold level is calculated using the ``snr`` input as the sigma level above the background. Here we generate a simple pixel-wise threshold at 3 sigma above the background:: >>> from photutils import detect_threshold >>> threshold = detect_threshold(data, snr=3.) For more sophisticated analyses, one should generate a 2D background and background-only error image (e.g., from your data reduction or by using :class:`~photutils.background.Background`). In that case, a 3-sigma threshold image is simply:: >>> threshold = bkg + (3.0 * bkg_rms) # doctest: +SKIP Note that if the threshold includes the background level (as above), then the image input into :func:`~photutils.detection.detect_sources` should *not* be background subtracted. Let's find sources that have 5 connected pixels that are each greater than the corresponding pixel-wise ``threshold`` level defined above. Because the threshold returned by :func:`~photutils.detection.detect_threshold` includes the background, we do not subtract the background from the data here. We will also input a 2D circular Gaussian kernel with a FWHM of 2 pixels to filter the image prior to thresholding: .. doctest-requires:: scipy >>> from astropy.convolution import Gaussian2DKernel >>> from astropy.stats import gaussian_fwhm_to_sigma >>> from photutils import detect_sources >>> sigma = 2.0 * gaussian_fwhm_to_sigma # FWHM = 2. >>> kernel = Gaussian2DKernel(sigma, x_size=3, y_size=3) >>> kernel.normalize() >>> segm = detect_sources(data, threshold, npixels=5, filter_kernel=kernel) The result is a :class:`~photutils.segmentation.SegmentationImage` object with the same shape as the data, where sources are labeled by different positive integer values. A value of zero is always reserved for the background. Let's plot both the image and the segmentation image showing the detected sources: .. doctest-skip:: >>> import numpy as np >>> import matplotlib.pylab as plt >>> from astropy.visualization import SqrtStretch >>> from astropy.visualization.mpl_normalize import ImageNormalize >>> from photutils.utils import random_cmap >>> rand_cmap = random_cmap(segm.max + 1, random_state=12345) >>> norm = ImageNormalize(stretch=SqrtStretch()) >>> fig, (ax1, ax2) = plt.subplots(2, 1, figsize=(8, 8)) >>> ax1.imshow(data, origin='lower', cmap='Greys_r', norm=norm) >>> ax2.imshow(segm, origin='lower', cmap=rand_cmap) .. plot:: import numpy as np import matplotlib.pylab as plt from astropy.stats import gaussian_fwhm_to_sigma from astropy.convolution import Gaussian2DKernel from astropy.visualization import SqrtStretch from astropy.visualization.mpl_normalize import ImageNormalize from photutils.datasets import make_100gaussians_image from photutils import detect_threshold, detect_sources from photutils.utils import random_cmap data = make_100gaussians_image() threshold = detect_threshold(data, snr=3.) sigma = 2.0 * gaussian_fwhm_to_sigma # FWHM = 2. kernel = Gaussian2DKernel(sigma, x_size=3, y_size=3) kernel.normalize() segm = detect_sources(data, threshold, npixels=5, filter_kernel=kernel) rand_cmap = random_cmap(segm.max + 1, random_state=12345) norm = ImageNormalize(stretch=SqrtStretch()) fig, (ax1, ax2) = plt.subplots(2, 1, figsize=(8, 8)) ax1.imshow(data, origin='lower', cmap='Greys_r', norm=norm) ax2.imshow(segm, origin='lower', cmap=rand_cmap) When the segmentation image is generated using image thresholding (e.g., using :func:`~photutils.detect_sources`), the source segments effectively represent the isophotal footprint of each source. Source Deblending ^^^^^^^^^^^^^^^^^ Note that overlapping sources are detected as single sources. Separating those sources requires a deblending procedure, such as a multi-thresholding technique used by `SExtractor `_. Photutils provides an experimental :func:`~photutils.deblend_sources` function that deblends sources uses a combination of multi-thresholding and `watershed segmentation `_. In order to deblend sources, they must be separated enough such that there is a saddle between them: .. doctest-requires:: scipy, skimage >>> from photutils import deblend_sources >>> segm_deblend = deblend_sources(data, segm, npixels=5, ... filter_kernel=kernel) where ``segm`` is the :class:`~photutils.segmentation.SegmentationImage` that was generated by :func:`~photutils.detect_sources`. Note that the ``npixels`` and ``filter_kernel`` input values should match those used in :func:`~photutils.detect_sources`. The result is a :class:`~photutils.segmentation.SegmentationImage` object containing the deblended segmentation image. Centroids, Photometry, and Morphological Properties ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ To calculate the centroids, photometry, and morphological properties of sources from a segmentation map, please see `Segmentation Photometry and Properties `_. Local Peak Detection -------------------- Photutils also includes a :func:`~photutils.detection.find_peaks` function to find local peaks in an image that are above a specified threshold value. Peaks are the local maxima above a specified threshold that separated by a a specified minimum number of pixels. The return pixel coordinates are always integer (i.e., no centroiding is performed, only the peak pixel is identified). :func:`~photutils.detection.find_peaks` also supports a number of options, including searching for peaks only within a segmentation image or a specified footprint. Please see the :func:`~photutils.detection.find_peaks` documentation for more options. As simple example, let's find the local peaks in an image that are 10 sigma above the background and a separated by a least 2 pixels: .. doctest-requires:: skimage >>> from astropy.stats import sigma_clipped_stats >>> from photutils.datasets import make_100gaussians_image >>> from photutils import find_peaks >>> data = make_100gaussians_image() >>> mean, median, std = sigma_clipped_stats(data, sigma=3.0) >>> threshold = median + (10.0 * std) >>> tbl = find_peaks(data, threshold, box_size=5) >>> print(tbl[:10]) # print only the first 10 peaks x_peak y_peak peak_value ------ ------ ------------- 233 0 27.4778521972 236 1 27.339519624 289 22 35.8532759965 442 31 30.2399941373 1 40 35.5482863002 89 59 41.2190469279 7 70 33.2880647048 258 75 26.5624808518 463 80 28.7588206692 182 93 38.0885687202 And let's plot the location of the detected peaks in the image: .. doctest-skip:: >>> from astropy.visualization import SqrtStretch >>> from astropy.visualization.mpl_normalize import ImageNormalize >>> import matplotlib.pylab as plt >>> norm = ImageNormalize(stretch=SqrtStretch()) >>> plt.imshow(data, cmap='Greys_r', origin='lower', norm=norm) >>> plt.plot(tbl['x_peak'], tbl['y_peak'], ls='none', color='cyan', ... marker='+', ms=10, lw=1.5) >>> plt.xlim(0, data.shape[1]-1) >>> plt.ylim(0, data.shape[0]-1) .. plot:: from astropy.stats import sigma_clipped_stats from photutils.datasets import make_100gaussians_image from photutils import find_peaks data = make_100gaussians_image() mean, median, std = sigma_clipped_stats(data, sigma=3.0) threshold = median + (10.0 * std) tbl = find_peaks(data, threshold, box_size=5) from astropy.visualization import SqrtStretch from astropy.visualization.mpl_normalize import ImageNormalize import matplotlib.pylab as plt norm = ImageNormalize(stretch=SqrtStretch()) plt.imshow(data, cmap='Greys_r', origin='lower', norm=norm) plt.plot(tbl['x_peak'], tbl['y_peak'], ls='none', color='cyan', marker='+', ms=10, lw=1.5) plt.xlim(0, data.shape[1]-1) plt.ylim(0, data.shape[0]-1) Reference/API ------------- .. automodapi:: photutils.detection :no-heading: .. _DAOFIND: http://stsdas.stsci.edu/cgi-bin/gethelp.cgi?daofind .. _starfind: http://stsdas.stsci.edu/cgi-bin/gethelp.cgi?starfind .. _image segmentation: http://en.wikipedia.org/wiki/Image_segmentation .. _sep: https://github.com/kbarbary/sep photutils-0.2.1/docs/photutils/geometry.rst0000600000214200020070000000041512444404542023273 0ustar lbradleySTSCI\science00000000000000Geometry Functions ================== Introduction ------------ The `photutils.geometry` package contains low-level geometry functions used mainly by `~photutils.aperture_photometry`. Reference/API ------------- .. automodapi:: photutils.geometry :no-heading: photutils-0.2.1/docs/photutils/getting_started.rst0000600000214200020070000001144612634600603024632 0ustar lbradleySTSCI\science00000000000000Getting Started =============== The following example uses Photutils to find sources in an astronomical image and perform circular aperture photometry on them. We start by loading an image from the bundled datasets and selecting a subset of the image. We then subtract a rough estimate of the background, calculated using the image median: >>> import numpy as np >>> from photutils import datasets >>> hdu = datasets.load_star_image() # doctest: +REMOTE_DATA Downloading ... >>> image = hdu.data[500:700, 500:700].astype(float) # doctest: +REMOTE_DATA >>> image -= np.median(image) # doctest: +REMOTE_DATA In the remainder of this example, we assume that the data is background-subtracted. Photutils supports several source detection algorithms. For this example, we use :func:`~photutils.daofind` to detect the stars in the image. We set the detection threshold at the 3-sigma noise level, estimated using the median absolution deviation of the image. The parameters of the detected sources are returned as an Astropy `~astropy.table.Table`: .. doctest-requires:: scipy, skimage >>> from photutils import daofind >>> from astropy.stats import mad_std >>> bkg_sigma = mad_std(image) # doctest: +REMOTE_DATA >>> sources = daofind(image, fwhm=4., threshold=3.*bkg_sigma) # doctest: +REMOTE_DATA >>> print(sources) # doctest: +REMOTE_DATA id xcentroid ycentroid ... peak flux mag --- ------------- -------------- ... ------ ------------- --------------- 1 182.838658938 0.167670190537 ... 3824.0 2.80283459469 -1.11899367311 2 189.204308134 0.260813525338 ... 4913.0 3.87291850311 -1.47009589582 3 5.79464911433 2.61254240807 ... 7752.0 4.1029107294 -1.53273016937 4 36.8470627804 1.32202279582 ... 8739.0 7.43158178793 -2.17770315441 5 3.2565602452 5.41895201748 ... 6935.0 3.81262984074 -1.45306160673 ... ... ... ... ... ... ... 148 124.313272579 188.305229159 ... 6702.0 6.63585429303 -2.05474210356 149 24.2572074962 194.714942814 ... 8342.0 3.2671036996 -1.28540729858 150 116.449998422 195.059233325 ... 3299.0 2.87752205766 -1.1475466535 151 18.9580860645 196.342065132 ... 3854.0 2.38352961224 -0.943051379595 152 111.525751196 195.731917995 ... 8109.0 7.9278607401 -2.24789003194 Length = 152 rows Using the list of source locations (``xcentroid`` and ``ycentroid``), we now compute the sum of the pixel values in circular apertures with a radius of 4 pixels. The :func:`~photutils.aperture_photometry` function returns an Astropy `~astropy.table.Table` with the results of the photometry: .. doctest-requires:: scipy, skimage >>> from photutils import aperture_photometry, CircularAperture >>> positions = (sources['xcentroid'], sources['ycentroid']) # doctest: +REMOTE_DATA >>> apertures = CircularAperture(positions, r=4.) # doctest: +REMOTE_DATA >>> phot_table = aperture_photometry(image, apertures) # doctest: +REMOTE_DATA >>> print(phot_table) # doctest: +REMOTE_DATA aperture_sum xcenter ycenter pix pix ------------- ------------- -------------- 18121.7594837 182.838658938 0.167670190537 29836.5152158 189.204308134 0.260813525338 331979.819037 5.79464911433 2.61254240807 183705.093284 36.8470627804 1.32202279582 349468.978627 3.2565602452 5.41895201748 ... ... ... 45084.8737867 124.313272579 188.305229159 355778.007298 24.2572074962 194.714942814 31232.9117818 116.449998422 195.059233325 162076.262752 18.9580860645 196.342065132 82795.7145661 111.525751196 195.731917995 Length = 152 rows The sum of the pixel values within the apertures are given in the column ``aperture_sum``. We now plot the image and the defined apertures: .. doctest-skip:: >>> import matplotlib.pylab as plt >>> plt.imshow(image, cmap='gray_r', origin='lower') >>> apertures.plot(color='blue', lw=1.5, alpha=0.5) .. plot:: import numpy as np import matplotlib.pylab as plt from astropy.stats import mad_std from photutils import datasets, daofind, aperture_photometry, CircularAperture hdu = datasets.load_star_image() image = hdu.data[500:700, 500:700].astype(float) image -= np.median(image) bkg_sigma = mad_std(image) sources = daofind(image, fwhm=4., threshold=3.*bkg_sigma) positions = (sources['xcentroid'], sources['ycentroid']) apertures = CircularAperture(positions, r=4.) phot_table = aperture_photometry(image, apertures) brightest_source_id = phot_table['aperture_sum'].argmax() plt.imshow(image, cmap='gray_r', origin='lower') apertures.plot(color='blue', lw=1.5, alpha=0.5) photutils-0.2.1/docs/photutils/high-level_API.rst0000600000214200020070000000011012444404542024145 0ustar lbradleySTSCI\science00000000000000Reference/API ============= .. automodapi:: photutils :no-heading: photutils-0.2.1/docs/photutils/install.rst0000600000214200020070000001347112634602151023111 0ustar lbradleySTSCI\science00000000000000************ Installation ************ Requirements ============ Photutils has the following strict requirements: * `Python `_ 2.7, 3.3, 3.4 or 3.5 * `Numpy `_ 1.6 or later * `Astropy`_ 1.0 or later You will also need `Cython`_ (0.15 or later) to build Photutils from source, unless you are installing a numbered release (see :ref:`sourceinstall` below). Some functionality is available only if the following optional dependencies are installed: * `Scipy`_ 0.15 or later * `scikit-image`_ 0.11 or later * `matplotlib `_ 1.3 or later .. warning:: While Photutils will import even if these dependencies are not installed, the functionality will be severely limited. It is very strongly recommended that you install `Scipy`_ and `scikit-image`_ to use Photutils. Both are easily installed via `pip`_ or `conda`_. .. _Scipy: http://www.scipy.org/ .. _scikit-image: http://scikit-image.org/ .. _pip: https://pip.pypa.io/en/latest/ .. _conda: http://conda.pydata.org/docs/ .. _Cython: http://cython.org Installing Photutils Using pip ============================== To install the latest Photutils **stable** version with `pip`_, simply run:: pip install --no-deps photutils To install the current Photutils **development** version using `pip`_:: pip install --no-deps git+https://github.com/astropy/photutils.git .. note:: You will need a C compiler (e.g. ``gcc`` or ``clang``) to be installed (see :ref:`sourceinstall` below) for the installation to succeed. .. note:: The ``--no-deps`` flag is optional, but highly recommended if you already have Numpy and Astropy installed, since otherwise pip will sometimes try to "help" you by upgrading your Numpy and Astropy installations, which may not always be desired. .. note:: If you get a ``PermissionError`` this means that you do not have the required administrative access to install new packages to your Python installation. In this case you may consider using the ``--user`` option to install the package into your home directory. You can read more about how to do this in the `pip documentation `_. Do **not** install Photutils or other third-party packages using ``sudo`` unless you are fully aware of the risks. .. _sourceinstall: Installing Photutils from Source ================================ Prerequisites ------------- You will need a compiler suite and the development headers for Python and Numpy in order to build Photutils. On Linux, using the package manager for your distribution will usually be the easiest route, while on MacOS X you will need the XCode command line tools. The `instructions for building Numpy from source `_ are also a good resource for setting up your environment to build Python packages. You will also need `Cython`_ (0.15 or later) to build from source, unless you are installing a numbered release. (The released packages have the necessary C files packaged with them, and hence do not require Cython.) .. note:: If you are using MacOS X, you will need to the XCode command line tools. One way to get them is to install `XCode `_. If you are using OS X 10.7 (Lion) or later, you must also explicitly install the command line tools. You can do this by opening the XCode application, going to **Preferences**, then **Downloads**, and then under **Components**, click on the Install button to the right of **Command Line Tools**. Alternatively, on 10.7 (Lion) or later, you do not need to install XCode, you can download just the command line tools from https://developer.apple.com/downloads/index.action (requires an Apple developer account). Obtaining the Source Package ---------------------------- Stable Version ^^^^^^^^^^^^^^ The latest stable source package for Photutils can be `downloaded here `_. Development Version ^^^^^^^^^^^^^^^^^^^ The latest development version of Photutils can be cloned from github using this command:: git clone git://github.com/astropy/photutils.git Building and Installing ----------------------- Photutils uses the Python `distutils framework `_ for building and installing and requires the `distribute `_ extension--the later is automatically downloaded when running ``python setup.py`` if it is not already provided by your system. Numpy and Astropy must already installed in your Python environment. To build Photutils (from the root of the source tree):: python setup.py build To install Photutils (from the root of the source tree):: python setup.py install .. _sourcebuildtest: Testing a Source-Code Build of Photutils ---------------------------------------- The easiest way to test that your Photutils built correctly (without installing Photutils) is to run this from the root of the source tree:: python setup.py test See the Astropy documentation for alternative methods of :ref:`running-tests`. Testing an Installed Photutils ============================== The easiest way to test your installed version of Photutils is running correctly is to use the :func:`photutils.test()` function: .. doctest-skip:: >>> import photutils >>> photutils.test() The tests should run and print out any failures, which you can report to the `Photutils issue tracker `_. .. note:: This way of running the tests may not work if you do it in the Photutils source distribution directory. See :ref:`sourcebuildtest` for how to run the tests from the source code directory. photutils-0.2.1/docs/photutils/morphology.rst0000600000214200020070000001753212634600603023644 0ustar lbradleySTSCI\science00000000000000Source Centroids and Morphological Properties ============================================= Centroiding a Source -------------------- `photutils.morphology` provides several functions to calculate the centroid of a single source. The centroid methods are: * :func:`~photutils.morphology.centroid_com`: Calculates the object center of mass from 2D image moments. * :func:`~photutils.morphology.centroid_1dg`: Calculates the centroid by fitting 1D Gaussians to the marginal x and y distributions of the data. * :func:`~photutils.morphology.centroid_2dg`: Calculates the centroid by fitting a 2D Gaussian to the 2D distribution of the data. Masks can be input into each of these functions to mask bad pixels. Error arrays can be input into the two fitting methods to weight the fits. Let's extract a single object from a synthetic dataset and find its centroid with each of these methods. For this simple example we will not subtract the background from the data (but in practice, one should subtract the background):: >>> from photutils.datasets import make_4gaussians_image >>> from photutils.morphology import (centroid_com, centroid_1dg, ... centroid_2dg) >>> data = make_4gaussians_image()[43:79, 76:104] .. doctest-requires:: skimage >>> x1, y1 = centroid_com(data) >>> print((x1, y1)) # doctest: +FLOAT_CMP (13.93157998341213, 17.051234441067088) .. doctest-requires:: scipy >>> x2, y2 = centroid_1dg(data) >>> print((x2, y2)) # doctest: +FLOAT_CMP (14.040352707371396, 16.962306463644801) .. doctest-requires:: scipy, skimage >>> x3, y3 = centroid_2dg(data) >>> print((x3, y3)) # doctest: +FLOAT_CMP (14.002212073733611, 16.996134592982017) Now let's plot the results. Because the centroids are all very similar, we also include an inset plot zoomed in near the centroid: .. doctest-skip:: >>> import matplotlib.pyplot as plt >>> fig, ax = plt.subplots(1, 1) >>> ax.imshow(data, origin='lower', cmap='Greys_r') >>> marker = '+' >>> ms, mew = 30, 2. >>> plt.plot(x1, y1, color='red', marker=marker, ms=ms) >>> plt.plot(x2, y2, color='blue', marker=marker, ms=ms) >>> plt.plot(x3, y3, color='green', marker=marker, ms=ms) >>> # include a zoomed inset plot >>> from mpl_toolkits.axes_grid1.inset_locator import zoomed_inset_axes >>> from mpl_toolkits.axes_grid1.inset_locator import mark_inset >>> ax2 = zoomed_inset_axes(ax, zoom=6, loc=9) >>> ax2.imshow(data, interpolation='nearest', origin='lower', ... cmap='Greys_r', vmin=190, vmax=220) >>> ax2.plot(x1, y1, color='red', marker=marker, ms=ms, mew=mew) >>> ax2.plot(x2, y2, color='blue', marker=marker, ms=ms, mew=mew) >>> ax2.plot(x3, y3, color='green', marker=marker, ms=ms, mew=mew) >>> ax2.set_xlim(13, 15) >>> ax2.set_ylim(16, 18) >>> mark_inset(ax, ax2, loc1=3, loc2=4, fc='none', ec='0.5') >>> ax2.axes.get_xaxis().set_visible(False) >>> ax2.axes.get_yaxis().set_visible(False) >>> ax.set_xlim(0, data.shape[1]-1) >>> ax.set_ylim(0, data.shape[0]-1) .. plot:: from photutils.datasets import make_4gaussians_image from photutils.morphology import (centroid_com, centroid_1dg, centroid_2dg) import matplotlib.pyplot as plt data = make_4gaussians_image()[43:79, 76:104] # extract single object x1, y1 = centroid_com(data) x2, y2 = centroid_1dg(data) x3, y3 = centroid_2dg(data) fig, ax = plt.subplots(1, 1) ax.imshow(data, origin='lower', cmap='Greys_r') marker = '+' ms, mew = 30, 2. plt.plot(x1, y1, color='red', marker=marker, ms=ms, mew=mew) plt.plot(x2, y2, color='blue', marker=marker, ms=ms, mew=mew) plt.plot(x3, y3, color='green', marker=marker, ms=ms, mew=mew) from mpl_toolkits.axes_grid1.inset_locator import zoomed_inset_axes from mpl_toolkits.axes_grid1.inset_locator import mark_inset ax2 = zoomed_inset_axes(ax, zoom=6, loc=9) ax2.imshow(data, interpolation='nearest', origin='lower', cmap='Greys_r', vmin=190, vmax=220) ax2.plot(x1, y1, color='red', marker=marker, ms=ms, mew=mew) ax2.plot(x2, y2, color='blue', marker=marker, ms=ms, mew=mew) ax2.plot(x3, y3, color='green', marker=marker, ms=ms, mew=mew) ax2.set_xlim(13, 15) ax2.set_ylim(16, 18) mark_inset(ax, ax2, loc1=3, loc2=4, fc='none', ec='0.5') ax2.axes.get_xaxis().set_visible(False) ax2.axes.get_yaxis().set_visible(False) ax.set_xlim(0, data.shape[1]-1) ax.set_ylim(0, data.shape[0]-1) Source Morphological Properties ------------------------------- The :func:`~photutils.morphology.data_properties` function can be used to calculate the properties of a single source from a cutout image. `~photutils.morphology.data_properties` returns a `~photutils.segmentation.SourceProperties` object. Please see `~photutils.segmentation.SourceProperties` for the list of the many properties that are calculated. Even more properties are likely to be added in the future. If you have a segmentation image, the :func:`~photutils.segmentation.source_properties` function can be used to calculate the properties for all (or a specified subset) of the segmented sources. Please see `Source Photometry and Properties from Image Segmentation `_ for more details. As an example, let's calculate the properties of the source defined above. For this example, we will subtract the background using simple sigma-clipped statistics: .. doctest-requires:: scipy, skimage >>> from astropy.stats import sigma_clipped_stats >>> from photutils.morphology import data_properties >>> from photutils import properties_table >>> mean, median, std = sigma_clipped_stats(data, sigma=3.0, iters=5) >>> data -= median # subtract background >>> props = data_properties(data) >>> columns = ['id', 'xcentroid', 'ycentroid', 'semimajor_axis_sigma', ... 'semiminor_axis_sigma', 'orientation'] >>> tbl = properties_table(props, columns=columns) >>> print(tbl) id xcentroid ycentroid ... semiminor_axis_sigma orientation pix pix ... pix rad --- ------------- ------------- ... -------------------- ------------- 1 14.0225090502 16.9901801466 ... 3.69777618702 1.04943689372 Now let's use the measured morphological properties to define an approximate isophotal ellipse for the source: .. doctest-skip:: >>> from photutils import properties_table, EllipticalAperture >>> position = (props.xcentroid.value, props.ycentroid.value) >>> r = 3.0 # approximate isophotal extent >>> a = props.semimajor_axis_sigma.value * r >>> b = props.semiminor_axis_sigma.value * r >>> theta = props.orientation.value >>> apertures = EllipticalAperture(position, a, b, theta=theta) >>> plt.imshow(data, origin='lower', cmap='Greys_r') >>> apertures.plot(color='red') .. plot:: from photutils.datasets import make_4gaussians_image from photutils.morphology import data_properties from photutils import properties_table, EllipticalAperture import matplotlib.pyplot as plt data = make_4gaussians_image()[43:79, 76:104] # extract single object props = data_properties(data) columns = ['id', 'xcentroid', 'ycentroid', 'semimajor_axis_sigma', 'semiminor_axis_sigma', 'orientation'] tbl = properties_table(props, columns=columns) r = 2.5 # approximate isophotal extent position = (props.xcentroid.value, props.ycentroid.value) a = props.semimajor_axis_sigma.value * r b = props.semiminor_axis_sigma.value * r theta = props.orientation.value apertures = EllipticalAperture(position, a, b, theta=theta) plt.imshow(data, origin='lower', cmap='Greys_r') apertures.plot(color='red') Reference/API ------------- .. automodapi:: photutils.morphology :no-heading: photutils-0.2.1/docs/photutils/overview.rst0000600000214200020070000000422112634600603023302 0ustar lbradleySTSCI\science00000000000000Overview ======== Introduction ------------ Photutils contains functions for: * estimating the background and background rms in astronomical images * detecting sources in astronomical images * estimating morphological parameters of those sources (e.g., centroid and shape parameters) * performing aperture and PSF photometry The code and the documentation are available at the following links: * Code: https://github.com/astropy/photutils * Issue Tracker: https://github.com/astropy/photutils/issues * Documentation: https://photutils.readthedocs.org/ .. _coordinate-conventions: Coordinate Conventions ---------------------- In Photutils, pixel coordinates are zero-indexed, meaning that ``(x, y) = (0, 0)`` corresponds to the center of the lowest, leftmost array element. This means that the value of ``data[0, 0]`` is taken as the value over the range ``-0.5 < x <= 0.5``, ``-0.5 < y <= 0.5``. Note that this differs from the SourceExtractor_, IRAF_, FITS, and ds9_ conventions, in which the center of the lowest, leftmost array element is ``(1, 1)``. The ``x`` (column) coordinate corresponds to the second (fast) array index and the ``y`` (row) coordinate corresponds to the first (slow) index. ``data[y, x]`` gives the value at coordinates (x, y). Along with zero-indexing, this means that an array is defined over the coordinate range ``-0.5 < x <= data.shape[1] - 0.5``, ``-0.5 < y <= data.shape[0] - 0.5``. .. _SourceExtractor: http://www.astromatic.net/software/sextractor .. _IRAF: http://iraf.noao.edu/ .. _ds9: http://ds9.si.edu/ Bundled Datasets ---------------- In this documentation, we use example `datasets `_ provided by calling functions such as :func:`~photutils.datasets.load_star_image`. This function returns an Astropy :class:`~astropy.io.fits.ImageHDU` object, and is equivalent to doing: .. doctest-skip:: >>> from astropy.io import fits >>> hdu = fits.open('dataset.fits')[0] where the ``[0]`` accesses the first HDU in the FITS file. Contributors ------------ For the complete list of contributors please see the `Photutils contributors page on Github `_. photutils-0.2.1/docs/photutils/psf.rst0000600000214200020070000000057212460257762022244 0ustar lbradleySTSCI\science00000000000000PSF Photometry ============== .. warning:: The PSF photometry API is currently *experimental* and may change in the future. For example, the functions currently accept `~numpy.ndarray` objects for the ``data`` parameters, but they may be changed to accept `astropy.nddata` objects. Reference/API ------------- .. automodapi:: photutils.psf :no-heading: photutils-0.2.1/docs/photutils/segmentation.rst0000600000214200020070000003701312640273732024144 0ustar lbradleySTSCI\science00000000000000Source Photometry and Properties from Image Segmentation ======================================================== Introduction ------------ After detecting sources using image segmentation (see :ref:`source_extraction`), we can measure their photometry, centroids, and morphological properties. The :class:`~photutils.segmentation.SegmentationImage` object also provides methods for modifying the segmentation image (e.g., combining labels, removing labels, removing border segments, etc.) prior to measuring photometry and other source properties. Getting Started --------------- The :func:`~photutils.segmentation.source_properties` function is the primary tool for measuring the photometry, centroids, and morphological properties of sources defined in a segmentation image. When the segmentation image is generated using image thresholding (e.g., using :func:`~photutils.detect_sources`), the source segments effectively represent the isophotal footprint of each source and the resulting photometry is effectively isophotal photometry. :func:`~photutils.segmentation.source_properties` returns a list of :class:`~photutils.segmentation.SourceProperties` objects, one for each segmented source (or a specified subset of sources). An Astropy `~astropy.table.Table` of source properties can be generated using the :func:`~photutils.segmentation.properties_table` function. Please see :class:`~photutils.segmentation.SourceProperties` for the list of the many properties that are calculated for each source. More properties are likely to be added in the future. Let's detect sources and measure their properties in a synthetic image. For this example, we will use the :class:`~photutils.background.Background` class to produce a background and background noise image. We define a 2D detection threshold image using the background and background rms maps. We set the threshold at 3 sigma above the background: .. doctest-requires:: scipy >>> from photutils.datasets import make_100gaussians_image >>> from photutils import Background, detect_threshold, detect_sources >>> from astropy.convolution import Gaussian2DKernel >>> data = make_100gaussians_image() >>> bkg = Background(data, (50, 50), filter_shape=(3, 3), method='median') >>> threshold = bkg.background + (3. * bkg.background_rms) Now we find sources that have 5 connected pixels that are each greater than the corresponding pixel-wise threshold image defined above. Because the threshold includes the background, we do not subtract the background from the data here. We also input a 2D circular Gaussian kernel with a FWHM of 2 pixels to filter the image prior to thresholding: .. doctest-requires:: scipy, skimage >>> from astropy.stats import gaussian_fwhm_to_sigma >>> sigma = 2.0 * gaussian_fwhm_to_sigma # FWHM = 2. >>> kernel = Gaussian2DKernel(sigma, x_size=3, y_size=3) >>> kernel.normalize() >>> segm = detect_sources(data, threshold, npixels=5, filter_kernel=kernel) The result is a :class:`~photutils.segmentation.SegmentationImage` where sources are labeled by different positive integer values. Now let's measure the properties of the detected sources defined in the segmentation image with the minimum number of inputs to :func:`~photutils.segmentation.source_properties`: .. doctest-requires:: scipy, skimage >>> from photutils import source_properties, properties_table >>> props = source_properties(data, segm) >>> tbl = properties_table(props) >>> print(tbl) id xcentroid ycentroid ... cxy cyy pix pix ... 1 / pix2 1 / pix2 --- ------------- ------------- ... ----------------- --------------- 1 235.187719359 1.09919615282 ... -0.192074627794 1.2174907202 2 494.139941114 5.77044246809 ... -0.541775595871 1.02440633651 3 207.375726658 10.0753101977 ... 0.77640832975 0.465060945444 4 364.689548633 10.8904591886 ... -0.547888762468 0.304081033554 5 258.192771992 11.9617673653 ... 0.0443061872873 0.321833380384 ... ... ... ... ... ... 82 74.4566900469 259.833303502 ... 0.47891309336 0.565732743194 83 82.5392499545 267.718933667 ... 0.067591261795 0.244881586651 84 477.674384997 267.891446048 ... -0.02140562548 0.391914760017 85 139.763784105 275.041398359 ... 0.232932536525 0.352391174432 86 434.040665678 285.607027036 ... -0.0607421731445 0.0555135557551 Length = 86 rows Let's use the measured source morphological properties to define approximate isophotal ellipses for each object: .. doctest-requires:: scipy, skimage >>> from photutils import source_properties, properties_table >>> props = source_properties(data, segm) >>> from photutils import EllipticalAperture >>> r = 3. # approximate isophotal extent >>> apertures = [] >>> for prop in props: ... position = (prop.xcentroid.value, prop.ycentroid.value) ... a = prop.semimajor_axis_sigma.value * r ... b = prop.semiminor_axis_sigma.value * r ... theta = prop.orientation.value ... apertures.append(EllipticalAperture(position, a, b, theta=theta)) Now let's plot the results: .. doctest-skip:: >>> import numpy as np >>> import matplotlib.pylab as plt >>> from astropy.visualization import SqrtStretch >>> from astropy.visualization.mpl_normalize import ImageNormalize >>> from photutils.utils import random_cmap >>> rand_cmap = random_cmap(segm.max + 1, random_state=12345) >>> norm = ImageNormalize(stretch=SqrtStretch()) >>> fig, (ax1, ax2) = plt.subplots(2, 1, figsize=(8, 8)) >>> ax1.imshow(data, origin='lower', cmap='Greys_r', norm=norm) >>> ax2.imshow(segm, origin='lower', cmap=rand_cmap) >>> for aperture in apertures: ... aperture.plot(color='blue', lw=1.5, alpha=0.5, ax=ax1) ... aperture.plot(color='white', lw=1.5, alpha=1.0, ax=ax2) .. plot:: import numpy as np import matplotlib.pylab as plt from astropy.stats import gaussian_fwhm_to_sigma from astropy.convolution import Gaussian2DKernel from astropy.visualization import SqrtStretch from astropy.visualization.mpl_normalize import ImageNormalize from photutils.datasets import make_100gaussians_image from photutils import Background, detect_threshold, detect_sources from photutils import source_properties, properties_table from photutils.utils import random_cmap from photutils import EllipticalAperture data = make_100gaussians_image() bkg = Background(data, (50, 50), filter_shape=(3, 3), method='median') threshold = bkg.background + (3. * bkg.background_rms) sigma = 2.0 * gaussian_fwhm_to_sigma # FWHM = 2. kernel = Gaussian2DKernel(sigma, x_size=3, y_size=3) kernel.normalize() segm = detect_sources(data, threshold, npixels=5, filter_kernel=kernel) rand_cmap = random_cmap(segm.max + 1, random_state=12345) props = source_properties(data, segm) apertures = [] for prop in props: position = (prop.xcentroid.value, prop.ycentroid.value) a = prop.semimajor_axis_sigma.value * 3. b = prop.semiminor_axis_sigma.value * 3. theta = prop.orientation.value apertures.append(EllipticalAperture(position, a, b, theta=theta)) norm = ImageNormalize(stretch=SqrtStretch()) fig, (ax1, ax2) = plt.subplots(2, 1, figsize=(8, 8)) ax1.imshow(data, origin='lower', cmap='Greys_r', norm=norm) ax2.imshow(segm, origin='lower', cmap=rand_cmap) for aperture in apertures: aperture.plot(color='blue', lw=1.5, alpha=0.5, ax=ax1) aperture.plot(color='white', lw=1.5, alpha=1.0, ax=ax2) We can also specify a specific subset of sources, defined by their labels in the segmentation image: .. doctest-requires:: scipy, skimage >>> labels = [1, 5, 20, 50, 75, 80] >>> props = source_properties(data, segm, labels=labels) >>> tbl = properties_table(props) >>> print(tbl) id xcentroid ycentroid ... cxy cyy pix pix ... 1 / pix2 1 / pix2 --- ------------- ------------- ... --------------- -------------- 1 235.187719359 1.09919615282 ... -0.192074627794 1.2174907202 5 258.192771992 11.9617673653 ... 0.0443061872873 0.321833380384 20 347.177561006 66.5509575226 ... 0.115277391421 0.359564354573 50 380.796873199 174.418513707 ... -1.03058291289 1.2769245589 75 32.176218827 241.158486946 ... 0.196860594008 0.601167034704 80 355.61483405 252.142253219 ... 0.178598051026 0.400332492208 By default, :func:`~photutils.segmentation.properties_table` will include all scalar-valued properties from :class:`~photutils.segmentation.SourceProperties`, but a subset of properties can also be specified (or excluded) in the `~astropy.table.Table`: .. doctest-requires:: scipy, skimage >>> labels = [1, 5, 20, 50, 75, 80] >>> props = source_properties(data, segm, labels=labels) >>> columns = ['id', 'xcentroid', 'ycentroid', 'source_sum', 'area'] >>> tbl = properties_table(props, columns=columns) >>> print(tbl) id xcentroid ycentroid source_sum area pix pix pix2 --- ------------- ------------- ------------- ---- 1 235.187719359 1.09919615282 496.635623206 27.0 5 258.192771992 11.9617673653 347.611342072 25.0 20 347.177561006 66.5509575226 415.992569678 31.0 50 380.796873199 174.418513707 145.726417518 11.0 75 32.176218827 241.158486946 398.411403711 29.0 80 355.61483405 252.142253219 906.422600037 45.0 A `~astropy.wcs.WCS` transformation can also be input to :func:`~photutils.segmentation.source_properties` via the ``wcs`` keyword, in which case the International Celestial Reference System (ICRS) Right Ascension and Declination coordinates at the source centroids will be returned. Background Properties ^^^^^^^^^^^^^^^^^^^^^ Like with :func:`~photutils.aperture_photometry`, the ``data`` array that is input to :func:`~photutils.segmentation.source_properties` should be background subtracted. If you input the ``background`` keyword to :func:`~photutils.segmentation.source_properties`, it will calculate background properties with each source segment: .. doctest-requires:: scipy, skimage >>> labels = [1, 5, 20, 50, 75, 80] >>> props = source_properties(data, segm, labels=labels, ... background=bkg.background) >>> columns = ['id', 'background_at_centroid', 'background_mean', ... 'background_sum'] >>> tbl = properties_table(props, columns=columns) >>> print(tbl) id background_at_centroid background_mean background_sum --- ---------------------- --------------- -------------- 1 5.20203264929 5.20212082569 140.457262294 5 5.21378104221 5.213780145 130.344503625 20 5.27885243993 5.27877182437 163.641926556 50 5.19865041002 5.1986157424 57.1847731664 75 5.21062790873 5.21060573569 151.107566335 80 5.12491678472 5.12502080804 230.625936362 Photometric Errors ^^^^^^^^^^^^^^^^^^ With :func:`~photutils.segmentation.source_properties` we can use the background-only error image and an effective gain to estimate the error in the photometry. Like the aperture photometry :ref:`error_estimation`, the :func:`~photutils.segmentation.source_properties` ``error`` keyword can either specify the total error array (i.e., it includes Poisson noise due to individual sources or such noise is irrelevant) or it can specify the background-only noise. In the later case, we can specify the ``effective_gain``, which is the ratio of counts (electrons or photons) to the units of the data, to explicitly include Poisson noise from the sources. The ``effective_gain`` can be a 2D gain image with the same shape as the ``data``. This is useful with mosaic images that have variable depths (i.e., exposure times) across the field. For example, one should use an exposure-time map as the ``effective_gain`` for a variable depth mosaic image in count-rate units. Let's assume our synthetic data is in units of electrons per second. In that case, the ``effective_gain`` should be the exposure time (here we set it to 500 seconds): .. doctest-requires:: scipy, skimage >>> labels = [1, 5, 20, 50, 75, 80] >>> props = source_properties(data, segm, labels=labels, ... error=bkg.background_rms, ... effective_gain=500.) >>> columns = ['id', 'xcentroid', 'ycentroid', 'source_sum', ... 'source_sum_err'] >>> tbl = properties_table(props, columns=columns) >>> print(tbl) id xcentroid ycentroid source_sum source_sum_err pix pix --- ------------- ------------- ------------- -------------- 1 235.187719359 1.09919615282 496.635623206 11.0788667038 5 258.192771992 11.9617673653 347.611342072 10.723068215 20 347.177561006 66.5509575226 415.992569678 12.1782078398 50 380.796873199 174.418513707 145.726417518 7.29536295106 75 32.176218827 241.158486946 398.411403711 11.553412812 80 355.61483405 252.142253219 906.422600037 13.7686828317 `~photutils.SourceProperties.source_sum` and `~photutils.SourceProperties.source_sum_err` are the instrumental flux and propagated flux error within the source segments. Pixel Masking ^^^^^^^^^^^^^ Pixels can be completely ignored/excluded when measuring the source properties by providing a boolean mask image via the ``mask`` keyword (`True` pixel values are masked). This is generally used to exclude bad pixels in the data. Filtering ^^^^^^^^^ `SExtractor`_'s centroid and morphological parameters are always calculated from a filtered "detection" image. The usual downside of the filtering is the sources will be made more circular than they actually are. If you wish to reproduce `SExtractor`_ results, then use the ``filter_kernel`` input to :func:`~photutils.segmentation.source_properties` to filter the ``data`` prior to centroid and morphological measurements. The kernel should be the same one used to define the source segments in :func:`~photutils.detect_sources`. If ``filter_kernel`` is `None`, then the centroid and morphological measurements will be performed on the unfiltered ``data``. Note that photometry is *always* performed on the unfiltered ``data``. Modifying Segmentation Images ----------------------------- The :class:`~photutils.segmentation.SegmentationImage` object provides several methods that can be used to modify itself prior to performing source photometry and measurements, including: * :meth:`~photutils.segmentation.SegmentationImage.relabel`: Relabel one or more label numbers. * :meth:`~photutils.segmentation.SegmentationImage.relabel_sequential`: Relable the label numbers sequentially. * :meth:`~photutils.segmentation.SegmentationImage.keep_labels`: Keep only certain label numbers. * :meth:`~photutils.segmentation.SegmentationImage.remove_labels`: Remove one or more label numbers. * :meth:`~photutils.segmentation.SegmentationImage.remove_border_labels`: Remove labeled segments near the image border. * :meth:`~photutils.segmentation.SegmentationImage.remove_masked_labels`: Remove labeled segments located within a masked region. * :meth:`~photutils.segmentation.SegmentationImage.outline_segments`: Outline the labeled segments for plotting. Reference/API ------------- .. automodapi:: photutils.segmentation :no-heading: .. _Sextractor: http://www.astromatic.net/software/sextractor photutils-0.2.1/docs/photutils/utils.rst0000600000214200020070000000033112444404542022575 0ustar lbradleySTSCI\science00000000000000Utility Functions ================= Introduction ------------ The `photutils.utils` package contains general-purpose utility functions. Reference/API ------------- .. automodapi:: photutils.utils :no-heading: photutils-0.2.1/docs/rtd-pip-requirements0000600000214200020070000000010312634600603022665 0ustar lbradleySTSCI\science00000000000000Cython numpy scipy matplotlib scikit-image astropy-helpers astropy photutils-0.2.1/ez_setup.py0000600000214200020070000002757312346164012020145 0ustar lbradleySTSCI\science00000000000000#!python """Bootstrap setuptools installation If you want to use setuptools in your package's setup.py, just include this file in the same directory with it, and add this to the top of your setup.py:: from ez_setup import use_setuptools use_setuptools() If you want to require a specific version of setuptools, set a download mirror, or use an alternate download directory, you can do so by supplying the appropriate options to ``use_setuptools()``. This file can also be run as a script to install or upgrade setuptools. """ import os import shutil import sys import tempfile import tarfile import optparse import subprocess import platform from distutils import log try: from site import USER_SITE except ImportError: USER_SITE = None DEFAULT_VERSION = "1.4.2" DEFAULT_URL = "https://pypi.python.org/packages/source/s/setuptools/" def _python_cmd(*args): args = (sys.executable,) + args return subprocess.call(args) == 0 def _check_call_py24(cmd, *args, **kwargs): res = subprocess.call(cmd, *args, **kwargs) class CalledProcessError(Exception): pass if not res == 0: msg = "Command '%s' return non-zero exit status %d" % (cmd, res) raise CalledProcessError(msg) vars(subprocess).setdefault('check_call', _check_call_py24) def _install(tarball, install_args=()): # extracting the tarball tmpdir = tempfile.mkdtemp() log.warn('Extracting in %s', tmpdir) old_wd = os.getcwd() try: os.chdir(tmpdir) tar = tarfile.open(tarball) _extractall(tar) tar.close() # going in the directory subdir = os.path.join(tmpdir, os.listdir(tmpdir)[0]) os.chdir(subdir) log.warn('Now working in %s', subdir) # installing log.warn('Installing Setuptools') if not _python_cmd('setup.py', 'install', *install_args): log.warn('Something went wrong during the installation.') log.warn('See the error message above.') # exitcode will be 2 return 2 finally: os.chdir(old_wd) shutil.rmtree(tmpdir) def _build_egg(egg, tarball, to_dir): # extracting the tarball tmpdir = tempfile.mkdtemp() log.warn('Extracting in %s', tmpdir) old_wd = os.getcwd() try: os.chdir(tmpdir) tar = tarfile.open(tarball) _extractall(tar) tar.close() # going in the directory subdir = os.path.join(tmpdir, os.listdir(tmpdir)[0]) os.chdir(subdir) log.warn('Now working in %s', subdir) # building an egg log.warn('Building a Setuptools egg in %s', to_dir) _python_cmd('setup.py', '-q', 'bdist_egg', '--dist-dir', to_dir) finally: os.chdir(old_wd) shutil.rmtree(tmpdir) # returning the result log.warn(egg) if not os.path.exists(egg): raise IOError('Could not build the egg.') def _do_download(version, download_base, to_dir, download_delay): egg = os.path.join(to_dir, 'setuptools-%s-py%d.%d.egg' % (version, sys.version_info[0], sys.version_info[1])) if not os.path.exists(egg): tarball = download_setuptools(version, download_base, to_dir, download_delay) _build_egg(egg, tarball, to_dir) sys.path.insert(0, egg) # Remove previously-imported pkg_resources if present (see # https://bitbucket.org/pypa/setuptools/pull-request/7/ for details). if 'pkg_resources' in sys.modules: del sys.modules['pkg_resources'] import setuptools setuptools.bootstrap_install_from = egg def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir, download_delay=15): # making sure we use the absolute path to_dir = os.path.abspath(to_dir) was_imported = 'pkg_resources' in sys.modules or \ 'setuptools' in sys.modules try: import pkg_resources except ImportError: return _do_download(version, download_base, to_dir, download_delay) try: pkg_resources.require("setuptools>=" + version) return except pkg_resources.VersionConflict: e = sys.exc_info()[1] if was_imported: sys.stderr.write( "The required version of setuptools (>=%s) is not available,\n" "and can't be installed while this script is running. Please\n" "install a more recent version first, using\n" "'easy_install -U setuptools'." "\n\n(Currently using %r)\n" % (version, e.args[0])) sys.exit(2) else: del pkg_resources, sys.modules['pkg_resources'] # reload ok return _do_download(version, download_base, to_dir, download_delay) except pkg_resources.DistributionNotFound: return _do_download(version, download_base, to_dir, download_delay) def _clean_check(cmd, target): """ Run the command to download target. If the command fails, clean up before re-raising the error. """ try: subprocess.check_call(cmd) except subprocess.CalledProcessError: if os.access(target, os.F_OK): os.unlink(target) raise def download_file_powershell(url, target): """ Download the file at url to target using Powershell (which will validate trust). Raise an exception if the command cannot complete. """ target = os.path.abspath(target) cmd = [ 'powershell', '-Command', "(new-object System.Net.WebClient).DownloadFile(%(url)r, %(target)r)" % vars(), ] _clean_check(cmd, target) def has_powershell(): if platform.system() != 'Windows': return False cmd = ['powershell', '-Command', 'echo test'] devnull = open(os.path.devnull, 'wb') try: try: subprocess.check_call(cmd, stdout=devnull, stderr=devnull) except: return False finally: devnull.close() return True download_file_powershell.viable = has_powershell def download_file_curl(url, target): cmd = ['curl', url, '--silent', '--output', target] _clean_check(cmd, target) def has_curl(): cmd = ['curl', '--version'] devnull = open(os.path.devnull, 'wb') try: try: subprocess.check_call(cmd, stdout=devnull, stderr=devnull) except: return False finally: devnull.close() return True download_file_curl.viable = has_curl def download_file_wget(url, target): cmd = ['wget', url, '--quiet', '--output-document', target] _clean_check(cmd, target) def has_wget(): cmd = ['wget', '--version'] devnull = open(os.path.devnull, 'wb') try: try: subprocess.check_call(cmd, stdout=devnull, stderr=devnull) except: return False finally: devnull.close() return True download_file_wget.viable = has_wget def download_file_insecure(url, target): """ Use Python to download the file, even though it cannot authenticate the connection. """ try: from urllib.request import urlopen except ImportError: from urllib2 import urlopen src = dst = None try: src = urlopen(url) # Read/write all in one block, so we don't create a corrupt file # if the download is interrupted. data = src.read() dst = open(target, "wb") dst.write(data) finally: if src: src.close() if dst: dst.close() download_file_insecure.viable = lambda: True def get_best_downloader(): downloaders = [ download_file_powershell, download_file_curl, download_file_wget, download_file_insecure, ] for dl in downloaders: if dl.viable(): return dl def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir, delay=15, downloader_factory=get_best_downloader): """Download setuptools from a specified location and return its filename `version` should be a valid setuptools version number that is available as an egg for download under the `download_base` URL (which should end with a '/'). `to_dir` is the directory where the egg will be downloaded. `delay` is the number of seconds to pause before an actual download attempt. ``downloader_factory`` should be a function taking no arguments and returning a function for downloading a URL to a target. """ # making sure we use the absolute path to_dir = os.path.abspath(to_dir) tgz_name = "setuptools-%s.tar.gz" % version url = download_base + tgz_name saveto = os.path.join(to_dir, tgz_name) if not os.path.exists(saveto): # Avoid repeated downloads log.warn("Downloading %s", url) downloader = downloader_factory() downloader(url, saveto) return os.path.realpath(saveto) def _extractall(self, path=".", members=None): """Extract all members from the archive to the current working directory and set owner, modification time and permissions on directories afterwards. `path' specifies a different directory to extract to. `members' is optional and must be a subset of the list returned by getmembers(). """ import copy import operator from tarfile import ExtractError directories = [] if members is None: members = self for tarinfo in members: if tarinfo.isdir(): # Extract directories with a safe mode. directories.append(tarinfo) tarinfo = copy.copy(tarinfo) tarinfo.mode = 448 # decimal for oct 0700 self.extract(tarinfo, path) # Reverse sort directories. if sys.version_info < (2, 4): def sorter(dir1, dir2): return cmp(dir1.name, dir2.name) directories.sort(sorter) directories.reverse() else: directories.sort(key=operator.attrgetter('name'), reverse=True) # Set correct owner, mtime and filemode on directories. for tarinfo in directories: dirpath = os.path.join(path, tarinfo.name) try: self.chown(tarinfo, dirpath) self.utime(tarinfo, dirpath) self.chmod(tarinfo, dirpath) except ExtractError: e = sys.exc_info()[1] if self.errorlevel > 1: raise else: self._dbg(1, "tarfile: %s" % e) def _build_install_args(options): """ Build the arguments to 'python setup.py install' on the setuptools package """ install_args = [] if options.user_install: if sys.version_info < (2, 6): log.warn("--user requires Python 2.6 or later") raise SystemExit(1) install_args.append('--user') return install_args def _parse_args(): """ Parse the command line for options """ parser = optparse.OptionParser() parser.add_option( '--user', dest='user_install', action='store_true', default=False, help='install in user site package (requires Python 2.6 or later)') parser.add_option( '--download-base', dest='download_base', metavar="URL", default=DEFAULT_URL, help='alternative URL from where to download the setuptools package') parser.add_option( '--insecure', dest='downloader_factory', action='store_const', const=lambda: download_file_insecure, default=get_best_downloader, help='Use internal, non-validating downloader' ) options, args = parser.parse_args() # positional arguments are ignored return options def main(version=DEFAULT_VERSION): """Install or upgrade setuptools and EasyInstall""" options = _parse_args() tarball = download_setuptools(download_base=options.download_base, downloader_factory=options.downloader_factory) return _install(tarball, _build_install_args(options)) if __name__ == '__main__': sys.exit(main()) photutils-0.2.1/licenses/0000700000214200020070000000000012646264032017530 5ustar lbradleySTSCI\science00000000000000photutils-0.2.1/licenses/LICENSE.rst0000600000214200020070000000272712345377273021366 0ustar lbradleySTSCI\science00000000000000Copyright (c) 2011-14, photutils developers All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the Astropy Team nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. photutils-0.2.1/licenses/README.rst0000600000214200020070000000024212345377273021227 0ustar lbradleySTSCI\science00000000000000Licenses ======== This directory holds license and credit information for the affiliated package, works the affiliated package is derived from, and/or datasets. photutils-0.2.1/LONG_DESCRIPTION.rst0000600000214200020070000000061012641304352021051 0ustar lbradleySTSCI\science00000000000000 * Code: https://github.com/astropy/photutils * Docs: https://photutils.readthedocs.org/ **Photutils** is an in-development `affiliated package `_ of `Astropy `_ to provide tools for detecting and performing photometry of astronomical sources. It is an open source (BSD licensed) Python package. Contributions welcome! photutils-0.2.1/photutils/0000700000214200020070000000000012646264032017756 5ustar lbradleySTSCI\science00000000000000photutils-0.2.1/photutils/__init__.py0000600000214200020070000000115212646263146022075 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst """ An Astropy affiliated package for photometry. """ # Affiliated packages may add whatever they like to this file, but # should keep this content at the top. # ---------------------------------------------------------------------------- from ._astropy_init import * # ---------------------------------------------------------------------------- if not _ASTROPY_SETUP_: from .aperture_core import * from .aperture_funcs import * from .background import * from .detection import * from .segmentation import * from .psf import * photutils-0.2.1/photutils/_astropy_init.py0000600000214200020070000001223112641262473023216 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst __all__ = ['__version__', '__githash__', 'test'] # this indicates whether or not we are in the package's setup.py try: _ASTROPY_SETUP_ except NameError: from sys import version_info if version_info[0] >= 3: import builtins else: import __builtin__ as builtins builtins._ASTROPY_SETUP_ = False try: from .version import version as __version__ except ImportError: __version__ = '' try: from .version import githash as __githash__ except ImportError: __githash__ = '' # set up the test command def _get_test_runner(): import os from astropy.tests.helper import TestRunner return TestRunner(os.path.dirname(__file__)) def test(package=None, test_path=None, args=None, plugins=None, verbose=False, pastebin=None, remote_data=False, pep8=False, pdb=False, coverage=False, open_files=False, **kwargs): """ Run the tests using `py.test `__. A proper set of arguments is constructed and passed to `pytest.main`_. .. _py.test: http://pytest.org/latest/ .. _pytest.main: http://pytest.org/latest/builtin.html#pytest.main Parameters ---------- package : str, optional The name of a specific package to test, e.g. 'io.fits' or 'utils'. If nothing is specified all default tests are run. test_path : str, optional Specify location to test by path. May be a single file or directory. Must be specified absolutely or relative to the calling directory. args : str, optional Additional arguments to be passed to pytest.main_ in the ``args`` keyword argument. plugins : list, optional Plugins to be passed to pytest.main_ in the ``plugins`` keyword argument. verbose : bool, optional Convenience option to turn on verbose output from py.test_. Passing True is the same as specifying ``'-v'`` in ``args``. pastebin : {'failed','all',None}, optional Convenience option for turning on py.test_ pastebin output. Set to ``'failed'`` to upload info for failed tests, or ``'all'`` to upload info for all tests. remote_data : bool, optional Controls whether to run tests marked with @remote_data. These tests use online data and are not run by default. Set to True to run these tests. pep8 : bool, optional Turn on PEP8 checking via the `pytest-pep8 plugin `_ and disable normal tests. Same as specifying ``'--pep8 -k pep8'`` in ``args``. pdb : bool, optional Turn on PDB post-mortem analysis for failing tests. Same as specifying ``'--pdb'`` in ``args``. coverage : bool, optional Generate a test coverage report. The result will be placed in the directory htmlcov. open_files : bool, optional Fail when any tests leave files open. Off by default, because this adds extra run time to the test suite. Requires the `psutil `_ package. parallel : int, optional When provided, run the tests in parallel on the specified number of CPUs. If parallel is negative, it will use the all the cores on the machine. Requires the `pytest-xdist `_ plugin installed. Only available when using Astropy 0.3 or later. kwargs Any additional keywords passed into this function will be passed on to the astropy test runner. This allows use of test-related functionality implemented in later versions of astropy without explicitly updating the package template. """ test_runner = _get_test_runner() return test_runner.run_tests( package=package, test_path=test_path, args=args, plugins=plugins, verbose=verbose, pastebin=pastebin, remote_data=remote_data, pep8=pep8, pdb=pdb, coverage=coverage, open_files=open_files, **kwargs) if not _ASTROPY_SETUP_: import os from warnings import warn from astropy import config # add these here so we only need to cleanup the namespace at the end config_dir = None if not os.environ.get('ASTROPY_SKIP_CONFIG_UPDATE', False): config_dir = os.path.dirname(__file__) config_template = os.path.join(config_dir, __package__ + ".cfg") if os.path.isfile(config_template): try: config.configuration.update_default_config( __package__, config_dir, version=__version__) except TypeError as orig_error: try: config.configuration.update_default_config( __package__, config_dir) except config.configuration.ConfigurationDefaultMissingError as e: wmsg = (e.args[0] + " Cannot install default profile. If you are " "importing from source, this is expected.") warn(config.configuration.ConfigurationDefaultMissingWarning(wmsg)) del e except: raise orig_error photutils-0.2.1/photutils/_compiler.c0000600000214200020070000000573112477406127022110 0ustar lbradleySTSCI\science00000000000000#include /*************************************************************************** * Macros for determining the compiler version. * * These are borrowed from boost, and majorly abridged to include only * the compilers we care about. ***************************************************************************/ #ifndef PY3K #if PY_MAJOR_VERSION >= 3 #define PY3K 1 #else #define PY3K 0 #endif #endif #define STRINGIZE(X) DO_STRINGIZE(X) #define DO_STRINGIZE(X) #X #if defined __clang__ /* Clang C++ emulates GCC, so it has to appear early. */ # define COMPILER "Clang version " __clang_version__ #elif defined(__INTEL_COMPILER) || defined(__ICL) || defined(__ICC) || defined(__ECC) /* Intel */ # if defined(__INTEL_COMPILER) # define INTEL_VERSION __INTEL_COMPILER # elif defined(__ICL) # define INTEL_VERSION __ICL # elif defined(__ICC) # define INTEL_VERSION __ICC # elif defined(__ECC) # define INTEL_VERSION __ECC # endif # define COMPILER "Intel C compiler version " STRINGIZE(INTEL_VERSION) #elif defined(__GNUC__) /* gcc */ # define COMPILER "GCC version " __VERSION__ #elif defined(__SUNPRO_CC) /* Sun Workshop Compiler */ # define COMPILER "Sun compiler version " STRINGIZE(__SUNPRO_CC) #elif defined(_MSC_VER) /* Microsoft Visual C/C++ Must be last since other compilers define _MSC_VER for compatibility as well */ # if _MSC_VER < 1200 # define COMPILER_VERSION 5.0 # elif _MSC_VER < 1300 # define COMPILER_VERSION 6.0 # elif _MSC_VER == 1300 # define COMPILER_VERSION 7.0 # elif _MSC_VER == 1310 # define COMPILER_VERSION 7.1 # elif _MSC_VER == 1400 # define COMPILER_VERSION 8.0 # elif _MSC_VER == 1500 # define COMPILER_VERSION 9.0 # elif _MSC_VER == 1600 # define COMPILER_VERSION 10.0 # else # define COMPILER_VERSION _MSC_VER # endif # define COMPILER "Microsoft Visual C++ version " STRINGIZE(COMPILER_VERSION) #else /* Fallback */ # define COMPILER "Unknown compiler" #endif /*************************************************************************** * Module-level ***************************************************************************/ struct module_state { /* The Sun compiler can't handle empty structs */ #if defined(__SUNPRO_C) || defined(_MSC_VER) int _dummy; #endif }; #if PY3K static struct PyModuleDef moduledef = { PyModuleDef_HEAD_INIT, "_compiler", NULL, sizeof(struct module_state), NULL, NULL, NULL, NULL, NULL }; #define INITERROR return NULL PyMODINIT_FUNC PyInit__compiler(void) #else #define INITERROR return PyMODINIT_FUNC init_compiler(void) #endif { PyObject* m; #if PY3K m = PyModule_Create(&moduledef); #else m = Py_InitModule3("_compiler", NULL, NULL); #endif if (m == NULL) INITERROR; PyModule_AddStringConstant(m, "compiler", COMPILER); #if PY3K return m; #endif } photutils-0.2.1/photutils/aperture_core.py0000600000214200020070000015256312646242520023203 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst """Functions for performing aperture photometry on 2-D arrays.""" from __future__ import (absolute_import, division, print_function, unicode_literals) import math import abc import numpy as np import copy import warnings import astropy.units as u from astropy.io import fits from astropy.table import Table from astropy.wcs import WCS from astropy.coordinates import SkyCoord from astropy.extern import six from astropy.utils.misc import InheritDocstrings from astropy.utils.exceptions import AstropyUserWarning from astropy.wcs.utils import skycoord_to_pixel from astropy.nddata import support_nddata from .aperture_funcs import (do_circular_photometry, do_elliptical_photometry, do_rectangular_photometry) from .utils.wcs_helpers import (skycoord_to_pixel_scale_angle, assert_angle, assert_angle_or_pixel) skycoord_to_pixel_mode = 'all' __all__ = ['Aperture', 'SkyAperture', 'PixelAperture', 'SkyCircularAperture', 'CircularAperture', 'SkyCircularAnnulus', 'CircularAnnulus', 'SkyEllipticalAperture', 'EllipticalAperture', 'SkyEllipticalAnnulus', 'EllipticalAnnulus', 'RectangularAperture', 'RectangularAnnulus', 'SkyRectangularAperture', 'SkyRectangularAnnulus', 'aperture_photometry'] def _sanitize_pixel_positions(positions): if isinstance(positions, u.Quantity): if positions.unit is u.pixel: positions = np.atleast_2d(positions.value) else: raise u.UnitsError("positions should be in pixel units") elif isinstance(positions, (list, tuple, np.ndarray)): positions = np.atleast_2d(positions) if positions.shape[1] != 2: if positions.shape[0] == 2: positions = np.transpose(positions) else: raise TypeError("List or array of (x, y) pixel coordinates " "is expected got '{0}'.".format(positions)) elif isinstance(positions, zip): # This is needed for zip to work seamlessly in Python 3 positions = np.atleast_2d(list(positions)) else: raise TypeError("List or array of (x, y) pixel coordinates " "is expected got '{0}'.".format(positions)) if positions.ndim > 2: raise ValueError('{0}-d position array not supported. Only 2-d ' 'arrays supported.'.format(positions.ndim)) return positions def _make_annulus_path(patch_inner, patch_outer): import matplotlib.path as mpath verts_inner = patch_inner.get_verts() verts_outer = patch_outer.get_verts() codes_inner = (np.ones(len(verts_inner), dtype=mpath.Path.code_type) * mpath.Path.LINETO) codes_inner[0] = mpath.Path.MOVETO codes_outer = (np.ones(len(verts_outer), dtype=mpath.Path.code_type) * mpath.Path.LINETO) codes_outer[0] = mpath.Path.MOVETO codes = np.concatenate((codes_inner, codes_outer)) verts = np.concatenate((verts_inner, verts_outer[::-1])) return mpath.Path(verts, codes) class _ABCMetaAndInheritDocstrings(InheritDocstrings, abc.ABCMeta): pass @six.add_metaclass(_ABCMetaAndInheritDocstrings) class Aperture(object): """ Abstract base class for all apertures. """ class SkyAperture(Aperture): """ Abstract base class for 2-d apertures defined in celestial coordinates. """ class PixelAperture(Aperture): """ Abstract base class for 2-d apertures defined in pixel coordinates. Derived classes should contain whatever internal data is needed to define the aperture, and provide the method `do_photometry` (and optionally, ``area``). """ @abc.abstractmethod def plot(self, ax=None, fill=False, **kwargs): """ Plot the aperture(s) on a matplotlib Axes instance. Parameters ---------- ax : `matplotlib.axes.Axes` instance, optional If `None`, then the current ``Axes`` instance is used. fill : bool, optional Set whether to fill the aperture patch. The default is `False`. kwargs Any keyword arguments accepted by `matplotlib.patches.Patch`. """ @abc.abstractmethod def do_photometry(self, data, error=None, effective_gain=None, pixelwise_error=True, method='exact', subpixels=5): """Sum flux within aperture(s). Parameters ---------- data : array_like The 2-d array on which to perform photometry. error : array_like, optional Error in each pixel, interpreted as Gaussian 1-sigma uncertainty. ``error`` has to have the same shape as ``data``. effective_gain : array_like, optional Ratio of counts (e.g., electrons or photons) to units of the data (e.g., ADU), for the purpose of calculating Poisson error from the object itself. ``effective_gain`` must have the same shape as ``data``. pixelwise_error : bool, optional For ``error`` and/or ``effective_gain`` arrays. If `True`, assume ``error`` and/or ``effective_gain`` vary significantly within an aperture: sum contribution from each pixel. If `False`, assume ``error`` and ``effective_gain`` do not vary significantly within an aperture. method : str, optional Method to use for determining overlap between the aperture and pixels. Options include ['center', 'subpixel', 'exact'], but not all options are available for all types of apertures. More precise methods will generally be slower. * ``'center'`` A pixel is considered to be entirely in or out of the aperture depending on whether its center is in or out of the aperture. * ``'subpixel'`` A pixel is divided into subpixels and the center of each subpixel is tested (as above). With ``subpixels`` set to 1, this method is equivalent to 'center'. Note that for subpixel sampling, the input array is only resampled once for each object. * ``'exact'`` (default) The exact overlap between the aperture and each pixel is calculated. subpixels : int, optional For the ``'subpixel'`` method, resample pixels by this factor (in each dimension). That is, each pixel is divided into ``subpixels ** 2`` subpixels. Returns ------- flux : `~astropy.units.Quantity` Sum of the values withint the aperture(s). Unit is kept to be the unit of the input ``data``. fluxvar : `~astropy.units.Quantity` Corresponting uncertainity in the ``flux`` values. Returned only if input ``error`` is not `None`. """ @abc.abstractmethod def area(self): """ Area of aperture. Returns ------- area : float Area of aperture. """ class SkyCircularAperture(SkyAperture): """ Circular aperture(s), defined in sky coordinates. Parameters ---------- positions : `~astropy.coordinates.SkyCoord` Celestial coordinates of the aperture center(s). This can be either scalar coordinates or an array of coordinates. r : `~astropy.units.Quantity` The radius of the aperture(s), either in angular or pixel units. """ def __init__(self, positions, r): if isinstance(positions, SkyCoord): self.positions = positions else: raise TypeError("positions should be a SkyCoord instance") assert_angle_or_pixel('r', r) self.r = r def to_pixel(self, wcs): """ Return a CircularAperture instance in pixel coordinates. """ x, y = skycoord_to_pixel(self.positions, wcs, mode=skycoord_to_pixel_mode) if self.r.unit.physical_type == 'angle': central_pos = SkyCoord([wcs.wcs.crval], frame=self.positions.name, unit=wcs.wcs.cunit) xc, yc, scale, angle = skycoord_to_pixel_scale_angle(central_pos, wcs) r = (scale * self.r).to(u.pixel).value else: # pixel r = self.r.value pixel_positions = np.array([x, y]).transpose() return CircularAperture(pixel_positions, r) class CircularAperture(PixelAperture): """ Circular aperture(s), defined in pixel coordinates. Parameters ---------- positions : tuple, list, array, or `~astropy.units.Quantity` Pixel coordinates of the aperture center(s), either as a single ``(x, y)`` tuple, a list of ``(x, y)`` tuples, an ``Nx2`` or ``2xN`` `~numpy.ndarray`, or an ``Nx2`` or ``2xN`` `~astropy.units.Quantity` in units of pixels. A ``2x2`` `~numpy.ndarray` or `~astropy.units.Quantity` is interpreted as ``Nx2``, i.e. two rows of (x, y) coordinates. r : float The radius of the aperture(s), in pixels. Raises ------ ValueError : `~.exceptions.ValueError` If the radius is negative. """ def __init__(self, positions, r): try: self.r = float(r) except TypeError: raise TypeError('r must be numeric, received {0}'.format(type(r))) if r < 0: raise ValueError('r must be non-negative') self.positions = _sanitize_pixel_positions(positions) def area(self): return math.pi * self.r ** 2 def plot(self, ax=None, fill=False, source_id=None, **kwargs): import matplotlib.pyplot as plt import matplotlib.patches as mpatches kwargs['fill'] = fill if ax is None: ax = plt.gca() if source_id is None: positions = self.positions else: positions = self.positions[np.atleast_1d(source_id)] for position in positions: patch = mpatches.Circle(position, self.r, **kwargs) ax.add_patch(patch) def do_photometry(self, data, error=None, effective_gain=None, pixelwise_error=True, method='exact', subpixels=5): if method not in ('center', 'subpixel', 'exact'): raise ValueError('{0} method not supported for aperture class ' '{1}'.format(method, self.__class__.__name__)) flux = do_circular_photometry(data, self.positions, self.r, error=error, effective_gain=effective_gain, pixelwise_error=pixelwise_error, method=method, subpixels=subpixels) return flux class SkyCircularAnnulus(SkyAperture): """ Circular annulus aperture(s), defined in sky coordinates. Parameters ---------- positions : `~astropy.coordinates.SkyCoord` Celestial coordinates of the aperture center(s). This can be either scalar coordinates or an array of coordinates. r_in : `~astropy.units.Quantity` The inner radius of the annulus, either in angular or pixel units. r_out : `~astropy.units.Quantity` The outer radius of the annulus, either in angular or pixel units. """ def __init__(self, positions, r_in, r_out): if isinstance(positions, SkyCoord): self.positions = positions else: raise TypeError("positions should be a SkyCoord instance") assert_angle_or_pixel('r_in', r_in) assert_angle_or_pixel('r_out', r_out) if r_in.unit.physical_type != r_out.unit.physical_type: raise ValueError("r_in and r_out should either both be angles " "or in pixels") self.r_in = r_in self.r_out = r_out def to_pixel(self, wcs): """ Return a CircularAnnulus instance in pixel coordinates. """ x, y = skycoord_to_pixel(self.positions, wcs, mode=skycoord_to_pixel_mode) if self.r_in.unit.physical_type == 'angle': central_pos = SkyCoord([wcs.wcs.crval], frame=self.positions.name, unit=wcs.wcs.cunit) xc, yc, scale, angle = skycoord_to_pixel_scale_angle(central_pos, wcs) r_in = (scale * self.r_in).to(u.pixel).value r_out = (scale * self.r_out).to(u.pixel).value else: # pixel r_in = self.r_in.value r_out = self.r_out.value pixel_positions = np.array([x, y]).transpose() return CircularAnnulus(pixel_positions, r_in, r_out) class CircularAnnulus(PixelAperture): """ Circular annulus aperture(s), defined in pixel coordinates. Parameters ---------- positions : tuple, list, array, or `~astropy.units.Quantity` Pixel coordinates of the aperture center(s), either as a single ``(x, y)`` tuple, a list of ``(x, y)`` tuples, an ``Nx2`` or ``2xN`` `~numpy.ndarray`, or an ``Nx2`` or ``2xN`` `~astropy.units.Quantity` in units of pixels. A ``2x2`` `~numpy.ndarray` or `~astropy.units.Quantity` is interpreted as ``Nx2``, i.e. two rows of (x, y) coordinates. r_in : float The inner radius of the annulus. r_out : float The outer radius of the annulus. Raises ------ ValueError : `~.exceptions.ValueError` If inner radius (``r_in``) is greater than outer radius (``r_out``). ValueError : `~.exceptions.ValueError` If inner radius is negative. """ def __init__(self, positions, r_in, r_out): try: self.r_in = r_in self.r_out = r_out except TypeError: raise TypeError("'r_in' and 'r_out' must be numeric, received {0} " "and {1}".format((type(r_in), type(r_out)))) if not (r_out > r_in): raise ValueError('r_out must be greater than r_in') if r_in < 0: raise ValueError('r_in must be non-negative') self.positions = _sanitize_pixel_positions(positions) def area(self): return math.pi * (self.r_out ** 2 - self.r_in ** 2) def do_photometry(self, data, error=None, effective_gain=None, pixelwise_error=True, method='exact', subpixels=5): if method not in ('center', 'subpixel', 'exact'): raise ValueError('{0} method not supported for aperture class ' '{1}'.format(method, self.__class__.__name__)) flux = do_circular_photometry(data, self.positions, self.r_out, error=error, effective_gain=effective_gain, pixelwise_error=pixelwise_error, method=method, subpixels=subpixels, r_in=self.r_in) return flux def plot(self, ax=None, fill=False, source_id=None, **kwargs): import matplotlib.pyplot as plt import matplotlib.patches as mpatches kwargs['fill'] = fill if ax is None: ax = plt.gca() if source_id is None: positions = self.positions else: positions = self.positions[np.atleast_1d(source_id)] resolution = 20 for position in positions: patch_inner = mpatches.CirclePolygon(position, self.r_in, resolution=resolution) patch_outer = mpatches.CirclePolygon(position, self.r_out, resolution=resolution) path = _make_annulus_path(patch_inner, patch_outer) patch = mpatches.PathPatch(path, **kwargs) ax.add_patch(patch) class SkyEllipticalAperture(SkyAperture): """ Elliptical aperture(s), defined in sky coordinates. Parameters ---------- positions : `~astropy.coordinates.SkyCoord` Celestial coordinates of the aperture center(s). This can be either scalar coordinates or an array of coordinates. a : `~astropy.units.Quantity` The semimajor axis, either in angular or pixel units. b : `~astropy.units.Quantity` The semiminor axis, either in angular or pixel units. theta : `~astropy.units.Quantity` The position angle of the semimajor axis (counterclockwise), either in angular or pixel units. """ def __init__(self, positions, a, b, theta): if isinstance(positions, SkyCoord): self.positions = positions else: raise TypeError("positions should be a SkyCoord instance") assert_angle_or_pixel('a', a) assert_angle_or_pixel('b', b) assert_angle('theta', theta) if a.unit.physical_type != b.unit.physical_type: raise ValueError("a and b should either both be angles " "or in pixels") self.a = a self.b = b self.theta = theta def to_pixel(self, wcs): """ Return a EllipticalAperture instance in pixel coordinates. """ x, y = skycoord_to_pixel(self.positions, wcs, mode=skycoord_to_pixel_mode) central_pos = SkyCoord([wcs.wcs.crval], frame=self.positions.name, unit=wcs.wcs.cunit) xc, yc, scale, angle = skycoord_to_pixel_scale_angle(central_pos, wcs) if self.a.unit.physical_type == 'angle': a = (scale * self.a).to(u.pixel).value b = (scale * self.b).to(u.pixel).value else: # pixel a = self.a.value b = self.b.value theta = (angle + self.theta).to(u.radian).value pixel_positions = np.array([x, y]).transpose() return EllipticalAperture(pixel_positions, a, b, theta) class EllipticalAperture(PixelAperture): """ Elliptical aperture(s), defined in pixel coordinates. Parameters ---------- positions : tuple, list, array, or `~astropy.units.Quantity` Pixel coordinates of the aperture center(s), either as a single ``(x, y)`` tuple, a list of ``(x, y)`` tuples, an ``Nx2`` or ``2xN`` `~numpy.ndarray`, or an ``Nx2`` or ``2xN`` `~astropy.units.Quantity` in units of pixels. A ``2x2`` `~numpy.ndarray` or `~astropy.units.Quantity` is interpreted as ``Nx2``, i.e. two rows of (x, y) coordinates. a : float The semimajor axis. b : float The semiminor axis. theta : float The position angle of the semimajor axis in radians (counterclockwise). Raises ------ ValueError : `~.exceptions.ValueError` If either axis (``a`` or ``b``) is negative. """ def __init__(self, positions, a, b, theta): try: self.a = float(a) self.b = float(b) self.theta = float(theta) except TypeError: raise TypeError("'a' and 'b' and 'theta' must be numeric, received" "{0} and {1} and {2}." .format((type(a), type(b), type(theta)))) if a < 0 or b < 0: raise ValueError("'a' and 'b' must be non-negative.") self.positions = _sanitize_pixel_positions(positions) def area(self): return math.pi * self.a * self.b def do_photometry(self, data, error=None, effective_gain=None, pixelwise_error=True, method='exact', subpixels=5): if method not in ('center', 'subpixel', 'exact'): raise ValueError('{0} method not supported for aperture class ' '{1}'.format(method, self.__class__.__name__)) flux = do_elliptical_photometry(data, self.positions, self.a, self.b, self.theta, error=error, effective_gain=effective_gain, pixelwise_error=pixelwise_error, method=method, subpixels=subpixels) return flux def plot(self, ax=None, fill=False, source_id=None, **kwargs): import matplotlib.pyplot as plt import matplotlib.patches as mpatches kwargs['fill'] = fill if ax is None: ax = plt.gca() if source_id is None: positions = self.positions else: positions = self.positions[np.atleast_1d(source_id)] theta_deg = self.theta * 180. / np.pi for position in positions: patch = mpatches.Ellipse(position, 2.*self.a, 2.*self.b, theta_deg, **kwargs) ax.add_patch(patch) class SkyEllipticalAnnulus(SkyAperture): """ Elliptical annulus aperture(s), defined in sky coordinates. Parameters ---------- positions : `~astropy.coordinates.SkyCoord` Celestial coordinates of the aperture center(s). This can be either scalar coordinates or an array of coordinates. a_in : `~astropy.units.Quantity` The inner semimajor axis, either in angular or pixel units. a_out : `~astropy.units.Quantity` The outer semimajor axis, either in angular or pixel units. b_out : `~astropy.units.Quantity` The outer semiminor axis, either in angular or pixel units. The inner semiminor axis is determined by scaling by a_in/a_out. theta : `~astropy.units.Quantity` The position angle of the semimajor axis (counterclockwise), either in angular or pixel units. """ def __init__(self, positions, a_in, a_out, b_out, theta): if isinstance(positions, SkyCoord): self.positions = positions else: raise TypeError("positions should be a SkyCoord instance") assert_angle_or_pixel('a_in', a_in) assert_angle_or_pixel('a_out', a_out) assert_angle_or_pixel('b_out', b_out) assert_angle('theta', theta) if a_in.unit.physical_type != a_out.unit.physical_type: raise ValueError("a_in and a_out should either both be angles " "or in pixels") if a_out.unit.physical_type != b_out.unit.physical_type: raise ValueError("a_out and b_out should either both be angles " "or in pixels") self.a_in = a_in self.a_out = a_out self.b_out = b_out self.theta = theta def to_pixel(self, wcs): """ Return a EllipticalAnnulus instance in pixel coordinates. """ x, y = skycoord_to_pixel(self.positions, wcs, mode=skycoord_to_pixel_mode) central_pos = SkyCoord([wcs.wcs.crval], frame=self.positions.name, unit=wcs.wcs.cunit) xc, yc, scale, angle = skycoord_to_pixel_scale_angle(central_pos, wcs) if self.a_in.unit.physical_type == 'angle': a_in = (scale * self.a_in).to(u.pixel).value a_out = (scale * self.a_out).to(u.pixel).value b_out = (scale * self.b_out).to(u.pixel).value else: a_in = self.a_in.value a_out = self.a_out.value b_out = self.b_out.value theta = (angle + self.theta).to(u.radian).value pixel_positions = np.array([x, y]).transpose() return EllipticalAnnulus(pixel_positions, a_in, a_out, b_out, theta) class EllipticalAnnulus(PixelAperture): """ Elliptical annulus aperture(s), defined in pixel coordinates. Parameters ---------- positions : tuple, list, array, or `~astropy.units.Quantity` Pixel coordinates of the aperture center(s), either as a single ``(x, y)`` tuple, a list of ``(x, y)`` tuples, an ``Nx2`` or ``2xN`` `~numpy.ndarray`, or an ``Nx2`` or ``2xN`` `~astropy.units.Quantity` in units of pixels. A ``2x2`` `~numpy.ndarray` or `~astropy.units.Quantity` is interpreted as ``Nx2``, i.e. two rows of (x, y) coordinates. a_in : float The inner semimajor axis. a_out : float The outer semimajor axis. b_out : float The outer semiminor axis. (The inner semiminor axis is determined by scaling by a_in/a_out.) theta : float The position angle of the semimajor axis in radians. (counterclockwise). Raises ------ ValueError : `~.exceptions.ValueError` If inner semimajor axis (``a_in``) is greater than outer semimajor axis (``a_out``). ValueError : `~.exceptions.ValueError` If either the inner semimajor axis (``a_in``) or the outer semiminor axis (``b_out``) is negative. """ def __init__(self, positions, a_in, a_out, b_out, theta): try: self.a_in = float(a_in) self.a_out = float(a_out) self.b_out = float(b_out) self.theta = float(theta) except TypeError: raise TypeError("'a_in' and 'a_out' and 'b_out' and 'theta' must " "be numeric, received {0} and {1} and {2} and {3}." .format((type(a_in), type(a_out), type(b_out), type(theta)))) if not (a_out > a_in): raise ValueError("'a_out' must be greater than 'a_in'") if a_in < 0 or b_out < 0: raise ValueError("'a_in' and 'b_out' must be non-negative") self.b_in = a_in * b_out / a_out self.positions = _sanitize_pixel_positions(positions) def area(self): return math.pi * (self.a_out * self.b_out - self.a_in * self.b_in) def plot(self, ax=None, fill=False, source_id=None, **kwargs): import matplotlib.pyplot as plt import matplotlib.patches as mpatches kwargs['fill'] = fill if ax is None: ax = plt.gca() if source_id is None: positions = self.positions else: positions = self.positions[np.atleast_1d(source_id)] theta_deg = self.theta * 180. / np.pi for position in positions: patch_inner = mpatches.Ellipse(position, 2.*self.a_in, 2.*self.b_in, theta_deg, **kwargs) patch_outer = mpatches.Ellipse(position, 2.*self.a_out, 2.*self.b_out, theta_deg, **kwargs) path = _make_annulus_path(patch_inner, patch_outer) patch = mpatches.PathPatch(path, **kwargs) ax.add_patch(patch) def do_photometry(self, data, error=None, effective_gain=None, pixelwise_error=True, method='exact', subpixels=5): if method not in ('center', 'subpixel', 'exact'): raise ValueError('{0} method not supported for aperture class ' '{1}'.format(method, self.__class__.__name__)) flux = do_elliptical_photometry(data, self.positions, self.a_out, self.b_out, self.theta, error=error, effective_gain=effective_gain, pixelwise_error=pixelwise_error, method=method, subpixels=subpixels, a_in=self.a_in) return flux class SkyRectangularAperture(SkyAperture): """ Rectangular aperture(s), defined in sky coordinates. Parameters ---------- positions : `~astropy.coordinates.SkyCoord` Celestial coordinates of the aperture center(s). This can be either scalar coordinates or an array of coordinates. w : `~astropy.units.Quantity` The full width of the aperture(s) (at theta = 0, this is the "x" axis), either in angular or pixel units. h : `~astropy.units.Quantity` The full height of the aperture(s) (at theta = 0, this is the "y" axis), either in angular or pixel units. theta : `~astropy.units.Quantity` The position angle of the width side in radians (counterclockwise). """ def __init__(self, positions, w, h, theta): if isinstance(positions, SkyCoord): self.positions = positions else: raise TypeError("positions should be a SkyCoord instance") assert_angle_or_pixel('w', w) assert_angle_or_pixel('h', h) assert_angle('theta', theta) if w.unit.physical_type != h.unit.physical_type: raise ValueError("'w' and 'h' should either both be angles or " "in pixels") self.w = w self.h = h self.theta = theta def to_pixel(self, wcs): """ Return a RectangularAperture instance in pixel coordinates. """ x, y = skycoord_to_pixel(self.positions, wcs, mode=skycoord_to_pixel_mode) central_pos = SkyCoord([wcs.wcs.crval], frame=self.positions.name, unit=wcs.wcs.cunit) xc, yc, scale, angle = skycoord_to_pixel_scale_angle(central_pos, wcs) if self.w.unit.physical_type == 'angle': w = (scale * self.w).to(u.pixel).value h = (scale * self.h).to(u.pixel).value else: # pixel w = self.w.value h = self.h.value theta = (angle + self.theta).to(u.radian).value pixel_positions = np.array([x, y]).transpose() return RectangularAperture(pixel_positions, w, h, theta) class RectangularAperture(PixelAperture): """ Rectangular aperture(s), defined in pixel coordinates. Parameters ---------- positions : tuple, or list, or array Pixel coordinates of the aperture center(s), either as a single ``(x, y)`` tuple, a list of ``(x, y)`` tuples, an ``Nx2`` or ``2xN`` `~numpy.ndarray`, or an ``Nx2`` or ``2xN`` `~astropy.units.Quantity` in units of pixels. A ``2x2`` `~numpy.ndarray` or `~astropy.units.Quantity` is interpreted as ``Nx2``, i.e. two rows of (x, y) coordinates. w : float The full width of the aperture (at theta = 0, this is the "x" axis). h : float The full height of the aperture (at theta = 0, this is the "y" axis). theta : float The position angle of the width side in radians (counterclockwise). Raises ------ ValueError : `~.exceptions.ValueError` If either width (``w``) or height (``h``) is negative. """ def __init__(self, positions, w, h, theta): try: self.w = float(w) self.h = float(h) self.theta = float(theta) except TypeError: raise TypeError("'w' and 'h' and 'theta' must " "be numeric, received {0} and {1} and {2}." .format((type(w), type(h), type(theta)))) if w < 0 or h < 0: raise ValueError("'w' and 'h' must be nonnegative.") self.positions = _sanitize_pixel_positions(positions) def area(self): return self.w * self.h def plot(self, ax=None, fill=False, source_id=None, **kwargs): import matplotlib.pyplot as plt import matplotlib.patches as mpatches kwargs['fill'] = fill if ax is None: ax = plt.gca() if source_id is None: positions = self.positions else: positions = self.positions[np.atleast_1d(source_id)] hw = self.w / 2. hh = self.h / 2. sint = math.sin(self.theta) cost = math.cos(self.theta) dx = (hh * sint) - (hw * cost) dy = -(hh * cost) - (hw * sint) positions = positions + np.array([dx, dy]) theta_deg = self.theta * 180. / np.pi for position in positions: patch = mpatches.Rectangle(position, self.w, self.h, theta_deg, **kwargs) ax.add_patch(patch) def do_photometry(self, data, error=None, effective_gain=None, pixelwise_error=True, method='subpixel', subpixels=5): if method == 'exact': warnings.warn("'exact' method is not implemented, defaults to " "'subpixel' method and subpixels=32 instead", AstropyUserWarning) method = 'subpixel' subpixels = 32 elif method not in ('center', 'subpixel'): raise ValueError('{0} method not supported for aperture class ' '{1}'.format(method, self.__class__.__name__)) flux = do_rectangular_photometry(data, self.positions, self.w, self.h, self.theta, error=error, effective_gain=effective_gain, pixelwise_error=pixelwise_error, method=method, subpixels=subpixels) return flux class SkyRectangularAnnulus(SkyAperture): """ Rectangular annulus aperture(s), defined in sky coordinates. Parameters ---------- positions : `~astropy.coordinates.SkyCoord` Celestial coordinates of the aperture center(s). This can be either scalar coordinates or an array of coordinates. w_in : `~astropy.units.Quantity` The inner full width of the aperture(s), either in angular or pixel units. w_out : `~astropy.units.Quantity` The outer full width of the aperture(s), either in angular or pixel units. h_out : `~astropy.units.Quantity` The outer full height of the aperture(s), either in angular or pixel units. (The inner full height is determined by scaling by w_in/w_out.) theta : `~astropy.units.Quantity` The position angle of the semimajor axis (counterclockwise), either in angular or pixel units. """ def __init__(self, positions, w_in, w_out, h_out, theta): if isinstance(positions, SkyCoord): self.positions = positions else: raise TypeError("positions should be a SkyCoord instance") assert_angle_or_pixel('w_in', w_in) assert_angle_or_pixel('w_out', w_out) assert_angle_or_pixel('h_out', h_out) assert_angle('theta', theta) if w_in.unit.physical_type != w_out.unit.physical_type: raise ValueError("w_in and w_out should either both be angles or " "in pixels") if w_out.unit.physical_type != h_out.unit.physical_type: raise ValueError("w_out and h_out should either both be angles or " "in pixels") self.w_in = w_in self.w_out = w_out self.h_out = h_out self.theta = theta def to_pixel(self, wcs): """ Return a EllipticalAnnulus instance in pixel coordinates. """ x, y = skycoord_to_pixel(self.positions, wcs, mode=skycoord_to_pixel_mode) central_pos = SkyCoord([wcs.wcs.crval], frame=self.positions.name, unit=wcs.wcs.cunit) xc, yc, scale, angle = skycoord_to_pixel_scale_angle(central_pos, wcs) if self.w_in.unit.physical_type == 'angle': w_in = (scale * self.w_in).to(u.pixel).value w_out = (scale * self.w_out).to(u.pixel).value h_out = (scale * self.h_out).to(u.pixel).value else: w_in = self.w_in.value w_out = self.w_out.value h_out = self.h_out.value theta = (angle + self.theta).to(u.radian).value pixel_positions = np.array([x, y]).transpose() return RectangularAnnulus(pixel_positions, w_in, w_out, h_out, theta) class RectangularAnnulus(PixelAperture): """ Rectangular annulus aperture(s), defined in pixel coordinates. Parameters ---------- positions : tuple, list, array, or `~astropy.units.Quantity` Pixel coordinates of the aperture center(s), either as a single ``(x, y)`` tuple, a list of ``(x, y)`` tuples, an ``Nx2`` or ``2xN`` `~numpy.ndarray`, or an ``Nx2`` or ``2xN`` `~astropy.units.Quantity` in units of pixels. A ``2x2`` `~numpy.ndarray` or `~astropy.units.Quantity` is interpreted as ``Nx2``, i.e. two rows of (x, y) coordinates. w_in : float The inner full width of the aperture. w_out : float The outer full width of the aperture. h_out : float The outer full height of the aperture. (The inner full height is determined by scaling by w_in/w_out.) theta : float The position angle of the width side in radians. (counterclockwise). Raises ------ ValueError : `~.exceptions.ValueError` If inner width (``w_in``) is greater than outer width (``w_out``). ValueError : `~.exceptions.ValueError` If either the inner width (``w_in``) or the outer height (``h_out``) is negative. """ def __init__(self, positions, w_in, w_out, h_out, theta): try: self.w_in = float(w_in) self.w_out = float(w_out) self.h_out = float(h_out) self.theta = float(theta) except TypeError: raise TypeError("'w_in' and 'w_out' and 'h_out' and 'theta' must " "be numeric, received {0} and {1} and {2} and {3}." .format((type(w_in), type(w_out), type(h_out), type(theta)))) if not (w_out > w_in): raise ValueError("'w_out' must be greater than 'w_in'") if w_in < 0 or h_out < 0: raise ValueError("'w_in' and 'h_out' must be non-negative") self.h_in = w_in * h_out / w_out self.positions = _sanitize_pixel_positions(positions) def area(self): return self.w_out * self.h_out - self.w_in * self.h_in def plot(self, ax=None, fill=False, source_id=None, **kwargs): import matplotlib.pyplot as plt import matplotlib.patches as mpatches kwargs['fill'] = fill if ax is None: ax = plt.gca() if source_id is None: positions = self.positions else: positions = self.positions[np.atleast_1d(source_id)] sint = math.sin(self.theta) cost = math.cos(self.theta) theta_deg = self.theta * 180. / np.pi hw_inner = self.w_in / 2. hh_inner = self.h_in / 2. dx_inner = (hh_inner * sint) - (hw_inner * cost) dy_inner = -(hh_inner * cost) - (hw_inner * sint) positions_inner = positions + np.array([dx_inner, dy_inner]) hw_outer = self.w_out / 2. hh_outer = self.h_out / 2. dx_outer = (hh_outer * sint) - (hw_outer * cost) dy_outer = -(hh_outer * cost) - (hw_outer * sint) positions_outer = positions + np.array([dx_outer, dy_outer]) for i, position_inner in enumerate(positions_inner): patch_inner = mpatches.Rectangle(position_inner, self.w_in, self.h_in, theta_deg, **kwargs) patch_outer = mpatches.Rectangle(positions_outer[i], self.w_out, self.h_out, theta_deg, **kwargs) path = _make_annulus_path(patch_inner, patch_outer) patch = mpatches.PathPatch(path, **kwargs) ax.add_patch(patch) def do_photometry(self, data, error=None, effective_gain=None, pixelwise_error=True, method='subpixel', subpixels=5): if method == 'exact': warnings.warn("'exact' method is not implemented, defaults to " "'subpixel' instead", AstropyUserWarning) method = 'subpixel' elif method not in ('center', 'subpixel'): raise ValueError('{0} method not supported for aperture class ' '{1}'.format(method, self.__class__.__name__)) flux = do_rectangular_photometry(data, self.positions, self.w_out, self.h_out, self.theta, error=error, effective_gain=effective_gain, pixelwise_error=pixelwise_error, method=method, subpixels=subpixels, w_in=self.w_in) return flux @support_nddata def aperture_photometry(data, apertures, unit=None, wcs=None, error=None, effective_gain=None, mask=None, method='exact', subpixels=5, pixelwise_error=True): """ Sum flux within an aperture at the given position(s). Parameters ---------- data : array_like, `~astropy.io.fits.ImageHDU`, `~astropy.io.fits.HDUList` The 2-d array on which to perform photometry. ``data`` should be background-subtracted. Units are used during the photometry, either provided along with the data array, or stored in the header keyword ``'BUNIT'``. apertures : `~photutils.Aperture` instance The apertures to use for the photometry. unit : `~astropy.units.UnitBase` instance, str An object that represents the unit associated with ``data``. Must be an `~astropy.units.UnitBase` object or a string parseable by the :mod:`~astropy.units` package. It overrides the ``data`` unit from the ``'BUNIT'`` header keyword and issues a warning if different. However an error is raised if ``data`` as an array already has a different unit. wcs : `~astropy.wcs.WCS`, optional Use this as the wcs transformation. It overrides any wcs transformation passed along with ``data`` either in the header or in an attribute. error : float or array_like, optional Error in each pixel, interpreted as Gaussian 1-sigma uncertainty. effective_gain : float or array_like, optional Ratio of counts (e.g., electrons or photons) to units of the data (e.g., ADU), for the purpose of calculating Poisson error from the object itself. If ``effective_gain`` is `None` (default), ``error`` is assumed to include all uncertainty in each pixel. If ``effective_gain`` is given, ``error`` is assumed to be the "background error" only (not accounting for Poisson error in the flux in the apertures). mask : array_like (bool), optional Mask to apply to the data. Masked pixels are excluded/ignored. method : str, optional Method to use for determining overlap between the aperture and pixels. Options include ['center', 'subpixel', 'exact'], but not all options are available for all types of apertures. More precise methods will generally be slower. * ``'center'`` A pixel is considered to be entirely in or out of the aperture depending on whether its center is in or out of the aperture. * ``'subpixel'`` A pixel is divided into subpixels and the center of each subpixel is tested (as above). With ``subpixels`` set to 1, this method is equivalent to 'center'. Note that for subpixel sampling, the input array is only resampled once for each object. * ``'exact'`` (default) The exact overlap between the aperture and each pixel is calculated. subpixels : int, optional For the ``'subpixel'`` method, resample pixels by this factor (in each dimension). That is, each pixel is divided into ``subpixels ** 2`` subpixels. pixelwise_error : bool, optional For ``error`` and/or ``effective_gain`` arrays. If `True`, assume ``error`` and/or ``effective_gain`` vary significantly within an aperture: sum contribution from each pixel. If `False`, assume ``error`` and ``effective_gain`` do not vary significantly within an aperture. Use the single value of ``error`` and/or ``effective_gain`` at the center of each aperture as the value for the entire aperture. Default is `True`. Returns ------- phot_table : `~astropy.table.Table` A table of the photometry with the following columns: * ``'aperture_sum'``: Sum of the values within the aperture. * ``'aperture_sum_err'``: Corresponding uncertainty in ``'aperture_sum'`` values. Returned only if input ``error`` is not `None`. * ``'xcenter'``, ``'ycenter'``: x and y pixel coordinates of the center of the apertures. Unit is pixel. * ``'xcenter_input'``, ``'ycenter_input'``: input x and y coordinates as they were given in the input ``positions`` parameter. The metadata of the table stores the version numbers of both astropy and photutils, as well as the calling arguments. Notes ----- This function is decorated with `~astropy.nddata.support_nddata` and thus supports `~astropy.nddata.NDData` objects as input. """ dataunit = None datamask = None wcs_transformation = wcs if isinstance(data, (fits.PrimaryHDU, fits.ImageHDU)): header = data.header data = data.data if 'BUNIT' in header: dataunit = header['BUNIT'] elif isinstance(data, fits.HDUList): for i in range(len(data)): if data[i].data is not None: warnings.warn("Input data is a HDUList object, photometry is " "run only for the {0} HDU." .format(i), AstropyUserWarning) return aperture_photometry(data[i], apertures, unit, wcs, error, effective_gain, mask, method, subpixels, pixelwise_error) # this is basically for NDData inputs and alike elif hasattr(data, 'data') and not isinstance(data, np.ndarray): if data.wcs is not None and wcs_transformation is None: wcs_transformation = data.wcs datamask = data.mask if hasattr(data, 'unit'): dataunit = data.unit if unit is not None and dataunit is not None: dataunit = u.Unit(dataunit, parse_strict='warn') unit = u.Unit(unit, parse_strict='warn') if not isinstance(unit, u.UnrecognizedUnit): data = u.Quantity(data, unit=unit, copy=False) if not isinstance(dataunit, u.UnrecognizedUnit): if unit != dataunit: warnings.warn('Unit of input data ({0}) and unit given by ' 'unit argument ({1}) are not identical.' .format(dataunit, unit)) else: if not isinstance(dataunit, u.UnrecognizedUnit): data = u.Quantity(data, unit=dataunit, copy=False) else: warnings.warn('Neither the unit of the input data ({0}), nor ' 'the unit given by the unit argument ({1}) is ' 'parseable as a valid unit' .format(dataunit, unit)) elif unit is None: if dataunit is not None: dataunit = u.Unit(dataunit, parse_strict='warn') data = u.Quantity(data, unit=dataunit, copy=False) else: data = u.Quantity(data, copy=False) else: unit = u.Unit(unit, parse_strict='warn') data = u.Quantity(data, unit=unit, copy=False) # Check input array type and dimension. if np.iscomplexobj(data): raise TypeError('Complex type not supported') if data.ndim != 2: raise ValueError('{0}-d array not supported. ' 'Only 2-d arrays supported.'.format(data.ndim)) # Deal with the mask if it exists if mask is not None or datamask is not None: if mask is None: mask = datamask else: mask = np.asarray(mask) if np.iscomplexobj(mask): raise TypeError('Complex type not supported') if mask.shape != data.shape: raise ValueError('Shapes of mask array and data array ' 'must match') if datamask is not None: # combine the masks mask = np.logical_or(mask, datamask) # masked values are replaced with zeros, so they do not contribute # to the aperture sums data = copy.deepcopy(data) # do not modify input data data[mask] = 0 # Check whether we really need to calculate pixelwise errors, even if # requested. If neither error nor effective_gain is an array, then it's # not neeed. if ((error is None) or (np.isscalar(error) and effective_gain is None) or (np.isscalar(error) and np.isscalar(effective_gain))): pixelwise_error = False # Check error shape. if error is not None: if isinstance(error, u.Quantity): if np.isscalar(error.value): error = u.Quantity(np.broadcast_arrays(error, data), unit=error.unit)[0] elif np.isscalar(error): error = u.Quantity(np.broadcast_arrays(error, data), unit=data.unit)[0] else: error = u.Quantity(error, unit=data.unit, copy=False) if error.shape != data.shape: raise ValueError('shapes of error array and data array must' ' match') # mask the error array, if necessary # masked values are replaced with zeros, so they do not contribute # to the sums if mask is not None: error = copy.deepcopy(error) # do not modify input data error[mask] = 0. # Check effective_gain shape. if effective_gain is not None: # effective_gain doesn't do anything without error set, so raise an # exception. (TODO: instead, should we just set effective_gain = None # and ignore it?) if error is None: raise ValueError('effective_gain requires error') if isinstance(effective_gain, u.Quantity): if np.isscalar(effective_gain.value): effective_gain = u.Quantity(np.broadcast_arrays( effective_gain, data), unit=effective_gain.unit)[0] elif np.isscalar(effective_gain): effective_gain = np.broadcast_arrays(effective_gain, data)[0] if effective_gain.shape != data.shape: raise ValueError('shapes of effective_gain array and data array ' 'must match') # Check that 'subpixels' is an int and is 1 or greater. if method == 'subpixel': subpixels = int(subpixels) if subpixels < 1: raise ValueError('subpixels: an integer greater than 0 is ' 'required') ap = apertures if isinstance(apertures, SkyAperture): positions = ap.positions if wcs_transformation is None: wcs_transformation = WCS(header) ap = ap.to_pixel(wcs_transformation) pixelpositions = ap.positions * u.pixel pixpos = np.transpose(pixelpositions) # check whether single or multiple positions if len(pixelpositions) > 1 and pixelpositions[0].size >= 2: coord_columns = (pixpos[0], pixpos[1], positions) else: coord_columns = (pixpos[0], pixpos[1], (positions, )) coord_col_names = ('xcenter', 'ycenter', 'center_input') else: pixelpositions = ap.positions * u.pixel pixpos = np.transpose(pixelpositions) # check whether single or multiple positions if len(pixelpositions) > 1 and pixelpositions[0].size >= 2: coord_columns = (pixpos[0], pixpos[1]) else: coord_columns = ((pixpos[0],), (pixpos[1],)) coord_col_names = ('xcenter', 'ycenter') # Prepare version return data from astropy import __version__ astropy_version = __version__ from photutils import __version__ photutils_version = __version__ photometry_result = ap.do_photometry(data, method=method, subpixels=subpixels, error=error, effective_gain=effective_gain, pixelwise_error=pixelwise_error) if error is None: phot_col_names = ('aperture_sum', ) else: phot_col_names = ('aperture_sum', 'aperture_sum_err') return Table(data=(photometry_result + coord_columns), names=(phot_col_names + coord_col_names), meta={'name': 'Aperture photometry results', 'version': 'astropy: {0}, photutils: {1}' .format(astropy_version, photutils_version), 'calling_args': ('method={0}, subpixels={1}, ' 'error={2}, effective_gain={3}, ' 'pixelwise_error={4}') .format(method, subpixels, error is not None, effective_gain is not None, pixelwise_error)}) photutils-0.2.1/photutils/aperture_funcs.py0000600000214200020070000003046412534402247023364 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst """Functions for performing aperture photometry on 2-D arrays.""" from __future__ import (absolute_import, division, print_function, unicode_literals) import numpy as np import warnings import astropy.units as u from astropy.utils.exceptions import AstropyUserWarning __all__ = [] def get_phot_extents(data, positions, extents): """ Get the photometry extents and check if the apertures is fully out of data. Parameters ---------- data : array_like The 2-d array on which to perform photometry. Returns ------- extents : dict The ``extents`` dictionary contains 3 elements: * ``'ood_filter'`` A boolean array with `True` elements where the aperture is falling out of the data region. * ``'pixel_extent'`` x_min, x_max, y_min, y_max : Refined extent of apertures with data coverage. * ``'phot_extent'`` x_pmin, x_pmax, y_pmin, y_pmax: Extent centered to the 0, 0 positions as required by the `~photutils.geometry` functions. """ # Check if an aperture is fully out of data ood_filter = np.logical_or(extents[:, 0] >= data.shape[1], extents[:, 1] <= 0) np.logical_or(ood_filter, extents[:, 2] >= data.shape[0], out=ood_filter) np.logical_or(ood_filter, extents[:, 3] <= 0, out=ood_filter) # TODO check whether it makes sense to have negative pixel # coordinate, one could imagine a stackes image where the reference # was a bit offset from some of the images? Or in those cases just # give Skycoord to the Aperture and it should deal with the # conversion for the actual case? x_min = np.maximum(extents[:, 0], 0) x_max = np.minimum(extents[:, 1], data.shape[1]) y_min = np.maximum(extents[:, 2], 0) y_max = np.minimum(extents[:, 3], data.shape[0]) x_pmin = x_min - positions[:, 0] - 0.5 x_pmax = x_max - positions[:, 0] - 0.5 y_pmin = y_min - positions[:, 1] - 0.5 y_pmax = y_max - positions[:, 1] - 0.5 # TODO: check whether any pixel is nan in data[y_min[i]:y_max[i], # x_min[i]:x_max[i])), if yes return something valid rather than nan pixel_extent = [x_min, x_max, y_min, y_max] phot_extent = [x_pmin, x_pmax, y_pmin, y_pmax] return ood_filter, pixel_extent, phot_extent def find_fluxvar(data, fraction, error, flux, effective_gain, imin, imax, jmin, jmax, pixelwise_error): if isinstance(error, u.Quantity): zero_variance = 0 * error.unit**2 else: zero_variance = 0 if pixelwise_error: subvariance = error[jmin:jmax, imin:imax] ** 2 if effective_gain is not None: subvariance += (data[jmin:jmax, imin:imax] / effective_gain[jmin:jmax, imin:imax]) # Make sure variance is > 0 fluxvar = np.maximum(np.sum(subvariance * fraction), zero_variance) else: local_error = error[int((jmin + jmax) / 2 + 0.5), int((imin + imax) / 2 + 0.5)] fluxvar = np.maximum(local_error ** 2 * np.sum(fraction), zero_variance) if effective_gain is not None: local_effective_gain = effective_gain[ int((jmin + jmax) / 2 + 0.5), int((imin + imax) / 2 + 0.5)] fluxvar += flux / local_effective_gain return fluxvar def do_circular_photometry(data, positions, radius, error, effective_gain, pixelwise_error, method, subpixels, r_in=None): extents = np.zeros((len(positions), 4), dtype=int) extents[:, 0] = positions[:, 0] - radius + 0.5 extents[:, 1] = positions[:, 0] + radius + 1.5 extents[:, 2] = positions[:, 1] - radius + 0.5 extents[:, 3] = positions[:, 1] + radius + 1.5 ood_filter, extent, phot_extent = get_phot_extents(data, positions, extents) flux = u.Quantity(np.zeros(len(positions), dtype=np.float), unit=data.unit) if error is not None: fluxvar = u.Quantity(np.zeros(len(positions), dtype=np.float), unit=error.unit ** 2) # TODO: flag these objects if np.sum(ood_filter): flux[ood_filter] = np.nan warnings.warn("The aperture at position {0} does not have any " "overlap with the data" .format(positions[ood_filter]), AstropyUserWarning) if np.sum(ood_filter) == len(positions): return (flux, ) x_min, x_max, y_min, y_max = extent x_pmin, x_pmax, y_pmin, y_pmax = phot_extent if method == 'center': use_exact = 0 subpixels = 1 elif method == 'subpixel': use_exact = 0 else: use_exact = 1 subpixels = 1 from .geometry import circular_overlap_grid for i in range(len(flux)): if not np.isnan(flux[i]): fraction = circular_overlap_grid(x_pmin[i], x_pmax[i], y_pmin[i], y_pmax[i], x_max[i] - x_min[i], y_max[i] - y_min[i], radius, use_exact, subpixels) if r_in is not None: fraction -= circular_overlap_grid(x_pmin[i], x_pmax[i], y_pmin[i], y_pmax[i], x_max[i] - x_min[i], y_max[i] - y_min[i], r_in, use_exact, subpixels) flux[i] = np.sum(data[y_min[i]:y_max[i], x_min[i]:x_max[i]] * fraction) if error is not None: fluxvar[i] = find_fluxvar(data, fraction, error, flux[i], effective_gain, x_min[i], x_max[i], y_min[i], y_max[i], pixelwise_error) if error is None: return (flux, ) else: return (flux, np.sqrt(fluxvar)) def do_elliptical_photometry(data, positions, a, b, theta, error, effective_gain, pixelwise_error, method, subpixels, a_in=None): extents = np.zeros((len(positions), 4), dtype=int) # TODO: we can be more efficient in terms of bounding box radius = max(a, b) extents[:, 0] = positions[:, 0] - radius + 0.5 extents[:, 1] = positions[:, 0] + radius + 1.5 extents[:, 2] = positions[:, 1] - radius + 0.5 extents[:, 3] = positions[:, 1] + radius + 1.5 ood_filter, extent, phot_extent = get_phot_extents(data, positions, extents) flux = u.Quantity(np.zeros(len(positions), dtype=np.float), unit=data.unit) if error is not None: fluxvar = u.Quantity(np.zeros(len(positions), dtype=np.float), unit=error.unit ** 2) # TODO: flag these objects if np.sum(ood_filter): flux[ood_filter] = np.nan warnings.warn("The aperture at position {0} does not have any " "overlap with the data" .format(positions[ood_filter]), AstropyUserWarning) if np.sum(ood_filter) == len(positions): return (flux, ) x_min, x_max, y_min, y_max = extent x_pmin, x_pmax, y_pmin, y_pmax = phot_extent if method == 'center': use_exact = 0 subpixels = 1 elif method == 'subpixel': use_exact = 0 else: use_exact = 1 subpixels = 1 from .geometry import elliptical_overlap_grid for i in range(len(flux)): if not np.isnan(flux[i]): fraction = elliptical_overlap_grid(x_pmin[i], x_pmax[i], y_pmin[i], y_pmax[i], x_max[i] - x_min[i], y_max[i] - y_min[i], a, b, theta, use_exact, subpixels) if a_in is not None: b_in = a_in * b / a fraction -= elliptical_overlap_grid(x_pmin[i], x_pmax[i], y_pmin[i], y_pmax[i], x_max[i] - x_min[i], y_max[i] - y_min[i], a_in, b_in, theta, use_exact, subpixels) flux[i] = np.sum(data[y_min[i]:y_max[i], x_min[i]:x_max[i]] * fraction) if error is not None: fluxvar[i] = find_fluxvar(data, fraction, error, flux[i], effective_gain, x_min[i], x_max[i], y_min[i], y_max[i], pixelwise_error) if error is None: return (flux, ) else: return (flux, np.sqrt(fluxvar)) def do_rectangular_photometry(data, positions, w, h, theta, error, effective_gain, pixelwise_error, method, subpixels, reduce='sum', w_in=None): extents = np.zeros((len(positions), 4), dtype=int) # TODO: this is an overestimate by up to sqrt(2) unless theta = 45 deg radius = max(h, w) * (2 ** -0.5) extents[:, 0] = positions[:, 0] - radius + 0.5 extents[:, 1] = positions[:, 0] + radius + 1.5 extents[:, 2] = positions[:, 1] - radius + 0.5 extents[:, 3] = positions[:, 1] + radius + 1.5 ood_filter, extent, phot_extent = get_phot_extents(data, positions, extents) flux = u.Quantity(np.zeros(len(positions), dtype=np.float), unit=data.unit) if error is not None: fluxvar = u.Quantity(np.zeros(len(positions), dtype=np.float), unit=error.unit ** 2) # TODO: flag these objects if np.sum(ood_filter): flux[ood_filter] = np.nan warnings.warn("The aperture at position {0} does not have any " "overlap with the data" .format(positions[ood_filter]), AstropyUserWarning) if np.sum(ood_filter) == len(positions): return (flux, ) x_min, x_max, y_min, y_max = extent x_pmin, x_pmax, y_pmin, y_pmax = phot_extent if method in ('center', 'subpixel'): if method == 'center': method = 'subpixel' subpixels = 1 from .geometry import rectangular_overlap_grid for i in range(len(flux)): if not np.isnan(flux[i]): fraction = rectangular_overlap_grid(x_pmin[i], x_pmax[i], y_pmin[i], y_pmax[i], x_max[i] - x_min[i], y_max[i] - y_min[i], w, h, theta, 0, subpixels) if w_in is not None: h_in = w_in * h / w fraction -= rectangular_overlap_grid(x_pmin[i], x_pmax[i], y_pmin[i], y_pmax[i], x_max[i] - x_min[i], y_max[i] - y_min[i], w_in, h_in, theta, 0, subpixels) flux[i] = np.sum(data[y_min[i]:y_max[i], x_min[i]:x_max[i]] * fraction) if error is not None: fluxvar[i] = find_fluxvar(data, fraction, error, flux[i], effective_gain, x_min[i], x_max[i], y_min[i], y_max[i], pixelwise_error) if error is None: return (flux, ) else: return (flux, np.sqrt(fluxvar)) photutils-0.2.1/photutils/background.py0000600000214200020070000003703412646242520022456 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst from __future__ import (absolute_import, division, print_function, unicode_literals) from distutils.version import LooseVersion import numpy as np from numpy.lib.index_tricks import index_exp from astropy.stats import sigma_clip from astropy.utils import lazyproperty import warnings import astropy if LooseVersion(astropy.__version__) < LooseVersion('1.1'): ASTROPY_LT_1P1 = True else: ASTROPY_LT_1P1 = False __all__ = ['Background'] __doctest_requires__ = {('Background'): ['scipy']} class Background(object): """ Class to estimate a 2D background and background rms noise in an image. The background is estimated using sigma-clipped statistics in each mesh of a grid that covers the input ``data`` to create a low-resolution background map. The final background map is the bicubic spline interpolation of the low-resolution map. The exact method used to estimate the background in each mesh can be set with the ``method`` parameter. The background rms in each mesh is estimated by the sigma-clipped standard deviation. """ def __init__(self, data, box_shape, filter_shape=(3, 3), filter_threshold=None, mask=None, method='sextractor', backfunc=None, interp_order=3, sigclip_sigma=3., sigclip_iters=10): """ Parameters ---------- data : array_like The 2D array from which to estimate the background and/or background rms map. box_shape : 2-tuple of int The ``(ny, nx)`` shape of the boxes in which to estimate the background. For best results, the box shape should be chosen such that the ``data`` are covered by an integer number of boxes in both dimensions. filter_shape : 2-tuple of int, optional The ``(ny, nx)`` shape of the median filter to apply to the low-resolution background map. A filter shape of ``(1, 1)`` means no filtering. filter_threshold : int, optional The threshold value for used for selective median filtering of the low-resolution background map. If not `None`, then the median filter will be applied to only the background meshes with values larger than ``filter_threshold``. mask : array_like (bool), optional A boolean mask, with the same shape as ``data``, where a `True` value indicates the corresponding element of ``data`` is masked. Masked data are excluded from all calculations. method : {'mean', 'median', 'sextractor', 'mode_estimate'}, optional The method use to estimate the background in the meshes. For all methods, the statistics are calculated from the sigma-clipped ``data`` values in each mesh. * 'mean': Mean. * 'median': Median. * 'sextractor': The method used by `SExtractor`_. The background in each mesh is a mode estimator: ``(2.5 * median) - (1.5 * mean)``. If ``(mean - median) / std > 0.3`` then the median is used instead. Despite what the `SExtractor`_ User's Manual says, this is the method it *always* uses. * 'mode_estimate': An alternative mode estimator: ``(3 * median) - (2 * mean)``. * 'custom': Use this method in combination with the ``backfunc`` parameter to specific a custom function to calculate the background in each mesh. backfunc : callable The function to compute the background in each mesh. Must be a callable that takes in a 3D `~numpy.ma.MaskedArray` of size ``MxNxZ``, where the ``Z`` axis (axis=2) contains the sigma-clipped pixels in each background mesh, and outputs a 2D `~numpy.ndarray` low-resolution background map of size ``MxN``. ``backfunc`` is used only if ``method='custom'``. interp_order : int, optional The order of the spline interpolation used to resize the low-resolution background and background rms maps. The value must be an integer in the range 0-5. The default is 3 (bicubic interpolation). sigclip_sigma : float, optional The number of standard deviations to use as the clipping limit when calculating the image background statistics. sigclip_iters : int, optional The number of iterations to perform sigma clipping, or `None` to clip until convergence is achieved (i.e., continue until the last iteration clips nothing) when calculating the image background statistics. The default is 10. Notes ----- If there is only 1 background mesh element (i.e., ``box_shape`` is the same size as the ``data``), then the background map will simply be a constant image with the value in the background mesh. Limiting ``sigclip_iters`` will speed up the calculations, especially for large images, at the cost of some precision. .. _SExtractor: http://www.astromatic.net/software/sextractor """ if mask is not None: if mask.shape != data.shape: raise ValueError('mask shape must match data shape') valid_methods = ['mean', 'median', 'sextractor', 'mode_estimate', 'custom'] if method not in valid_methods: raise ValueError('method "{0}" is not valid'.format(method)) self.box_shape = (min(box_shape[0], data.shape[0]), min(box_shape[1], data.shape[1])) self.filter_shape = filter_shape self.filter_threshold = filter_threshold self.mask = mask self.method = method self.backfunc = backfunc self.interp_order = interp_order self.sigclip_sigma = sigclip_sigma self.sigclip_iters = sigclip_iters self.yextra = data.shape[0] % box_shape[0] self.xextra = data.shape[1] % box_shape[1] self.data_shape = data.shape self.data_region = index_exp[0:data.shape[0], 0:data.shape[1]] if (self.yextra > 0) or (self.xextra > 0): self.padded = True data_ma = self._pad_data(data, mask) else: self.padded = False data_ma = np.ma.masked_array(data, mask=mask) self.data_ma_shape = data_ma.shape self._sigclip_data(data_ma) @staticmethod def _pad(data, xpad, ypad, value=np.nan): """ Pad a data array on the right and top. Used only for numpy 1.6, where np.pad is not available. """ ny, nx = data.shape shape = (ny + ypad, nx + xpad) padded_data = np.ones(shape) * value padded_data[0:ny, 0:nx] = data return padded_data def _pad_data(self, data, mask=None): """ Pad the ``data`` and ``mask`` on the right and top with zeros if necessary to have a integer number of background meshes of size ``box_shape``. """ try: from numpy import pad has_nppad = True except ImportError: has_nppad = False ypad, xpad = 0, 0 if self.yextra > 0: ypad = self.box_shape[0] - self.yextra if self.xextra > 0: xpad = self.box_shape[1] - self.xextra if has_nppad: pad_width = ((0, ypad), (0, xpad)) mode = str('constant') padded_data = np.pad(data, pad_width, mode=mode, constant_values=[np.nan]) else: padded_data = self._pad(data, xpad, ypad, value=np.nan) padded_mask = np.isnan(padded_data) if mask is not None: if has_nppad: mask_pad = np.pad(mask, pad_width, mode=mode, constant_values=[False]) else: mask_pad = self._pad(mask, xpad, ypad, value=False).astype(np.bool) padded_mask = np.logical_or(padded_mask, mask_pad) return np.ma.masked_array(padded_data, mask=padded_mask) def _sigclip_data(self, data_ma): """ Perform sigma clipping on the data in regions of size ``box_shape``. """ ny, nx = data_ma.shape ny_box, nx_box = self.box_shape y_nbins = int(ny / ny_box) # always integer because data were padded x_nbins = int(nx / nx_box) # always integer because data were padded data_rebin = np.ma.swapaxes(data_ma.reshape( y_nbins, ny_box, x_nbins, nx_box), 1, 2).reshape(y_nbins, x_nbins, ny_box * nx_box) del data_ma with warnings.catch_warnings(): warnings.simplefilter('ignore') if ASTROPY_LT_1P1: self.data_sigclip = sigma_clip( data_rebin, sig=self.sigclip_sigma, axis=2, iters=self.sigclip_iters, cenfunc=np.ma.median, varfunc=np.ma.var) else: self.data_sigclip = sigma_clip( data_rebin, sigma=self.sigclip_sigma, axis=2, iters=self.sigclip_iters, cenfunc=np.ma.median, stdfunc=np.std) del data_rebin def _filter_meshes(self, data_low_res): """ Apply a 2d median filter to the low-resolution background map, including only pixels inside the image at the borders. """ from scipy.ndimage import generic_filter try: nanmedian_func = np.nanmedian # numpy >= 1.9 except AttributeError: from scipy.stats import nanmedian nanmedian_func = nanmedian if self.filter_threshold is None: return generic_filter(data_low_res, nanmedian_func, size=self.filter_shape, mode='constant', cval=np.nan) else: data_out = np.copy(data_low_res) for i, j in zip(*np.nonzero(data_low_res > self.filter_threshold)): yfs, xfs = self.filter_shape hyfs, hxfs = yfs // 2, xfs // 2 y0, y1 = max(i - hyfs, 0), min(i - hyfs + yfs, data_low_res.shape[0]) x0, x1 = max(j - hxfs, 0), min(j - hxfs + xfs, data_low_res.shape[1]) data_out[i, j] = np.median(data_low_res[y0:y1, x0:x1]) return data_out def _resize_meshes(self, data_low_res): """ Resize the low-resolution background meshes to the original data size using bicubic interpolation. """ if np.min(data_low_res) == np.max(data_low_res): # constant image (or only 1 mesh) return np.zeros(self.data_shape) + np.min(data_low_res) else: from scipy.ndimage import zoom zoom_factor = (int(self.data_ma_shape[0] / data_low_res.shape[0]), int(self.data_ma_shape[1] / data_low_res.shape[1])) return zoom(data_low_res, zoom_factor, order=self.interp_order, mode='reflect') @lazyproperty def background_low_res(self): """ A 2D `~numpy.ndarray` containing the background estimate in each of the meshes of size ``box_shape``. This low-resolution background map is equivalent to the low-resolution "MINIBACKGROUND" background map in `SExtractor`_. """ if self.method == 'mean': bkg_low_res = np.ma.mean(self.data_sigclip, axis=2) elif self.method == 'median': bkg_low_res = np.ma.median(self.data_sigclip, axis=2) elif self.method == 'sextractor': box_mean = np.ma.mean(self.data_sigclip, axis=2) box_median = np.ma.median(self.data_sigclip, axis=2) box_std = np.ma.std(self.data_sigclip, axis=2) condition = (np.abs(box_mean - box_median) / box_std) < 0.3 bkg_est = (2.5 * box_median) - (1.5 * box_mean) bkg_low_res = np.ma.where(condition, bkg_est, box_median) bkg_low_res = np.ma.where(box_std == 0, box_mean, bkg_low_res) elif self.method == 'mode_estimate': bkg_low_res = (3. * np.ma.median(self.data_sigclip, axis=2) - 2. * np.ma.mean(self.data_sigclip, axis=2)) elif self.method == 'custom': bkg_low_res = self.backfunc(self.data_sigclip) if not isinstance(bkg_low_res, np.ndarray): # np.ma will pass raise ValueError('"backfunc" must return a numpy.ndarray.') if isinstance(bkg_low_res, np.ma.MaskedArray): raise ValueError('"backfunc" must return a numpy.ndarray.') if bkg_low_res.shape != (self.data_sigclip.shape[0], self.data_sigclip.shape[1]): raise ValueError('The shape of the array returned by ' '"backfunc" is not correct.') if self.method != 'custom': bkg_low_res = np.ma.filled(bkg_low_res, fill_value=np.ma.median(bkg_low_res)) if self.filter_shape != (1, 1): bkg_low_res = self._filter_meshes(bkg_low_res) return bkg_low_res @lazyproperty def background_rms_low_res(self): """ A 2D `~numpy.ndarray` containing the background rms estimate in each of the meshes of size ``box_shape``. This low-resolution background rms map is equivalent to the low-resolution "MINIBACK_RMS" background rms map in `SExtractor`_. """ bkgrms_low_res = np.ma.std(self.data_sigclip, axis=2) bkgrms_low_res = np.ma.filled(bkgrms_low_res, fill_value=np.ma.median(bkgrms_low_res)) if self.filter_shape != (1, 1): bkgrms_low_res = self._filter_meshes(bkgrms_low_res) return bkgrms_low_res @lazyproperty def background(self): """ A 2D `~numpy.ndarray` containing the background estimate. This is equivalent to the low-resolution "BACKGROUND" background map in `SExtractor`_. """ bkg = self._resize_meshes(self.background_low_res) if self.padded: bkg = bkg[self.data_region] return bkg @lazyproperty def background_rms(self): """ A 2D `~numpy.ndarray` containing the background rms estimate. This is equivalent to the low-resolution "BACKGROUND_RMS" background rms map in `SExtractor`_. """ bkgrms = self._resize_meshes(self.background_rms_low_res) if self.padded: bkgrms = bkgrms[self.data_region] return bkgrms @lazyproperty def background_median(self): """ The median value of the low-resolution background map. This is equivalent to the value `SExtractor`_ prints to stdout (i.e., "(M+D) Background: "). """ return np.median(self.background_low_res) @lazyproperty def background_rms_median(self): """ The median value of the low-resolution background rms map. This is equivalent to the value `SExtractor`_ prints to stdout (i.e., "(M+D) RMS: "). """ return np.median(self.background_rms_low_res) photutils-0.2.1/photutils/conftest.py0000600000214200020070000000226012641261176022160 0ustar lbradleySTSCI\science00000000000000# this contains imports plugins that configure py.test for astropy tests. # by importing them here in conftest.py they are discoverable by py.test # no matter how it is invoked within the source tree. from astropy.tests.pytest_plugins import * # Uncomment the following line to treat all DeprecationWarnings as # exceptions enable_deprecations_as_exceptions() # Uncomment and customize the following lines to add/remove entries # from the list of packages for which version numbers are displayed # when running the tests try: PYTEST_HEADER_MODULES['Astropy'] = 'astropy' PYTEST_HEADER_MODULES['scikit-image'] = 'skimage' del PYTEST_HEADER_MODULES['h5py'] except NameError: # needed to support Astropy < 1.0 pass # Uncomment the following lines to display the version number of the # package rather than the version number of Astropy in the top line when # running the tests. import os # This is to figure out the affiliated package version, rather than # using Astropy's from . import version try: packagename = os.path.basename(os.path.dirname(__file__)) TESTED_VERSIONS[packagename] = version.version except NameError: # Needed to support Astropy <= 1.0.0 pass photutils-0.2.1/photutils/cython_version.py0000600000214200020070000000007212646264032023402 0ustar lbradleySTSCI\science00000000000000# Generated file; do not modify cython_version = '0.23.4' photutils-0.2.1/photutils/data/0000700000214200020070000000000012646264032020667 5ustar lbradleySTSCI\science00000000000000photutils-0.2.1/photutils/data/README.rst0000600000214200020070000000040112345377273022363 0ustar lbradleySTSCI\science00000000000000Data directory ============== This directory contains data files included with the affiliated package source code distribution. Note that this is intended only for relatively small files - large files should be externally hosted and downloaded as needed. photutils-0.2.1/photutils/datasets/0000700000214200020070000000000012646264032021566 5ustar lbradleySTSCI\science00000000000000photutils-0.2.1/photutils/datasets/__init__.py0000600000214200020070000000023612346164012023674 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst """ Load or make datasets for examples and tests. """ from .load import * from .make import * photutils-0.2.1/photutils/datasets/data/0000700000214200020070000000000012646264032022477 5ustar lbradleySTSCI\science00000000000000photutils-0.2.1/photutils/datasets/data/fermi_counts.fits.gz0000600000214200020070000005066012346164012026505 0ustar lbradleySTSCI\science00000000000000‹{‰Rfermi_counts_gc.fitsí}m\DZÞY.%ù^$äK¾$› øJFL“Ô‹e3qšZË„%JW†å‹€ ©•Ęä2»«·Ÿ™Y¶Tûl½wõ™³2 ¢v¦OwUuuÕSÕ}ÎÌÜ¿ûáÇìïíýn¡ƒ½ë{Žž}qtüôdïôhïwîïœ>|öùÃãϹ{{¿¿{ðñÝ¿ü~³â÷ðøøá÷{Ÿ?<}¸wúýóCžËtïö_îÞßøÝXñ{öõÓ¿ï}Ñ8?~zøìäñѳ–ßþ_öï½'Î7Lf/é%½¤—ô’^ÒKzI/é†Öåäý»ÝûÝÞëw?¼ýþª’Þ{\¾¾wÖzøÝéYUjñÓêç·ÞºwíÎíOÎûË'·¯]»öóŸÿü—{«ÿ­¸??><9|¶ZéÓ¯÷žýßÃG§k?zzxúÕÑç{w>Y¹Ë†ß›¿ºqó„öÿûõrøÅáñá³G‡’‹œ×ï“?ßþ€_ß½¿Úè·÷ðt£Ì±‡ñ÷ö?8`ù]»ñ«µýþrm³¤Ÿ=:Þ8ó¯Õr?ÿêû“Ç>Yí@Wf] }~tòøÎ§÷îžñ{ýóÃ/7ŒÎÛïã6ìëgO×|^æ»^7_¬Ç탋ëñÞþÈ‚lÖcÃïfÝzðñq¶+ý" ²YžßÙz|–X7#ëñ™¾Ÿ|tp[›ïݧ¿\MõèôáÆêo¬¤þB±ß{·Ö˜¼Öo…'o]»yóÚÍwnܸõæ[·n¼ûúŠáŸî=:><㷙ý7>[ѵ?¼öÞ{_}uëéÓ[''{Ÿnøýáîû÷n¸¿â÷·ÇÏž~þàÑÑ×+oxððW_¬ðxÍ0Dûìß¿óÑÇgþwÿà‚ýž=|z¸6Ûéá“ÓGGÏ÷¾<|vx¼ÒöÙ—gxŽîÞ»ðɧýVî¼iâù=~vrzüõÓ•'« ×ö»öÑïïoìwã7×Öÿ½}pó[o¿uë­_ÿjí×ë9Ÿœ><>=3ÞÃgŸï>~¡ôÊ+þvrxüÍ‹ÕútÃoÿÞ{m=Îø­ÖcóßüWLÜîÜýpí‚+~ͧÎÏwív'{_o†oX>Y±þ±Ïùâšß_÷?ùHô¿GOŽý}ÇÇ/âÞXß¿ûŸÝ_ûßÁ§ßæl=¹µf'ߟœ>]iºŠ®UŒ|}rˆÇlk~ŸìÿaÍïƒîÜþà¿Aà‹ãõRoxl¦¿p1ìüéödzùí+~ß~µÂµ<|1óÏqJçÿÕÓ½¿>Û{øüù“Çï|ÿÁGŸðù’ò[u<›ó·«ñ_?{øÍÃÇOþmŠ«©?|öýٵϿ¾÷Þý?íoìÇÐÛ¢ÙEÚÿߟ޽÷Ñ_.ò[y÷f}÷WéüÙÑwë%Y¥ºÝàëÉóÃG¿X¡Øé…sÅUhìòçýOVëññáéj^>~ôÕá““£g›e¹¾·‰êëëXüø®C¿;Ÿìß>øè“õú~yºB˜=\ßûG_œ~ûðø,2¾9<Þ•gðµŠß ˜QúãÝû+vŸ1’>xxzg ]>|~pøôù:$~ùÍ*k½µ6Å;×o¼}ýÆ;{oÞ¼uã×·Þúí*<\Íëûøí÷Ü1Ç|ÿ¸çO÷?ýp5ßÇ_üñèñ_ÿøìñç««¿¯oæûÇ÷>Ý[I~ô÷“¯Ÿî}ýüóMäþå¿>XáøÊó‚ß _n¯Ømðþ×ïÜüÍM´ßá6¹ÈÅõ½û«á¬ÞX•æ>¼}ÿOoìÿyÿÞÁƒ;«…½ÿË·~ùñ»þõ/^g¦ÆÒ{÷WhuÆï½U(oö« pßÍà¿V¯½~óÖYÉ™eõ‚ßj¾gù| 5üVó=ãÇás‚_«‡^?¸ýûp¿•à·BÓ3~·Þ?¸[ ßÊ~omøíßÛÿäýÏ*ìwÆïÃÃ?ï跲߿›ëd{ëæ‹ê4Éu3ß·7üþº¿ÊÃ|pûÞûì§uÜÌ÷m±žLð[Í÷Œßz®ïôòÛÿËÁºü[ó»÷à£{¨ßu²ÓßTZ5<=X'_=yrôíÆ¿z|rztüý&7®j¾Çë~|ôtU´=ÿútò«œûý^Ë ¿kEÔøý~ÿý»÷~ЋêtøÍz7ô`­Ô‹"øß6yÿÿhó­ÖïîÆ2OŸÙçÖÞõ“G«¢öÑW׿|òðäôéóëß|ëÆµ?ܼ~ãúñ7ßúí;ï¼ûöÍ·|sóÍ6u|tÔøæ]„ï?YW«š{µ¾·öÞX鱿6Ü•r'ÿíw7~±÷¯ÿº÷Æþ7§ûO>_•lëòç­võ/ô|wµÉY÷ø!ÿžïù?_ôüÍwohÛ!Q¿;ë{»w?:+OÏ9ãÕׯ¿[o~7Î}ztVt¬Jê•Sì®K·[„Ÿfý/ŽŽÖ~ÒÜäß¾<}|&ã¹0¬ñ#ÿ|òäÁwÏ<_µ<8¿oÝ\ó}°*¡Ÿ¯xþË/ÜÆ|-…0Äoì7~?–×ßþÅÏßÜûÝïönn|äGcqÓsû-bd 衧 9ñ8ÌüÀþÏ¿Ê9̰ù~uôôðúáÑ·‡Ï®¯KÒë«]ÛÓÇןutzôìúªpöòÁ·‡‡òýƒooÜøíÙ ¾¹qãææø!œ¹YÔßœ[ÔMš_ÃÄ‹ªdÕôâÕª­Õ«ÖÆom¥Õ~ÿÆÍõõM%¸±ù»zÿÖoß}ó×ï¾yã­uã†+ÍýëÆöþ‡ùn.lD½“ðâ ?¦Þøtͽñ#6§˜ou¾\?·ò"‹·¤ž¢jý^>Oó’^ÒKzI/é%½¤Ñ4ÍC;3ɹ̱öÝa^_éSG”é¯éY©ƒ&ÓË{'1Ö÷šæŽ%NÞ6ãyþ.$=—¤ÿ:þTâa4Uͧ'ŸxÇTcæòê×;ÏøˆŒÝé,‡_Æyr^U¾±Æ=u’·ÖYÎq6ÎêQUëq¤éÔë'#±c >» áËK¨÷¤÷#äeó¡‡säi\d>Zß‘óFR\-_–¨S£lœfÇrãªjàžs‹¹i ûB«–«ÂÜ%û?¥H½Þÿb_Ôs¾×#wÔØjsíq«xxx{qv[qšñIϹ}ô}Oô´GåÌuΗÅVUÚ´Š.ËYÛ(¬ŽêQ5~é6IÕs§ñU]÷eûõ𯨫2}¥1K¯gFÉßÖùJ5Uï]¤÷sҒψ3´íœ6wmâ‘›¹ÿ²”u½Ì˜ù’Æçó/×z>òì‹{Ïœ":DúY>3 o"{ú¨ŒŠºä²ÅÏeÓwéôS±§7άšhiöµ×Ÿ£ÏÈñ£({v°Ôù¬i®³ß¥ð®ËÕK]ïmÕÆ•µÝ½-žs=G=wñèµ_lzÎ¥Ë6|¤z\”8_ø©ãÍM™{‘þ?Õçó–â7œÿüŒÝó™ÃG×öKð‹Ë®ÿ4꜎‹ÇmÅÑ4*ž¶±ÏXâó5^Zж±k•þÔ“_©|Ïܸ1ǹNïxÏ&*iÔ³=ýG¬I¦ofï¥%âÿÈÜF½ÛÓ?;fmÐýs4-EFÛÔ§úÌ,Z¿djoné=[³t ÿ¬¾‘öŒ.s“5§Þšui1š¥jÿþ)ÐÈóϾ#¯ÖuÜ-Éï3X3k£´­û@ÙõÞÖ3-?Ç×s¯ïèsï|æ”Ý‹i=²G’§ž[¢Þ£)ZS.ÅFÛÈÛžû(ìÔøpÏsD0`d¶-y½Ô9K4;ç:ÿõðÎÆ\Ä_zq·ç{ô8‹F<ãV‘'æ: B²¾¯l[±‘‘—½?µä3õËÆw¹—)E1µbo”é[ͧúüškáÕë•å_5n4/äKkùŠÜ±äX¯8§¬î_ÅϳvK^JÛÀÌ¥Èé¥mŸ•/ ÷¸ó2žÁJ´ÏÐ\±þûÚ”¿'5ÁXÿޏ—²ÔøöèºísÎ%ÄU–.£Îm³ÎÎò‹øÐeX³UAœ«kûÌYTËsÝÃØ6UœÿZ}·] VÒ¶q¡ªfÈì'qMw„×½²zÇÍÍ3J#íÁÆžziäù~æ,³³k›ùbiõ‡–¸·ãdYõˆ·ŸÄ4mkOhñªXÿÞº¥ºÖÔøáþ6#/ëS#~:;†ŽÍâÛ¨Øé‰ályÙq{IgNž¾ÕBûl«nïáU}.•?ªÖÌ—?—æ>Oñ½ŽùÛ”³ ŒòðÛÕ{Ð <äê–¹êÓj;SÞ&£ýUÒÍãw=þ¡µEjÃȘ¹jLj¬9q[㑟ªÞci|ªÏþ2õFÎe¦¥øxOüõʉʛû»€«Ï5(Eμç#=úôRï³÷ÑZ màõ¯ž\7·Ý%yÈ/ò»•™ÞkK«-G¯MvGp·µkß:«ªjÕÑç #Î’$9#ûæƒ4âY-/Uøó¶ÏZztÕöL޹/õPt­çÖsŽü¶-¢9Û¼cé{o-¤ÅKÔïGÿ>aÅ^¡×‡,<ù|¾;,‘³Çˆoxøyè2Çrä\Å{­ò¢G¿ÑÄùotÏYM6Ý­uÒ~ft_e¿Ñ{ìHî‹à¯g-zr“¥Ç÷cŸˆ/Eë— Íu†cшg¡"ø7 «—ˆ¯ÄoçéÓ«gï^;3Ϊ“$ýzýó²Ö^ÊÎ/š»2û‡ˆ]çüþímŸqTÊϬD'î|Ã+÷§FÛð¯ê:ÅÛ18Sÿ"õüݨ³ )ïÌù J´w¼ã3g^¬ä}í:öãöm‘3XM®&»Ê3ùµ‚*÷’ej…LŸ¥œ{e® ¶ë3$ k3û|Á—ˆ=*cõÍäð9×rTmŠsÏàu¶¾Ÿ;¤{%Q¿òàµÕ‘×;¦Šw5¶ebidÅgí3u¨5ÎsÝC46Öñó³#uðRñÀ’iím<û#Mfï|«ãGÓ+Ûœ½z0":ßž:4CZLdjßÈûê=‰&#;¾Š*yVåæl Ô#ÛÛ¯çÙ÷l_Í®¯:dTQOþ´ø-*kË^Šìû²¼¼X«ôè“yfãyGàÓCž³ Ϙ¬ÜmÔÓªÀ¾è\­Xõ½}žÚ\;'Ä~Úø Ì‹K‘þV¿,¯ ®Z1‹¥{äRûHÜŽ­Ö‰“Ä}oêÈÜÕ“[³ø¤Åp…îÛÆm¤9ÏL­ªá{óÕ#‹[دz ½ùõŸ•rZ&xæ\‰ÑÞübÉÎ×[KDtÒxpuÅzË/¶±êå«­IE~îáåñïL š‘ã!+ž+ꈌþ#rüˆ>•ã´±­ÀÞLŒö÷žÕs2#­:ùiyÐSiü9=­¾^5Y^š^™8¬Æžl !ýfDÔF=X¤½ÏÖ¢Uq—­×~ T•ó­ö›Y¸ É¹"ôãøàøž|š­·qçÔ™ïqÈÆV¶¿$¯gO õåðÞ““zc8’ó¢øÓ›OFDÚÇX¼*dfpbTèåÕs!b³ªúgî<;rçå­“²ò310⹎ª|›Ñ%"¯ê÷çôiiÏVÉwD^çÆUÛ-ãk¿âž—ïÁÝ©ŸOu^ñðÔpÆÂ Í·zlñßJÊ~—‡zöðÜu\‹lò´U¬…´ÈòÊôíõÕª¹gøZõ\Ïo¨4ýz~+(S‡fûJ~Tµ·ôøI6î*kE­oÍOnŽs`gå>§ºfò®u—ð:=“ââ8òݯ\äãçØÿXýGò‘'¼k®­Ëœµ·ßRîˆðÏê…Tñ[b½ý½ùmD]™sõÞ£’*ðWêŸ]‡[yócÕ÷.е}ÅÑ'"/’ë³þV»¢¦å:i}´Tª·½Ô§Þ5¶ÎÒªœ ‡KÒs†^Š`W«dïgGütgê·¿·Vã®q¹4«OtÞ^õU”oÕ˜ ¼ÉR¤æ˜ Û¢y®J©N•bÑ‹èžÉ¢lž‹Ä¼ÅÛ²ƒôÚsÆÏéåsµOJ{‰~Õ}½kÇ}® ûkŸ}óØAò‹+ðº"†‘oT¯ÈumL/yí™cö·‰´š¨7ï{Ö k‡h½ƒçÌÑ¢jߊ̹'Þ´óæ,O‹8¿ã®Y<¬Ü“©#µAd\DžÔ'ãѸæÆië%æemæý®I«Æñø@U:G¼EeIùEš7gw)Oys^4v«jH¯?D)ãVný,FeóJs°oÆF#êÄ^¼ÐâAòY ã<>¦µizxÆZ„úáë]Òæù,§{iÏ¢röó♥_Åù‚–ü¾$é ýíWož•Ö»:ÿzyD×ÇKÑgq¼~Öc3Mf?¯OFùfÛ. q±Óó]ÞœôððÔØÒ˜lM!®ŽˆþÒ~Ek“ö¹sølE=ì¹7è‘Cç¼KÚ𺛼Ÿ9ñê%õÑê1ªËȵÌäG´e¦fÍ~__V¦fc ë¼X˜_D¬/ôúj¶¯„SÞZÄ«&»‘çÙ',L¶ÖÅ’EßGrw]³Ÿ‹4¾\?ézo|jgNø>â/ø¹¡®GâÂÓ_[o/E1жÎ+žû¿™Z4‹S™œEùxmñÊ;¢ò·ðg޼¡µiö‹ÌG‹MO¼j~`ñôÜg­¸wèë݃h9gŽú2“oFS÷¥6®Ô/òœRâý~:ìÓƒŸT¶VÇpr-òÖ4VÿhέÐ%zûDñÔÓó•ÈøŒLlóÔkYÙ]¿Òò@Ô×¢ëéyþ9b#O®[SälÑÞÜoQfŒ—·¶ÿµmv…kïö·ac¦¦”Ú)OOâ­g¼ûªjêÁ.'jµ˜ä›žÏÉZTy¶­ñíñ¥¨ÿ¶×^;H‰sq±ÅÅ`¡°ÆÖðÇöâ·ÖNÉÚ—dó”7F$œáâ–’ö]óžûœ^óúsæ;“­þ^Ì¥zJÏOIºà¾`wúÑo­Ü¤Õ\_«žMœãÚ*j+¯ßèØh}›¡ª:¦‚"qÐKÞg+¬ü©óbʉî<˜JõÉø¢FÃ<¿‰ÍsVüIqÒÚ¥{Ä?K^K¼y4"+’ÿw”¸ÒøbÍÃÉAÒÎ’8ŠÔí–N™Z‚ËyIë6â³%‘ÏR{k òÄi†¬ùzr‡…‰·6Öâ!éáåÁÕa´¯´¦QìÈ`M#m?›±KgÇã5ü|c„21Ðó¸ŸlÝnù­)®Nç÷ Ó¤ÛLòi¬›¼¼P_NiœFVÌk2"Ÿaµâœãѯ—0—qkåÕ^[óÕð0#ÏÓ¯çZ¤¶îÉ•ÜXŒ oÌ[6öú>GÒ^€»Ó“°^ã^kñï‰1ÚÆÅ}Õ籪ê&m ¥µÓÚ£²#c×5Þ«/þþó‹W>ž9á²÷FG¬ŸçÚú¯÷w³}"ýpL¶¾”Ú#zdóŽGÎMÊKÚü«b·——uBßWŸé"z}^#í3q½~¬é¥álçõ‰è~‡# ã¼ëoñ¶æ£­µ¯¹±¼÷ºÖýþiõïµÕ¿ÿ²ú÷_§ó9Dª5‘V‹Ò¶Ìó'yê,éó?Üx­ïšv᯴=uj”‡6xë=ë}¤Þìi÷7ßFÖÉ[ kmšœH®ÌèíÅnI®T_y>Áa\‹c,}­:Õ»&ÚùæUAž¥×Þ“W,ü·Æyðѫ׺?æ†5­÷ ?›ÎòÇzñšb=ÅJŸimhS-GEÖMÃI+Ÿrq¡ù¨äŸVN‘øKý¢ù£‘Sž³ø9Î{¹u·ò$Ó’_¹²rmöÙ)zjWoþá®EmÅÝ·öÖ\_N‡¨NÞšË[ažŒÞ_‹ø,’dÓ¨¸³Zé5Öûx­½_ãÞ+/þþ‡él?r•´IzIzÐ6Ï™P&wxûIÏ(OB;Î׊Km^ÌF}¬>š<üç•˽ÏàÇ»g^Ö#zDÚ£}£>ѧw ès–ÈÓËÛz>ª—4 ÓðŽã#ùm—žïÑ0“ÓMºæÍIkí_䬯ŠNg+jµLÓoGxý ù+åïºJÚÆÒçÀ8~ÑüŠzJ|µ:’æÕiâ}Ú+ZßfpE»fa•ã+pAóá(Ž×•‰ÇÁ(?ºö[°“Ö–ÍgÚGr®ÅS:óÏ®}V©¯Õ'ú,&—⠇ІÜ:Yò"íÙœÏùŠ뛼vf…{Žʵ^cÆ6b»%Çz/Å•”S´˜ëÅ(^õÈð>?çyÞyJµl„8ß¶ðNÃ~O­©=¼×¤…këÅ… ü¤|8[zðSò!K_OÞG^Ü}Iïž\¥a8‡Ù\ìÉåQ|¥mZ>÷òõÆ‘d+úk¾hŒzî­Yï38€}9~’?KßMÙ^kX!å?mœ—<¹!sÖïÉ]Œ†­»ÓÅú¥‘§¶èÍ>™|¯­_Ö¦š_¡/Xuo‹sim¤’bžÃ݉iß™.Ön(Çû¯e±õ´î‘Fb?g‘\01:p¹KÃ8‹?^oóÆuo}®NçÏr<þ/a®¥W¦®¥ý´ýµ¦‡ƒQ\Ö0OÃ?íšæKÒœ=<²ùŒÃŽbm—ÚÚ½·Ÿ1¼4 ×¹½¤—‡+¼8fñ´®yó#ʎȳps½GÖš¸8ðø¤$Ûj—| ¯k˜À½·|Púl¶ôW{­µ­ÉºCñ:r®£åBéµ”#=6çäqyÏë'§¤û(Y1låcÚæñ7ª¯ô žØŽÜG“tiã%ýè{+†²Ï2Eqyýwý,ù:‡ÐïÚ±ø´ØÕÎǦ‰^¨çtÒbyFÉë¿ÖkªG'é8<§î½WdµI¼$ý<ã"ùóÎvÖy°ä#‘œÄñ‘ô±ô¶ôàúxI£ùš…Õ‘8ÐÖei:dc…öçjié^­¦‹Ç_¹qT¦ÇÆœ®¹fF)ê^¿ }[ÎxÍËÅ›¦¯$›ÓÅK–ŸÐ÷8îÙéûU-ÜkºDHÂ+®°wf%éŠzZqÄá2§’šLIžg^œ/zb]ãíÅÚfù#Õûx1^³“•c¸÷<•üTòAí¸þvrºZçTZüïÂ{*ã%µI×½ñEÉ:3òø§¦Sï8ßzÖÕ’ÇñÌ<—"­¡ägôºW&cN‘dJ˜‰Äù!ç÷¨ŽÁñ´ýêdÏSÏÉãÎ<ø¢ñ—Ú´sNž´¶ôA»sd}qyG»¯EûrÏ@qxFåàP$‰Gžõó`úxdÏ<ÁxϼQVÔ$¾TwêÿÜ=IIž¥—öž“ý,œñP4' Eîÿp~â­½­}Ÿ–sü±óKoœp:FúröÃ>Ü9«µŽXÿ!qx§Å€4õ¢¼8²Ö•òçÆõÚßÂ0ÌÜžSz–m)Õª»ooÍ6žüý%_ñâ7ןËURÜq:H÷½½ßË*}î1SòkNljé+­þ¥¾ÐÎf88ùÑ{÷RÌr<%ݽ¯%~šj¾¬ùR#\7)¥ó@:&bËG´±/ª'’tÏŒêAÇzqóg®ÊB\‘âÇIë)ÝÇÔâ ãÆsdùö‘Î)¸>”h~¦Mãgw6ŠºKûiiM¸k´4–ãÑtD}¸ë”8L³|Pk—jtN®·žG9ܾSŠiœ§Æåt²æÄéï­a,½<×¹¿HÞs”­A=6£Ïrã$Üy;qk'­§—g#í™//k^\\aɾT/./pŸáÐ|ŽkËæIîšÕÞ®qòÛk »w ‡7ZÌéÉÉ×|ûã3n6îL¼m§P®¦£„×Ú\"{^äëÍG¨¿fŽ„ã´Íûœ®(ïÊt~ §)f_/Žxr“¶þÈOóY‰—Ä1FÃ>ÉîtNÖs¹Üžû£NíÝOs1"í¯¹{#Ó—òÐjWïþVZ Ï4l–0†{ÏÅ™D_¶°êèåMùJ6ÐHŠWN†äçÚ\iv”|SãMÛ_}ñÏ€#çéÓÇš—gÜ^K50ö‘tm¯Â{G³‰öÛ{’Or˜Ž}P.¶!YüiüÓ>R?Nõ!̹è\_)N-Ìð’7î9œoqÂÉGÿ—润‹vÅñÔ—®Nç×…Û·îÂ{ ³ZÜÓ=?Õ‰óE«­ýŒ·¶÷ÕÖ–óGÔÍ㟴æçè=ÝÆS«û¿qݤ}‡åãŽpëNeKõ —ÃP'É÷¥—óöçOWåaýƒë¡}o•ƒ¿5„:!iëíÁd‹pmaÞ´tF¬˜È{i߃:j¹Aò )7Ð>ÍæfYÄÅ•”Q7:¦bdkC~Ò~”óuîyX”gù ^£×)î#_œëšÚ÷H^yñš“oá ·VNIï%¡Äù«g\›”s9}$ÙFiúr¿Y&ñåj`idá¾å§†i±ê±“¦+µ=WksÏëXø¦éÌa$âú"/Å7ÎÇÂ(-×IûB-v‘8Œ’®5³bíƒ>„|­8Ôöô\¬hØËùW‡pó r¹ù£¾Ú?Ú_Ó–Ã{i<7OÔ‹“ÅÍ­ý¥ûQÉ9]hÞâpš«©ÐæW oëÏ̓¾·~‹ž«QO_8F›3ö‘j Î’Îô:mÇÜ$a g'-N9ì“âV:סüÖÔâýIÒÑ£¿ÔG‹[©N•tçÖR‹-Úoý÷UÒ_Zc-WHx…ûkÜWÒØA¾\Í€:qížïxÒü–úŠÛœµkønØg®ss§ã8>öÒ÷t¿Á=‡¸!a¦fwOþš9ô5ú'ËÒ‡«uè¼ñž¿Xxµ¦öÝJܺâñzQÛóIõG»ÆÅƼ„ãZm3Á5ÚŽñ)żƃúbg+ÖÑŽœOaÌ!îHAÇKù‚ë+Õ T_)þ¸u•jUJÞﲓÖ1±Žå|ë*Œ§g²‡°Ÿ`\› çS’¿qñÍÍ›«q¹z•Ê@âbžÓ[G ƒ¨´ß¢˜˜>Òo Q=¤ïÓÑ|ýñ…«¸ë¯LmÁ£5Ö«Ðg0~¸9LП¾çüÃÚÿHú#_ÎŽxašÎïéu©l|hMÏ«`®A_¡ü¤X¦óÄxÄëT_¼†uŽãt¡üÐîÜþ‡›—•9µµç®q{m®®‘üUõæIÎ/¸vl“ê.ko#á#õA®?wÿypÏO®‰žÝîÀiÞÔNø·ço8 s9~œoq×iŸÆ“Þãábý‰bú.Þ›§|1–´8˜kèçRüÐyá~Jóu.×j¯¹ç÷®B_J¸7k}¸X±Îg,_àlÊ=‹‹²¸5ELAûI¶ÁñO)&ôK/ÎæØc’Ži÷m¸zrbú£Ýp.šè8ŒõöšÓ›ÊåüŸ«ûè|P_Š C¹}=‡ T? [ék´‡7tîôúUè;Me¶qÔŸ^ëVÝÆá37h3ºÁ³(œ ç¸öt.hoÄ_´+Û“ò—Oå#I¶Ã>ÓtÞR|Ð6¬k%œåæ*õ·ìÓdbŒ`,Jµ^×to6E_¦<¥ûÜ&!hDçˆXù•ú—KÑ–T6Ý?ìNçmÜÚ'2–¾§ça­1»µ¡L)Ss÷̨íðû‡Ð'¨ h_û¸~h_´!ú”vomÄa0çSTW)Ïb}%ùíú_û~ø¶¦-ß¶õÄ<„8Eu£:^1œŽtÜ9cö`ý0Mçqw—Ìk®½2÷ oQß« oœó<´­Ö„Ò¹‡%\ŠÏFJøKe`_*S«M%=h_|ÝüL«»è{ëqNÔ§Ðܽj[íÞ±Trûn¬†IW˜œ©L.h|h±*ÅW/Òv®ÆáôD¼§uçCÈïUr;£@{p6@{Q½Zæ±ÖÛããþ•ÚX’Ïù+ýÛx"Qÿår7‡éœ->í <©^í=bç4?Šwë¾ëµjßñÛd½6ýˆ­ˆ›’­Ðwq 9Œâæ<)ïGqÏ¢~´ÆÁyá=.¿µqt-Zô+ÊŸûìy#®nàæËõÕì†x±#­EÓã›»ïCåJ˜.õå®q<¤34ìŽz`ÞÅsN.‡MÓy»q¾.]Ÿ˜vª'?´…V«I˜Bç#í‰[ûU×ú¬éCy¢PGúwšÎÛú5¢Åºn-¶°Þ£>Ì݃D¿Aœçü‡®úü4ý³Ü3üv§‹q޶h23¨?Ðþ8?¬¯h¦±ÁùêÐæ³;·5ž)qµÍ-íÚzM<š~m½©©ž\¾@ü£r9,äòÆ·ÈWª(:?j›W Ã•W&Y'j{/¦éâhìp„ö¡s–êÄb\Ô“‹»†m¾®S^ȃbæs<¿C|šàºåKÆâ¾—«Û<¿0ÏH¾‰:âz!6Ðkt½q´¾—æÃÉåÖ×ý˜âžAÑ8ÁÕ×󱉴a¾¢1߯`<4Â}#êD÷\^ã| ±ªí蜗Ú|0Néßç¯M?>3òOÓùuâöæèóÔF˜÷(Z—O/d"!~#.bô‡Æk¬f3êë˜7h=ñÏÓy_§¼¨­qÎt]±ÖÄúa"íTíËa'ÖèRþ¢¯ƒ¦é"oäÏÅ5Ö/4Žwa<æ: Oé{ô?är%<áâ´ñàäÒXÆ5E]'¦Oû» ©Ïq¹ëU¦ ç8M×Ã/ÃéƒûN?+¯Lë.ԓÛi=ÜÚ[íú‡>„sCŸ£ÔÖ²½FÝÚ8Z'ÒØÆØÃ<έÑDþJ¹Ú‚ž1M0ž{¾»_ÄÅù4Ï8~ý÷ÕéGœ£ÏÒ5ÆùТø€sçð—¶qµ÷#.LÂ{Œ_Êcš.Ötœï´÷íà4ñëÊéÖÚ(_ÄßѯQ6ú]̘Sðo«±éZ¿FôÆzƒö¥±†µ*êŠygš.Η®áUèÏÙ†Æe³óÕé<>N0Žòk„÷)¨|Ê“Êl5ÆÎ4—‹v¡„˜Ìá;µ)òÇqè T¬%^…¾ë¹ýûÿþóêß$}®>Í_#¨nˆ›4?#Ñ1\ŽjxÖâ…ÚabÚû9¬Ã\EóúZ3Á8J¨ òçr·v\ ÷0'¢_IÏp±DmÄåJÎní:â"õqúL bêÁ7qñï±Fŵ£u"½‡GûKøIýwš.ú=Å`N¦„hG¬—<9AzMm1M÷›¸'Ãó1j'<ì‹×p<[Ógwº8?zނפ¸‘Ö•¶ÑýW¿Oðþ ´Q_§s§òwá/­I¸œ¾ü§éÇøhDÇJkƒsnrp^LÓù¹4MÓù«ÅUÛËýlú±Â=¾–öSô/Î…Ë;4)/Ü×Òµ£9ŸÃHNäóêtž?ú5b‡ P& ÛðœþãpèµéüºP»N0ñyÓÜÍí ¸X×r7Ž®õajcnmv }"í­â3ú>‡EWá:—ç¥=.Ú }uG~ˆ#\ÎáÆcžâæÆá5Ú‰êCåp9Q´]ò—ê…÷‰9Ÿ@}&2†Ú®}û+}þŒòi×¹øä°—âÀ.ü£v³úÞ_âæÚx·¿ Ô'©oM¤þ¥üiÜ¢R}§é¼N˜S)íÀ5®îkúpÿZžù'"‡Ö†»Óùß.à0}ïHþMç€×è9Æ ú2}9”Ο‹äGuB›bNÇ9ruÆ4שéÂíwp[~çâ‚ÃHº^QÛ¢ °m\×zbÆqøCyR´æ¤c±^âêÎ8ì¤~€{¤iºÈ_s¥½&â&ú·œí&f,úÚ׆‹Yinxßʦ÷ª8þ¨âåÕößœšC¨~xÇÑ÷R¼ÓyÒkæà>³uë'Å §Ór)_ÄWií&¸Fý±ûÓxäb…öÅ9MЧ®­†ïÎp˜ÂåF‰·ˆ·hKn^?\;:ïs±Ì­'‡ö•ðŒË[Ôfíî¸õäâÇÑë\ç{¸†8ªî}¸ØãäaŽálŽv™˜ñÒ™…tŽ€úáëiº(SŠn ^Çk¸nqzPûãz4ÜHªýÛˆžQáÜѯµx¤ý^›.êLqk‚þéÃÕž­ýÇå>©ŽòêGç„þ3Mϲñ™3<ǧþ¾Cúp±Ž1xúpþÂÍCÊ·hÒÚp1ƒºáÜׄ÷#¹5Çùp~Ž:ríÓt1hîŒI®‘øJxŽþ„²Ú\‘Ú ûJשÿhºsïQgN')†%Ûr2¯À_j#´9žq¾ˆqÌù4g·ÖÎå^úšâ7ú+òhzrxLy#¯ÖÆñB>»pòÁ3Òv‹%ç˜ß&èÏù ­¤û'í:Úw‚6Îo¹ó< 'íËÙ’³›VsQþÜG‹g Ï´¸§íœÿL~Š$ÕY\å-áô·õEý‘/§Êåüû"¦Ó±xåigûèCX#j¸Ku”öáx®%ÙB«%° õxpk ­òÃsl“ü–êÏp˜ÈÉ‘æ%ù•´.´m=î5rÃÖ ®SÌAÞøÜ-â· v¤|QOªG#ÎQÎDú¡]=úMð^Zw Ë´÷ØÎǽªôšÓ‰ówIIÊ^—ÎÛ{®^àêGŽ$,àôàü…ó.o ÎøL±ÄŸÓm-åoËϧé|,q±§E]¸8ÐúIëOek˜C_ã½InWIúqyqbúHçx”'ÚCZNç¿í5÷y"Ä ®æðè%áæΞܺKµ(mãöê\sº£,Ô}­ÍcwâךÚùHy\óO-ÿp¼¨.œí8%¾Ö{ÔÕCXËqëÃÙ…ú!wÊñÔöÏ~#áÙóÄüm:MÐN× ÏÐñŒKÂWi­¹÷k_kÞGë‹|¤s±ÖOÚ3pü´µ§ò8ûj„}$\“ð_søHýHº_GÇIçi\_ª«d+lC½¨Þ8?ŠÇ!®S8ŸÀzÏÔ¸³]#¹¹JØŒ±lá©Ö†ã%[Jc%¬ vi¹¸åôæø5âîIs¢üð5ò”ÆqçO¨/î×è½Ͼ ¯K±Ïù7Æ3.²Î’žZ^àâEÃgf([ò+)†P/꿜ÍRT|Mûr5¾6_mèXÉO¥õÍwœ4 Wµ9¬IºoÃÙ˜Ó‡òÔb–ëO¯{ð µyî ¾ }9INÛ¹= §Ç ñB:Ç”|JâI_Kkƒ¹ÆÚSã>ûI52ÕuõÄ£EÜ3([ª§‰·/æ\©¶Ú™Î¯!7_ëÕ×ŸÚ uôÄ¥ôëF¨;gîs^t¼Eœý9°üCÂxs%–|WÓÓAZi¼GN#i¯/õ—ôÒ°/¢&Óª1i†c$›âûH}!‘´Å>^Lçtôìi¬õãü™;{âò77No­ŽÇùÓqÚwº iñ'=—´#\Ã9xžÁv‹'Îßz-å¡ îùmN7i¿§Í_KÏÎJñ¤í…©¾4/J5„‡¤ùHø"ÕbV OLŒ% Ó¤5¢<½g9Ÿ E1]ó)Ï8mݤ~Üù'[³wÆÂTî:ŽÏ朓ÆOó!ä×^s¸Œ¥Ú»íO4_´Îx°%iß&ù––K¸½ òÅkßÔüÑòEÉæíµtö|¸yI{6ŠÛÔ—$¼°æÄÕø8ÔÊÇkÆRRl7þ8^Ã^‰§„3’–? <¼æ­y%²žgòðÓöO^\çdYþ¯½ÖÖ_Â;mÎ~Xó’â/2ŽÃH‹?¶iö“t²b@ÛKKõ‡Ukb¿Ièká¶£¼æ>wbr׬ë´ÝÚ‡qµ g;mΜI¶œ¦‹±%Õ«–|œ#'¿Éãü ç‹û2ª?÷,Ÿ$OÒŸƒ<=ØÄ½—ôâdFðY›—öI Ë$_ôê$µi¶ÉøµÕ§‘ôYGKô mÝ,ý¼vúKŸoÔb©ýÕâ_cãg¤ñ? ϸXçHÃ'”-á*¾æžßËb…4Î:£ôìMÖ_aúàx_NÓùï³Hª§¡éÑl§}OígéŒï­5ÕtÔæíÍOÞZ¼-~™{—–¾Z?nÆòóúWó4¿Îà=ë&=gãÅCާtÆÂõ—ÖŽê†ØÏÙƒ’ç+ÊäÚ-¬ÔH³½'nPŽõä0É'<û7I~†$½0'xýX‹kË>Ú½s齯³½÷ø3ömï¥3^K¾´–]Qw|ïÅ7.½9‹9Hž=a$†=þAßGìšÁ¯]аtœ†MˆÍÚ}a8ž(“Ó£ý»)ßõ¿«L;÷9Un}µVjãbÏâ£ëü¼Xfá…—´{gžxo¯­¼ÀµsýÑÎQ¼ä®q¾Ëݳ‰ØM#ïz{Ú½q6‡îZ³Î¸1oéºv~®Ù"rFíÁl/I¸­ÉñžƒzH«¹véLÉÃ[²­µf\—·¹ïPãdcÓ°Úš¿–{­½Œû™œ< =û8I'¯ÕŸÊçleñ•òåËÉxP’ö´MËçš-=¹œ#m~Ïy4wFHÿ¡ŸX÷K<ë§µ¡ ½¸kùp…íµqžvϽ&ɇzs”ER¬®_sß%&é—yÀÛÎ]×θ#Äõ®?®¾–~Còu=ß«¦éÊŘÔߛù¾qúdÇc»–k,>‘uF™=ñJùà˜èÚeÈk'ÍϼxÀÕ%˜«q|ë£õóRd="ï5žÞ=¥'§Zí½<1âÍ£¸Ž‘1HÑ{ÐÖñ¦7^{ŽÆÂǨ½9’puŽìSé8‹¤<#á®us#ñcQD¾4ÖŠ¡FÜÙcôŒhÝWú5”cñ¡¹kÒ{ï5/yž‘Åvï&£Ÿ”;µ|êÕAÛçGó¢ô^#­ÎÈðˆ`„×4ì‘Ö"³ïæäYã%LãtÒäHzpm‘û2Ò™ 7Ž;çpÉë#˜o¸ñYŸ±¾óCjËä«­‘tJº®ÉŒ¬-76kcçëZÆæ‘>ÜótŒt¯/³ð`'§‡wŽž:–’öÜG-²¾ç6ŠÛyÎéûèºY¸já{ä^w=ëß.Hkì±{Ã)i÷Yð½?9ûÓ×Ñ3@´Q/þYX̵epŽó-´‹„oÈ;¢«ÖÛ1$ŸÒ°Ð3‡²Ö€ÊõÜWöòò´·k\ªñ¢×¥Üf­ŸÇ75ŸÄ³çu<ùÅËOÃ+oLX|{Ρ½ºS½µ˜Òüųw–j&Êד±/ž yî5[>ì™—Ó$²Ö±Ç_$þŽÈêÕ±±ênL$ιïÅB,Òîé{|ÉsU"/Frã,½¸°ðI{£åîÜQ‹)-V¬|eµ!?©¿‡_fí2ë¦õõ>Ë@ûzÏþ5¹ÙyxÆHµ½¦Õ e|É“«ñLuÕøc—÷´>œž/OÍñåâWúŽø¨ÏDâHÂ?Ú®}Ž<ªö·ÆZ~ç‘]ù,¥fË,ŸÞq¨‡gŸê½.­•çÙ=I?/i1Ê]ó¬³w>)ý4œòÔš<ÔQÓ‹ë#µyúhÏRry0ól¢7ïrkyî š³¹Ü¼¼ë¡É£ÔsvhéÔ“ ‡ÐÆFó¼·¯õ9ò‰<ƒ åGîºÖ¯‚¢ºVñƒ"çá^?·p=ó,Ф„9Úy©%Ǫy²:{ãÊÊmquk„¸Ø“ødy{s9Žáþjü8>–n#(ZJ˜×«£•Ç«ê%¯|nݬø³žYñÆOÖ–^=3Tñl„·Ÿ·¿÷ù`K^eó<®½4/éùĨoKŸQ¤~ÌÍC›[o}á5iŒ4Nš»%#›S¥þ‘³T©†Ç^ŠæÌ^,ª—­,]¢6ˆà’Ͻu”w#6ò>ï\!+ÊÈßÓ~VJ¸§ñÔxEÆôò§ãðþ:òôÌÉò[+GÐ>Z®öÄGE}„y³•$7›Ó35htm¬œ­¬>Öšzô°â#[ÃUÖš’>èãyïs|¸öP¯¢ë8‚zãldŸHަäÉ5²âÝ#ŸŽ“t±ÎÃ<ÏŽeÉSC!~Gòwk¯¾7 ‘õLš7ßkØá£]÷òÒÆgI[ç‘á!ë™@Ižç³Z}y¾ëãÍ‘ÜéµEëŸY³9òÊì©á"¼½|³ç 5biµ³†ñܹU¦Nµ®KñªÅD»¤s:OÔ¾_)B#Æj>áO׌{ÞÜâÙ/D÷ºÕ±%åpÏà3M^ß·úhzjºUåËϼ㣵®§Þ«~VËEÚÚecΪI¥÷™ú•ÒÚn‘{"^]¼ŸýäàµH,TáõnŒ&wD}àñ•žš%Ú?ÂO['î>p7¢úpc#¶³¾ÏÉ’eµ{^Gek¸á“é7'yãÑÂ}J‘Å{ÿ BÑgr+ûFȪٰ֑l„ßÓŽ×=zhü[íæ¡ÌgW=ØÌÕ5\ã­½:Jï›,íúܤÕdR ¥ñ²ê7_´ÖòŒ«Ê¡QYÚó–ÞMâí‰ÿ?‰—÷š…I¾^òú¤uÝŠMO-è‘íå£Õٺ““½ã´v‰¯Çf#bWjëy>/j«¾´Ö¡*'I:U]‹Ê®ä5'Yþå}VŸ»æÙ [¾µIµ ¥ZrkE)#_ª%«eG®k¸Ñóš¶õ®UÆ÷£|GÔÕT™Ó®0¯­1ZNò^«ð…Þqk›ÙcõÆz¦¶âøUc{DvTL­æãÉžºš»9wŠÚÏ[‹{Û£Ôã7ÜÜÑ^ÑïM@Þ–M´ü'áú{ã/ò Ië/QD§¨lnN‘=Œwoáy~_[}%},ž|ÑøTç;K.×··«¬}8ŠÔš}ïmåKoÌj}-}v”kUà‘FÖçü³þ:_8,«¨ÛGÌ%âOY™ÙzËêS9ßQäÑ{y¥WŽ7—Wɯ–1‚¬ZxdD}(»7°Ú¸vo“xõ¬±'ÿhíÖxé3ð_wkÏ~Ö0ÓVõ¹®l®ï­${yäVãGE½#­¯§ö§Ôû]–>ž~=6¶> ÕËy¨!«|À{'wÑg‚¢6‰~dz‡¨m8y;Â?M'IúIû]•g}W þ^¡'xô–Þ[c²µ^ËÆT”<¹VòÇÏ+j©LŸ©½3¼zuék=£êͯ=Ø5—ý8^žšÖ³Þ£âÛs>¦ñöÔÍÞÏÉyëÒªìé[7U¹ SëzõÏøOÏ÷ŒdäZå§é±­|Ðd{çäÙ+XsóÌu®ïcÈ'·ò¹rÄ‚^ÿ“Ö`T¬"ÿ ï;Ïé7˜ñ5®M4oyò]$Æ,ò|-JV ¦õÑÆÐq†{ý*2_§Tx÷UñÍm½¹pi”­O#µñlìY·Œnõ¤÷ZöœÙSc÷ä¼lÜ÷ö‹•/-=¬ÏíFëµõ?ϳQë4M±ïùÏð§ý£µˆ¶&œÞQ{÷Pœˆ¢±Ô«K%ï옞>’/p¾aý7Þâ©é±W¦6P¯ÿö`—ć{ïÕ«"ö½±Âí!¬üìÍß8뻀,²ösa§'ö*åeøEj6Ϻg}9J‘ú®Š,ìlò‘2µž÷û£2*ÉÒ ±£JF´OO²l\Þ1’/nË'4Ûxü×s=²o‰ÔÙ<±u•?Gq®:ÏIµÐ¶)û}¹È#2VùHílɑڪ¨×Ÿ{cÈê7b]=|%,²êhÍÌ]S½õІÓQ~=zDIÚ#H¸&­wdm-òîKz)cÞüX…W;“¼žž±Qþ‘ß/òêßS³aî‰Ì§Êo=ò¢˜à­'{}nDœUðŒÆ[¤6æd ŽEs€ÆÛ’½¦žïfaïÈþ#óÝ–|K·,Eô‘âLó,롹â8ƒcÙ|N×*>â½6JV»Þ;¯lNåÆY±^‘çzÇUä¿êuî?:¶=y”ËWsÆI„‡µïŒê!ÍŽÑ\gÅTðw'"cGP4n%ßœ3ïjDõˆ|µ;‘º·ÊW4œŒ~n7R£oƒªsÖèçm<÷=¢û!麵'ðÈjšÊ:E’˽ÎÈÊÚÛZskœ§¾‰Î)Ã#‹_sÄ|¥Œh¼Js¯Ú›Tçÿß“hßÐSK{rbO]4º†¬¦ŠÜÐ#¯çùí3¨Z®áújäÅ;IŸh¾“â3£gE>¨¢h™oöslÛö¯ «öèÕ±×½u\DŸJþÖÜ"ù,ƒAYŸñPEMé±±«^̪š«vMZ‹‘¹w ¸»d¹Û®—·I=˜R=X©ñÈø}Å~U‹oîŒnIµS…®¾²Ö«bŸÖ›_22=ý<û_iŒG~åïަžøª¦&¯ò{´«r휶ðÆf•NsÆi%Uä©(¯Þ½—µŸ« ϳÜ^=´ë•öߟ*»¢ã¸ÜìñŠzon\Ëø=WÇE0«wSEÙ¼ìÝëfuðú[FŽå5i¯¹xmµ2Êööï•Å­-Wóir³zDj¦ŠÜ¨õÍŽ Yš{ïBåE>ÐHòwš¯9{Æ É‡25~ï^Vºfa~U­ÑkëèøÈï&÷èÞûû–â°¶’¼˜§a×úuö»Ãµ>sû5>Z§Ò÷^UP¤æÊÄCVíºÔó…©<Ôó9oÿŠý ¶-ý;`«hä>.½¹¾G^tL%.J<=ß)nái&pûÔ±ëzö"ÙOË+=ØÒ“w­Üƒmžï¦çøTÕ}3|GÒÒ0¥ZÞè}¯öm¹™¯ mø'3³W÷ò¶ê‘4zŸ¥ÉÕÚ/½5µÕ®õ«¶†éšÍ=:ØTàÒ?ŠêŸù^ù Y5ÈO<µA´¶óø”UõÔȽc2{Ï ]¬ñ=õ+¾ÏÔ#Uy¬»#ûK®£{(‹sëU1nŽXi—¹ê¤mïu¢Øbý¦÷Þ[㌨s¼|²²{ϸ×kꉟž:e›{ƒ9b![x‹°G‡¬xô™ã·d¥~h³h â%MçÞz`„~]ªeTÈ÷®[oáAûFý*òÝ'Ú8Žzëâ5Z–GÕÞªgœ¶/Û“ÒW“ãÙsxøôR$.¼úYØÖ›{²±,é%Ų'ß i>Ð[?õŒ™ƒ¢þ«}_-öÙ&Í•#GÅ$£sUOX|GaaUáï‘gÙ|Äþ!j—9ÖÊ"ÔÙûí‘ëÙ¾~ZîòèQQ'gø{0>BUû9KÆHz׈êPñ{bÒžFÚ·jµ“·–µt©îëå׋u=²{øUî•GÈñ¶EÉ㯕ò$ÞÿQy¡ýÍždìÒ;ߥî[-Q¿¨NôJt¬ç7 ¤qÑ<ãå]‘+µq\Kóñè9c=vË<³™«Ö•W™KçÀÞ ßž\Ø‹¥VííñÙˆ®KÃÏQ¹_â9W}UÅ_Ò¿×nÕu–Ƴ÷=}Ov¿¡ê5ˆîq¤ö{à Ÿ¯ŠsOÏxîw%\Ûž æˆó‘Q5f†ÅXkßÙÚ²Ÿw‰êB_[¾Y—ž½yÅø¬¼È¹Àˆ}Z¤ÞÂ1sî½Xã;'Gúw-¥xŽÎ#º§Í|Wìœ5[ÕÚ Ÿès}’m£v™«NËúyÔ"ò³}GÔ†RåúôÊöäÎ 9=Ï&VQU]݃ÜÚâ:·g3{¯Q˜TÍoDG|¹šæÚ#6VîÍìÅ¢×zó$Çûý·Ú{K‡ ýz×Ú¯}o–g„"õ{V—lÝáÁù¥7>ªö(wDþÞöiTå?Ñš-:ߪõ¨&/®Î×£iiòzða©5ØHûnâ›Ñgî³%’f—LnÙYªµ¼u˜WfeiLU½Ø3wK~fëáÛK\~ªXGm¾YÌãé»ÓFÊ®ðç9b1ËSï¨_Œðo¯œ¹žQÅÞö沞þ~RnÈÈš«V‰âr†gïü2X‘]é«=ºnƒ¢øÛÃ/šGå±(U×{š « ¯WÄQdl¶Två~oŽõ³(£®oG瘷WOÍg=óÕäfÞW‘5¯%'ÏyíÍ™süælf/õ7<éú6ü`)øPEsÆØy2óÝ9ZÞ™Ó?£µŒ•C¤qÖøê}_Ïø*û:«˜‹*üœëÛkß^_©´sÕÞw‰T=—Þó4 ‡zÖ ‹G^ªä‘¥ÍËÒÞ`t>ŠâNvï:jm§õY$mÍæzþº‡Ï\¾á‘¿>¯%œuPù£ëÎ¥ïFðÉä· ÖeÎizs¢—ßœu:í¿í¸¢„Ï|ŒÐÍû\Éœqˆü­ý`µnKñk^£Ï/zp|)6´¨gŽÚïüFyYä=;ÉêâÑuŽÏÂWМ{%”Ë½Ž¶EeEùôìµé{Ëÿ3ò¬¾™ßè]J~ÈüvWškvÏœåSA‘½K¯Œª~V_nNÛÈ×ÙºÛÝ,57y)ºŸó\‹ö—~“ r?¿í<Í‘7¯USÅž·jO@Û<9·ú÷©ÙsÍ×*ñyÔþÜŠ•‘û¿ŒíæŽåm`‡uŽ^¡ÓÎÄóª²{eýZÉ_ã±ä|ÞûÛ=Ù±‹ø‘GŸ±ï­g22Ökƒù<3‡ê3ù|,;z}¥gÏìù¬ó¶Îg4’rxÔ‘zÁKUg=ÛÀÔ¹ðpô\*u‰®CÅ~o„_fiÄÙˆ5&ËkýþZÏ9ÚœµÁ¶øŽÞ£,!oT¬cOÌWŽÑøpk9VY4çÃ6ÈÒgiºFúEöQQŠœqhzK}¹3´Qg'#öܼ3÷ë*È»–ž9/©õÈ¡C… 2q.±~ÿvnŒÌÔ=]«ööò®×\çDÿÈÔ³©àÕK½2³ço£p+ãß#÷Z’Ž–žÿÈñX}†·„Üíc1Om_9zo·íÚ(Ãc„ΣîåeûÀ)nÝGŸÁE÷ѺÑÚ=ÉÊø­ôͨOfeGöò—…zÖ$º·X¿Ïà‡§™ƒ$[-57ŒàÕó “¹k^žK±ÅTU_ôæ/Oûh½î=þ·«\óò—rÓÜ¿:£´}<ñ0Z¿Ñ{Ïì~Ìë÷#ê·LŸÖoÄ^:sÞš‘3'--îªý§bÍFúôe¡Þ³Ñ(æŒÞÓGú¤¹}k®<6÷ÙWeÏTæðÕjª>ïíáQ}žë=Ÿ“|µ"4w]¹”šii{ÒmQï9_v/ºd;WíW²wm=ú SãFåVå¥jUDñÄÛ¿G–Ô–É—½²GаoY>RµŸ_^ž#~óÚcInä»y4æ&ÏœGગÏ;iûIÚ‰LŽ[¢O¬iIº¬©›¬µí©Uæ"¯o¢o{ÇX1¿„ýØ´´3¼*Zzí3âLinÏWužW…CžxŽRv.™}}¯/Ðó—9êK”ïmÏöë¡j|[Âb)¼æ¦HŒ/ažÕ:hŸEâß\±·:+s®é¡Ê߃Ëô™³&Ñr}fO½4º úÍ]ëõòÑ|£÷¼T?çg¸©æ;¢Ϫz?£ËÒã4BK¨‹·µßïÅ3n:õê<·ÌQ䎥Ÿ»hr²ydäœGå›9È[#fæU]cxe\F²ì\U[õ¬IïÞÌÛ÷§²¦¶9Ÿ‘ùmDŽ™«fž³6÷öûsÝÀ 횇·ÇFÖ=|ß‹ŸHUë8çYÒølCÞÒrÍæ6¢žµxnë|ˆk¯¨u·}Oii~­‘ÇîKˆ nüˆß½Íè1§ÜÔ{~iáËœgSÛ®-ç–×kÛŠûTKöó%ë&‘v<"×i|¬séÈ~‚ãÕ³o}®Øãû™ñÑ{‘þÛ¼gâÝ â{ תϽz¨'–4͵WÐ>'^MsÝ“ÑüÞSCY×¢úD© kªög•5ef_‘[éÏ^âµ¥kJ4'¶y~ÕKÛæÃáÆ6ö@saЬôÿ,á«æphotutils-0.2.1/photutils/datasets/data/README.rst0000600000214200020070000000025612410036146024163 0ustar lbradleySTSCI\science00000000000000This folder contains data files bundled with `photutils`. fermi_counts.fits.gz -------------------- Fermi LAT counts image created by Christoph Deil (copied from Gammapy). photutils-0.2.1/photutils/datasets/load.py0000600000214200020070000000723412444404542023065 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst """ Load example datasets. """ from __future__ import (absolute_import, division, print_function, unicode_literals) from astropy.io import fits from astropy.table import Table from astropy.utils.data import get_pkg_data_filename, download_file __all__ = ['get_path', 'load_spitzer_image', 'load_spitzer_catalog', 'load_fermi_image', 'load_star_image' ] def get_path(filename, location='local'): """Get path (location on your disk) for a given file. Parameters ---------- filename : str File name in the local or remote data folder location : {'local', 'remote'} File location. ``'local'`` means bundled with ``photutils``. ``'remote'`` means a server or the Astropy cache on your machine. Returns ------- path : str Path (location on your disk) of the file. Examples -------- >>> from astropy.io import fits >>> from photutils import datasets >>> hdu_list = fits.open(datasets.get_path('fermi_counts.fits.gz')) """ if location == 'local': path = get_pkg_data_filename('data/' + filename) elif location == 'remote': # pragma: no cover url = ('https://github.com/astropy/photutils-datasets/blob/master/' 'data/{0}?raw=true'.format(filename)) path = download_file(url, cache=True) else: raise ValueError('Invalid location: {0}'.format(location)) return path def load_spitzer_image(): # pragma: no cover """ Load 4.5 micron Spitzer image. Returns ------- hdu : `~astropy.io.fits.ImageHDU` The 4.5 micron image Examples -------- .. plot:: :include-source: from photutils import datasets hdu = datasets.load_spitzer_image() plt.imshow(hdu.data, origin='lower', vmax=50) """ path = get_path('spitzer_example_image.fits', location='remote') hdu = fits.open(path)[0] return hdu def load_spitzer_catalog(): # pragma: no cover """ Load 4.5 micron Spitzer catalog. This is the catalog corresponding to the image returned by `~photutils.datasets.load_spitzer_image`. Returns ------- catalog : `~astropy.table.Table` The catalog of sources Examples -------- .. plot:: :include-source: from photutils import datasets catalog = datasets.load_spitzer_catalog() plt.scatter(catalog['l'], catalog['b']) plt.xlim(18.39, 18.05) plt.ylim(0.13, 0.30) """ path = get_path('spitzer_example_catalog.xml', location='remote') table = Table.read(path) return table def load_fermi_image(): """Load Fermi counts image for the Galactic center region. Returns ------- hdu : `~astropy.io.fits.ImageHDU` Image HDU Examples -------- .. plot:: :include-source: from photutils import datasets hdu = datasets.load_fermi_image() plt.imshow(hdu.data, origin='lower', vmax=10) """ path = get_path('fermi_counts.fits.gz', location='local') hdu = fits.open(path)[1] return hdu def load_star_image(): # pragma: no cover """Load an optical image with stars. Returns ------- hdu : `~astropy.io.fits.ImageHDU` Image HDU Examples -------- .. plot:: :include-source: from photutils import datasets hdu = datasets.load_star_image() plt.imshow(hdu.data, origin='lower', cmap='gray') """ path = get_path('M6707HH.fits.gz', location='remote') hdu = fits.open(path)[0] return hdu photutils-0.2.1/photutils/datasets/make.py0000600000214200020070000004720312627615324023070 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst """ Make example datasets. """ from __future__ import (absolute_import, division, print_function, unicode_literals) import numpy as np from ..utils import check_random_state from astropy.table import Table from astropy.modeling.models import Gaussian2D from astropy.convolution import discretize_model import astropy.units as u __all__ = ['make_noise_image', 'make_poisson_noise', 'make_gaussian_sources', 'make_random_gaussians', 'make_4gaussians_image', 'make_100gaussians_image'] def make_noise_image(image_shape, type='gaussian', mean=None, stddev=None, unit=None, random_state=None): """ Make a noise image containing Gaussian or Poisson noise. Parameters ---------- image_shape : 2-tuple of int Shape of the output 2D image. type : {'gaussian', 'poisson'} The distribution used to generate the random noise. * ``'gaussian'``: Gaussian distributed noise. * ``'poisson'``: Poisson distributed nose. mean : float The mean of the random distribution. Required for both Gaussian and Poisson noise. stddev : float, optional The standard deviation of the Gaussian noise to add to the output image. Required for Gaussian noise and ignored for Poisson noise (the variance of the Poisson distribution is equal to its mean). unit : `~astropy.units.UnitBase` instance, str An object that represents the unit desired for the output image. Must be an `~astropy.units.UnitBase` object or a string parseable by the `~astropy.units` package. random_state : int or `~numpy.random.RandomState`, optional Pseudo-random number generator state used for random sampling. Separate function calls with the same noise parameters and ``random_state`` will generate the identical noise image. Returns ------- image : `~numpy.ndarray` Image containing random noise. See Also -------- make_poisson_noise, make_gaussian_sources, make_random_gaussians Examples -------- .. plot:: :include-source: # make a Gaussian and Poisson noise image from photutils.datasets import make_noise_image shape = (100, 200) image1 = make_noise_image(shape, type='gaussian', mean=0., stddev=5.) image2 = make_noise_image(shape, type='poisson', mean=5.) # plot the images import matplotlib.pyplot as plt fig, (ax1, ax2) = plt.subplots(2, 1, figsize=(8, 8)) ax1.imshow(image1, origin='lower', interpolation='nearest') ax2.imshow(image2, origin='lower', interpolation='nearest') """ if mean is None: raise ValueError('"mean" must be input') prng = check_random_state(random_state) if type == 'gaussian': if stddev is None: raise ValueError('"stddev" must be input for Gaussian noise') image = prng.normal(loc=mean, scale=stddev, size=image_shape) elif type == 'poisson': image = prng.poisson(lam=mean, size=image_shape) else: raise ValueError('Invalid type: {0}. Use one of ' '{"gaussian", "poisson"}.'.format(type)) if unit is not None: image = u.Quantity(image, unit=unit) return image def make_poisson_noise(image, random_state=None): """ Make a Poisson noise image from an image whose pixel values represent the expected number of counts (e.g., electrons or photons). Each pixel in the output noise image is generated by drawing a random sample from a Poisson distribution with expectation value given by the input ``image``. Parameters ---------- image : `~numpy.ndarray` or `~astropy.units.Quantity` The 2D image from which to make Poisson noise. Each pixel in the image must have a positive value (e.g., electron or photon counts). random_state : int or `~numpy.random.RandomState`, optional Pseudo-random number generator state used for random sampling. Returns ------- image : `~numpy.ndarray` or `~astropy.units.Quantity` The 2D image of Poisson noise. The image is generated by drawing samples from a Poisson distribution with expectation values for each pixel given by the input ``image``. See Also -------- make_noise_image, make_gaussian_sources, make_random_gaussians Examples -------- .. plot:: :include-source: # make a table of Gaussian sources from astropy.table import Table table = Table() table['amplitude'] = [50, 70, 150, 210] table['x_mean'] = [160, 25, 150, 90] table['y_mean'] = [70, 40, 25, 60] table['x_stddev'] = [15.2, 5.1, 3., 8.1] table['y_stddev'] = [2.6, 2.5, 3., 4.7] table['theta'] = np.array([145., 20., 0., 60.]) * np.pi / 180. # make an image of the sources and add a background level, # then make the Poisson noise image. from photutils.datasets import make_gaussian_sources from photutils.datasets import make_poisson_noise shape = (100, 200) bkgrd = 10. image1 = make_gaussian_sources(shape, table) + bkgrd image2 = make_poisson_noise(image1, random_state=12345) # plot the images import matplotlib.pyplot as plt fig, (ax1, ax2) = plt.subplots(2, 1, figsize=(8, 8)) ax1.imshow(image1, origin='lower', interpolation='nearest') ax2.imshow(image2, origin='lower', interpolation='nearest') """ prng = check_random_state(random_state) if isinstance(image, u.Quantity): return prng.poisson(image.value) * image.unit else: return prng.poisson(image) def make_gaussian_sources(image_shape, source_table, oversample=1, unit=None, hdu=False, wcs=False, wcsheader=None): """ Make an image containing 2D Gaussian sources. Parameters ---------- image_shape : 2-tuple of int Shape of the output 2D image. source_table : `~astropy.table.Table` Table of parameters for the Gaussian sources. Each row of the table corresponds to a Gaussian source whose parameters are defined by the column names. The column names must include ``flux`` or ``amplitude``, ``x_mean``, ``y_mean``, ``x_stddev``, ``y_stddev``, and ``theta`` (see `~astropy.modeling.functional_models.Gaussian2D` for a description of most of these parameter names). If both ``flux`` and ``amplitude`` are present, then ``amplitude`` will be ignored. oversample : float, optional The sampling factor used to discretize the `~astropy.modeling.functional_models.Gaussian2D` models on a pixel grid. If the value is 1.0 (the default), then the models will be discretized by taking the value at the center of the pixel bin. Note that this method will not preserve the total flux of very small sources. Otherwise, the models will be discretized by taking the average over an oversampled grid. The pixels will be oversampled by the ``oversample`` factor. unit : `~astropy.units.UnitBase` instance, str, optional An object that represents the unit desired for the output image. Must be an `~astropy.units.UnitBase` object or a string parseable by the `~astropy.units` package. hdu : bool, optional If `True` returns ``image`` as an `~astropy.io.fits.ImageHDU` object. To include WCS information in the header, use the ``wcs`` and ``wcsheader`` inputs. Otherwise the header will be minimal. Default is `False`. wcs : bool, optional If `True` and ``hdu=True``, then a simple WCS will be included in the returned `~astropy.io.fits.ImageHDU` header. Default is `False`. wcsheader : dict or `None`, optional If ``hdu`` and ``wcs`` are `True`, this dictionary is passed to `~astropy.wcs.WCS` to generate the returned `~astropy.io.fits.ImageHDU` header. Returns ------- image : `~numpy.ndarray` or `~astropy.units.Quantity` or `~astropy.io.fits.ImageHDU` Image or `~astropy.io.fits.ImageHDU` containing 2D Gaussian sources. See Also -------- make_random_gaussians, make_noise_image, make_poisson_noise Examples -------- .. plot:: :include-source: # make a table of Gaussian sources from astropy.table import Table table = Table() table['amplitude'] = [50, 70, 150, 210] table['x_mean'] = [160, 25, 150, 90] table['y_mean'] = [70, 40, 25, 60] table['x_stddev'] = [15.2, 5.1, 3., 8.1] table['y_stddev'] = [2.6, 2.5, 3., 4.7] table['theta'] = np.array([145., 20., 0., 60.]) * np.pi / 180. # make an image of the sources without noise, with Gaussian # noise, and with Poisson noise from photutils.datasets import make_gaussian_sources from photutils.datasets import make_noise_image shape = (100, 200) image1 = make_gaussian_sources(shape, table) image2 = image1 + make_noise_image(shape, type='gaussian', mean=5., stddev=5.) image3 = image1 + make_noise_image(shape, type='poisson', mean=5.) # plot the images import matplotlib.pyplot as plt fig, (ax1, ax2, ax3) = plt.subplots(3, 1, figsize=(8, 12)) ax1.imshow(image1, origin='lower', interpolation='nearest') ax2.imshow(image2, origin='lower', interpolation='nearest') ax3.imshow(image3, origin='lower', interpolation='nearest') """ image = np.zeros(image_shape, dtype=np.float64) y, x = np.indices(image_shape) if 'flux' in source_table.colnames: amplitude = source_table['flux'] / (2. * np.pi * source_table['x_stddev'] * source_table['y_stddev']) elif 'amplitude' in source_table.colnames: amplitude = source_table['amplitude'] else: raise ValueError('either "amplitude" or "flux" must be columns in ' 'the input source_table') for i, source in enumerate(source_table): model = Gaussian2D(amplitude=amplitude[i], x_mean=source['x_mean'], y_mean=source['y_mean'], x_stddev=source['x_stddev'], y_stddev=source['y_stddev'], theta=source['theta']) if oversample == 1: image += model(x, y) else: image += discretize_model(model, (0, image_shape[1]), (0, image_shape[0]), mode='oversample', factor=oversample) if unit is not None: image = u.Quantity(image, unit=unit) if wcs and not hdu: raise ValueError("wcs header only works with hdu output, use keyword " "'hdu=True'") if hdu is True: from astropy.io import fits if wcs: from astropy.wcs import WCS if wcsheader is None: # Go with the simplest valid header header = WCS({'CTYPE1': 'RA---TAN', 'CTYPE2': 'DEC--TAN', 'CRPIX1': int(image_shape[1] / 2), 'CRPIX2': int(image_shape[0] / 2)}, ).to_header() else: header = WCS(wcsheader) else: header = None image = fits.ImageHDU(image, header=header) return image def make_random_gaussians(n_sources, flux_range, xmean_range, ymean_range, xstddev_range, ystddev_range, amplitude_range=None, random_state=None): """ Make a `~astropy.table.Table` containing parameters for randomly generated 2D Gaussian sources. Each row of the table corresponds to a Gaussian source whose parameters are defined by the column names. The parameters are drawn from a uniform distribution over the specified input bounds. The output table can be input into `make_gaussian_sources` to create an image containing the 2D Gaussian sources. Parameters ---------- n_sources : float The number of random Gaussian sources to generate. flux_range : array-like The lower and upper boundaries, ``(lower, upper)``, of the uniform distribution from which to draw source fluxes. ``flux_range`` will be ignored if ``amplitude_range`` is input. xmean_range : array-like The lower and upper boundaries, ``(lower, upper)``, of the uniform distribution from which to draw source ``x_mean``. ymean_range : array-like The lower and upper boundaries, ``(lower, upper)``, of the uniform distribution from which to draw source ``y_mean``. xstddev_range : array-like The lower and upper boundaries, ``(lower, upper)``, of the uniform distribution from which to draw source ``x_stddev``. ystddev_range : array-like The lower and upper boundaries, ``(lower, upper)``, of the uniform distribution from which to draw source ``y_stddev``. amplitude_range : array-like, optional The lower and upper boundaries, ``(lower, upper)``, of the uniform distribution from which to draw source amplitudes. If ``amplitude_range`` is input, then ``flux_range`` will be ignored. random_state : int or `~numpy.random.RandomState`, optional Pseudo-random number generator state used for random sampling. Separate function calls with the same parameters and ``random_state`` will generate the identical sources. Returns ------- table : `~astropy.table.Table` A table of parameters for the randomly generated Gaussian sources. Each row of the table corresponds to a Gaussian source whose parameters are defined by the column names. The column names will include ``flux`` or ``amplitude``, ``x_mean``, ``y_mean``, ``x_stddev``, ``y_stddev``, and ``theta`` (see `~astropy.modeling.functional_models.Gaussian2D` for a description of most of these parameter names). See Also -------- make_gaussian_sources, make_noise_image, make_poisson_noise Examples -------- .. plot:: :include-source: # create the random sources from photutils.datasets import make_random_gaussians n_sources = 100 flux_range = [500, 1000] xmean_range = [0, 500] ymean_range = [0, 300] xstddev_range = [1, 5] ystddev_range = [1, 5] table = make_random_gaussians(n_sources, flux_range, xmean_range, ymean_range, xstddev_range, ystddev_range, random_state=12345) # make an image of the random sources without noise, with # Gaussian noise, and with Poisson noise from photutils.datasets import make_gaussian_sources from photutils.datasets import make_noise_image shape = (300, 500) image1 = make_gaussian_sources(shape, table) image2 = image1 + make_noise_image(shape, type='gaussian', mean=5., stddev=2.) image3 = image1 + make_noise_image(shape, type='poisson', mean=5.) # plot the images import matplotlib.pyplot as plt fig, (ax1, ax2, ax3) = plt.subplots(3, 1, figsize=(8, 12)) ax1.imshow(image1, origin='lower', interpolation='nearest') ax2.imshow(image2, origin='lower', interpolation='nearest') ax3.imshow(image3, origin='lower', interpolation='nearest') """ prng = check_random_state(random_state) sources = Table() if amplitude_range is None: sources['flux'] = prng.uniform(flux_range[0], flux_range[1], n_sources) else: sources['amplitude'] = prng.uniform(amplitude_range[0], amplitude_range[1], n_sources) sources['x_mean'] = prng.uniform(xmean_range[0], xmean_range[1], n_sources) sources['y_mean'] = prng.uniform(ymean_range[0], ymean_range[1], n_sources) sources['x_stddev'] = prng.uniform(xstddev_range[0], xstddev_range[1], n_sources) sources['y_stddev'] = prng.uniform(ystddev_range[0], ystddev_range[1], n_sources) sources['theta'] = prng.uniform(0, 2.*np.pi, n_sources) return sources def make_4gaussians_image(hdu=False, wcs=False, wcsheader=None): """ Make an example image containing four 2D Gaussians plus Gaussian noise. The background has a mean and standard deviation of 5. Parameters ---------- hdu : bool, optional If `True` returns ``image`` as an `~astropy.io.fits.ImageHDU` object. To include WCS information in the header, use the ``wcs`` and ``wcsheader`` inputs. Otherwise the header will be minimal. Default is `False`. wcs : bool, optional If `True` and ``hdu=True``, then a simple WCS will be included in the returned `~astropy.io.fits.ImageHDU` header. Default is `False`. wcsheader : dict or `None`, optional If ``hdu`` and ``wcs`` are `True`, this dictionary is passed to `~astropy.wcs.WCS` to generate the returned `~astropy.io.fits.ImageHDU` header. Returns ------- image : `~numpy.ndarray` or `~astropy.io.fits.ImageHDU` Image or `~astropy.io.fits.ImageHDU` containing Gaussian sources. See Also -------- make_100gaussians_image Examples -------- .. plot:: :include-source: from photutils import datasets image = datasets.make_4gaussians_image() plt.imshow(image, origin='lower', cmap='gray') """ table = Table() table['amplitude'] = [50, 70, 150, 210] table['x_mean'] = [160, 25, 150, 90] table['y_mean'] = [70, 40, 25, 60] table['x_stddev'] = [15.2, 5.1, 3., 8.1] table['y_stddev'] = [2.6, 2.5, 3., 4.7] table['theta'] = np.array([145., 20., 0., 60.]) * np.pi / 180. shape = (100, 200) sources = make_gaussian_sources(shape, table, hdu=hdu, wcs=wcs, wcsheader=wcsheader) noise = make_noise_image(shape, type='gaussian', mean=5., stddev=5., random_state=12345) if hdu is True: sources.data += noise data = sources else: data = (sources + noise) return data def make_100gaussians_image(): """ Make an example image containing 100 2D Gaussians plus Gaussian noise. The background has a mean of 5 and a standard deviation of 2. Returns ------- image : `~numpy.ndarray` Image containing Gaussian sources. See Also -------- make_4gaussians_image Examples -------- .. plot:: :include-source: from photutils import datasets image = datasets.make_100gaussians_image() plt.imshow(image, origin='lower', cmap='gray') """ n_sources = 100 flux_range = [500, 1000] xmean_range = [0, 500] ymean_range = [0, 300] xstddev_range = [1, 5] ystddev_range = [1, 5] table = make_random_gaussians(n_sources, flux_range, xmean_range, ymean_range, xstddev_range, ystddev_range, random_state=12345) shape = (300, 500) image1 = make_gaussian_sources(shape, table) image2 = image1 + make_noise_image(shape, type='gaussian', mean=5., stddev=2., random_state=12345) return image2 photutils-0.2.1/photutils/datasets/setup_package.py0000600000214200020070000000021012641263606024747 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst def get_package_data(): return {'photutils.datasets': ['data/*']} photutils-0.2.1/photutils/datasets/tests/0000700000214200020070000000000012646264032022730 5ustar lbradleySTSCI\science00000000000000photutils-0.2.1/photutils/datasets/tests/__init__.py0000600000214200020070000000000012346164012025023 0ustar lbradleySTSCI\science00000000000000photutils-0.2.1/photutils/datasets/tests/test_load.py0000600000214200020070000000121612413315656025263 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst from __future__ import (absolute_import, division, print_function, unicode_literals) from astropy.tests.helper import pytest, remote_data from .. import load, get_path def test_get_path(): with pytest.raises(ValueError): get_path('filename', location='invalid') def test_load_fermi_image(): hdu = load.load_fermi_image() assert len(hdu.header) == 81 assert hdu.data.shape == (201, 401) @remote_data def test_load_star_image(): hdu = load.load_star_image() assert len(hdu.header) == 104 assert hdu.data.shape == (1059, 1059) photutils-0.2.1/photutils/datasets/tests/test_make.py0000600000214200020070000001117412627615324025267 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst from __future__ import (absolute_import, division, print_function, unicode_literals) import numpy as np from numpy.testing import assert_allclose from astropy.tests.helper import pytest, assert_quantity_allclose from astropy.table import Table import astropy.units as u from .. import (make_noise_image, make_poisson_noise, make_gaussian_sources, make_random_gaussians, make_4gaussians_image, make_100gaussians_image) TABLE = Table() TABLE['flux'] = [1, 2, 3] TABLE['x_mean'] = [30, 50, 70.5] TABLE['y_mean'] = [50, 50, 50.5] TABLE['x_stddev'] = [1, 2, 3.5] TABLE['y_stddev'] = [2, 1, 3.5] TABLE['theta'] = np.array([0., 30, 50]) * np.pi / 180. def test_make_noise_image(): shape = (100, 100) image = make_noise_image(shape, 'gaussian', mean=0., stddev=2.) assert image.shape == shape assert_allclose(image.mean(), 0., atol=1.) def test_make_noise_image_poisson(): shape = (100, 100) image = make_noise_image(shape, 'poisson', mean=1.) assert image.shape == shape assert_allclose(image.mean(), 1., atol=1.) def test_make_noise_image_nomean(): """ Test if ValueError raises if mean is not input. """ with pytest.raises(ValueError): shape = (100, 100) make_noise_image(shape, 'gaussian', stddev=2.) def test_make_noise_image_nostddev(): """ Test if ValueError raises if stddev is not input for Gaussian noise. """ with pytest.raises(ValueError): shape = (100, 100) make_noise_image(shape, 'gaussian', mean=2.) def test_make_noise_image_unit(): shape = (100, 100) unit = u.electron / u.s image = make_noise_image(shape, 'gaussian', mean=0., stddev=2., unit=unit) assert image.shape == shape assert image.unit == unit assert_quantity_allclose(image.mean(), 0.*unit, atol=1.*unit) def test_make_poisson_noise(): shape = (100, 100) data = np.ones(shape) result = make_poisson_noise(data) assert result.shape == shape assert_allclose(result.mean(), 1., atol=1.) def test_make_poisson_noise_negative(): """Test if negative image values raises ValueError.""" with pytest.raises(ValueError): shape = (100, 100) data = np.zeros(shape) - 1. make_poisson_noise(data) def test_make_poisson_noise_unit(): shape = (100, 100) unit = u.electron / u.s data = np.ones(shape) * unit result = make_poisson_noise(data) assert result.shape == shape assert result.unit == unit assert_quantity_allclose(result.mean(), 1.*unit, atol=1.*unit) def test_make_gaussian_sources(): shape = (100, 100) image = make_gaussian_sources(shape, TABLE) assert image.shape == shape assert_allclose(image.sum(), TABLE['flux'].sum()) def test_make_gaussian_sources_amplitude(): table = TABLE.copy() table.remove_column('flux') table['amplitude'] = [1, 2, 3] shape = (100, 100) image = make_gaussian_sources(shape, table) assert image.shape == shape def test_make_gaussian_sources_oversample(): shape = (100, 100) image = make_gaussian_sources(shape, TABLE, oversample=10) assert image.shape == shape assert_allclose(image.sum(), TABLE['flux'].sum()) def test_make_gaussian_sources_parameters(): with pytest.raises(ValueError): table = TABLE.copy() table.remove_column('flux') shape = (100, 100) make_gaussian_sources(shape, table) def test_make_gaussian_sources_unit(): shape = (100, 100) unit = u.electron / u.s image = make_gaussian_sources(shape, TABLE, unit=unit) assert image.shape == shape assert image.unit == unit assert_quantity_allclose(image.sum(), TABLE['flux'].sum()*unit) def test_make_random_gaussians(): n_sources = 5 bounds = [0, 1] table = make_random_gaussians(n_sources, bounds, bounds, bounds, bounds, bounds) assert len(table) == n_sources def test_make_random_gaussians_amplitude(): n_sources = 5 bounds = [0, 1] table = make_random_gaussians(n_sources, bounds, bounds, bounds, bounds, bounds, amplitude_range=bounds) assert len(table) == n_sources def test_make_4gaussians_image(): shape = (100, 200) data_sum = 176219.18059091491 image = make_4gaussians_image() assert image.shape == shape assert_allclose(image.sum(), data_sum, rtol=1.e-6) def test_make_100gaussians_image(): shape = (300, 500) data_sum = 826182.24501251709 image = make_100gaussians_image() assert image.shape == shape assert_allclose(image.sum(), data_sum, rtol=1.e-6) photutils-0.2.1/photutils/detection/0000700000214200020070000000000012646264032021734 5ustar lbradleySTSCI\science00000000000000photutils-0.2.1/photutils/detection/__init__.py0000600000214200020070000000035512641136622024050 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst """ This subpackage contains modules and packages for identifying sources in an astronomical image. """ from .core import * from .deblend import * from .findstars import * photutils-0.2.1/photutils/detection/core.py0000600000214200020070000004230612646242520023243 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst """Functions for detecting sources in an astronomical image.""" from __future__ import (absolute_import, division, print_function, unicode_literals) from distutils.version import LooseVersion import numpy as np from astropy.table import Column, Table from astropy.stats import sigma_clipped_stats from ..segmentation import SegmentationImage from ..morphology import cutout_footprint, fit_2dgaussian from ..utils.convolution import _convolve_data from ..utils.wcs_helpers import pixel_to_icrs_coords import astropy if LooseVersion(astropy.__version__) < LooseVersion('1.1'): ASTROPY_LT_1P1 = True else: ASTROPY_LT_1P1 = False __all__ = ['detect_threshold', 'detect_sources', 'find_peaks'] def detect_threshold(data, snr, background=None, error=None, mask=None, mask_value=None, sigclip_sigma=3.0, sigclip_iters=None): """ Calculate a pixel-wise threshold image to be used to detect sources. Parameters ---------- data : array_like The 2D array of the image. snr : float The signal-to-noise ratio per pixel above the ``background`` for which to consider a pixel as possibly being part of a source. background : float or array_like, optional The background value(s) of the input ``data``. ``background`` may either be a scalar value or a 2D image with the same shape as the input ``data``. If the input ``data`` has been background-subtracted, then set ``background`` to ``0.0``. If `None`, then a scalar background value will be estimated using sigma-clipped statistics. error : float or array_like, optional The Gaussian 1-sigma standard deviation of the background noise in ``data``. ``error`` should include all sources of "background" error, but *exclude* the Poisson error of the sources. If ``error`` is a 2D image, then it should represent the 1-sigma background error in each pixel of ``data``. If `None`, then a scalar background rms value will be estimated using sigma-clipped statistics. mask : array_like, bool, optional A boolean mask with the same shape as ``data``, where a `True` value indicates the corresponding element of ``data`` is masked. Masked pixels are ignored when computing the image background statistics. mask_value : float, optional An image data value (e.g., ``0.0``) that is ignored when computing the image background statistics. ``mask_value`` will be ignored if ``mask`` is input. sigclip_sigma : float, optional The number of standard deviations to use as the clipping limit when calculating the image background statistics. sigclip_iters : float, optional The number of iterations to perform sigma clipping, or `None` to clip until convergence is achieved (i.e., continue until the last iteration clips nothing) when calculating the image background statistics. Returns ------- threshold : 2D `~numpy.ndarray` A 2D image with the same shape as ``data`` containing the pixel-wise threshold values. See Also -------- detect_sources Notes ----- The ``mask``, ``mask_value``, ``sigclip_sigma``, and ``sigclip_iters`` inputs are used only if it is necessary to estimate ``background`` or ``error`` using sigma-clipped background statistics. If ``background`` and ``error`` are both input, then ``mask``, ``mask_value``, ``sigclip_sigma``, and ``sigclip_iters`` are ignored. """ if background is None or error is None: # TODO: remove when astropy 1.1 is released if ASTROPY_LT_1P1: data_mean, data_median, data_std = sigma_clipped_stats( data, mask=mask, mask_val=mask_value, sigma=sigclip_sigma, iters=sigclip_iters) else: data_mean, data_median, data_std = sigma_clipped_stats( data, mask=mask, mask_value=mask_value, sigma=sigclip_sigma, iters=sigclip_iters) bkgrd_image = np.zeros_like(data) + data_mean bkgrdrms_image = np.zeros_like(data) + data_std if background is None: background = bkgrd_image else: if np.isscalar(background): background = np.zeros_like(data) + background else: if background.shape != data.shape: raise ValueError('If input background is 2D, then it ' 'must have the same shape as the input ' 'data.') if error is None: error = bkgrdrms_image else: if np.isscalar(error): error = np.zeros_like(data) + error else: if error.shape != data.shape: raise ValueError('If input error is 2D, then it ' 'must have the same shape as the input ' 'data.') return background + (error * snr) def detect_sources(data, threshold, npixels, filter_kernel=None, connectivity=8): """ Detect sources above a specified threshold value in an image and return a `~photutils.segmentation.SegmentationImage` object. Detected sources must have ``npixels`` connected pixels that are each greater than the ``threshold`` value. If the filtering option is used, then the ``threshold`` is applied to the filtered image. This function does not deblend overlapping sources. First use this function to detect sources followed by :func:`~photutils.detection.deblend_sources` to deblend sources. Parameters ---------- data : array_like The 2D array of the image. threshold : float or array-like The data value or pixel-wise data values to be used for the detection threshold. A 2D ``threshold`` must have the same shape as ``data``. See `detect_threshold` for one way to create a ``threshold`` image. npixels : int The number of connected pixels, each greater than ``threshold``, that an object must have to be detected. ``npixels`` must be a positive integer. filter_kernel : array-like (2D) or `~astropy.convolution.Kernel2D`, optional The 2D array of the kernel used to filter the image before thresholding. Filtering the image will smooth the noise and maximize detectability of objects with a shape similar to the kernel. connectivity : {4, 8}, optional The type of pixel connectivity used in determining how pixels are grouped into a detected source. The options are 4 or 8 (default). 4-connected pixels touch along their edges. 8-connected pixels touch along their edges or corners. For reference, SExtractor uses 8-connected pixels. Returns ------- segment_image : `~photutils.segmentation.SegmentationImage` A 2D segmentation image, with the same shape as ``data``, where sources are marked by different positive integer values. A value of zero is reserved for the background. See Also -------- detect_threshold, :class:`photutils.segmentation.SegmentationImage`, :func:`photutils.segmentation.source_properties` :func:`photutils.detection.deblend_sources` Examples -------- .. plot:: :include-source: # make a table of Gaussian sources from astropy.table import Table table = Table() table['amplitude'] = [50, 70, 150, 210] table['x_mean'] = [160, 25, 150, 90] table['y_mean'] = [70, 40, 25, 60] table['x_stddev'] = [15.2, 5.1, 3., 8.1] table['y_stddev'] = [2.6, 2.5, 3., 4.7] table['theta'] = np.array([145., 20., 0., 60.]) * np.pi / 180. # make an image of the sources with Gaussian noise from photutils.datasets import make_gaussian_sources from photutils.datasets import make_noise_image shape = (100, 200) sources = make_gaussian_sources(shape, table) noise = make_noise_image(shape, type='gaussian', mean=0., stddev=5., random_state=12345) image = sources + noise # detect the sources from photutils import detect_threshold, detect_sources threshold = detect_threshold(image, snr=3) from astropy.convolution import Gaussian2DKernel sigma = 3.0 / (2.0 * np.sqrt(2.0 * np.log(2.0))) # FWHM = 3 kernel = Gaussian2DKernel(sigma, x_size=3, y_size=3) kernel.normalize() segm = detect_sources(image, threshold, npixels=5, filter_kernel=kernel) # plot the image and the segmentation image import matplotlib.pyplot as plt fig, (ax1, ax2) = plt.subplots(2, 1, figsize=(8, 8)) ax1.imshow(image, origin='lower', interpolation='nearest') ax2.imshow(segm.data, origin='lower', interpolation='nearest') """ from scipy import ndimage if (npixels <= 0) or (int(npixels) != npixels): raise ValueError('npixels must be a positive integer, got ' '"{0}"'.format(npixels)) image = (_convolve_data( data, filter_kernel, mode='constant', fill_value=0.0, check_normalization=True) > threshold) if connectivity == 4: selem = ndimage.generate_binary_structure(2, 1) elif connectivity == 8: selem = ndimage.generate_binary_structure(2, 2) else: raise ValueError('Invalid connectivity={0}. ' 'Options are 4 or 8'.format(connectivity)) objlabels, nobj = ndimage.label(image, structure=selem) objslices = ndimage.find_objects(objlabels) # remove objects with less than npixels for objslice in objslices: objlabel = objlabels[objslice] obj_npix = len(np.where(objlabel.ravel() != 0)[0]) if obj_npix < npixels: objlabels[objslice] = 0 # relabel to make sequential label indices objlabels, nobj = ndimage.label(objlabels, structure=selem) return SegmentationImage(objlabels) def find_peaks(data, threshold, box_size=3, footprint=None, mask=None, border_width=None, npeaks=np.inf, subpixel=False, error=None, wcs=None): """ Find local peaks in an image that are above above a specified threshold value. Peaks are the maxima above the ``threshold`` within a local region. The regions are defined by either the ``box_size`` or ``footprint`` parameters. ``box_size`` defines the local region around each pixel as a square box. ``footprint`` is a boolean array where `True` values specify the region shape. If multiple pixels within a local region have identical intensities, then the coordinates of all such pixels are returned. Otherwise, there will be only one peak pixel per local region. Thus, the defined region effectively imposes a minimum separation between peaks (unless there are identical peaks within the region). When using subpixel precision (``subpixel=True``), then a cutout of the specified ``box_size`` or ``footprint`` will be taken centered on each peak and fit with a 2D Gaussian (plus a constant). In this case, the fitted local centroid and peak value (the Gaussian amplitude plus the background constant) will also be returned in the output table. Parameters ---------- data : array_like The 2D array of the image. threshold : float The data value to be used for the detection threshold. box_size : scalar or tuple, optional The size of the local region to search for peaks at every point in ``data``. If ``box_size`` is a scalar, then the region shape will be ``(box_size, box_size)``. Either ``box_size`` or ``footprint`` must be defined. If they are both defined, then ``footprint`` overrides ``box_size``. footprint : `~numpy.ndarray` of bools, optional A boolean array where `True` values describe the local footprint region within which to search for peaks at every point in ``data``. ``box_size=(n, m)`` is equivalent to ``footprint=np.ones((n, m))``. Either ``box_size`` or ``footprint`` must be defined. If they are both defined, then ``footprint`` overrides ``box_size``. mask : array_like, bool, optional A boolean mask with the same shape as ``data``, where a `True` value indicates the corresponding element of ``data`` is masked. border_width : bool, optional The width in pixels to exclude around the border of the ``data``. npeaks : int, optional The maximum number of peaks to return. When the number of detected peaks exceeds ``npeaks``, the peaks with the highest peak intensities will be returned. subpixel : bool, optional If `True`, then a cutout of the specified ``box_size`` or ``footprint`` will be taken centered on each peak and fit with a 2D Gaussian (plus a constant). In this case, the fitted local centroid and peak value (the Gaussian amplitude plus the background constant) will also be returned in the output table. error : array_like, optional The 2D array of the 1-sigma errors of the input ``data``. ``error`` is used only to weight the 2D Gaussian fit performed when ``subpixel=True``. wcs : `~astropy.wcs.WCS` The WCS transformation to use to convert from pixel coordinates to ICRS world coordinates. If `None`, then the world coordinates will not be returned in the output `~astropy.table.Table`. Returns ------- output : `~astropy.table.Table` A table containing the x and y pixel location of the peaks and their values. If ``subpixel=True``, then the table will also contain the local centroid and fitted peak value. """ from scipy import ndimage if np.all(data == data.flat[0]): return [] if footprint is not None: data_max = ndimage.maximum_filter(data, footprint=footprint, mode='constant', cval=0.0) else: data_max = ndimage.maximum_filter(data, size=box_size, mode='constant', cval=0.0) peak_goodmask = (data == data_max) # good pixels are True if mask is not None: mask = np.asanyarray(mask) if data.shape != mask.shape: raise ValueError('data and mask must have the same shape') peak_goodmask = np.logical_and(peak_goodmask, ~mask) if border_width is not None: for i in range(peak_goodmask.ndim): peak_goodmask = peak_goodmask.swapaxes(0, i) peak_goodmask[:border_width] = False peak_goodmask[-border_width:] = False peak_goodmask = peak_goodmask.swapaxes(0, i) peak_goodmask = np.logical_and(peak_goodmask, (data > threshold)) y_peaks, x_peaks = peak_goodmask.nonzero() peak_values = data[y_peaks, x_peaks] if len(x_peaks) > npeaks: idx = np.argsort(peak_values)[::-1][:npeaks] x_peaks = x_peaks[idx] y_peaks = y_peaks[idx] peak_values = peak_values[idx] if subpixel: x_centroid, y_centroid = [], [] fit_peak_values = [] for (y_peak, x_peak) in zip(y_peaks, x_peaks): rdata, rmask, rerror, slc = cutout_footprint( data, (x_peak, y_peak), box_size=box_size, footprint=footprint, mask=mask, error=error) gaussian_fit = fit_2dgaussian(rdata, mask=rmask, error=rerror) if gaussian_fit is None: x_cen, y_cen, fit_peak_value = np.nan, np.nan, np.nan else: x_cen = slc[1].start + gaussian_fit.x_mean_1.value y_cen = slc[0].start + gaussian_fit.y_mean_1.value fit_peak_value = (gaussian_fit.amplitude_0.value + gaussian_fit.amplitude_1.value) x_centroid.append(x_cen) y_centroid.append(y_cen) fit_peak_values.append(fit_peak_value) columns = (x_peaks, y_peaks, peak_values, x_centroid, y_centroid, fit_peak_values) names = ('x_peak', 'y_peak', 'peak_value', 'x_centroid', 'y_centroid', 'fit_peak_value') else: columns = (x_peaks, y_peaks, peak_values) names = ('x_peak', 'y_peak', 'peak_value') table = Table(columns, names=names) if wcs is not None: icrs_ra_peak, icrs_dec_peak = pixel_to_icrs_coords(x_peaks, y_peaks, wcs) table.add_column(Column(icrs_ra_peak, name='icrs_ra_peak'), index=2) table.add_column(Column(icrs_dec_peak, name='icrs_dec_peak'), index=3) if subpixel: icrs_ra_centroid, icrs_dec_centroid = pixel_to_icrs_coords( x_centroid, y_centroid, wcs) idx = table.colnames.index('y_centroid') table.add_column(Column(icrs_ra_centroid, name='icrs_ra_centroid'), index=idx+1) table.add_column(Column(icrs_dec_centroid, name='icrs_dec_centroid'), index=idx+2) return table photutils-0.2.1/photutils/detection/deblend.py0000600000214200020070000002563612641136622023717 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst """Functions for deblending sources.""" from __future__ import (absolute_import, division, print_function, unicode_literals) from copy import deepcopy import warnings import numpy as np from astropy.utils.exceptions import AstropyUserWarning from .core import _convolve_data, detect_sources from ..segmentation import SegmentationImage __all__ = ['deblend_sources'] def deblend_sources(data, segment_img, npixels, filter_kernel=None, labels=None, nlevels=32, contrast=0.001, mode='exponential', connectivity=8, relabel=True): """ Deblend overlapping sources labeled in a segmentation image. Sources are deblended using a combination of multi-thresholding and `watershed segmentation `_. In order to deblend sources, they must be separated enough such that there is a saddle between them. .. note:: This function is experimental. Please report any issues on the `Photutils GitHub issue tracker `_ Parameters ---------- data : array_like The 2D array of the image. segment_img : `~photutils.segmentation.SegmentationImage` or array_like (int) A 2D segmentation image, either as a `~photutils.segmentation.SegmentationImage` object or an `~numpy.ndarray`, with the same shape as ``data`` where sources are labeled by different positive integer values. A value of zero is reserved for the background. npixels : int The number of connected pixels, each greater than ``threshold``, that an object must have to be detected. ``npixels`` must be a positive integer. filter_kernel : array-like (2D) or `~astropy.convolution.Kernel2D`, optional The 2D array of the kernel used to filter the image before thresholding. Filtering the image will smooth the noise and maximize detectability of objects with a shape similar to the kernel. labels : int or array-like of int, optional The label numbers to deblend. If `None` (default), then all labels in the segmentation image will be deblended. nlevels : int, optional The number of multi-thresholding levels to use. Each source will be re-thresholded at ``nlevels``, spaced exponentially or linearly (see the ``mode`` keyword), between its minimum and maximum values within the source segment. contrast : float, optional The fraction of the total (blended) source flux that a local peak must have to be considered as a separate object. ``contrast`` must be between 0 and 1, inclusive. If ``contrast = 0`` then every local peak will be made a separate object (maximum deblending). If ``contrast = 1`` then no deblending will occur. The default is 0.001, which will deblend sources with a magnitude differences of about 7.5. mode : {'exponential', 'linear'}, optional The mode used in defining the spacing between the multi-thresholding levels (see the ``nlevels`` keyword). connectivity : {4, 8}, optional The type of pixel connectivity used in determining how pixels are grouped into a detected source. The options are 4 or 8 (default). 4-connected pixels touch along their edges. 8-connected pixels touch along their edges or corners. For reference, SExtractor uses 8-connected pixels. relabel : bool If `True` (default), then the segmentation image will be relabeled such that the labels are in sequential order starting from 1. Returns ------- segment_image : `~photutils.segmentation.SegmentationImage` A 2D segmentation image, with the same shape as ``data``, where sources are marked by different positive integer values. A value of zero is reserved for the background. See Also -------- :func:`photutils.detection.detect_sources` """ if not isinstance(segment_img, SegmentationImage): segment_img = SegmentationImage(segment_img) if segment_img.shape != data.shape: raise ValueError('The data and segmentation image must have ' 'the same shape') if labels is None: labels = segment_img.labels labels = np.atleast_1d(labels) data = _convolve_data(data, filter_kernel, mode='constant', fill_value=0.0) last_label = segment_img.max segm_deblended = deepcopy(segment_img) for label in labels: segment_img.check_label(label) source_slice = segment_img.slices[label - 1] source_data = data[source_slice] source_segm = SegmentationImage(np.copy( segment_img.data[source_slice])) source_segm.keep_labels(label) # include only one label source_deblended = _deblend_source( source_data, source_segm, npixels, nlevels=nlevels, contrast=contrast, mode=mode, connectivity=connectivity) if source_deblended.nlabels > 1: # replace the original source with the deblended source source_mask = (source_deblended.data > 0) segm_deblended._data[source_slice][source_mask] = ( source_deblended.data[source_mask] + last_label) last_label += source_deblended.nlabels if relabel: segm_deblended.relabel_sequential() return segm_deblended def _deblend_source(data, segment_img, npixels, nlevels=32, contrast=0.001, mode='exponential', connectivity=8): """ Deblend a single labeled source. Parameters ---------- data : array_like The 2D array of the image. The should be a cutout for a single source. ``data`` should already be smoothed by the same filter used in :func:`~photutils.detect_sources`, if applicable. segment_img : `~photutils.segmentation.SegmentationImage` A cutout `~photutils.segmentation.SegmentationImage` object with the same shape as ``data``. ``segment_img`` should contain only *one* source label. npixels : int The number of connected pixels, each greater than ``threshold``, that an object must have to be detected. ``npixels`` must be a positive integer. nlevels : int, optional The number of multi-thresholding levels to use. Each source will be re-thresholded at ``nlevels``, spaced exponentially or linearly (see the ``mode`` keyword), between its minimum and maximum values within the source segment. contrast : float, optional The fraction of the total (blended) source flux that a local peak must have to be considered as a separate object. ``contrast`` must be between 0 and 1, inclusive. If ``contrast = 0`` then every local peak will be made a separate object (maximum deblending). If ``contrast = 1`` then no deblending will occur. The default is 0.001, which will deblend sources with a magnitude differences of about 7.5. mode : {'exponential', 'linear'}, optional The mode used in defining the spacing between the multi-thresholding levels (see the ``nlevels`` keyword). connectivity : {4, 8}, optional The type of pixel connectivity used in determining how pixels are grouped into a detected source. The options are 4 or 8 (default). 4-connected pixels touch along their edges. 8-connected pixels touch along their edges or corners. For reference, SExtractor uses 8-connected pixels. Returns ------- segment_image : `~photutils.segmentation.SegmentationImage` A 2D segmentation image, with the same shape as ``data``, where sources are marked by different positive integer values. A value of zero is reserved for the background. """ from scipy import ndimage from skimage.morphology import watershed if nlevels < 1: raise ValueError('nlevels must be >= 1, got "{0}"'.format(nlevels)) if contrast < 0 or contrast > 1: raise ValueError('contrast must be >= 0 or <= 1, got ' '"{0}"'.format(contrast)) segm_mask = (segment_img.data > 0) source_values = data[segm_mask] source_min = np.min(source_values) source_max = np.max(source_values) if source_min == source_max: return segment_img # no deblending if source_min < 0: warnings.warn('Source "{0}" contains negative values, setting ' 'deblending mode to "linear"'.format( segment_img.labels[0]), AstropyUserWarning) mode = 'linear' source_sum = float(np.sum(source_values)) steps = np.arange(1., nlevels + 1) if mode == 'exponential': if source_min == 0: source_min = source_max * 0.01 thresholds = source_min * ((source_max / source_min) ** (steps / (nlevels + 1))) elif mode == 'linear': thresholds = source_min + ((source_max - source_min) / (nlevels + 1)) * steps else: raise ValueError('"{0}" is an invalid mode; mode must be ' '"exponential" or "linear"') # create top-down tree of local peaks segm_tree = [] for level in thresholds[::-1]: segm_tmp = detect_sources(data, level, npixels=npixels, connectivity=connectivity) if segm_tmp.nlabels >= 2: fluxes = [] for i in segm_tmp.labels: fluxes.append(np.sum(data[segm_tmp == i])) idx = np.where((np.array(fluxes) / source_sum) >= contrast)[0] if len(idx >= 2): segm_tree.append(segm_tmp) nbranch = len(segm_tree) if nbranch == 0: return segment_img else: for j in np.arange(nbranch - 1, 0, -1): intersect_mask = (segm_tree[j].data * segm_tree[j - 1].data).astype(bool) intersect_labels = np.unique(segm_tree[j].data[intersect_mask]) if segm_tree[j - 1].nlabels <= len(intersect_labels): segm_tree[j - 1] = segm_tree[j] else: # If a higher tree level has more peaks than in the # intersected label(s) with the level below, then remove # the intersected label(s) in the lower level, add the # higher level, and relabel. segm_tree[j].remove_labels(intersect_labels) new_segments = segm_tree[j].data + segm_tree[j - 1].data new_segm, nsegm = ndimage.label(new_segments) segm_tree[j - 1] = SegmentationImage(new_segm) return SegmentationImage(watershed(-data, segm_tree[0].data, mask=segment_img.data)) photutils-0.2.1/photutils/detection/findstars.py0000600000214200020070000007710012634600424024306 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst """Functions for detecting stars in an astronomical image.""" from __future__ import (absolute_import, division, print_function, unicode_literals) from collections import defaultdict import warnings import math import numpy as np from astropy.table import Column, Table from astropy.utils.exceptions import AstropyUserWarning from astropy.stats import gaussian_fwhm_to_sigma from .core import _convolve_data, find_peaks __all__ = ['daofind', 'irafstarfind'] def daofind(data, threshold, fwhm, ratio=1.0, theta=0.0, sigma_radius=1.5, sharplo=0.2, sharphi=1.0, roundlo=-1.0, roundhi=1.0, sky=0.0, exclude_border=False): """ Detect stars in an image using the DAOFIND algorithm. `DAOFIND`_ (`Stetson 1987; PASP 99, 191 `_) searches images for local density maxima that have a peak amplitude greater than ``threshold`` (approximately; ``threshold`` is applied to a convolved image) and have a size and shape similar to the defined 2D Gaussian kernel. The Gaussian kernel is defined by the ``fwhm``, ``ratio``, ``theta``, and ``sigma_radius`` input parameters. .. _DAOFIND: http://iraf.net/irafhelp.php?val=daofind&help=Help+Page ``daofind`` finds the object centroid by fitting the the marginal x and y 1D distributions of the Gaussian kernel to the marginal x and y distributions of the input (unconvolved) ``data`` image. ``daofind`` calculates the object roundness using two methods. The ``roundlo`` and ``roundhi`` bounds are applied to both measures of roundness. The first method (``roundness1``; called ``SROUND`` in `DAOFIND`_) is based on the source symmetry and is the ratio of a measure of the object's bilateral (2-fold) to four-fold symmetry. The second roundness statistic (``roundness2``; called ``GROUND`` in `DAOFIND`_) measures the ratio of the difference in the height of the best fitting Gaussian function in x minus the best fitting Gaussian function in y, divided by the average of the best fitting Gaussian functions in x and y. A circular source will have a zero roundness. An source extended in x or y will have a negative or positive roundness, respectively. The sharpness statistic measures the ratio of the difference between the height of the central pixel and the mean of the surrounding non-bad pixels in the convolved image, to the height of the best fitting Gaussian function at that point. Parameters ---------- data : array_like The 2D array of the image. threshold : float The absolute image value above which to select sources. fwhm : float The full-width half-maximum (FWHM) of the major axis of the Gaussian kernel in units of pixels. ratio : float, optional The ratio of the minor to major axis standard deviations of the Gaussian kernel. ``ratio`` must be strictly positive and less than or equal to 1.0. The default is 1.0 (i.e., a circular Gaussian kernel). theta : float, optional The position angle (in degrees) of the major axis of the Gaussian kernel measured counter-clockwise from the positive x axis. sigma_radius : float, optional The truncation radius of the Gaussian kernel in units of sigma (standard deviation) [``1 sigma = FWHM / (2.0*sqrt(2.0*log(2.0)))``]. sharplo : float, optional The lower bound on sharpness for object detection. sharphi : float, optional The upper bound on sharpness for object detection. roundlo : float, optional The lower bound on roundess for object detection. roundhi : float, optional The upper bound on roundess for object detection. sky : float, optional The background sky level of the image. Setting ``sky`` affects only the output values of the object ``peak``, ``flux``, and ``mag`` values. The default is 0.0, which should be used to replicate the results from `DAOFIND`_. exclude_border : bool, optional Set to `True` to exclude sources found within half the size of the convolution kernel from the image borders. The default is `False`, which is the mode used by `DAOFIND`_. Returns ------- table : `~astropy.table.Table` A table of found objects with the following parameters: * ``id``: unique object identification number. * ``xcentroid, ycentroid``: object centroid. * ``sharpness``: object sharpness. * ``roundness1``: object roundness based on symmetry. * ``roundness2``: object roundness based on marginal Gaussian fits. * ``npix``: number of pixels in the Gaussian kernel. * ``sky``: the input ``sky`` parameter. * ``peak``: the peak, sky-subtracted, pixel value of the object. * ``flux``: the object flux calculated as the peak density in the convolved image divided by the detection threshold. This derivation matches that of `DAOFIND`_ if ``sky`` is 0.0. * ``mag``: the object instrumental magnitude calculated as ``-2.5 * log10(flux)``. The derivation matches that of `DAOFIND`_ if ``sky`` is 0.0. See Also -------- irafstarfind Notes ----- For the convolution step, this routine sets pixels beyond the image borders to 0.0. The equivalent parameters in `DAOFIND`_ are ``boundary='constant'`` and ``constant=0.0``. References ---------- .. [1] Stetson, P. 1987; PASP 99, 191 (http://adsabs.harvard.edu/abs/1987PASP...99..191S) .. [2] http://iraf.net/irafhelp.php?val=daofind&help=Help+Page .. [3] http://stsdas.stsci.edu/cgi-bin/gethelp.cgi?daofind """ daofind_kernel = _FindObjKernel(fwhm, ratio, theta, sigma_radius) threshold *= daofind_kernel.relerr objs = _findobjs(data, threshold, daofind_kernel, exclude_border=exclude_border) tbl = _daofind_properties(objs, threshold, daofind_kernel, sky) if len(objs) == 0: warnings.warn('No sources were found.', AstropyUserWarning) return tbl # empty table table_mask = ((tbl['sharpness'] > sharplo) & (tbl['sharpness'] < sharphi) & (tbl['roundness1'] > roundlo) & (tbl['roundness1'] < roundhi) & (tbl['roundness2'] > roundlo) & (tbl['roundness2'] < roundhi)) tbl = tbl[table_mask] idcol = Column(name='id', data=np.arange(len(tbl)) + 1) tbl.add_column(idcol, 0) if len(tbl) == 0: warnings.warn('Sources were found, but none pass the sharpness and ' 'roundness criteria.', AstropyUserWarning) return tbl def irafstarfind(data, threshold, fwhm, sigma_radius=1.5, minsep_fwhm=2.5, sharplo=0.5, sharphi=2.0, roundlo=0.0, roundhi=0.2, sky=None, exclude_border=False): """ Detect stars in an image using IRAF's "starfind" algorithm. `starfind`_ searches images for local density maxima that have a peak amplitude greater than ``threshold`` above the local background and have a PSF full-width half-maximum similar to the input ``fwhm``. The objects' centroid, roundness (ellipticity), and sharpness are calculated using image moments. .. _starfind: http://iraf.net/irafhelp.php?val=starfind&help=Help+Page Parameters ---------- data : array_like The 2D array of the image. threshold : float The absolute image value above which to select sources. fwhm : float The full-width half-maximum (FWHM) of the 2D circular Gaussian kernel in units of pixels. minsep_fwhm : float, optional The minimum separation for detected objects in units of ``fwhm``. sigma_radius : float, optional The truncation radius of the Gaussian kernel in units of sigma (standard deviation) [``1 sigma = FWHM / 2.0*sqrt(2.0*log(2.0))``]. sharplo : float, optional The lower bound on sharpness for object detection. sharphi : float, optional The upper bound on sharpness for object detection. roundlo : float, optional The lower bound on roundess for object detection. roundhi : float, optional The upper bound on roundess for object detection. sky : float, optional The background sky level of the image. Inputing a ``sky`` value will override the background sky estimate. Setting ``sky`` affects only the output values of the object ``peak``, ``flux``, and ``mag`` values. The default is ``None``, which means the sky value will be estimated using the `starfind`_ method. exclude_border : bool, optional Set to `True` to exclude sources found within half the size of the convolution kernel from the image borders. The default is `False`, which is the mode used by `starfind`_. Returns ------- table : `~astropy.table.Table` A table of found objects with the following parameters: * ``id``: unique object identification number. * ``xcentroid, ycentroid``: object centroid (zero-based origin). * ``fwhm``: estimate of object FWHM from image moments. * ``sharpness``: object sharpness calculated from image moments. * ``roundness``: object ellipticity calculated from image moments. * ``pa``: object position angle in degrees from the positive x axis calculated from image moments. * ``npix``: number of pixels in the object used to calculate ``flux``. * ``sky``: the derived background sky value, unless ``sky`` was input. If ``sky`` was input, then that value overrides the background sky estimation. * ``peak``: the peak, sky-subtracted, pixel value of the object. * ``flux``: the object sky-subtracted flux, calculated by summing object pixels over the Gaussian kernel. The derivation matches that of `starfind`_ if ``sky`` is ``None``. * ``mag``: the object instrumental magnitude calculated as ``-2.5 * log10(flux)``. The derivation matches that of `starfind`_ if ``sky`` is ``None``. See Also -------- daofind Notes ----- For the convolution step, this routine sets pixels beyond the image borders to 0.0. The equivalent parameters in `starfind`_ are ``boundary='constant'`` and ``constant=0.0``. IRAF's `starfind`_ uses ``hwhmpsf``, ``fradius``, and ``sepmin`` as input parameters. The equivalent input values for ``irafstarfind`` are: * ``fwhm = hwhmpsf * 2`` * ``sigma_radius = fradius * sqrt(2.0*log(2.0))`` * ``minsep_fwhm = 0.5 * sepmin`` The main differences between ``daofind`` and ``irafstarfind`` are: * ``irafstarfind`` always uses a 2D circular Gaussian kernel, while ``daofind`` can use an elliptical Gaussian kernel. * ``irafstarfind`` calculates the objects' centroid, roundness, and sharpness using image moments. References ---------- .. [1] http://iraf.net/irafhelp.php?val=starfind&help=Help+Page .. [2] http://stsdas.stsci.edu/cgi-bin/gethelp.cgi?starfind """ starfind_kernel = _FindObjKernel(fwhm, ratio=1.0, theta=0.0, sigma_radius=sigma_radius) min_separation = max(2, int((fwhm * minsep_fwhm) + 0.5)) objs = _findobjs(data, threshold, starfind_kernel, min_separation=min_separation, exclude_border=exclude_border) tbl = _irafstarfind_properties(objs, starfind_kernel, sky) if len(objs) == 0: warnings.warn('No sources were found.', AstropyUserWarning) return tbl # empty table table_mask = ((tbl['sharpness'] > sharplo) & (tbl['sharpness'] < sharphi) & (tbl['roundness'] > roundlo) & (tbl['roundness'] < roundhi)) tbl = tbl[table_mask] idcol = Column(name='id', data=np.arange(len(tbl)) + 1) tbl.add_column(idcol, 0) if len(tbl) == 0: warnings.warn('Sources were found, but none pass the sharpness and ' 'roundness criteria.', AstropyUserWarning) return tbl def _findobjs(data, threshold, kernel, min_separation=None, exclude_border=False, local_peaks=True): """ Find sources in an image by convolving the image with the input kernel and selecting connected pixels above a given threshold. Parameters ---------- data : array_like The 2D array of the image. threshold : float The absolute image value above which to select sources. Note that this threshold is not the same threshold input to ``daofind`` or ``irafstarfind``. It should be multiplied by the kernel relerr. kernel : `_FindObjKernel` The convolution kernel. The dimensions should match those of the cutouts. The kernel should be normalized to zero sum. exclude_border : bool, optional Set to `True` to exclude sources found within half the size of the convolution kernel from the image borders. The default is `False`, which is the mode used by `DAOFIND`_ and `starfind`_. local_peaks : bool, optional Set to `True` to exactly match the `DAOFIND`_ method of finding local peaks. If `False`, then only one peak per thresholded segment will be used. Returns ------- objects : list of `_ImgCutout` A list of `_ImgCutout` objects containing the image cutout for each source. """ from scipy import ndimage x_kernradius = kernel.kern.shape[1] // 2 y_kernradius = kernel.kern.shape[0] // 2 if not exclude_border: # create a larger image padded by zeros ysize = int(data.shape[0] + (2. * y_kernradius)) xsize = int(data.shape[1] + (2. * x_kernradius)) data_padded = np.zeros((ysize, xsize)) data_padded[y_kernradius:y_kernradius + data.shape[0], x_kernradius:x_kernradius + data.shape[1]] = data data = data_padded convolved_data = _convolve_data(data, kernel.kern, mode='constant', fill_value=0.0, check_normalization=False) if not exclude_border: # keep border=0 in convolved data convolved_data[:y_kernradius, :] = 0. convolved_data[-y_kernradius:, :] = 0. convolved_data[:, :x_kernradius] = 0. convolved_data[:, -x_kernradius:] = 0. selem = ndimage.generate_binary_structure(2, 2) object_labels, nobjects = ndimage.label(convolved_data > threshold, structure=selem) objects = [] if nobjects == 0: return objects # find object peaks in the convolved data if local_peaks: # footprint overrides min_separation in find_peaks if min_separation is None: # daofind footprint = kernel.mask.astype(np.bool) else: from skimage.morphology import disk footprint = disk(min_separation) tbl = find_peaks(convolved_data, threshold, footprint=footprint) coords = np.transpose([tbl['y_peak'], tbl['x_peak']]) else: object_slices = ndimage.find_objects(object_labels) coords = [] for object_slice in object_slices: # thresholded_object is not the same size as the kernel thresholded_object = convolved_data[object_slice] ypeak, xpeak = np.unravel_index(thresholded_object.argmax(), thresholded_object.shape) xpeak += object_slice[1].start ypeak += object_slice[0].start coords.append((ypeak, xpeak)) for (ypeak, xpeak) in coords: # now extract the object from the data, centered on the peak # pixel in the convolved image, with the same size as the kernel x0 = xpeak - x_kernradius x1 = xpeak + x_kernradius + 1 y0 = ypeak - y_kernradius y1 = ypeak + y_kernradius + 1 if x0 < 0 or x1 > data.shape[1]: continue # pragma: no cover (isolated continue is never tested) if y0 < 0 or y1 > data.shape[0]: continue # pragma: no cover (isolated continue is never tested) object_data = data[y0:y1, x0:x1] object_convolved_data = convolved_data[y0:y1, x0:x1].copy() if not exclude_border: # correct for image padding x0 -= x_kernradius y0 -= y_kernradius imgcutout = _ImgCutout(object_data, object_convolved_data, x0, y0) objects.append(imgcutout) return objects def _irafstarfind_properties(imgcutouts, kernel, sky=None): """ Find the properties of each detected source, as defined by IRAF's ``starfind``. Parameters ---------- imgcutouts : list of `_ImgCutout` A list of `_ImgCutout` objects containing the image cutout for each source. kernel : `_FindObjKernel` The convolution kernel. The dimensions should match those of the cutouts. ``kernel.gkernel`` should have a peak pixel value of 1.0 and not contain any masked pixels. sky : float, optional The absolute sky level. If sky is ``None``, then a local sky level will be estimated (in a crude fashion). Returns ------- table : `~astropy.table.Table` A table of the objects' properties. """ result = defaultdict(list) for imgcutout in imgcutouts: if sky is None: skymask = ~kernel.mask.astype(np.bool) # 1=sky, 0=obj nsky = np.count_nonzero(skymask) if nsky == 0: meansky = imgcutout.data.max() - imgcutout.convdata.max() else: meansky = (imgcutout.data * skymask).sum() / nsky else: meansky = sky objvals = _irafstarfind_moments(imgcutout, kernel, meansky) for key, val in objvals.items(): result[key].append(val) names = ['xcentroid', 'ycentroid', 'fwhm', 'sharpness', 'roundness', 'pa', 'npix', 'sky', 'peak', 'flux', 'mag'] if len(result) == 0: for name in names: result[name] = [] table = Table(result, names=names) return table def _irafstarfind_moments(imgcutout, kernel, sky): """ Find the properties of each detected source, as defined by IRAF's ``starfind``. Parameters ---------- imgcutout : `_ImgCutout` The image cutout for a single detected source. kernel : `_FindObjKernel` The convolution kernel. The dimensions should match those of ``imgcutout``. ``kernel.gkernel`` should have a peak pixel value of 1.0 and not contain any masked pixels. sky : float The local sky level around the source. Returns ------- result : dict A dictionary of the object parameters. """ from skimage.measure import moments, moments_central result = defaultdict(list) img = np.array((imgcutout.data - sky) * kernel.mask) img = np.where(img > 0, img, 0) # starfind discards negative pixels if np.count_nonzero(img) <= 1: return {} m = moments(img, 1) result['xcentroid'] = m[1, 0] / m[0, 0] result['ycentroid'] = m[0, 1] / m[0, 0] result['npix'] = float(np.count_nonzero(img)) # float for easier testing result['sky'] = sky result['peak'] = np.max(img) flux = img.sum() result['flux'] = flux result['mag'] = -2.5 * np.log10(flux) mu = moments_central( img, result['ycentroid'], result['xcentroid'], 2) / m[0, 0] musum = mu[2, 0] + mu[0, 2] mudiff = mu[2, 0] - mu[0, 2] result['fwhm'] = 2.0 * np.sqrt(np.log(2.0) * musum) result['sharpness'] = result['fwhm'] / kernel.fwhm result['roundness'] = np.sqrt(mudiff**2 + 4.0*mu[1, 1]**2) / musum pa = 0.5 * np.arctan2(2.0 * mu[1, 1], mudiff) * (180.0 / np.pi) if pa < 0.0: pa += 180.0 result['pa'] = pa result['xcentroid'] += imgcutout.x0 result['ycentroid'] += imgcutout.y0 return result def _daofind_properties(imgcutouts, threshold, kernel, sky=0.0): """ Find the properties of each detected source, as defined by `DAOFIND`_. Parameters ---------- imgcutouts : list of `_ImgCutout` A list of `_ImgCutout` objects containing the image cutout for each source. threshold : float The absolute image value above which to select sources. kernel : `_FindObjKernel` The convolution kernel. The dimensions should match those of the objects in ``imgcutouts``. ``kernel.gkernel`` should have a peak pixel value of 1.0 and not contain any masked pixels. sky : float, optional The local sky level around the source. ``sky`` is used only to calculate the source peak value and flux. The default is 0.0. Returns ------- table : `~astropy.table.Table` A table of the object parameters. """ result = defaultdict(list) ykcen, xkcen = kernel.center for imgcutout in imgcutouts: convobj = imgcutout.convdata.copy() convobj[ykcen, xkcen] = 0.0 q1 = convobj[0:ykcen+1, xkcen+1:] q2 = convobj[0:ykcen, 0:xkcen+1] q3 = convobj[ykcen:, 0:xkcen] q4 = convobj[ykcen+1:, xkcen:] sum2 = -q1.sum() + q2.sum() - q3.sum() + q4.sum() sum4 = np.abs(convobj).sum() result['roundness1'].append(2.0 * sum2 / sum4) obj = imgcutout.data objpeak = obj[ykcen, xkcen] convpeak = imgcutout.convdata[ykcen, xkcen] npts = kernel.mask.sum() obj_masked = obj * kernel.mask objmean = (obj_masked.sum() - objpeak) / (npts - 1) # exclude peak sharp = (objpeak - objmean) / convpeak result['sharpness'].append(sharp) dx, dy, g_roundness = _daofind_centroid_roundness(obj, kernel) yc, xc = imgcutout.center result['xcentroid'].append(xc + dx) result['ycentroid'].append(yc + dy) result['roundness2'].append(g_roundness) result['sky'].append(sky) # DAOFIND uses sky=0 result['npix'].append(float(obj.size)) result['peak'].append(objpeak - sky) flux = (convpeak / threshold) - (sky * obj.size) result['flux'].append(flux) if flux <= 0: mag = np.nan else: mag = -2.5 * np.log10(flux) result['mag'].append(mag) names = ['xcentroid', 'ycentroid', 'sharpness', 'roundness1', 'roundness2', 'npix', 'sky', 'peak', 'flux', 'mag'] if len(result) == 0: for name in names: result[name] = [] table = Table(result, names=names) return table def _daofind_centroid_roundness(obj, kernel): """ Calculate the source (x, y) centroid and `DAOFIND`_ "GROUND" roundness statistic. `DAOFIND`_ finds the centroid by fitting 1D Gaussians (marginal x/y distributions of the kernel) to the marginal x/y distributions of the original (unconvolved) image. The roundness statistic measures the ratio of the difference in the height of the best fitting Gaussian function in x minus the best fitting Gaussian function in y, divided by the average of the best fitting Gaussian functions in x and y. A circular source will have a zero roundness. An source extended in x (y) will have a negative (positive) roundness. Parameters ---------- obj : array_like The 2D array of the source cutout. kernel : `_FindObjKernel` The convolution kernel. The dimensions should match those of ``obj``. ``kernel.gkernel`` should have a peak pixel value of 1.0 and not contain any masked pixels. Returns ------- dx, dy : float Fractional shift in x and y of the image centroid relative to the maximum pixel. g_roundness : float `DAOFIND`_ roundness (GROUND) statistic. """ dx, hx = _daofind_centroidfit(obj, kernel, axis=0) dy, hy = _daofind_centroidfit(obj, kernel, axis=1) g_roundness = 2.0 * (hx - hy) / (hx + hy) return dx, dy, g_roundness def _daofind_centroidfit(obj, kernel, axis): """ Find the source centroid along one axis by fitting a 1D Gaussian to the marginal x or y distribution of the unconvolved source data. Parameters ---------- obj : array_like The 2D array of the source cutout. kernel : `_FindObjKernel` The convolution kernel. The dimensions should match those of ``obj``. ``kernel.gkernel`` should have a peak pixel value of 1.0 and not contain any masked pixels. axis : {0, 1} The axis for which the centroid is computed: * 0: for the x axis * 1: for the y axis Returns ------- dx : float Fractional shift in x or y (depending on ``axis`` value) of the image centroid relative to the maximum pixel. hx : float Height of the best-fitting Gaussian to the marginal x or y (depending on ``axis`` value) distribution of the unconvolved source data. """ # define a triangular weighting function, peaked in the middle # and equal to one at the edge nyk, nxk = kernel.shape ykrad, xkrad = kernel.center ywtd, xwtd = np.mgrid[0:nyk, 0:nxk] xwt = xkrad - abs(xwtd - xkrad) + 1.0 ywt = ykrad - abs(ywtd - ykrad) + 1.0 if axis == 0: wt = xwt[0] wts = ywt ksize = nxk kernel_sigma = kernel.xsigma krad = ksize // 2 sumdx_vec = krad - np.arange(ksize) elif axis == 1: wt = ywt.T[0] wts = xwt ksize = nyk kernel_sigma = kernel.ysigma krad = ksize // 2 sumdx_vec = np.arange(ksize) - krad n = wt.sum() sg = (kernel.gkernel * wts).sum(axis) sumg = (wt * sg).sum() sumg2 = (wt * sg**2).sum() vec = krad - np.arange(ksize) dgdx = sg * vec sdgdx = (wt * dgdx).sum() sdgdx2 = (wt * dgdx**2).sum() sgdgdx = (wt * sg * dgdx).sum() sd = (obj * wts).sum(axis) sumd = (wt * sd).sum() sumgd = (wt * sg * sd).sum() sddgdx = (wt * sd * dgdx).sum() sumdx = (wt * sd * sumdx_vec).sum() # linear least-squares fit (data = sky + hx*gkernel) to find amplitudes denom = (n*sumg2 - sumg**2) hx = (n*sumgd - sumg*sumd) / denom # sky = (sumg2*sumd - sumg*sumgd) / denom dx = (sgdgdx - (sddgdx - sdgdx*sumd)) / (hx * sdgdx2 / kernel_sigma**2) hsize = (ksize / 2.) if abs(dx) > hsize: dx = 0 if sumd == 0: dx = 0.0 else: dx = float(sumdx / sumd) if abs(dx) > hsize: dx = 0.0 return dx, hx class _ImgCutout(object): """Class to hold image cutouts.""" def __init__(self, data, convdata, x0, y0): """ Parameters ---------- data : array_like The cutout 2D image from the input unconvolved 2D image. convdata : array_like The cutout 2D image from the convolved 2D image. x0, y0 : float Image coordinates of the lower left pixel of the cutout region. The pixel origin is (0, 0). """ self.data = data self.convdata = convdata self.x0 = x0 self.y0 = y0 @property def radius(self): return [size // 2 for size in self.data.shape] @property def center(self): yr, xr = self.radius return yr + self.y0, xr + self.x0 class _FindObjKernel(object): """ Calculate a 2D Gaussian density enhancement kernel. This kernel has negative wings and sums to zero. It is used by both `daofind` and `irafstarfind`. Parameters ---------- fwhm : float The full-width half-maximum (FWHM) of the major axis of the Gaussian kernel in units of pixels. ratio : float, optional The ratio of the minor to major axis standard deviations of the Gaussian kernel. ``ratio`` must be strictly positive and less than or equal to 1.0. The default is 1.0 (i.e., a circular Gaussian kernel). theta : float, optional The position angle (in degrees) of the major axis of the Gaussian kernel measured counter-clockwise from the positive x axis. sigma_radius : float, optional The truncation radius of the Gaussian kernel in units of sigma (standard deviation) [``1 sigma = FWHM / 2.0*sqrt(2.0*log(2.0))``]. The default is 1.5. Notes ----- The object attributes include the dimensions of the elliptical kernel and the coefficients of a 2D elliptical Gaussian function expressed as: ``f(x,y) = A * exp(-g(x,y))`` where ``g(x,y) = a*(x-x0)**2 + 2*b*(x-x0)*(y-y0) + c*(y-y0)**2`` References ---------- .. [1] http://en.wikipedia.org/wiki/Gaussian_function """ def __init__(self, fwhm, ratio=1.0, theta=0.0, sigma_radius=1.5): assert fwhm > 0, 'FWHM must be positive' assert ((ratio > 0) & (ratio <= 1)), \ 'ratio must be positive and less than 1' assert sigma_radius > 0, 'sigma_radius must be positive' self.fwhm = fwhm self.sigma_radius = sigma_radius self.ratio = ratio self.theta = theta self.theta_radians = np.deg2rad(self.theta) self.xsigma = self.fwhm * gaussian_fwhm_to_sigma self.ysigma = self.xsigma * self.ratio self.a = None self.b = None self.c = None self.f = None self.nx = None self.ny = None self.xc = None self.yc = None self.circrad = None self.ellrad = None self.gkernel = None self.mask = None self.npts = None self.kern = None self.relerr = None self.set_gausspars() self.mk_kern() @property def shape(self): return self.kern.shape @property def center(self): """Index of the kernel center.""" return [size // 2 for size in self.kern.shape] def set_gausspars(self): xsigma2 = self.xsigma**2 ysigma2 = self.ysigma**2 cost = np.cos(self.theta_radians) sint = np.sin(self.theta_radians) self.a = (cost**2 / (2.0 * xsigma2)) + (sint**2 / (2.0 * ysigma2)) self.b = 0.5 * cost * sint * (1.0/xsigma2 - 1.0/ysigma2) # CCW self.c = (sint**2 / (2.0 * xsigma2)) + (cost**2 / (2.0 * ysigma2)) # find the extent of an ellipse with radius = sigma_radius*sigma; # solve for the horizontal and vertical tangents of an ellipse # defined by g(x,y) = f self.f = self.sigma_radius**2 / 2.0 denom = self.a*self.c - self.b**2 self.nx = 2 * int(max(2, math.sqrt(self.c*self.f / denom))) + 1 self.ny = 2 * int(max(2, math.sqrt(self.a*self.f / denom))) + 1 return def mk_kern(self): yy, xx = np.mgrid[0:self.ny, 0:self.nx] self.xc = self.nx // 2 self.yc = self.ny // 2 self.circrad = np.sqrt((xx-self.xc)**2 + (yy-self.yc)**2) self.ellrad = (self.a*(xx-self.xc)**2 + 2.0*self.b*(xx-self.xc)*(yy-self.yc) + self.c*(yy-self.yc)**2) self.gkernel = np.exp(-self.ellrad) self.mask = np.where((self.ellrad <= self.f) | (self.circrad <= 2.0), 1, 0).astype(np.int16) self.npts = self.mask.sum() self.kern = self.gkernel * self.mask # normalize the kernel to zero sum (denom = variance * npts) denom = ((self.kern**2).sum() - (self.kern.sum()**2 / self.npts)) self.relerr = 1.0 / np.sqrt(denom) self.kern = (((self.kern - (self.kern.sum() / self.npts)) / denom) * self.mask) return photutils-0.2.1/photutils/detection/setup_package.py0000600000214200020070000000022312444404542025116 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst def get_package_data(): return {'photutils.detection.tests': ['data/*.txt']} photutils-0.2.1/photutils/detection/tests/0000700000214200020070000000000012646264032023076 5ustar lbradleySTSCI\science00000000000000photutils-0.2.1/photutils/detection/tests/__init__.py0000600000214200020070000000017112345377273025220 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst """ This packages contains affiliated package tests. """ photutils-0.2.1/photutils/detection/tests/data/0000700000214200020070000000000012646264032024007 5ustar lbradleySTSCI\science00000000000000photutils-0.2.1/photutils/detection/tests/data/daofind_test_thresh08.0_fwhm01.0.txt0000600000214200020070000000646412444404542032430 0ustar lbradleySTSCI\science00000000000000id xcentroid ycentroid sharpness roundness1 roundness2 npix sky peak flux mag 1 88.46990059776188 58.48886418244315 0.8762686366344555 0.5208952612806851 -0.4122721184034913 25.0 0.0 41.219046927862664 1.7835016184670074 -0.6281837694550259 2 327.4237440417888 65.44679142919296 0.9157937804266859 0.04525792010641404 0.7509409883712366 25.0 0.0 22.751918266079162 1.0446321071558946 -0.04740842477087964 3 35.3030291035496 100.99885418235492 0.9642784405023673 0.8997709899005626 0.4262749271277977 25.0 0.0 20.102985322609683 1.0144135507640197 -0.015537604949063939 4 207.35081374580741 114.17862428357554 0.8924335237573308 0.9346385083631819 -0.518807699686835 25.0 0.0 29.754644643579955 1.3969918280271438 -0.3629846640809128 5 290.43063459156474 113.06404861735642 0.898082603591199 -0.05099656208774482 -0.23165223978862307 25.0 0.0 46.446092373907746 1.900514493186413 -0.6971779646253444 6 200.92861884647542 131.13339385033788 0.9484922230198581 0.22387509766367475 -0.27402570026586753 25.0 0.0 35.98220832083827 1.0238148922854393 -0.025553606135659993 7 314.47263346346375 129.3969056629089 0.8887239985499058 -0.415497488077957 -0.981667389821615 25.0 0.0 37.2058611011273 1.462461712936029 -0.41271126282013204 8 10.651479210211352 141.89200443111378 0.8874321043149441 0.1038427584432066 0.6135710025317431 25.0 0.0 31.413937832962418 1.033701663235285 -0.035988037644573874 9 125.38583354043459 147.12287931014475 0.9045758881095933 0.018740208509969953 0.9822435679992049 25.0 0.0 47.21336918933935 1.6322194134762291 -0.5319463475288915 10 145.14914494499064 169.8101867232563 0.8849770368050671 0.15624574204422784 0.17519144635671952 25.0 0.0 83.38951276487094 5.207804548890224 -1.7916366915254869 11 394.08757117974244 186.3394174191881 0.8802050226751206 0.35607460226075754 0.09146988324132699 25.0 0.0 110.35005452953492 7.319441130206205 -2.161194805332651 12 206.70671685848117 198.52606581209523 0.8981872955879281 -0.914696580134408 0.03140476242070839 25.0 0.0 34.44956649698919 1.1330527665066235 -0.13562533880024377 13 48.107054682499836 199.00601737015663 0.8865292982659505 -0.25299384635714167 -0.29924860045592516 25.0 0.0 46.62575574744383 1.6718429529072263 -0.5579886972773125 14 426.0377480701111 211.01291166877795 0.8767982886712559 -0.18983407274095807 0.46718907337348503 25.0 0.0 76.36050307691691 4.157089774588257 -1.5469735085756775 15 256.89065375229984 218.8702651417756 0.8919076919119704 -0.6574612471815833 0.9250674332112004 25.0 0.0 31.145480617595414 1.3162412640878085 -0.29833875446097147 16 256.72686483357546 220.39592428590072 0.8657852930536363 -0.6868946128505259 0.7806774957564329 25.0 0.0 35.92343258547273 1.3961484705669713 -0.36232901226396025 17 10.748287200873916 224.20057800236486 0.8530832269725744 -0.6801043879386687 0.5439043607509917 25.0 0.0 55.76846840338447 2.9686701641588544 -1.1814048693326866 18 355.7777559665791 251.24144545680184 0.9076091250435318 0.03794133476381934 0.3071068705575514 25.0 0.0 34.568381338063475 1.194628367857395 -0.19308205841850107 19 140.49990182298185 275.4562630541407 0.8956136505852358 -0.12260502762650799 0.28058974799126774 25.0 0.0 29.39237884586493 1.0140636761486634 -0.015163066319055899 20 434.4873254828115 287.5722770696709 0.9358461422138549 0.7057077340015893 -0.2758037043682071 25.0 0.0 33.411944319652875 1.0657776539076416 -0.06916652543885461 photutils-0.2.1/photutils/detection/tests/data/daofind_test_thresh08.0_fwhm01.5.txt0000600000214200020070000001112212444404542032420 0ustar lbradleySTSCI\science00000000000000id xcentroid ycentroid sharpness roundness1 roundness2 npix sky peak flux mag 1 441.25133516377946 31.44957631443119 0.7184774674544862 0.2540826457659647 0.33820558007054197 25.0 0.0 30.239994137265167 1.0192109043077802 -0.020660153587305028 2 88.79813107802212 58.81911572547198 0.6412388176817487 0.5199389854407557 -0.44797314831347357 25.0 0.0 41.219046927862664 2.4129090339570833 -0.9563523735710178 3 327.7440399874977 64.66175083365357 0.8223868740403482 -0.11894585756005756 0.8073553959462378 25.0 0.0 22.751918266079162 1.1516880702259864 -0.15333717054005433 4 230.91695759765258 65.9894379571403 0.7813631775972321 0.4774209234454751 -0.05879164786084709 25.0 0.0 10.922343382751748 1.022964317973155 -0.02465121336733659 5 99.95188614111407 98.10665397029018 0.9127911170174968 0.5594087143983953 0.8968738122629868 25.0 0.0 24.984494810798402 1.0915006340968902 -0.09505998086117816 6 71.4226160551628 111.66081527853272 0.619266520607775 -0.05983418788263739 0.4400254302666273 25.0 0.0 35.0913969385426 1.2593500685848913 -0.2503661753928418 7 206.54934787497413 114.06617385814583 0.7025595284696313 0.9767349175473904 -0.5834171877869196 25.0 0.0 29.754644643579955 1.7568577222085846 -0.6118414797745659 8 290.7911753889566 113.64828526813636 0.7060267926521758 -0.07996579234428655 -0.22858041274721436 25.0 0.0 46.446092373907746 2.393405398069706 -0.9475406654982715 9 341.27356655729886 114.4587775240903 0.5829404636239032 -0.7700415392818774 -0.3323734952946145 25.0 0.0 28.65755220774481 1.1798300357956324 -0.17954862031485538 10 200.33443823023921 130.4136477492795 0.8372831521724797 0.22155345712781147 -0.23896573945028038 25.0 0.0 35.98220832083827 1.1482404524644518 -0.1500821074451444 11 313.52800888962287 129.7741880324062 0.6842530424213573 -0.3959581050304958 -0.9378705237493801 25.0 0.0 37.2058611011273 1.88054900173178 -0.6857116359467628 12 10.867021165882411 142.54063824155378 0.6947552024609119 0.11878849281679056 0.6710643184520064 25.0 0.0 31.413937832962418 1.3072195133461557 -0.29087130527521743 13 125.13873545366265 148.07110612241445 0.7149614754541866 -0.019729049737502204 0.9618448688309467 25.0 0.0 47.21336918933935 2.04451774222952 -0.776477209234867 14 344.82714268313856 166.27735480015838 0.5551520317059323 0.4640472588827457 -0.18830878258989417 25.0 0.0 27.631382749951754 1.025656792366861 -0.027505151167814216 15 145.04161669340027 168.43979551421813 0.6418746565917449 -0.02736696618181218 0.1153966295770878 25.0 0.0 82.74848117792747 6.884763660996454 -2.0947225911530913 16 394.65502401524253 187.37357173892647 0.6692365367195389 0.3413113809170677 0.08770438935586308 25.0 0.0 110.35005452953492 9.530860217374974 -2.44783025023155 17 480.1442854950754 188.34294135511698 0.9105534140545337 0.8093219184197902 0.9481584847725933 25.0 0.0 23.07234835743072 1.0771739794755455 -0.08071463480942372 18 48.67675424075205 200.4511294253465 0.637320895047539 -0.571948558370518 -0.3831872251686798 25.0 0.0 47.2892911443403 2.2190254912470717 -0.865405728140129 19 426.64088605663267 211.0035331399752 0.6532673887534252 -0.22682231797770286 0.43515782187184765 25.0 0.0 76.36050307691691 5.523929114370442 -1.8556202421835335 20 305.6288921959932 216.1599509336425 0.5855765105365481 -0.007370981867631505 0.3512345640013347 25.0 0.0 26.565020985170975 1.1775541535016305 -0.17745222161727764 21 257.6002296718719 217.77146625690213 0.6907143669914155 -0.6586594988741606 0.9959103449675526 25.0 0.0 31.145480617595414 1.6827007962410163 -0.5650172505850533 22 256.265775002328 220.7587474377063 0.6330394123373777 -0.6815183858246547 0.824192111519761 25.0 0.0 35.92343258547273 1.8904319045703657 -0.691402595542391 23 10.906589762292864 224.07169129851232 0.5915881373471015 -0.7302006348846717 0.4954582336704235 25.0 0.0 55.76846840338447 4.238223669541717 -1.5679596814822927 24 355.91280082770714 252.31749264525953 0.7520228837688127 0.008366802620332457 0.31569853010198345 25.0 0.0 34.568381338063475 1.4274161278306714 -0.38637649844105226 25 139.59065348749309 275.1884233884024 0.7154853585505654 -0.18441687745205232 0.2548543643003899 25.0 0.0 29.39237884586493 1.2567102535141665 -0.24808789627317712 26 121.14388458069425 284.8118762076604 0.7574664205028767 0.18170258067684428 0.16985955244315368 25.0 0.0 12.415425631454825 1.0092893140555754 -0.010039187860971983 27 433.5551160149825 288.4794012861741 0.8097201173279633 0.6995511520935703 -0.27322026456220144 25.0 0.0 33.411944319652875 1.2195121002893914 -0.21546528461092726 28 471.001033909076 297.8111400615592 0.7934292830937713 0.6600959397482591 0.23721748404523008 25.0 0.0 10.524420303596958 1.030199275938046 -0.032303100766317684 photutils-0.2.1/photutils/detection/tests/data/daofind_test_thresh08.0_fwhm02.0.txt0000600000214200020070000001163712415340320032416 0ustar lbradleySTSCI\science00000000000000id xcentroid ycentroid sharpness roundness1 roundness2 npix sky peak flux mag 1 441.3499172083869 31.402878654917814 0.6332823251229039 0.30085528401312445 0.3680354928019628 25.0 0.0 30.239994137265167 1.1572788429613632 -0.15859503387229676 2 0.8496908619052633 40.04305508436788 0.45619405869493956 -0.22810071231008808 0.7232872696244564 25.0 0.0 35.54828630019193 2.6662543983339755 -1.064753962208504 3 88.79956140550843 58.84568931520913 0.5582944988778225 0.5136344718362899 -0.4745844416283111 25.0 0.0 41.219046927862664 2.773675000415222 -1.1076389304199645 4 14.009742492766007 62.28240400026239 0.593724897815523 0.11641944621802239 0.15287632672275359 25.0 0.0 21.481924963251483 1.0271337239470224 -0.029067471679799464 5 327.70218373934637 64.7320262123344 0.8815643782278983 -0.25650986945379883 0.8672581850871744 25.0 0.0 22.751918266079162 1.0752641632256226 -0.07878792932136536 6 230.95864015413127 65.96089819494524 0.7532093773427389 0.5841683591471404 0.017434633001189193 25.0 0.0 10.922343382751748 1.062076683475109 -0.06538968642057963 7 7.328434526380554 69.5156220324513 0.5970223288209795 -0.9902229999019926 -0.36777328827511824 25.0 0.0 33.2880647048335 1.7553590999611413 -0.6109149375862932 8 99.90338602734467 97.94590143760601 0.9369113497949474 0.374463505034526 0.6482107118468855 25.0 0.0 24.984494810798402 1.0642779488426795 -0.0676376598520223 9 34.271919795938956 97.94540042765118 0.43062202850526665 0.9672893343791893 -0.1317036542420994 25.0 0.0 19.27625317566386 1.008392639521492 -0.009074167513830694 10 71.39201494648567 111.67855457865032 0.5196724941219817 -0.07293019182386253 0.3886579935129361 25.0 0.0 35.0913969385426 1.501939736999388 -0.44163126906439054 11 206.5524841594021 114.05764949550421 0.65064321348857 0.9917528207729931 -0.6371226317458737 25.0 0.0 29.754644643579955 1.8986065838796236 -0.696087456404153 12 290.81980079648145 113.6713740964111 0.6430087933779546 -0.09541554335946509 -0.2261751623126485 25.0 0.0 46.446092373907746 2.630139011027921 -1.0499467572765857 13 341.22590232689697 114.47439289227742 0.5191441535865722 -0.8605565678486781 -0.3979504981737904 25.0 0.0 28.65755220774481 1.325909399182182 -0.30628462318182176 14 313.4809249369467 129.79531153878077 0.6196365438299545 -0.36416701339821556 -0.9040072517542573 25.0 0.0 37.2058611011273 2.078368421780885 -0.7943063380385879 15 200.50844425205247 130.3249145251344 0.36839322322757534 0.09087190631722986 -0.22452517495084987 25.0 0.0 31.0622608687501 1.3149161534868317 -0.2972451515721313 16 10.872821371928692 142.50648812470342 0.6466298462154676 0.13850521836332988 0.718945864012764 25.0 0.0 31.413937832962418 1.4056679733123312 -0.36970687498996746 17 124.98844282543168 147.82993328621993 0.4556966042329859 -0.04138895629887515 0.67091498778985 25.0 0.0 45.57926969566492 2.325230959735237 -0.9161652420508276 18 344.7017528266213 166.2683042839413 0.4663098831416211 0.48104307824902254 -0.1252798314146538 25.0 0.0 27.631382749951754 1.2220741014411993 -0.21774385124610166 19 145.03763842687044 168.50637255629331 0.5701020092842325 -0.029731702887011314 0.10804684626541045 25.0 0.0 82.74848117792747 7.757912197426944 -2.2243621500740023 20 394.70347564634125 187.545695732136 0.6053888128969426 -0.17663263158596582 0.15140081222163074 25.0 0.0 111.07213962758318 10.54663671636893 -2.5577849669998876 21 480.1438082712454 188.24825828577048 0.961962354511558 0.7093991969108856 0.8500100573287711 25.0 0.0 23.07234835743072 1.0204491563081264 -0.021978427370778375 22 48.70622094028462 200.38639624622746 0.5563443241052142 -0.5730567456777012 -0.38716010778330917 25.0 0.0 47.2892911443403 2.544104543607104 -1.0138373839688648 23 426.68129895275075 210.99941585113444 0.5819568229039869 -0.25649780804993694 0.4101751816817609 25.0 0.0 76.36050307691691 6.205924359380613 -1.9820161947559602 24 305.66418356557824 216.1095259373655 0.49589375430169474 0.018404255168539715 0.40299126313766576 25.0 0.0 26.565020985170975 1.3916629465991646 -0.35883516046196595 25 10.914912580605002 224.06603573687934 0.5057191364084963 -0.7830489024133768 0.45914226256028107 25.0 0.0 55.76846840338447 4.961946854725386 -1.7391302710501153 26 355.83177174460354 252.09033401412367 0.5247423718988266 -0.01542369728380577 0.03998195526685211 25.0 0.0 35.77616395203726 1.6536995591431092 -0.5461415265566998 27 139.57526527495273 275.22358348387263 0.6714573499096007 -0.2016681835803816 0.23336192730652747 25.0 0.0 29.39237884586493 1.3402186094935478 -0.3179391100037833 28 121.14216985229885 284.808001888565 0.756547266010023 0.1816100396332748 0.29688354539695194 25.0 0.0 12.415425631454825 1.0113492584189694 -0.012252900872686396 29 433.3024759192166 288.60871367718977 0.4437378655853536 0.4050695181704022 -0.2599032109478057 25.0 0.0 29.897454380832716 1.3995809443498977 -0.36499505205356075 30 470.994349464043 297.7565141346699 0.7661467132938748 0.5285364269442019 0.10769026748619974 25.0 0.0 10.524420303596958 1.0677650194503476 -0.07118922259211052 photutils-0.2.1/photutils/detection/tests/data/daofind_test_thresh10.0_fwhm01.0.txt0000600000214200020070000000400612444404542032407 0ustar lbradleySTSCI\science00000000000000id xcentroid ycentroid sharpness roundness1 roundness2 npix sky peak flux mag 1 88.46990059776188 58.48886418244315 0.8762686366344555 0.5208952612806851 -0.4122721184034913 25.0 0.0 41.219046927862664 1.426801294773606 -0.38590873693488487 2 207.35081374580741 114.17862428357554 0.8924335237573308 0.9346385083631819 -0.518807699686835 25.0 0.0 29.754644643579955 1.117593462421715 -0.12070963156077162 3 290.43063459156474 113.06404861735642 0.898082603591199 -0.05099656208774482 -0.23165223978862307 25.0 0.0 46.446092373907746 1.5204115945491306 -0.45490293210520344 4 314.47263346346375 129.3969056629089 0.8887239985499058 -0.415497488077957 -0.981667389821615 25.0 0.0 37.2058611011273 1.169969370348823 -0.17043623029999083 5 125.38583354043459 147.12287931014475 0.9045758881095933 0.018740208509969953 0.9822435679992049 25.0 0.0 47.21336918933935 1.3057755307809833 -0.2896713150087505 6 145.14914494499064 169.8101867232563 0.8849770368050671 0.15624574204422784 0.17519144635671952 25.0 0.0 83.38951276487094 4.166243639112179 -1.5493616590053458 7 394.08757117974244 186.3394174191881 0.8802050226751206 0.35607460226075754 0.09146988324132699 25.0 0.0 110.35005452953492 5.855552904164964 -1.9189197728125098 8 48.107054682499836 199.00601737015663 0.8865292982659505 -0.25299384635714167 -0.29924860045592516 25.0 0.0 46.62575574744383 1.337474362325781 -0.31571366475717144 9 426.0377480701111 211.01291166877795 0.8767982886712559 -0.18983407274095807 0.46718907337348503 25.0 0.0 76.36050307691691 3.3256718196706054 -1.3046984760555367 10 256.89065375229984 218.8702651417756 0.8919076919119704 -0.6574612471815833 0.9250674332112004 25.0 0.0 31.145480617595414 1.0529930112702468 -0.05606372194083043 11 256.72686483357546 220.39592428590072 0.8657852930536363 -0.6868946128505259 0.7806774957564329 25.0 0.0 35.92343258547273 1.116918776453577 -0.12005397974381918 12 10.748287200873916 224.20057800236486 0.8530832269725744 -0.6801043879386687 0.5439043607509917 25.0 0.0 55.76846840338447 2.3749361313270834 -0.9391298368125456 photutils-0.2.1/photutils/detection/tests/data/daofind_test_thresh10.0_fwhm01.5.txt0000600000214200020070000000522312444404542032416 0ustar lbradleySTSCI\science00000000000000id xcentroid ycentroid sharpness roundness1 roundness2 npix sky peak flux mag 1 88.79813107802212 58.81911572547198 0.6412388176817487 0.5199389854407557 -0.44797314831347357 25.0 0.0 41.219046927862664 1.9303272271656666 -0.7140773410508767 2 71.4226160551628 111.66081527853272 0.619266520607775 -0.05983418788263739 0.4400254302666273 25.0 0.0 35.0913969385426 1.007480054867913 -0.008091142872700756 3 206.54934787497413 114.06617385814583 0.7025595284696313 0.9767349175473904 -0.5834171877869196 25.0 0.0 29.754644643579955 1.405486177766868 -0.3695664472544251 4 290.7911753889566 113.64828526813636 0.7060267926521758 -0.07996579234428655 -0.22858041274721436 25.0 0.0 46.446092373907746 1.914724318455765 -0.7052656329781305 5 313.52800888962287 129.7741880324062 0.6842530424213573 -0.3959581050304958 -0.9378705237493801 25.0 0.0 37.2058611011273 1.504439201385424 -0.4434366034266216 6 10.867021165882411 142.54063824155378 0.6947552024609119 0.11878849281679056 0.6710643184520064 25.0 0.0 31.413937832962418 1.0457756106769245 -0.04859627275507633 7 125.13873545366265 148.07110612241445 0.7149614754541866 -0.019729049737502204 0.9618448688309467 25.0 0.0 47.21336918933935 1.6356141937836162 -0.5342021767147259 8 145.04161669340027 168.43979551421813 0.6418746565917449 -0.02736696618181218 0.1153966295770878 25.0 0.0 82.74848117792747 5.507810928797164 -1.8524475586329505 9 394.65502401524253 187.37357173892647 0.6692365367195389 0.3413113809170677 0.08770438935586308 25.0 0.0 110.35005452953492 7.62468817389998 -2.2055552177114084 10 48.67675424075205 200.4511294253465 0.637320895047539 -0.571948558370518 -0.3831872251686798 25.0 0.0 47.2892911443403 1.7752203929976573 -0.6231306956199879 11 426.64088605663267 211.0035331399752 0.6532673887534252 -0.22682231797770286 0.43515782187184765 25.0 0.0 76.36050307691691 4.419143291496353 -1.6133452096633925 12 257.6002296718719 217.77146625690213 0.6907143669914155 -0.6586594988741606 0.9959103449675526 25.0 0.0 31.145480617595414 1.346160636992813 -0.32274221806491205 13 256.265775002328 220.7587474377063 0.6330394123373777 -0.6815183858246547 0.824192111519761 25.0 0.0 35.92343258547273 1.5123455236562926 -0.4491275630222501 14 10.906589762292864 224.07169129851232 0.5915881373471015 -0.7302006348846717 0.4954582336704235 25.0 0.0 55.76846840338447 3.3905789356333735 -1.3256846489621514 15 355.91280082770714 252.31749264525953 0.7520228837688127 0.008366802620332457 0.31569853010198345 25.0 0.0 34.568381338063475 1.1419329022645373 -0.14410146592091136 16 139.59065348749309 275.1884233884024 0.7154853585505654 -0.18441687745205232 0.2548543643003899 25.0 0.0 29.39237884586493 1.0053682028113333 -0.00581286375303618 photutils-0.2.1/photutils/detection/tests/data/daofind_test_thresh10.0_fwhm02.0.txt0000600000214200020070000000645712444404542032424 0ustar lbradleySTSCI\science00000000000000id xcentroid ycentroid sharpness roundness1 roundness2 npix sky peak flux mag 1 0.8496908619052633 40.04305508436788 0.45619405869493956 -0.22810071231008808 0.7232872696244564 25.0 0.0 35.54828630019193 2.1330035186671803 -0.8224789296883628 2 88.79956140550843 58.84568931520913 0.5582944988778225 0.5136344718362899 -0.4745844416283111 25.0 0.0 41.219046927862664 2.2189400003321778 -0.8653638978998236 3 7.328434526380554 69.5156220324513 0.5970223288209795 -0.9902229999019926 -0.36777328827511824 25.0 0.0 33.2880647048335 1.404287279968913 -0.3686399050661522 4 71.39201494648567 111.67855457865032 0.5196724941219817 -0.07293019182386253 0.3886579935129361 25.0 0.0 35.0913969385426 1.2015517895995103 -0.19935623654424928 5 206.5524841594021 114.05764949550421 0.65064321348857 0.9917528207729931 -0.6371226317458737 25.0 0.0 29.754644643579955 1.5188852671036988 -0.45381242388401194 6 290.81980079648145 113.6713740964111 0.6430087933779546 -0.09541554335946509 -0.2261751623126485 25.0 0.0 46.446092373907746 2.1041112088223364 -0.8076717247564446 7 341.22590232689697 114.47439289227742 0.5191441535865722 -0.8605565678486781 -0.3979504981737904 25.0 0.0 28.65755220774481 1.0607275193457455 -0.0640095906616806 8 313.4809249369467 129.79531153878077 0.6196365438299545 -0.36416701339821556 -0.9040072517542573 25.0 0.0 37.2058611011273 1.662694737424708 -0.5520313055184468 9 200.50844425205247 130.3249145251344 0.36839322322757534 0.09087190631722986 -0.22452517495084987 25.0 0.0 31.0622608687501 1.0519329227894652 -0.0549701190519901 10 10.872821371928692 142.50648812470342 0.6466298462154676 0.13850521836332988 0.718945864012764 25.0 0.0 31.413937832962418 1.124534378649865 -0.12743184246982645 11 124.98844282543168 147.82993328621993 0.4556966042329859 -0.04138895629887515 0.67091498778985 25.0 0.0 45.57926969566492 1.8601847677881895 -0.6738902095306866 12 145.03763842687044 168.50637255629331 0.5701020092842325 -0.029731702887011314 0.10804684626541045 25.0 0.0 82.74848117792747 6.206329757941555 -1.9820871175538612 13 394.70347564634125 187.545695732136 0.6053888128969426 -0.17663263158596582 0.15140081222163074 25.0 0.0 111.07213962758318 8.437309373095143 -2.315509934479746 14 48.70622094028462 200.38639624622746 0.5563443241052142 -0.5730567456777012 -0.38716010778330917 25.0 0.0 47.2892911443403 2.035283634885683 -0.7715623514487234 15 426.68129895275075 210.99941585113444 0.5819568229039869 -0.25649780804993694 0.4101751816817609 25.0 0.0 76.36050307691691 4.96473948750449 -1.7397411622358192 16 305.66418356557824 216.1095259373655 0.49589375430169474 0.018404255168539715 0.40299126313766576 25.0 0.0 26.565020985170975 1.1133303572793316 -0.11656012794182484 17 10.914912580605002 224.06603573687934 0.5057191364084963 -0.7830489024133768 0.45914226256028107 25.0 0.0 55.76846840338447 3.9695574837803087 -1.4968552385299745 18 355.83177174460354 252.09033401412367 0.5247423718988266 -0.01542369728380577 0.03998195526685211 25.0 0.0 35.77616395203726 1.3229596473144873 -0.3038664940365588 19 139.57526527495273 275.22358348387263 0.6714573499096007 -0.2016681835803816 0.23336192730652747 25.0 0.0 29.39237884586493 1.072174887594838 -0.07566407748364207 20 433.3024759192166 288.60871367718977 0.4437378655853536 0.4050695181704022 -0.2599032109478057 25.0 0.0 29.897454380832716 1.1196647554799182 -0.12272001953341974 photutils-0.2.1/photutils/detection/tests/data/irafstarfind_test_thresh08.0_fwhm01.0.txt0000600000214200020070000000232312415340320033455 0ustar lbradleySTSCI\science00000000000000id xcentroid ycentroid fwhm sharpness roundness pa npix sky peak flux mag 1 333.32967620268926 0.4922715732671872 1.2389649115388133 1.2389649115388133 0.1632730683139897 26.751332591232657 5.0 2.757612577414644 7.470385598813738 17.87026271806645 -3.1303273432349914 2 145.0334216330022 168.39799687136576 1.8918921328609848 1.8918921328609848 0.028604480029024524 118.25194333308633 12.0 16.46507005975501 66.92444270511594 406.86074671794165 -6.523614479572233 3 394.7628492905675 187.59049488469253 1.8259269954390203 1.8259269954390203 0.10712610861905057 131.1948064263936 11.0 20.151710346274722 90.92042928130846 527.6471044360048 -6.80585889802106 4 89.21399519459558 198.23805598325862 1.9699369976778611 1.9699369976778611 0.140512496831343 139.49061946497739 10.0 5.046355096294733 8.916265520602554 20.380914697547418 -3.2730591782220264 5 355.940683491333 251.70235184396 1.7522952194564725 1.7522952194564725 0.11598331430783908 52.09576852830077 10.0 19.585761501344383 16.190402450692876 88.75108703293594 -4.870434202614015 6 378.5365504434283 273.08553439796117 1.9282124502623856 1.9282124502623856 0.09786276609110564 14.700858135363946 8.0 4.744381064470213 8.45586154664661 18.53113999199971 -3.1697553422808005 photutils-0.2.1/photutils/detection/tests/data/irafstarfind_test_thresh08.0_fwhm01.5.txt0000600000214200020070000000504312415340320033464 0ustar lbradleySTSCI\science00000000000000id xcentroid ycentroid fwhm sharpness roundness pa npix sky peak flux mag 1 333.32967620268926 0.4922715732671872 1.2389649115388133 0.8259766076925422 0.1632730683139897 26.751332591232657 5.0 2.757612577414644 7.470385598813738 17.87026271806645 -3.1303273432349914 2 230.98520543324977 65.96062094855215 1.1045257887737336 0.7363505258491557 0.08474087768196263 175.16563683708682 7.0 4.906490485436556 6.015852897315193 10.355696896573836 -2.5379483261935247 3 71.21785006913522 111.76487474565829 2.041287275833218 1.360858183888812 0.13679659319094278 77.80260478241559 11.0 21.001696161595063 14.089700776947538 107.15742741630842 -5.075055696823615 4 290.88594008616707 113.76868287298815 2.0132511884469353 1.3421674589646235 0.09921593553744701 172.63151133250068 12.0 21.19225795812126 25.253834415786486 157.2638285640319 -5.491572110730435 5 200.23683161129125 130.21911528245474 2.068730352200946 1.3791535681339642 0.0772733520073215 8.31574194223727 13.0 20.931309472117615 15.050898848720653 96.98092311348633 -4.966715784084392 6 344.3860440796261 166.22517276873882 1.8853557992763632 1.2569038661842422 0.11363886565891375 142.91674058093935 11.0 18.685078458637985 11.30249791672627 62.9878292683161 -4.498141604100731 7 145.04228403850357 168.6571618278717 1.9066993974327817 1.2711329316218545 0.01132060172865575 34.75701626174368 12.0 16.35083410366516 67.03867866120578 413.9858186416701 -6.5424636608266695 8 394.7628492905675 187.59049488469253 1.8259269954390203 1.2172846636260135 0.10712610861905057 131.1948064263936 11.0 20.151710346274722 90.92042928130846 527.6471044360048 -6.80585889802106 9 243.47516596181347 197.2493890490569 1.7827428108977648 1.1884952072651764 0.17856028127225676 98.90230482066524 8.0 14.345012293985468 8.2293190831917 34.45785068493779 -3.843220461887511 10 439.9142185199256 197.98835995057703 1.431190377976779 0.9541269186511859 0.14568617232313683 165.69248581691983 8.0 5.521741711694806 6.475686441345677 12.410831724229434 -2.734502217876459 11 48.84191877412477 200.23603953697418 2.044906279964065 1.3632708533093767 0.15397555058991969 8.669913148933764 13.0 21.891667190520494 25.397623953819803 185.00884809430943 -5.667981247854074 12 305.8226567441267 215.56678011460988 1.8118994096837677 1.2079329397891785 0.15302459233581697 71.90351161795856 10.0 16.561617853554058 12.39941531540315 70.11439579638966 -4.614517989747707 13 355.940683491333 251.70235184396 1.7522952194564725 1.1681968129709817 0.11598331430783908 52.09576852830077 10.0 19.585761501344383 16.190402450692876 88.75108703293594 -4.870434202614015 photutils-0.2.1/photutils/detection/tests/data/irafstarfind_test_thresh08.0_fwhm02.0.txt0000600000214200020070000000616512415340320033466 0ustar lbradleySTSCI\science00000000000000id xcentroid ycentroid fwhm sharpness roundness pa npix sky peak flux mag 1 0.9463803041037677 40.05930171275073 2.1172882811901297 1.0586441405950648 0.15700998967332774 103.73294282811226 12.0 12.639904993835687 22.908381306356247 185.7046678317134 -5.672057050519047 2 13.990504104618 62.55334108277186 1.9112198263358675 0.9556099131679338 0.15520530817401776 50.54366391030623 11.0 13.70300905281337 7.8569227383370634 45.67009375413011 -4.14907975787997 3 230.98520543324977 65.96062094855215 1.1045257887737336 0.5522628943868668 0.08474087768196263 175.16563683708682 7.0 4.906490485436556 6.015852897315193 10.355696896573836 -2.5379483261935247 4 71.21785006913522 111.76487474565829 2.041287275833218 1.020643637916609 0.13679659319094278 77.80260478241559 11.0 21.001696161595063 14.089700776947538 107.15742741630842 -5.075055696823615 5 290.88594008616707 113.76868287298815 2.0132511884469353 1.0066255942234676 0.09921593553744701 172.63151133250068 12.0 21.19225795812126 25.253834415786486 157.2638285640319 -5.491572110730435 6 476.3854019214201 123.17381910435793 1.9095864585977254 0.9547932292988627 0.049460563907413366 141.18558248492255 10.0 13.976425258573249 7.392939939729255 49.30462300038852 -4.232219105973428 7 344.3860440796261 166.22517276873882 1.8853557992763632 0.9426778996381816 0.11363886565891375 142.91674058093935 11.0 18.685078458637985 11.30249791672627 62.9878292683161 -4.498141604100731 8 145.04228403850357 168.6571618278717 1.9066993974327817 0.9533496987163909 0.01132060172865575 34.75701626174368 12.0 16.35083410366516 67.03867866120578 413.9858186416701 -6.5424636608266695 9 433.96150057644644 172.11618975119973 1.5605837424622429 0.7802918712311214 0.09193780106796648 95.87470166499466 8.0 4.626744929765067 5.595633376366347 17.514050923880667 -3.1084665203219473 10 394.77243654370204 187.3653258347458 1.8382851657518942 0.9191425828759471 0.07664537864845197 57.84086299955225 11.0 20.06339188622815 91.00874774135504 535.3679088447971 -6.821630837610465 11 243.47516596181347 197.2493890490569 1.7827428108977648 0.8913714054488824 0.17856028127225676 98.90230482066524 8.0 14.345012293985468 8.2293190831917 34.45785068493779 -3.843220461887511 12 439.9142185199256 197.98835995057703 1.431190377976779 0.7155951889883895 0.14568617232313683 165.69248581691983 8.0 5.521741711694806 6.475686441345677 12.410831724229434 -2.734502217876459 13 48.84191877412477 200.23603953697418 2.044906279964065 1.0224531399820325 0.15397555058991969 8.669913148933764 13.0 21.891667190520494 25.397623953819803 185.00884809430943 -5.667981247854074 14 305.8226567441267 215.56678011460988 1.8118994096837677 0.9059497048418839 0.15302459233581697 71.90351161795856 10.0 16.561617853554058 12.39941531540315 70.11439579638966 -4.614517989747707 15 292.1680865716507 245.66007865305278 1.9132639276510426 0.9566319638255213 0.13981297941973697 131.64176988617768 12.0 17.382922811106205 26.281111155294354 151.39790010868757 -5.450299628835927 16 355.815359095706 252.07315473269793 2.040873269492875 1.0204366347464375 0.04014555235557765 166.92243604044648 13.0 20.266399267107513 15.509764684929745 112.63065620256117 -5.129141535958461 photutils-0.2.1/photutils/detection/tests/data/irafstarfind_test_thresh10.0_fwhm01.0.txt0000600000214200020070000000121612415340320033446 0ustar lbradleySTSCI\science00000000000000id xcentroid ycentroid fwhm sharpness roundness pa npix sky peak flux mag 1 145.0334216330022 168.39799687136576 1.8918921328609848 1.8918921328609848 0.028604480029024524 118.25194333308633 12.0 16.46507005975501 66.92444270511594 406.86074671794165 -6.523614479572233 2 394.7628492905675 187.59049488469253 1.8259269954390203 1.8259269954390203 0.10712610861905057 131.1948064263936 11.0 20.151710346274722 90.92042928130846 527.6471044360048 -6.80585889802106 3 355.940683491333 251.70235184396 1.7522952194564725 1.7522952194564725 0.11598331430783908 52.09576852830077 10.0 19.585761501344383 16.190402450692876 88.75108703293594 -4.870434202614015 photutils-0.2.1/photutils/detection/tests/data/irafstarfind_test_thresh10.0_fwhm01.5.txt0000600000214200020070000000262712415340320033462 0ustar lbradleySTSCI\science00000000000000id xcentroid ycentroid fwhm sharpness roundness pa npix sky peak flux mag 1 71.21785006913522 111.76487474565829 2.041287275833218 1.360858183888812 0.13679659319094278 77.80260478241559 11.0 21.001696161595063 14.089700776947538 107.15742741630842 -5.075055696823615 2 290.88594008616707 113.76868287298815 2.0132511884469353 1.3421674589646235 0.09921593553744701 172.63151133250068 12.0 21.19225795812126 25.253834415786486 157.2638285640319 -5.491572110730435 3 145.04228403850357 168.6571618278717 1.9066993974327817 1.2711329316218545 0.01132060172865575 34.75701626174368 12.0 16.35083410366516 67.03867866120578 413.9858186416701 -6.5424636608266695 4 394.7628492905675 187.59049488469253 1.8259269954390203 1.2172846636260135 0.10712610861905057 131.1948064263936 11.0 20.151710346274722 90.92042928130846 527.6471044360048 -6.80585889802106 5 48.84191877412477 200.23603953697418 2.044906279964065 1.3632708533093767 0.15397555058991969 8.669913148933764 13.0 21.891667190520494 25.397623953819803 185.00884809430943 -5.667981247854074 6 305.8226567441267 215.56678011460988 1.8118994096837677 1.2079329397891785 0.15302459233581697 71.90351161795856 10.0 16.561617853554058 12.39941531540315 70.11439579638966 -4.614517989747707 7 355.940683491333 251.70235184396 1.7522952194564725 1.1681968129709817 0.11598331430783908 52.09576852830077 10.0 19.585761501344383 16.190402450692876 88.75108703293594 -4.870434202614015 photutils-0.2.1/photutils/detection/tests/data/irafstarfind_test_thresh10.0_fwhm02.0.txt0000600000214200020070000000374712415340321033463 0ustar lbradleySTSCI\science00000000000000id xcentroid ycentroid fwhm sharpness roundness pa npix sky peak flux mag 1 0.9463803041037677 40.05930171275073 2.1172882811901297 1.0586441405950648 0.15700998967332774 103.73294282811226 12.0 12.639904993835687 22.908381306356247 185.7046678317134 -5.672057050519047 2 71.21785006913522 111.76487474565829 2.041287275833218 1.020643637916609 0.13679659319094278 77.80260478241559 11.0 21.001696161595063 14.089700776947538 107.15742741630842 -5.075055696823615 3 290.88594008616707 113.76868287298815 2.0132511884469353 1.0066255942234676 0.09921593553744701 172.63151133250068 12.0 21.19225795812126 25.253834415786486 157.2638285640319 -5.491572110730435 4 344.3860440796261 166.22517276873882 1.8853557992763632 0.9426778996381816 0.11363886565891375 142.91674058093935 11.0 18.685078458637985 11.30249791672627 62.9878292683161 -4.498141604100731 5 145.04228403850357 168.6571618278717 1.9066993974327817 0.9533496987163909 0.01132060172865575 34.75701626174368 12.0 16.35083410366516 67.03867866120578 413.9858186416701 -6.5424636608266695 6 394.77243654370204 187.3653258347458 1.8382851657518942 0.9191425828759471 0.07664537864845197 57.84086299955225 11.0 20.06339188622815 91.00874774135504 535.3679088447971 -6.821630837610465 7 48.84191877412477 200.23603953697418 2.044906279964065 1.0224531399820325 0.15397555058991969 8.669913148933764 13.0 21.891667190520494 25.397623953819803 185.00884809430943 -5.667981247854074 8 305.8226567441267 215.56678011460988 1.8118994096837677 0.9059497048418839 0.15302459233581697 71.90351161795856 10.0 16.561617853554058 12.39941531540315 70.11439579638966 -4.614517989747707 9 292.1680865716507 245.66007865305278 1.9132639276510426 0.9566319638255213 0.13981297941973697 131.64176988617768 12.0 17.382922811106205 26.281111155294354 151.39790010868757 -5.450299628835927 10 355.815359095706 252.07315473269793 2.040873269492875 1.0204366347464375 0.04014555235557765 166.92243604044648 13.0 20.266399267107513 15.509764684929745 112.63065620256117 -5.129141535958461 photutils-0.2.1/photutils/detection/tests/test_core.py0000600000214200020070000002462712634600603025447 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst from __future__ import (absolute_import, division, print_function, unicode_literals) import numpy as np from numpy.testing import assert_array_equal, assert_allclose from astropy.tests.helper import pytest, catch_warnings from astropy.utils.exceptions import AstropyUserWarning from astropy.convolution import Gaussian2DKernel from ..core import detect_threshold, detect_sources, find_peaks try: import scipy HAS_SCIPY = True except ImportError: HAS_SCIPY = False try: import skimage HAS_SKIMAGE = True except ImportError: HAS_SKIMAGE = False DATA = np.array([[0, 1, 0], [0, 2, 0], [0, 0, 0]]).astype(np.float) REF1 = np.array([[0, 0, 0], [0, 0, 0], [0, 0, 0]]) REF2 = np.array([[0, 1, 0], [0, 1, 0], [0, 0, 0]]) REF3 = np.array([[0, 0, 0], [0, 1, 0], [0, 0, 0]]) PEAKDATA = np.array([[1, 0, 0], [0, 0, 0], [0, 0, 1]]).astype(np.float) PEAKREF1 = np.array([[0, 0], [2, 2]]) @pytest.mark.skipif('not HAS_SCIPY') class TestDetectThreshold(object): def test_snr(self): """Test basic snr.""" threshold = detect_threshold(DATA, snr=0.1) ref = 0.4 * np.ones((3, 3)) assert_allclose(threshold, ref) def test_snr_zero(self): """Test snr=0.""" threshold = detect_threshold(DATA, snr=0.0) ref = (1. / 3.) * np.ones((3, 3)) assert_allclose(threshold, ref) def test_background(self): threshold = detect_threshold(DATA, snr=1.0, background=1) ref = (5. / 3.) * np.ones((3, 3)) assert_allclose(threshold, ref) def test_background_image(self): background = np.ones((3, 3)) threshold = detect_threshold(DATA, snr=1.0, background=background) ref = (5. / 3.) * np.ones((3, 3)) assert_allclose(threshold, ref) def test_background_badshape(self): wrong_shape = np.zeros((2, 2)) with pytest.raises(ValueError): detect_threshold(DATA, snr=2., background=wrong_shape) def test_error(self): threshold = detect_threshold(DATA, snr=1.0, error=1) ref = (4. / 3.) * np.ones((3, 3)) assert_allclose(threshold, ref) def test_error_image(self): error = np.ones((3, 3)) threshold = detect_threshold(DATA, snr=1.0, error=error) ref = (4. / 3.) * np.ones((3, 3)) assert_allclose(threshold, ref) def test_error_badshape(self): wrong_shape = np.zeros((2, 2)) with pytest.raises(ValueError): detect_threshold(DATA, snr=2., error=wrong_shape) def test_background_error(self): threshold = detect_threshold(DATA, snr=2.0, background=10., error=1.) ref = 12. * np.ones((3, 3)) assert_allclose(threshold, ref) def test_background_error_images(self): background = np.ones((3, 3)) * 10. error = np.ones((3, 3)) threshold = detect_threshold(DATA, snr=2.0, background=background, error=error) ref = 12. * np.ones((3, 3)) assert_allclose(threshold, ref) def test_mask_value(self): """Test detection with mask_value.""" threshold = detect_threshold(DATA, snr=1.0, mask_value=0.0) ref = 2. * np.ones((3, 3)) assert_array_equal(threshold, ref) def test_image_mask(self): """ Test detection with image_mask. sig=10 and iters=1 to prevent sigma clipping after applying the mask. """ mask = REF3.astype(np.bool) threshold = detect_threshold(DATA, snr=1., error=0, mask=mask, sigclip_sigma=10, sigclip_iters=1) ref = (1. / 8.) * np.ones((3, 3)) assert_array_equal(threshold, ref) def test_image_mask_override(self): """Test that image_mask overrides mask_value.""" mask = REF3.astype(np.bool) threshold = detect_threshold(DATA, snr=0.1, error=0, mask_value=0.0, mask=mask, sigclip_sigma=10, sigclip_iters=1) ref = np.ones((3, 3)) assert_array_equal(threshold, ref) @pytest.mark.skipif('not HAS_SCIPY') class TestDetectSources(object): def setup_class(self): FWHM2SIGMA = 1.0 / (2.0 * np.sqrt(2.0 * np.log(2.0))) filter_kernel = Gaussian2DKernel(2.*FWHM2SIGMA, x_size=3, y_size=3) filter_kernel.normalize() self.filter_kernel = filter_kernel def test_detection(self): """Test basic detection.""" segm = detect_sources(DATA, threshold=0.9, npixels=2) assert_array_equal(segm.data, REF2) def test_small_sources(self): """Test detection where sources are smaller than npixels size.""" segm = detect_sources(DATA, threshold=0.9, npixels=5) assert_array_equal(segm.data, REF1) def test_zerothresh(self): """Test detection with zero threshold.""" segm = detect_sources(DATA, threshold=0., npixels=2) assert_array_equal(segm.data, REF2) def test_zerodet(self): """Test detection with large snr_threshold giving no detections.""" segm = detect_sources(DATA, threshold=7, npixels=2) assert_array_equal(segm.data, REF1) def test_8connectivity(self): """Test detection with connectivity=8.""" data = np.eye(3) segm = detect_sources(data, threshold=0.9, npixels=1, connectivity=8) assert_array_equal(segm.data, data) def test_4connectivity(self): """Test detection with connectivity=4.""" data = np.eye(3) ref = np.diag([1, 2, 3]) segm = detect_sources(data, threshold=0.9, npixels=1, connectivity=4) assert_array_equal(segm.data, ref) def test_basic_filter_kernel(self): """Test detection with filter_kernel.""" kernel = np.ones((3, 3)) / 9. threshold = 0.3 expected = np.ones((3, 3)) expected[2] = 0 segm = detect_sources(DATA, threshold, npixels=1, filter_kernel=kernel) assert_array_equal(segm.data, expected) def test_npixels_nonint(self): """Test if error raises if npixel is non-integer.""" with pytest.raises(ValueError): detect_sources(DATA, threshold=1, npixels=0.1) def test_npixels_negative(self): """Test if error raises if npixel is negative.""" with pytest.raises(ValueError): detect_sources(DATA, threshold=1, npixels=-1) def test_connectivity_invalid(self): """Test if error raises if connectivity is invalid.""" with pytest.raises(ValueError): detect_sources(DATA, threshold=1, npixels=1, connectivity=10) def test_filter_kernel_array(self): segm = detect_sources(DATA, 0.1, npixels=1, filter_kernel=self.filter_kernel.array) assert_array_equal(segm.data, np.ones((3, 3))) def test_filter_kernel(self): segm = detect_sources(DATA, 0.1, npixels=1, filter_kernel=self.filter_kernel) assert_array_equal(segm.data, np.ones((3, 3))) def test_unnormalized_filter_kernel(self): with catch_warnings(AstropyUserWarning) as warning_lines: detect_sources(DATA, 0.1, npixels=1, filter_kernel=self.filter_kernel*10.) assert warning_lines[0].category == AstropyUserWarning assert ('The kernel is not normalized.' in str(warning_lines[0].message)) @pytest.mark.skipif('not HAS_SCIPY') @pytest.mark.skipif('not HAS_SKIMAGE') class TestFindPeaks(object): def test_box_size(self): """Test with box_size.""" tbl = find_peaks(PEAKDATA, 0.1, box_size=3) assert_array_equal(tbl['x_peak'], PEAKREF1[:, 1]) assert_array_equal(tbl['y_peak'], PEAKREF1[:, 0]) assert_array_equal(tbl['peak_value'], [1., 1.]) def test_footprint(self): """Test with footprint.""" tbl = find_peaks(PEAKDATA, 0.1, footprint=np.ones((3, 3))) assert_array_equal(tbl['x_peak'], PEAKREF1[:, 1]) assert_array_equal(tbl['y_peak'], PEAKREF1[:, 0]) assert_array_equal(tbl['peak_value'], [1., 1.]) def test_subpixel_regionsize(self): """Test that data cutout has at least 6 values.""" tbl = find_peaks(PEAKDATA, 0.1, box_size=2, subpixel=True) assert np.all(np.isnan(tbl['x_centroid'])) assert np.all(np.isnan(tbl['y_centroid'])) assert np.all(np.isnan(tbl['fit_peak_value'])) def test_mask(self): """Test with mask.""" mask = np.zeros_like(PEAKDATA, dtype=bool) mask[0, 0] = True tbl = find_peaks(PEAKDATA, 0.1, box_size=3, mask=mask) assert len(tbl) == 1 assert_array_equal(tbl['x_peak'], PEAKREF1[1, 0]) assert_array_equal(tbl['y_peak'], PEAKREF1[1, 1]) assert_array_equal(tbl['peak_value'], 1.0) def test_maskshape(self): """Test if make shape doesn't match data shape.""" with pytest.raises(ValueError): find_peaks(PEAKDATA, 0.1, mask=np.ones((5, 5))) def test_npeaks(self): """Test npeaks.""" tbl = find_peaks(PEAKDATA, 0.1, box_size=3, npeaks=1) assert_array_equal(tbl['x_peak'], PEAKREF1[1, 1]) assert_array_equal(tbl['y_peak'], PEAKREF1[1, 0]) def test_border_width(self): """Test border exclusion.""" tbl = find_peaks(PEAKDATA, 0.1, box_size=3, border_width=3) assert_array_equal(len(tbl), 0) def test_zerodet(self): """Test with large threshold giving no sources.""" tbl = find_peaks(PEAKDATA, 5., box_size=3, border_width=3) assert_array_equal(len(tbl), 0) def test_constant_data(self): """Test constant data.""" tbl = find_peaks(np.ones((5, 5)), 0.1, box_size=3.) assert_array_equal(len(tbl), 0) def test_box_size_int(self): """Test non-integer box_size.""" tbl1 = find_peaks(PEAKDATA, 0.1, box_size=5.) tbl2 = find_peaks(PEAKDATA, 0.1, box_size=5.5) assert_array_equal(tbl1, tbl2) def test_wcs(self): """Test with WCS.""" from photutils.datasets import make_4gaussians_image from astropy.wcs import WCS hdu = make_4gaussians_image(hdu=True, wcs=True) wcs = WCS(hdu.header) tbl = find_peaks(hdu.data, 100, wcs=wcs, subpixel=True) cols = ['icrs_ra_peak', 'icrs_dec_peak', 'icrs_ra_centroid', 'icrs_dec_centroid'] for col in cols: assert col in tbl.colnames photutils-0.2.1/photutils/detection/tests/test_deblend.py0000600000214200020070000000547712641136622026121 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst from __future__ import (absolute_import, division, print_function, unicode_literals) import numpy as np from numpy.testing import assert_allclose from astropy.tests.helper import pytest from astropy.modeling import models from ..core import detect_sources from ..deblend import deblend_sources try: import scipy HAS_SCIPY = True except ImportError: HAS_SCIPY = False try: import skimage HAS_SKIMAGE = True except ImportError: HAS_SKIMAGE = False @pytest.mark.skipif('not HAS_SCIPY') @pytest.mark.skipif('not HAS_SKIMAGE') class TestDeblendSources(object): def setup_class(self): g1 = models.Gaussian2D(100, 50, 50, 5, 5) g2 = models.Gaussian2D(100, 35, 50, 5, 5) g3 = models.Gaussian2D(30, 70, 50, 5, 5) y, x = np.mgrid[0:100, 0:100] self.data = g1(x, y) + g2(x, y) self.data3 = self.data + g3(x, y) self.threshold = 10 self.npixels = 5 self.segm = detect_sources(self.data, self.threshold, self.npixels) self.segm3 = detect_sources(self.data3, self.threshold, self.npixels) @pytest.mark.parametrize('mode', ['exponential', 'linear']) def test_deblend_sources(self, mode): result = deblend_sources(self.data, self.segm, self.npixels, mode=mode) assert result.nlabels == 2 mask1 = (result.data == 1) mask2 = (result.data == 2) assert_allclose(len(result.data[mask1]), len(result.data[mask2])) assert_allclose(np.sum(self.data[mask1]), np.sum(self.data[mask2])) assert_allclose(np.nonzero(self.segm), np.nonzero(result)) @pytest.mark.parametrize('mode', ['exponential', 'linear']) def test_deblend_three_sources(self, mode): result = deblend_sources(self.data3, self.segm3, self.npixels, mode=mode) assert result.nlabels == 3 assert_allclose(np.nonzero(self.segm3), np.nonzero(result)) def test_deblend_sources_segm_array(self): result = deblend_sources(self.data, self.segm.data, self.npixels) assert result.nlabels == 2 def test_segment_img_badshape(self): segm_wrong = np.zeros((2, 2)) with pytest.raises(ValueError): deblend_sources(self.data, segm_wrong, self.npixels) def test_invalid_nlevels(self): with pytest.raises(ValueError): deblend_sources(self.data, self.segm, self.npixels, nlevels=0) def test_invalid_contrast(self): with pytest.raises(ValueError): deblend_sources(self.data, self.segm, self.npixels, contrast=-1) def test_invalid_mode(self): with pytest.raises(ValueError): deblend_sources(self.data, self.segm, self.npixels, mode='invalid') photutils-0.2.1/photutils/detection/tests/test_findstars.py0000600000214200020070000001017212632337152026506 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst from __future__ import (absolute_import, division, print_function, unicode_literals) import os.path as op import itertools import warnings import numpy as np from numpy.testing import assert_allclose from astropy.tests.helper import pytest from astropy.table import Table from astropy.utils.exceptions import AstropyUserWarning from ..findstars import daofind, irafstarfind from ...datasets import make_100gaussians_image try: import scipy HAS_SCIPY = True except ImportError: HAS_SCIPY = False try: import skimage HAS_SKIMAGE = True except ImportError: HAS_SKIMAGE = False DATA = make_100gaussians_image() THRESHOLDS = [8.0, 10.0] FWHMS = [1.0, 1.5, 2.0] warnings.simplefilter('always', AstropyUserWarning) @pytest.mark.skipif('not HAS_SCIPY') @pytest.mark.skipif('not HAS_SKIMAGE') class TestDAOFind(object): @pytest.mark.parametrize(('threshold', 'fwhm'), list(itertools.product(THRESHOLDS, FWHMS))) def test_daofind(self, threshold, fwhm): t = daofind(DATA, threshold, fwhm, sigma_radius=1.5) datafn = ('daofind_test_thresh{0:04.1f}_fwhm{1:04.1f}' '.txt'.format(threshold, fwhm)) datafn = op.join(op.dirname(op.abspath(__file__)), 'data', datafn) t_ref = Table.read(datafn, format='ascii') assert_allclose(np.array(t).astype(np.float), np.array(t_ref).astype(np.float)) def test_daofind_include_border(self): t = daofind(DATA, threshold=10, fwhm=2, sigma_radius=1.5, exclude_border=False) assert len(t) == 20 def test_daofind_exclude_border(self): t = daofind(DATA, threshold=10, fwhm=2, sigma_radius=1.5, exclude_border=True) assert len(t) == 19 def test_daofind_nosources(self): data = np.ones((3, 3)) t = daofind(data, threshold=10, fwhm=1) assert len(t) == 0 def test_daofind_sharpness(self): """Sources found, but none pass the sharpness criteria.""" t = daofind(DATA, threshold=50, fwhm=1.0, sharplo=1.) assert len(t) == 0 def test_daofind_roundness(self): """Sources found, but none pass the roundness criteria.""" t = daofind(DATA, threshold=50, fwhm=1.0, roundlo=1.) assert len(t) == 0 def test_daofind_flux_negative(self): """Test handling of negative flux (here created by large sky).""" data = np.ones((5, 5)) data[2, 2] = 10. t = daofind(data, threshold=0.1, fwhm=1.0, sky=10) assert not np.isfinite(t['mag']) @pytest.mark.skipif('not HAS_SCIPY') @pytest.mark.skipif('not HAS_SKIMAGE') class TestIRAFStarFind(object): @pytest.mark.parametrize(('threshold', 'fwhm'), list(itertools.product(THRESHOLDS, FWHMS))) def test_irafstarfind(self, threshold, fwhm): t = irafstarfind(DATA, threshold, fwhm, sigma_radius=1.5) datafn = ('irafstarfind_test_thresh{0:04.1f}_fwhm{1:04.1f}' '.txt'.format(threshold, fwhm)) datafn = op.join(op.dirname(op.abspath(__file__)), 'data', datafn) t_ref = Table.read(datafn, format='ascii') assert_allclose(np.array(t).astype(np.float), np.array(t_ref).astype(np.float)) def test_irafstarfind_nosources(self): data = np.ones((3, 3)) t = irafstarfind(data, threshold=10, fwhm=1) assert len(t) == 0 def test_irafstarfind_sharpness(self): """Sources found, but none pass the sharpness criteria.""" t = irafstarfind(DATA, threshold=50, fwhm=1.0, sharplo=2.) assert len(t) == 0 def test_irafstarfind_roundness(self): """Sources found, but none pass the roundness criteria.""" t = irafstarfind(DATA, threshold=50, fwhm=1.0, roundlo=1.) assert len(t) == 0 def test_irafstarfind_sky(self): t = irafstarfind(DATA, threshold=25.0, fwhm=2.0, sky=10.) assert len(t) == 4 def test_irafstarfind_largesky(self): t = irafstarfind(DATA, threshold=25.0, fwhm=2.0, sky=100.) assert len(t) == 0 photutils-0.2.1/photutils/extern/0000700000214200020070000000000012646264032021263 5ustar lbradleySTSCI\science00000000000000photutils-0.2.1/photutils/extern/__init__.py0000600000214200020070000000061512345377273023410 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst """ This packages contains python packages that are bundled with the affiliated package but are external to the affiliated package, and hence are developed in a separate source tree. Note that this package is distinct from the /cextern directory of the source code distribution, as that directory only contains C extension code. """ photutils-0.2.1/photutils/geometry/0000700000214200020070000000000012646264032021611 5ustar lbradleySTSCI\science00000000000000photutils-0.2.1/photutils/geometry/__init__.py0000600000214200020070000000052612444404542023725 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst """ Geometry subpackage for low-level geometry functions. """ from .circular_overlap import * from .elliptical_overlap import * from .rectangular_overlap import * __all__ = ['circular_overlap_grid', 'elliptical_overlap_grid', 'rectangular_overlap_grid'] photutils-0.2.1/photutils/geometry/circular_overlap.c0000600000214200020070000127236212646264027025334 0ustar lbradleySTSCI\science00000000000000/* Generated by Cython 0.23.4 */ #define PY_SSIZE_T_CLEAN #include "Python.h" #ifndef Py_PYTHON_H #error Python headers needed to compile C extensions, please install development version of Python. #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000) #error Cython requires Python 2.6+ or Python 3.2+. #else #define CYTHON_ABI "0_23_4" #include #ifndef offsetof #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) #endif #if !defined(WIN32) && !defined(MS_WINDOWS) #ifndef __stdcall #define __stdcall #endif #ifndef __cdecl #define __cdecl #endif #ifndef __fastcall #define __fastcall #endif #endif #ifndef DL_IMPORT #define DL_IMPORT(t) t #endif #ifndef DL_EXPORT #define DL_EXPORT(t) t #endif #ifndef PY_LONG_LONG #define PY_LONG_LONG LONG_LONG #endif #ifndef Py_HUGE_VAL #define Py_HUGE_VAL HUGE_VAL #endif #ifdef PYPY_VERSION #define CYTHON_COMPILING_IN_PYPY 1 #define CYTHON_COMPILING_IN_CPYTHON 0 #else #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_CPYTHON 1 #endif #if !defined(CYTHON_USE_PYLONG_INTERNALS) && CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x02070000 #define CYTHON_USE_PYLONG_INTERNALS 1 #endif #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag) #define Py_OptimizeFlag 0 #endif #define __PYX_BUILD_PY_SSIZE_T "n" #define CYTHON_FORMAT_SSIZE_T "z" #if PY_MAJOR_VERSION < 3 #define __Pyx_BUILTIN_MODULE_NAME "__builtin__" #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) #define __Pyx_DefaultClassType PyClass_Type #else #define __Pyx_BUILTIN_MODULE_NAME "builtins" #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) #define __Pyx_DefaultClassType PyType_Type #endif #ifndef Py_TPFLAGS_CHECKTYPES #define Py_TPFLAGS_CHECKTYPES 0 #endif #ifndef Py_TPFLAGS_HAVE_INDEX #define Py_TPFLAGS_HAVE_INDEX 0 #endif #ifndef Py_TPFLAGS_HAVE_NEWBUFFER #define Py_TPFLAGS_HAVE_NEWBUFFER 0 #endif #ifndef Py_TPFLAGS_HAVE_FINALIZE #define Py_TPFLAGS_HAVE_FINALIZE 0 #endif #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) #define CYTHON_PEP393_ENABLED 1 #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\ 0 : _PyUnicode_Ready((PyObject *)(op))) #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u) #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i) #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u) #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u) #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i) #else #define CYTHON_PEP393_ENABLED 0 #define __Pyx_PyUnicode_READY(op) (0) #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u) #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i])) #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE)) #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u)) #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i])) #endif #if CYTHON_COMPILING_IN_PYPY #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b) #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b) #else #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b) #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\ PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b)) #endif #if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains) #define PyUnicode_Contains(u, s) PySequence_Contains(u, s) #endif #define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b)) #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b)) #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b) #else #define __Pyx_PyString_Format(a, b) PyString_Format(a, b) #endif #if PY_MAJOR_VERSION >= 3 #define PyBaseString_Type PyUnicode_Type #define PyStringObject PyUnicodeObject #define PyString_Type PyUnicode_Type #define PyString_Check PyUnicode_Check #define PyString_CheckExact PyUnicode_CheckExact #endif #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj) #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj) #else #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj)) #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj)) #endif #ifndef PySet_CheckExact #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) #endif #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) #if PY_MAJOR_VERSION >= 3 #define PyIntObject PyLongObject #define PyInt_Type PyLong_Type #define PyInt_Check(op) PyLong_Check(op) #define PyInt_CheckExact(op) PyLong_CheckExact(op) #define PyInt_FromString PyLong_FromString #define PyInt_FromUnicode PyLong_FromUnicode #define PyInt_FromLong PyLong_FromLong #define PyInt_FromSize_t PyLong_FromSize_t #define PyInt_FromSsize_t PyLong_FromSsize_t #define PyInt_AsLong PyLong_AsLong #define PyInt_AS_LONG PyLong_AS_LONG #define PyInt_AsSsize_t PyLong_AsSsize_t #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask #define PyNumber_Int PyNumber_Long #endif #if PY_MAJOR_VERSION >= 3 #define PyBoolObject PyLongObject #endif #if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY #ifndef PyUnicode_InternFromString #define PyUnicode_InternFromString(s) PyUnicode_FromString(s) #endif #endif #if PY_VERSION_HEX < 0x030200A4 typedef long Py_hash_t; #define __Pyx_PyInt_FromHash_t PyInt_FromLong #define __Pyx_PyInt_AsHash_t PyInt_AsLong #else #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t #endif #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func)) #else #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass) #endif #if PY_VERSION_HEX >= 0x030500B1 #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async) #elif CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 typedef struct { unaryfunc am_await; unaryfunc am_aiter; unaryfunc am_anext; } __Pyx_PyAsyncMethodsStruct; #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved)) #else #define __Pyx_PyType_AsAsync(obj) NULL #endif #ifndef CYTHON_RESTRICT #if defined(__GNUC__) #define CYTHON_RESTRICT __restrict__ #elif defined(_MSC_VER) && _MSC_VER >= 1400 #define CYTHON_RESTRICT __restrict #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define CYTHON_RESTRICT restrict #else #define CYTHON_RESTRICT #endif #endif #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None) #ifndef CYTHON_INLINE #if defined(__GNUC__) #define CYTHON_INLINE __inline__ #elif defined(_MSC_VER) #define CYTHON_INLINE __inline #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define CYTHON_INLINE inline #else #define CYTHON_INLINE #endif #endif #if defined(WIN32) || defined(MS_WINDOWS) #define _USE_MATH_DEFINES #endif #include #ifdef NAN #define __PYX_NAN() ((float) NAN) #else static CYTHON_INLINE float __PYX_NAN() { float value; memset(&value, 0xFF, sizeof(value)); return value; } #endif #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) #else #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) #endif #ifndef __PYX_EXTERN_C #ifdef __cplusplus #define __PYX_EXTERN_C extern "C" #else #define __PYX_EXTERN_C extern #endif #endif #define __PYX_HAVE__photutils__geometry__circular_overlap #define __PYX_HAVE_API__photutils__geometry__circular_overlap #include "string.h" #include "stdio.h" #include "stdlib.h" #include "numpy/arrayobject.h" #include "numpy/ufuncobject.h" #include "math.h" #ifdef _OPENMP #include #endif /* _OPENMP */ #ifdef PYREX_WITHOUT_ASSERTIONS #define CYTHON_WITHOUT_ASSERTIONS #endif #ifndef CYTHON_UNUSED # if defined(__GNUC__) # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) # define CYTHON_UNUSED __attribute__ ((__unused__)) # else # define CYTHON_UNUSED # endif # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER)) # define CYTHON_UNUSED __attribute__ ((__unused__)) # else # define CYTHON_UNUSED # endif #endif #ifndef CYTHON_NCP_UNUSED # if CYTHON_COMPILING_IN_CPYTHON # define CYTHON_NCP_UNUSED # else # define CYTHON_NCP_UNUSED CYTHON_UNUSED # endif #endif typedef struct {PyObject **p; char *s; const Py_ssize_t n; const char* encoding; const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0 #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0 #define __PYX_DEFAULT_STRING_ENCODING "" #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize #define __Pyx_uchar_cast(c) ((unsigned char)c) #define __Pyx_long_cast(x) ((long)x) #define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\ (sizeof(type) < sizeof(Py_ssize_t)) ||\ (sizeof(type) > sizeof(Py_ssize_t) &&\ likely(v < (type)PY_SSIZE_T_MAX ||\ v == (type)PY_SSIZE_T_MAX) &&\ (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\ v == (type)PY_SSIZE_T_MIN))) ||\ (sizeof(type) == sizeof(Py_ssize_t) &&\ (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\ v == (type)PY_SSIZE_T_MAX))) ) #if defined (__cplusplus) && __cplusplus >= 201103L #include #define __Pyx_sst_abs(value) std::abs(value) #elif SIZEOF_INT >= SIZEOF_SIZE_T #define __Pyx_sst_abs(value) abs(value) #elif SIZEOF_LONG >= SIZEOF_SIZE_T #define __Pyx_sst_abs(value) labs(value) #elif defined (_MSC_VER) && defined (_M_X64) #define __Pyx_sst_abs(value) _abs64(value) #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define __Pyx_sst_abs(value) llabs(value) #elif defined (__GNUC__) #define __Pyx_sst_abs(value) __builtin_llabs(value) #else #define __Pyx_sst_abs(value) ((value<0) ? -value : value) #endif static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*); static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s)) #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l) #define __Pyx_PyBytes_FromString PyBytes_FromString #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); #if PY_MAJOR_VERSION < 3 #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize #else #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize #endif #define __Pyx_PyObject_AsSString(s) ((signed char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s) #define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s) #define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s) #define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s) #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s) #if PY_MAJOR_VERSION < 3 static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) { const Py_UNICODE *u_end = u; while (*u_end++) ; return (size_t)(u_end - u - 1); } #else #define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen #endif #define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u)) #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj) #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None) #define __Pyx_PyBool_FromLong(b) ((b) ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False)) static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x); static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); #if CYTHON_COMPILING_IN_CPYTHON #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x)) #else #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x) #endif #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x)) #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII static int __Pyx_sys_getdefaultencoding_not_ascii; static int __Pyx_init_sys_getdefaultencoding_params(void) { PyObject* sys; PyObject* default_encoding = NULL; PyObject* ascii_chars_u = NULL; PyObject* ascii_chars_b = NULL; const char* default_encoding_c; sys = PyImport_ImportModule("sys"); if (!sys) goto bad; default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL); Py_DECREF(sys); if (!default_encoding) goto bad; default_encoding_c = PyBytes_AsString(default_encoding); if (!default_encoding_c) goto bad; if (strcmp(default_encoding_c, "ascii") == 0) { __Pyx_sys_getdefaultencoding_not_ascii = 0; } else { char ascii_chars[128]; int c; for (c = 0; c < 128; c++) { ascii_chars[c] = c; } __Pyx_sys_getdefaultencoding_not_ascii = 1; ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL); if (!ascii_chars_u) goto bad; ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL); if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) { PyErr_Format( PyExc_ValueError, "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.", default_encoding_c); goto bad; } Py_DECREF(ascii_chars_u); Py_DECREF(ascii_chars_b); } Py_DECREF(default_encoding); return 0; bad: Py_XDECREF(default_encoding); Py_XDECREF(ascii_chars_u); Py_XDECREF(ascii_chars_b); return -1; } #endif #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL) #else #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL) #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT static char* __PYX_DEFAULT_STRING_ENCODING; static int __Pyx_init_sys_getdefaultencoding_params(void) { PyObject* sys; PyObject* default_encoding = NULL; char* default_encoding_c; sys = PyImport_ImportModule("sys"); if (!sys) goto bad; default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL); Py_DECREF(sys); if (!default_encoding) goto bad; default_encoding_c = PyBytes_AsString(default_encoding); if (!default_encoding_c) goto bad; __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c)); if (!__PYX_DEFAULT_STRING_ENCODING) goto bad; strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c); Py_DECREF(default_encoding); return 0; bad: Py_XDECREF(default_encoding); return -1; } #endif #endif /* Test for GCC > 2.95 */ #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))) #define likely(x) __builtin_expect(!!(x), 1) #define unlikely(x) __builtin_expect(!!(x), 0) #else /* !__GNUC__ or GCC < 2.95 */ #define likely(x) (x) #define unlikely(x) (x) #endif /* __GNUC__ */ static PyObject *__pyx_m; static PyObject *__pyx_d; static PyObject *__pyx_b; static PyObject *__pyx_empty_tuple; static PyObject *__pyx_empty_bytes; static int __pyx_lineno; static int __pyx_clineno = 0; static const char * __pyx_cfilenm= __FILE__; static const char *__pyx_filename; #if !defined(CYTHON_CCOMPLEX) #if defined(__cplusplus) #define CYTHON_CCOMPLEX 1 #elif defined(_Complex_I) #define CYTHON_CCOMPLEX 1 #else #define CYTHON_CCOMPLEX 0 #endif #endif #if CYTHON_CCOMPLEX #ifdef __cplusplus #include #else #include #endif #endif #if CYTHON_CCOMPLEX && !defined(__cplusplus) && defined(__sun__) && defined(__GNUC__) #undef _Complex_I #define _Complex_I 1.0fj #endif static const char *__pyx_f[] = { "photutils/geometry/circular_overlap.pyx", "__init__.pxd", "type.pxd", }; #define IS_UNSIGNED(type) (((type) -1) > 0) struct __Pyx_StructField_; #define __PYX_BUF_FLAGS_PACKED_STRUCT (1 << 0) typedef struct { const char* name; struct __Pyx_StructField_* fields; size_t size; size_t arraysize[8]; int ndim; char typegroup; char is_unsigned; int flags; } __Pyx_TypeInfo; typedef struct __Pyx_StructField_ { __Pyx_TypeInfo* type; const char* name; size_t offset; } __Pyx_StructField; typedef struct { __Pyx_StructField* field; size_t parent_offset; } __Pyx_BufFmt_StackElem; typedef struct { __Pyx_StructField root; __Pyx_BufFmt_StackElem* head; size_t fmt_offset; size_t new_count, enc_count; size_t struct_alignment; int is_complex; char enc_type; char new_packmode; char enc_packmode; char is_valid_array; } __Pyx_BufFmt_Context; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":725 * # in Cython to enable them only on the right systems. * * ctypedef npy_int8 int8_t # <<<<<<<<<<<<<< * ctypedef npy_int16 int16_t * ctypedef npy_int32 int32_t */ typedef npy_int8 __pyx_t_5numpy_int8_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":726 * * ctypedef npy_int8 int8_t * ctypedef npy_int16 int16_t # <<<<<<<<<<<<<< * ctypedef npy_int32 int32_t * ctypedef npy_int64 int64_t */ typedef npy_int16 __pyx_t_5numpy_int16_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":727 * ctypedef npy_int8 int8_t * ctypedef npy_int16 int16_t * ctypedef npy_int32 int32_t # <<<<<<<<<<<<<< * ctypedef npy_int64 int64_t * #ctypedef npy_int96 int96_t */ typedef npy_int32 __pyx_t_5numpy_int32_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":728 * ctypedef npy_int16 int16_t * ctypedef npy_int32 int32_t * ctypedef npy_int64 int64_t # <<<<<<<<<<<<<< * #ctypedef npy_int96 int96_t * #ctypedef npy_int128 int128_t */ typedef npy_int64 __pyx_t_5numpy_int64_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":732 * #ctypedef npy_int128 int128_t * * ctypedef npy_uint8 uint8_t # <<<<<<<<<<<<<< * ctypedef npy_uint16 uint16_t * ctypedef npy_uint32 uint32_t */ typedef npy_uint8 __pyx_t_5numpy_uint8_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":733 * * ctypedef npy_uint8 uint8_t * ctypedef npy_uint16 uint16_t # <<<<<<<<<<<<<< * ctypedef npy_uint32 uint32_t * ctypedef npy_uint64 uint64_t */ typedef npy_uint16 __pyx_t_5numpy_uint16_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":734 * ctypedef npy_uint8 uint8_t * ctypedef npy_uint16 uint16_t * ctypedef npy_uint32 uint32_t # <<<<<<<<<<<<<< * ctypedef npy_uint64 uint64_t * #ctypedef npy_uint96 uint96_t */ typedef npy_uint32 __pyx_t_5numpy_uint32_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":735 * ctypedef npy_uint16 uint16_t * ctypedef npy_uint32 uint32_t * ctypedef npy_uint64 uint64_t # <<<<<<<<<<<<<< * #ctypedef npy_uint96 uint96_t * #ctypedef npy_uint128 uint128_t */ typedef npy_uint64 __pyx_t_5numpy_uint64_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":739 * #ctypedef npy_uint128 uint128_t * * ctypedef npy_float32 float32_t # <<<<<<<<<<<<<< * ctypedef npy_float64 float64_t * #ctypedef npy_float80 float80_t */ typedef npy_float32 __pyx_t_5numpy_float32_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":740 * * ctypedef npy_float32 float32_t * ctypedef npy_float64 float64_t # <<<<<<<<<<<<<< * #ctypedef npy_float80 float80_t * #ctypedef npy_float128 float128_t */ typedef npy_float64 __pyx_t_5numpy_float64_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":749 * # The int types are mapped a bit surprising -- * # numpy.int corresponds to 'l' and numpy.long to 'q' * ctypedef npy_long int_t # <<<<<<<<<<<<<< * ctypedef npy_longlong long_t * ctypedef npy_longlong longlong_t */ typedef npy_long __pyx_t_5numpy_int_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":750 * # numpy.int corresponds to 'l' and numpy.long to 'q' * ctypedef npy_long int_t * ctypedef npy_longlong long_t # <<<<<<<<<<<<<< * ctypedef npy_longlong longlong_t * */ typedef npy_longlong __pyx_t_5numpy_long_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":751 * ctypedef npy_long int_t * ctypedef npy_longlong long_t * ctypedef npy_longlong longlong_t # <<<<<<<<<<<<<< * * ctypedef npy_ulong uint_t */ typedef npy_longlong __pyx_t_5numpy_longlong_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":753 * ctypedef npy_longlong longlong_t * * ctypedef npy_ulong uint_t # <<<<<<<<<<<<<< * ctypedef npy_ulonglong ulong_t * ctypedef npy_ulonglong ulonglong_t */ typedef npy_ulong __pyx_t_5numpy_uint_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":754 * * ctypedef npy_ulong uint_t * ctypedef npy_ulonglong ulong_t # <<<<<<<<<<<<<< * ctypedef npy_ulonglong ulonglong_t * */ typedef npy_ulonglong __pyx_t_5numpy_ulong_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":755 * ctypedef npy_ulong uint_t * ctypedef npy_ulonglong ulong_t * ctypedef npy_ulonglong ulonglong_t # <<<<<<<<<<<<<< * * ctypedef npy_intp intp_t */ typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":757 * ctypedef npy_ulonglong ulonglong_t * * ctypedef npy_intp intp_t # <<<<<<<<<<<<<< * ctypedef npy_uintp uintp_t * */ typedef npy_intp __pyx_t_5numpy_intp_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":758 * * ctypedef npy_intp intp_t * ctypedef npy_uintp uintp_t # <<<<<<<<<<<<<< * * ctypedef npy_double float_t */ typedef npy_uintp __pyx_t_5numpy_uintp_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":760 * ctypedef npy_uintp uintp_t * * ctypedef npy_double float_t # <<<<<<<<<<<<<< * ctypedef npy_double double_t * ctypedef npy_longdouble longdouble_t */ typedef npy_double __pyx_t_5numpy_float_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":761 * * ctypedef npy_double float_t * ctypedef npy_double double_t # <<<<<<<<<<<<<< * ctypedef npy_longdouble longdouble_t * */ typedef npy_double __pyx_t_5numpy_double_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":762 * ctypedef npy_double float_t * ctypedef npy_double double_t * ctypedef npy_longdouble longdouble_t # <<<<<<<<<<<<<< * * ctypedef npy_cfloat cfloat_t */ typedef npy_longdouble __pyx_t_5numpy_longdouble_t; /* "photutils/geometry/circular_overlap.pyx":21 * * DTYPE = np.float64 * ctypedef np.float64_t DTYPE_t # <<<<<<<<<<<<<< * * # NOTE: Here we need to make sure we use cimport to import the C functions from */ typedef __pyx_t_5numpy_float64_t __pyx_t_9photutils_8geometry_16circular_overlap_DTYPE_t; #if CYTHON_CCOMPLEX #ifdef __cplusplus typedef ::std::complex< float > __pyx_t_float_complex; #else typedef float _Complex __pyx_t_float_complex; #endif #else typedef struct { float real, imag; } __pyx_t_float_complex; #endif #if CYTHON_CCOMPLEX #ifdef __cplusplus typedef ::std::complex< double > __pyx_t_double_complex; #else typedef double _Complex __pyx_t_double_complex; #endif #else typedef struct { double real, imag; } __pyx_t_double_complex; #endif /*--- Type declarations ---*/ /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":764 * ctypedef npy_longdouble longdouble_t * * ctypedef npy_cfloat cfloat_t # <<<<<<<<<<<<<< * ctypedef npy_cdouble cdouble_t * ctypedef npy_clongdouble clongdouble_t */ typedef npy_cfloat __pyx_t_5numpy_cfloat_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":765 * * ctypedef npy_cfloat cfloat_t * ctypedef npy_cdouble cdouble_t # <<<<<<<<<<<<<< * ctypedef npy_clongdouble clongdouble_t * */ typedef npy_cdouble __pyx_t_5numpy_cdouble_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":766 * ctypedef npy_cfloat cfloat_t * ctypedef npy_cdouble cdouble_t * ctypedef npy_clongdouble clongdouble_t # <<<<<<<<<<<<<< * * ctypedef npy_cdouble complex_t */ typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":768 * ctypedef npy_clongdouble clongdouble_t * * ctypedef npy_cdouble complex_t # <<<<<<<<<<<<<< * * cdef inline object PyArray_MultiIterNew1(a): */ typedef npy_cdouble __pyx_t_5numpy_complex_t; /* --- Runtime support code (head) --- */ #ifndef CYTHON_REFNANNY #define CYTHON_REFNANNY 0 #endif #if CYTHON_REFNANNY typedef struct { void (*INCREF)(void*, PyObject*, int); void (*DECREF)(void*, PyObject*, int); void (*GOTREF)(void*, PyObject*, int); void (*GIVEREF)(void*, PyObject*, int); void* (*SetupContext)(const char*, int, const char*); void (*FinishContext)(void**); } __Pyx_RefNannyAPIStruct; static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL; static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL; #ifdef WITH_THREAD #define __Pyx_RefNannySetupContext(name, acquire_gil)\ if (acquire_gil) {\ PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\ __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\ PyGILState_Release(__pyx_gilstate_save);\ } else {\ __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\ } #else #define __Pyx_RefNannySetupContext(name, acquire_gil)\ __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__) #endif #define __Pyx_RefNannyFinishContext()\ __Pyx_RefNanny->FinishContext(&__pyx_refnanny) #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__) #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__) #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__) #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__) #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0) #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0) #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0) #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0) #else #define __Pyx_RefNannyDeclarations #define __Pyx_RefNannySetupContext(name, acquire_gil) #define __Pyx_RefNannyFinishContext() #define __Pyx_INCREF(r) Py_INCREF(r) #define __Pyx_DECREF(r) Py_DECREF(r) #define __Pyx_GOTREF(r) #define __Pyx_GIVEREF(r) #define __Pyx_XINCREF(r) Py_XINCREF(r) #define __Pyx_XDECREF(r) Py_XDECREF(r) #define __Pyx_XGOTREF(r) #define __Pyx_XGIVEREF(r) #endif #define __Pyx_XDECREF_SET(r, v) do {\ PyObject *tmp = (PyObject *) r;\ r = v; __Pyx_XDECREF(tmp);\ } while (0) #define __Pyx_DECREF_SET(r, v) do {\ PyObject *tmp = (PyObject *) r;\ r = v; __Pyx_DECREF(tmp);\ } while (0) #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0) #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0) #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) { PyTypeObject* tp = Py_TYPE(obj); if (likely(tp->tp_getattro)) return tp->tp_getattro(obj, attr_name); #if PY_MAJOR_VERSION < 3 if (likely(tp->tp_getattr)) return tp->tp_getattr(obj, PyString_AS_STRING(attr_name)); #endif return PyObject_GetAttr(obj, attr_name); } #else #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n) #endif static PyObject *__Pyx_GetBuiltinName(PyObject *name); static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\ PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\ const char* function_name); static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name); #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw); #else #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw) #endif static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); static CYTHON_INLINE int __Pyx_GetBufferAndValidate(Py_buffer* buf, PyObject* obj, __Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack); static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info); static void __Pyx_RaiseBufferIndexError(int axis); #define __Pyx_BufPtrStrided2d(type, buf, i0, s0, i1, s1) (type)((char*)buf + i0 * s0 + i1 * s1) static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); static void __Pyx_WriteUnraisable(const char *name, int clineno, int lineno, const char *filename, int full_traceback, int nogil); static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) { PyObject *value; value = PyDict_GetItemWithError(d, key); if (unlikely(!value)) { if (!PyErr_Occurred()) { PyObject* args = PyTuple_Pack(1, key); if (likely(args)) PyErr_SetObject(PyExc_KeyError, args); Py_XDECREF(args); } return NULL; } Py_INCREF(value); return value; } #else #define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key) #endif static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected); static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index); static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void); static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); typedef struct { int code_line; PyCodeObject* code_object; } __Pyx_CodeObjectCacheEntry; struct __Pyx_CodeObjectCache { int count; int max_count; __Pyx_CodeObjectCacheEntry* entries; }; static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL}; static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line); static PyCodeObject *__pyx_find_code_object(int code_line); static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object); static void __Pyx_AddTraceback(const char *funcname, int c_line, int py_line, const char *filename); typedef struct { Py_ssize_t shape, strides, suboffsets; } __Pyx_Buf_DimInfo; typedef struct { size_t refcount; Py_buffer pybuffer; } __Pyx_Buffer; typedef struct { __Pyx_Buffer *rcbuffer; char *data; __Pyx_Buf_DimInfo diminfo[8]; } __Pyx_LocalBuf_ND; #if PY_MAJOR_VERSION < 3 static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags); static void __Pyx_ReleaseBuffer(Py_buffer *view); #else #define __Pyx_GetBuffer PyObject_GetBuffer #define __Pyx_ReleaseBuffer PyBuffer_Release #endif static Py_ssize_t __Pyx_zeros[] = {0, 0, 0, 0, 0, 0, 0, 0}; static Py_ssize_t __Pyx_minusones[] = {-1, -1, -1, -1, -1, -1, -1, -1}; static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value); static CYTHON_INLINE unsigned int __Pyx_PyInt_As_unsigned_int(PyObject *); #if CYTHON_CCOMPLEX #ifdef __cplusplus #define __Pyx_CREAL(z) ((z).real()) #define __Pyx_CIMAG(z) ((z).imag()) #else #define __Pyx_CREAL(z) (__real__(z)) #define __Pyx_CIMAG(z) (__imag__(z)) #endif #else #define __Pyx_CREAL(z) ((z).real) #define __Pyx_CIMAG(z) ((z).imag) #endif #if (defined(_WIN32) || defined(__clang__)) && defined(__cplusplus) && CYTHON_CCOMPLEX #define __Pyx_SET_CREAL(z,x) ((z).real(x)) #define __Pyx_SET_CIMAG(z,y) ((z).imag(y)) #else #define __Pyx_SET_CREAL(z,x) __Pyx_CREAL(z) = (x) #define __Pyx_SET_CIMAG(z,y) __Pyx_CIMAG(z) = (y) #endif static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float, float); #if CYTHON_CCOMPLEX #define __Pyx_c_eqf(a, b) ((a)==(b)) #define __Pyx_c_sumf(a, b) ((a)+(b)) #define __Pyx_c_difff(a, b) ((a)-(b)) #define __Pyx_c_prodf(a, b) ((a)*(b)) #define __Pyx_c_quotf(a, b) ((a)/(b)) #define __Pyx_c_negf(a) (-(a)) #ifdef __cplusplus #define __Pyx_c_is_zerof(z) ((z)==(float)0) #define __Pyx_c_conjf(z) (::std::conj(z)) #if 1 #define __Pyx_c_absf(z) (::std::abs(z)) #define __Pyx_c_powf(a, b) (::std::pow(a, b)) #endif #else #define __Pyx_c_is_zerof(z) ((z)==0) #define __Pyx_c_conjf(z) (conjf(z)) #if 1 #define __Pyx_c_absf(z) (cabsf(z)) #define __Pyx_c_powf(a, b) (cpowf(a, b)) #endif #endif #else static CYTHON_INLINE int __Pyx_c_eqf(__pyx_t_float_complex, __pyx_t_float_complex); static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sumf(__pyx_t_float_complex, __pyx_t_float_complex); static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_difff(__pyx_t_float_complex, __pyx_t_float_complex); static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prodf(__pyx_t_float_complex, __pyx_t_float_complex); static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quotf(__pyx_t_float_complex, __pyx_t_float_complex); static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_negf(__pyx_t_float_complex); static CYTHON_INLINE int __Pyx_c_is_zerof(__pyx_t_float_complex); static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conjf(__pyx_t_float_complex); #if 1 static CYTHON_INLINE float __Pyx_c_absf(__pyx_t_float_complex); static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_powf(__pyx_t_float_complex, __pyx_t_float_complex); #endif #endif static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double, double); #if CYTHON_CCOMPLEX #define __Pyx_c_eq(a, b) ((a)==(b)) #define __Pyx_c_sum(a, b) ((a)+(b)) #define __Pyx_c_diff(a, b) ((a)-(b)) #define __Pyx_c_prod(a, b) ((a)*(b)) #define __Pyx_c_quot(a, b) ((a)/(b)) #define __Pyx_c_neg(a) (-(a)) #ifdef __cplusplus #define __Pyx_c_is_zero(z) ((z)==(double)0) #define __Pyx_c_conj(z) (::std::conj(z)) #if 1 #define __Pyx_c_abs(z) (::std::abs(z)) #define __Pyx_c_pow(a, b) (::std::pow(a, b)) #endif #else #define __Pyx_c_is_zero(z) ((z)==0) #define __Pyx_c_conj(z) (conj(z)) #if 1 #define __Pyx_c_abs(z) (cabs(z)) #define __Pyx_c_pow(a, b) (cpow(a, b)) #endif #endif #else static CYTHON_INLINE int __Pyx_c_eq(__pyx_t_double_complex, __pyx_t_double_complex); static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum(__pyx_t_double_complex, __pyx_t_double_complex); static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff(__pyx_t_double_complex, __pyx_t_double_complex); static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod(__pyx_t_double_complex, __pyx_t_double_complex); static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot(__pyx_t_double_complex, __pyx_t_double_complex); static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg(__pyx_t_double_complex); static CYTHON_INLINE int __Pyx_c_is_zero(__pyx_t_double_complex); static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj(__pyx_t_double_complex); #if 1 static CYTHON_INLINE double __Pyx_c_abs(__pyx_t_double_complex); static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow(__pyx_t_double_complex, __pyx_t_double_complex); #endif #endif static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum__NPY_TYPES(enum NPY_TYPES value); static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); static int __Pyx_check_binary_version(void); #if !defined(__Pyx_PyIdentifier_FromString) #if PY_MAJOR_VERSION < 3 #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s) #else #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s) #endif #endif static PyObject *__Pyx_ImportModule(const char *name); static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict); static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig); static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /* Module declarations from 'cpython.buffer' */ /* Module declarations from 'libc.string' */ /* Module declarations from 'libc.stdio' */ /* Module declarations from '__builtin__' */ /* Module declarations from 'cpython.type' */ static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0; /* Module declarations from 'cpython' */ /* Module declarations from 'cpython.object' */ /* Module declarations from 'cpython.ref' */ /* Module declarations from 'libc.stdlib' */ /* Module declarations from 'numpy' */ /* Module declarations from 'numpy' */ static PyTypeObject *__pyx_ptype_5numpy_dtype = 0; static PyTypeObject *__pyx_ptype_5numpy_flatiter = 0; static PyTypeObject *__pyx_ptype_5numpy_broadcast = 0; static PyTypeObject *__pyx_ptype_5numpy_ndarray = 0; static PyTypeObject *__pyx_ptype_5numpy_ufunc = 0; static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *, char *, char *, int *); /*proto*/ /* Module declarations from 'photutils.geometry.core' */ static double (*__pyx_f_9photutils_8geometry_4core_area_arc)(double, double, double, double, double); /*proto*/ static double (*__pyx_f_9photutils_8geometry_4core_area_triangle)(double, double, double, double, double, double); /*proto*/ /* Module declarations from 'photutils.geometry.circular_overlap' */ static double __pyx_f_9photutils_8geometry_16circular_overlap_circular_overlap_single_subpixel(double, double, double, double, double, int); /*proto*/ static double __pyx_f_9photutils_8geometry_16circular_overlap_circular_overlap_single_exact(double, double, double, double, double); /*proto*/ static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_9photutils_8geometry_16circular_overlap_DTYPE_t = { "DTYPE_t", NULL, sizeof(__pyx_t_9photutils_8geometry_16circular_overlap_DTYPE_t), { 0 }, 0, 'R', 0, 0 }; #define __Pyx_MODULE_NAME "photutils.geometry.circular_overlap" int __pyx_module_is_main_photutils__geometry__circular_overlap = 0; /* Implementation of 'photutils.geometry.circular_overlap' */ static PyObject *__pyx_builtin_range; static PyObject *__pyx_builtin_ValueError; static PyObject *__pyx_builtin_RuntimeError; static char __pyx_k_B[] = "B"; static char __pyx_k_H[] = "H"; static char __pyx_k_I[] = "I"; static char __pyx_k_L[] = "L"; static char __pyx_k_O[] = "O"; static char __pyx_k_Q[] = "Q"; static char __pyx_k_b[] = "b"; static char __pyx_k_d[] = "d"; static char __pyx_k_f[] = "f"; static char __pyx_k_g[] = "g"; static char __pyx_k_h[] = "h"; static char __pyx_k_i[] = "i"; static char __pyx_k_j[] = "j"; static char __pyx_k_l[] = "l"; static char __pyx_k_q[] = "q"; static char __pyx_k_r[] = "r"; static char __pyx_k_x[] = "x"; static char __pyx_k_y[] = "y"; static char __pyx_k_Zd[] = "Zd"; static char __pyx_k_Zf[] = "Zf"; static char __pyx_k_Zg[] = "Zg"; static char __pyx_k_d1[] = "d1"; static char __pyx_k_d2[] = "d2"; static char __pyx_k_dx[] = "dx"; static char __pyx_k_dy[] = "dy"; static char __pyx_k_np[] = "np"; static char __pyx_k_nx[] = "nx"; static char __pyx_k_ny[] = "ny"; static char __pyx_k_x1[] = "x1"; static char __pyx_k_x2[] = "x2"; static char __pyx_k_y1[] = "y1"; static char __pyx_k_y2[] = "y2"; static char __pyx_k_all[] = "__all__"; static char __pyx_k_area[] = "area"; static char __pyx_k_frac[] = "frac"; static char __pyx_k_main[] = "__main__"; static char __pyx_k_test[] = "__test__"; static char __pyx_k_xmax[] = "xmax"; static char __pyx_k_xmin[] = "xmin"; static char __pyx_k_ymax[] = "ymax"; static char __pyx_k_ymin[] = "ymin"; static char __pyx_k_DTYPE[] = "DTYPE"; static char __pyx_k_bxmax[] = "bxmax"; static char __pyx_k_bxmin[] = "bxmin"; static char __pyx_k_bymax[] = "bymax"; static char __pyx_k_bymin[] = "bymin"; static char __pyx_k_dtype[] = "dtype"; static char __pyx_k_numpy[] = "numpy"; static char __pyx_k_pxcen[] = "pxcen"; static char __pyx_k_pxmax[] = "pxmax"; static char __pyx_k_pxmin[] = "pxmin"; static char __pyx_k_pycen[] = "pycen"; static char __pyx_k_pymax[] = "pymax"; static char __pyx_k_pymin[] = "pymin"; static char __pyx_k_range[] = "range"; static char __pyx_k_zeros[] = "zeros"; static char __pyx_k_import[] = "__import__"; static char __pyx_k_float64[] = "float64"; static char __pyx_k_subpixels[] = "subpixels"; static char __pyx_k_use_exact[] = "use_exact"; static char __pyx_k_ValueError[] = "ValueError"; static char __pyx_k_RuntimeError[] = "RuntimeError"; static char __pyx_k_pixel_radius[] = "pixel_radius"; static char __pyx_k_circular_overlap_core[] = "circular_overlap_core"; static char __pyx_k_circular_overlap_grid[] = "circular_overlap_grid"; static char __pyx_k_ndarray_is_not_C_contiguous[] = "ndarray is not C contiguous"; static char __pyx_k_Users_lbradley_Dropbox_softw_de[] = "/Users/lbradley/Dropbox/softw/development/photutils/photutils/geometry/circular_overlap.pyx"; static char __pyx_k_unknown_dtype_code_in_numpy_pxd[] = "unknown dtype code in numpy.pxd (%d)"; static char __pyx_k_Format_string_allocated_too_shor[] = "Format string allocated too short, see comment in numpy.pxd"; static char __pyx_k_Non_native_byte_order_not_suppor[] = "Non-native byte order not supported"; static char __pyx_k_ndarray_is_not_Fortran_contiguou[] = "ndarray is not Fortran contiguous"; static char __pyx_k_photutils_geometry_circular_over[] = "photutils.geometry.circular_overlap"; static char __pyx_k_Format_string_allocated_too_shor_2[] = "Format string allocated too short."; static PyObject *__pyx_n_s_DTYPE; static PyObject *__pyx_kp_u_Format_string_allocated_too_shor; static PyObject *__pyx_kp_u_Format_string_allocated_too_shor_2; static PyObject *__pyx_kp_u_Non_native_byte_order_not_suppor; static PyObject *__pyx_n_s_RuntimeError; static PyObject *__pyx_kp_s_Users_lbradley_Dropbox_softw_de; static PyObject *__pyx_n_s_ValueError; static PyObject *__pyx_n_s_all; static PyObject *__pyx_n_s_area; static PyObject *__pyx_n_s_bxmax; static PyObject *__pyx_n_s_bxmin; static PyObject *__pyx_n_s_bymax; static PyObject *__pyx_n_s_bymin; static PyObject *__pyx_n_s_circular_overlap_core; static PyObject *__pyx_n_s_circular_overlap_grid; static PyObject *__pyx_n_u_circular_overlap_grid; static PyObject *__pyx_n_s_d; static PyObject *__pyx_n_s_d1; static PyObject *__pyx_n_s_d2; static PyObject *__pyx_n_s_dtype; static PyObject *__pyx_n_s_dx; static PyObject *__pyx_n_s_dy; static PyObject *__pyx_n_s_float64; static PyObject *__pyx_n_s_frac; static PyObject *__pyx_n_s_i; static PyObject *__pyx_n_s_import; static PyObject *__pyx_n_s_j; static PyObject *__pyx_n_s_main; static PyObject *__pyx_kp_u_ndarray_is_not_C_contiguous; static PyObject *__pyx_kp_u_ndarray_is_not_Fortran_contiguou; static PyObject *__pyx_n_s_np; static PyObject *__pyx_n_s_numpy; static PyObject *__pyx_n_s_nx; static PyObject *__pyx_n_s_ny; static PyObject *__pyx_n_s_photutils_geometry_circular_over; static PyObject *__pyx_n_s_pixel_radius; static PyObject *__pyx_n_s_pxcen; static PyObject *__pyx_n_s_pxmax; static PyObject *__pyx_n_s_pxmin; static PyObject *__pyx_n_s_pycen; static PyObject *__pyx_n_s_pymax; static PyObject *__pyx_n_s_pymin; static PyObject *__pyx_n_s_r; static PyObject *__pyx_n_s_range; static PyObject *__pyx_n_s_subpixels; static PyObject *__pyx_n_s_test; static PyObject *__pyx_kp_u_unknown_dtype_code_in_numpy_pxd; static PyObject *__pyx_n_s_use_exact; static PyObject *__pyx_n_s_x; static PyObject *__pyx_n_s_x1; static PyObject *__pyx_n_s_x2; static PyObject *__pyx_n_s_xmax; static PyObject *__pyx_n_s_xmin; static PyObject *__pyx_n_s_y; static PyObject *__pyx_n_s_y1; static PyObject *__pyx_n_s_y2; static PyObject *__pyx_n_s_ymax; static PyObject *__pyx_n_s_ymin; static PyObject *__pyx_n_s_zeros; static PyObject *__pyx_pf_9photutils_8geometry_16circular_overlap_circular_overlap_grid(CYTHON_UNUSED PyObject *__pyx_self, double __pyx_v_xmin, double __pyx_v_xmax, double __pyx_v_ymin, double __pyx_v_ymax, int __pyx_v_nx, int __pyx_v_ny, double __pyx_v_r, int __pyx_v_use_exact, int __pyx_v_subpixels); /* proto */ static PyObject *__pyx_pf_9photutils_8geometry_16circular_overlap_2circular_overlap_core(CYTHON_UNUSED PyObject *__pyx_self, double __pyx_v_xmin, double __pyx_v_ymin, double __pyx_v_xmax, double __pyx_v_ymax, double __pyx_v_r); /* proto */ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /* proto */ static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info); /* proto */ static PyObject *__pyx_tuple_; static PyObject *__pyx_tuple__2; static PyObject *__pyx_tuple__3; static PyObject *__pyx_tuple__4; static PyObject *__pyx_tuple__5; static PyObject *__pyx_tuple__6; static PyObject *__pyx_tuple__7; static PyObject *__pyx_tuple__9; static PyObject *__pyx_codeobj__8; static PyObject *__pyx_codeobj__10; /* "photutils/geometry/circular_overlap.pyx":29 * * * def circular_overlap_grid(double xmin, double xmax, double ymin, double ymax, # <<<<<<<<<<<<<< * int nx, int ny, double r, int use_exact, * int subpixels): */ /* Python wrapper */ static PyObject *__pyx_pw_9photutils_8geometry_16circular_overlap_1circular_overlap_grid(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_9photutils_8geometry_16circular_overlap_circular_overlap_grid[] = "\n circular_overlap_grid(xmin, xmax, ymin, ymax, nx, ny, r,\n use_exact, subpixels)\n\n Area of overlap between a circle and a pixel grid. The circle is centered\n on the origin.\n\n Parameters\n ----------\n xmin, xmax, ymin, ymax : float\n Extent of the grid in the x and y direction.\n nx, ny : int\n Grid dimensions.\n r : float\n The radius of the circle.\n use_exact : 0 or 1\n If ``1`` calculates exact overlap, if ``0`` uses ``subpixel`` number\n of subpixels to calculate the overlap.\n subpixels : int\n Each pixel resampled by this factor in each dimension, thus each\n pixel is divided into ``subpixels ** 2`` subpixels.\n\n Returns\n -------\n frac : `~numpy.ndarray` (float)\n 2-d array of shape (ny, nx) giving the fraction of the overlap.\n "; static PyMethodDef __pyx_mdef_9photutils_8geometry_16circular_overlap_1circular_overlap_grid = {"circular_overlap_grid", (PyCFunction)__pyx_pw_9photutils_8geometry_16circular_overlap_1circular_overlap_grid, METH_VARARGS|METH_KEYWORDS, __pyx_doc_9photutils_8geometry_16circular_overlap_circular_overlap_grid}; static PyObject *__pyx_pw_9photutils_8geometry_16circular_overlap_1circular_overlap_grid(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { double __pyx_v_xmin; double __pyx_v_xmax; double __pyx_v_ymin; double __pyx_v_ymax; int __pyx_v_nx; int __pyx_v_ny; double __pyx_v_r; int __pyx_v_use_exact; int __pyx_v_subpixels; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("circular_overlap_grid (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_xmin,&__pyx_n_s_xmax,&__pyx_n_s_ymin,&__pyx_n_s_ymax,&__pyx_n_s_nx,&__pyx_n_s_ny,&__pyx_n_s_r,&__pyx_n_s_use_exact,&__pyx_n_s_subpixels,0}; PyObject* values[9] = {0,0,0,0,0,0,0,0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8); case 8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7); case 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6); case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_xmin)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_xmax)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("circular_overlap_grid", 1, 9, 9, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ymin)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("circular_overlap_grid", 1, 9, 9, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 3: if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ymax)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("circular_overlap_grid", 1, 9, 9, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 4: if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_nx)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("circular_overlap_grid", 1, 9, 9, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 5: if (likely((values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ny)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("circular_overlap_grid", 1, 9, 9, 5); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 6: if (likely((values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_r)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("circular_overlap_grid", 1, 9, 9, 6); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 7: if (likely((values[7] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_use_exact)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("circular_overlap_grid", 1, 9, 9, 7); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 8: if (likely((values[8] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_subpixels)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("circular_overlap_grid", 1, 9, 9, 8); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "circular_overlap_grid") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 9) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[2] = PyTuple_GET_ITEM(__pyx_args, 2); values[3] = PyTuple_GET_ITEM(__pyx_args, 3); values[4] = PyTuple_GET_ITEM(__pyx_args, 4); values[5] = PyTuple_GET_ITEM(__pyx_args, 5); values[6] = PyTuple_GET_ITEM(__pyx_args, 6); values[7] = PyTuple_GET_ITEM(__pyx_args, 7); values[8] = PyTuple_GET_ITEM(__pyx_args, 8); } __pyx_v_xmin = __pyx_PyFloat_AsDouble(values[0]); if (unlikely((__pyx_v_xmin == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_xmax = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_xmax == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_ymin = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_ymin == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_ymax = __pyx_PyFloat_AsDouble(values[3]); if (unlikely((__pyx_v_ymax == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_nx = __Pyx_PyInt_As_int(values[4]); if (unlikely((__pyx_v_nx == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_ny = __Pyx_PyInt_As_int(values[5]); if (unlikely((__pyx_v_ny == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_r = __pyx_PyFloat_AsDouble(values[6]); if (unlikely((__pyx_v_r == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_use_exact = __Pyx_PyInt_As_int(values[7]); if (unlikely((__pyx_v_use_exact == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_subpixels = __Pyx_PyInt_As_int(values[8]); if (unlikely((__pyx_v_subpixels == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("circular_overlap_grid", 1, 9, 9, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("photutils.geometry.circular_overlap.circular_overlap_grid", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_9photutils_8geometry_16circular_overlap_circular_overlap_grid(__pyx_self, __pyx_v_xmin, __pyx_v_xmax, __pyx_v_ymin, __pyx_v_ymax, __pyx_v_nx, __pyx_v_ny, __pyx_v_r, __pyx_v_use_exact, __pyx_v_subpixels); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_9photutils_8geometry_16circular_overlap_circular_overlap_grid(CYTHON_UNUSED PyObject *__pyx_self, double __pyx_v_xmin, double __pyx_v_xmax, double __pyx_v_ymin, double __pyx_v_ymax, int __pyx_v_nx, int __pyx_v_ny, double __pyx_v_r, int __pyx_v_use_exact, int __pyx_v_subpixels) { unsigned int __pyx_v_i; unsigned int __pyx_v_j; double __pyx_v_dx; double __pyx_v_dy; double __pyx_v_d; double __pyx_v_pixel_radius; double __pyx_v_bxmin; double __pyx_v_bxmax; double __pyx_v_bymin; double __pyx_v_bymax; double __pyx_v_pxmin; double __pyx_v_pxcen; double __pyx_v_pxmax; double __pyx_v_pymin; double __pyx_v_pycen; double __pyx_v_pymax; PyArrayObject *__pyx_v_frac = 0; __Pyx_LocalBuf_ND __pyx_pybuffernd_frac; __Pyx_Buffer __pyx_pybuffer_frac; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyArrayObject *__pyx_t_5 = NULL; double __pyx_t_6; int __pyx_t_7; unsigned int __pyx_t_8; int __pyx_t_9; int __pyx_t_10; int __pyx_t_11; unsigned int __pyx_t_12; size_t __pyx_t_13; size_t __pyx_t_14; int __pyx_t_15; double __pyx_t_16; size_t __pyx_t_17; size_t __pyx_t_18; size_t __pyx_t_19; size_t __pyx_t_20; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("circular_overlap_grid", 0); __pyx_pybuffer_frac.pybuffer.buf = NULL; __pyx_pybuffer_frac.refcount = 0; __pyx_pybuffernd_frac.data = NULL; __pyx_pybuffernd_frac.rcbuffer = &__pyx_pybuffer_frac; /* "photutils/geometry/circular_overlap.pyx":66 * * # Define output array * cdef np.ndarray[DTYPE_t, ndim=2] frac = np.zeros([ny, nx], dtype=DTYPE) # <<<<<<<<<<<<<< * * # Find the width of each element in x and y */ __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_ny); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_nx); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyList_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_1); PyList_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_3); PyList_SET_ITEM(__pyx_t_4, 1, __pyx_t_3); __pyx_t_1 = 0; __pyx_t_3 = 0; __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_DTYPE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_5 = ((PyArrayObject *)__pyx_t_1); { __Pyx_BufFmt_StackElem __pyx_stack[1]; if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_frac.rcbuffer->pybuffer, (PyObject*)__pyx_t_5, &__Pyx_TypeInfo_nn___pyx_t_9photutils_8geometry_16circular_overlap_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) { __pyx_v_frac = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_frac.rcbuffer->pybuffer.buf = NULL; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } else {__pyx_pybuffernd_frac.diminfo[0].strides = __pyx_pybuffernd_frac.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_frac.diminfo[0].shape = __pyx_pybuffernd_frac.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_frac.diminfo[1].strides = __pyx_pybuffernd_frac.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_frac.diminfo[1].shape = __pyx_pybuffernd_frac.rcbuffer->pybuffer.shape[1]; } } __pyx_t_5 = 0; __pyx_v_frac = ((PyArrayObject *)__pyx_t_1); __pyx_t_1 = 0; /* "photutils/geometry/circular_overlap.pyx":69 * * # Find the width of each element in x and y * dx = (xmax - xmin) / nx # <<<<<<<<<<<<<< * dy = (ymax - ymin) / ny * */ __pyx_t_6 = (__pyx_v_xmax - __pyx_v_xmin); if (unlikely(__pyx_v_nx == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "float division"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_v_dx = (__pyx_t_6 / ((double)__pyx_v_nx)); /* "photutils/geometry/circular_overlap.pyx":70 * # Find the width of each element in x and y * dx = (xmax - xmin) / nx * dy = (ymax - ymin) / ny # <<<<<<<<<<<<<< * * # Find the radius of a single pixel */ __pyx_t_6 = (__pyx_v_ymax - __pyx_v_ymin); if (unlikely(__pyx_v_ny == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "float division"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_v_dy = (__pyx_t_6 / ((double)__pyx_v_ny)); /* "photutils/geometry/circular_overlap.pyx":73 * * # Find the radius of a single pixel * pixel_radius = 0.5 * sqrt(dx * dx + dy * dy) # <<<<<<<<<<<<<< * * # Define bounding box */ __pyx_v_pixel_radius = (0.5 * sqrt(((__pyx_v_dx * __pyx_v_dx) + (__pyx_v_dy * __pyx_v_dy)))); /* "photutils/geometry/circular_overlap.pyx":76 * * # Define bounding box * bxmin = -r - 0.5 * dx # <<<<<<<<<<<<<< * bxmax = +r + 0.5 * dx * bymin = -r - 0.5 * dy */ __pyx_v_bxmin = ((-__pyx_v_r) - (0.5 * __pyx_v_dx)); /* "photutils/geometry/circular_overlap.pyx":77 * # Define bounding box * bxmin = -r - 0.5 * dx * bxmax = +r + 0.5 * dx # <<<<<<<<<<<<<< * bymin = -r - 0.5 * dy * bymax = +r + 0.5 * dy */ __pyx_v_bxmax = (__pyx_v_r + (0.5 * __pyx_v_dx)); /* "photutils/geometry/circular_overlap.pyx":78 * bxmin = -r - 0.5 * dx * bxmax = +r + 0.5 * dx * bymin = -r - 0.5 * dy # <<<<<<<<<<<<<< * bymax = +r + 0.5 * dy * */ __pyx_v_bymin = ((-__pyx_v_r) - (0.5 * __pyx_v_dy)); /* "photutils/geometry/circular_overlap.pyx":79 * bxmax = +r + 0.5 * dx * bymin = -r - 0.5 * dy * bymax = +r + 0.5 * dy # <<<<<<<<<<<<<< * * for i in range(nx): */ __pyx_v_bymax = (__pyx_v_r + (0.5 * __pyx_v_dy)); /* "photutils/geometry/circular_overlap.pyx":81 * bymax = +r + 0.5 * dy * * for i in range(nx): # <<<<<<<<<<<<<< * pxmin = xmin + i * dx # lower end of pixel * pxcen = pxmin + dx * 0.5 */ __pyx_t_7 = __pyx_v_nx; for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) { __pyx_v_i = __pyx_t_8; /* "photutils/geometry/circular_overlap.pyx":82 * * for i in range(nx): * pxmin = xmin + i * dx # lower end of pixel # <<<<<<<<<<<<<< * pxcen = pxmin + dx * 0.5 * pxmax = pxmin + dx # upper end of pixel */ __pyx_v_pxmin = (__pyx_v_xmin + (__pyx_v_i * __pyx_v_dx)); /* "photutils/geometry/circular_overlap.pyx":83 * for i in range(nx): * pxmin = xmin + i * dx # lower end of pixel * pxcen = pxmin + dx * 0.5 # <<<<<<<<<<<<<< * pxmax = pxmin + dx # upper end of pixel * if pxmax > bxmin and pxmin < bxmax: */ __pyx_v_pxcen = (__pyx_v_pxmin + (__pyx_v_dx * 0.5)); /* "photutils/geometry/circular_overlap.pyx":84 * pxmin = xmin + i * dx # lower end of pixel * pxcen = pxmin + dx * 0.5 * pxmax = pxmin + dx # upper end of pixel # <<<<<<<<<<<<<< * if pxmax > bxmin and pxmin < bxmax: * for j in range(ny): */ __pyx_v_pxmax = (__pyx_v_pxmin + __pyx_v_dx); /* "photutils/geometry/circular_overlap.pyx":85 * pxcen = pxmin + dx * 0.5 * pxmax = pxmin + dx # upper end of pixel * if pxmax > bxmin and pxmin < bxmax: # <<<<<<<<<<<<<< * for j in range(ny): * pymin = ymin + j * dy */ __pyx_t_10 = ((__pyx_v_pxmax > __pyx_v_bxmin) != 0); if (__pyx_t_10) { } else { __pyx_t_9 = __pyx_t_10; goto __pyx_L6_bool_binop_done; } __pyx_t_10 = ((__pyx_v_pxmin < __pyx_v_bxmax) != 0); __pyx_t_9 = __pyx_t_10; __pyx_L6_bool_binop_done:; if (__pyx_t_9) { /* "photutils/geometry/circular_overlap.pyx":86 * pxmax = pxmin + dx # upper end of pixel * if pxmax > bxmin and pxmin < bxmax: * for j in range(ny): # <<<<<<<<<<<<<< * pymin = ymin + j * dy * pycen = pymin + dy * 0.5 */ __pyx_t_11 = __pyx_v_ny; for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) { __pyx_v_j = __pyx_t_12; /* "photutils/geometry/circular_overlap.pyx":87 * if pxmax > bxmin and pxmin < bxmax: * for j in range(ny): * pymin = ymin + j * dy # <<<<<<<<<<<<<< * pycen = pymin + dy * 0.5 * pymax = pymin + dy */ __pyx_v_pymin = (__pyx_v_ymin + (__pyx_v_j * __pyx_v_dy)); /* "photutils/geometry/circular_overlap.pyx":88 * for j in range(ny): * pymin = ymin + j * dy * pycen = pymin + dy * 0.5 # <<<<<<<<<<<<<< * pymax = pymin + dy * if pymax > bymin and pymin < bymax: */ __pyx_v_pycen = (__pyx_v_pymin + (__pyx_v_dy * 0.5)); /* "photutils/geometry/circular_overlap.pyx":89 * pymin = ymin + j * dy * pycen = pymin + dy * 0.5 * pymax = pymin + dy # <<<<<<<<<<<<<< * if pymax > bymin and pymin < bymax: * */ __pyx_v_pymax = (__pyx_v_pymin + __pyx_v_dy); /* "photutils/geometry/circular_overlap.pyx":90 * pycen = pymin + dy * 0.5 * pymax = pymin + dy * if pymax > bymin and pymin < bymax: # <<<<<<<<<<<<<< * * # Distance from circle center to pixel center. */ __pyx_t_10 = ((__pyx_v_pymax > __pyx_v_bymin) != 0); if (__pyx_t_10) { } else { __pyx_t_9 = __pyx_t_10; goto __pyx_L11_bool_binop_done; } __pyx_t_10 = ((__pyx_v_pymin < __pyx_v_bymax) != 0); __pyx_t_9 = __pyx_t_10; __pyx_L11_bool_binop_done:; if (__pyx_t_9) { /* "photutils/geometry/circular_overlap.pyx":93 * * # Distance from circle center to pixel center. * d = sqrt(pxcen * pxcen + pycen * pycen) # <<<<<<<<<<<<<< * * # If pixel center is "well within" circle, count full */ __pyx_v_d = sqrt(((__pyx_v_pxcen * __pyx_v_pxcen) + (__pyx_v_pycen * __pyx_v_pycen))); /* "photutils/geometry/circular_overlap.pyx":97 * # If pixel center is "well within" circle, count full * # pixel. * if d < r - pixel_radius: # <<<<<<<<<<<<<< * frac[j, i] = 1. * */ __pyx_t_9 = ((__pyx_v_d < (__pyx_v_r - __pyx_v_pixel_radius)) != 0); if (__pyx_t_9) { /* "photutils/geometry/circular_overlap.pyx":98 * # pixel. * if d < r - pixel_radius: * frac[j, i] = 1. # <<<<<<<<<<<<<< * * # If pixel center is "close" to circle border, find */ __pyx_t_13 = __pyx_v_j; __pyx_t_14 = __pyx_v_i; __pyx_t_15 = -1; if (unlikely(__pyx_t_13 >= (size_t)__pyx_pybuffernd_frac.diminfo[0].shape)) __pyx_t_15 = 0; if (unlikely(__pyx_t_14 >= (size_t)__pyx_pybuffernd_frac.diminfo[1].shape)) __pyx_t_15 = 1; if (unlikely(__pyx_t_15 != -1)) { __Pyx_RaiseBufferIndexError(__pyx_t_15); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } *__Pyx_BufPtrStrided2d(__pyx_t_9photutils_8geometry_16circular_overlap_DTYPE_t *, __pyx_pybuffernd_frac.rcbuffer->pybuffer.buf, __pyx_t_13, __pyx_pybuffernd_frac.diminfo[0].strides, __pyx_t_14, __pyx_pybuffernd_frac.diminfo[1].strides) = 1.; /* "photutils/geometry/circular_overlap.pyx":97 * # If pixel center is "well within" circle, count full * # pixel. * if d < r - pixel_radius: # <<<<<<<<<<<<<< * frac[j, i] = 1. * */ goto __pyx_L13; } /* "photutils/geometry/circular_overlap.pyx":102 * # If pixel center is "close" to circle border, find * # overlap. * elif d < r + pixel_radius: # <<<<<<<<<<<<<< * * # Either do exact calculation or use subpixel */ __pyx_t_9 = ((__pyx_v_d < (__pyx_v_r + __pyx_v_pixel_radius)) != 0); if (__pyx_t_9) { /* "photutils/geometry/circular_overlap.pyx":106 * # Either do exact calculation or use subpixel * # sampling: * if use_exact: # <<<<<<<<<<<<<< * frac[j, i] = circular_overlap_single_exact( * pxmin, pymin, pxmax, pymax, r) / (dx * dy) */ __pyx_t_9 = (__pyx_v_use_exact != 0); if (__pyx_t_9) { /* "photutils/geometry/circular_overlap.pyx":107 * # sampling: * if use_exact: * frac[j, i] = circular_overlap_single_exact( # <<<<<<<<<<<<<< * pxmin, pymin, pxmax, pymax, r) / (dx * dy) * else: */ __pyx_t_6 = __pyx_f_9photutils_8geometry_16circular_overlap_circular_overlap_single_exact(__pyx_v_pxmin, __pyx_v_pymin, __pyx_v_pxmax, __pyx_v_pymax, __pyx_v_r); /* "photutils/geometry/circular_overlap.pyx":108 * if use_exact: * frac[j, i] = circular_overlap_single_exact( * pxmin, pymin, pxmax, pymax, r) / (dx * dy) # <<<<<<<<<<<<<< * else: * frac[j, i] = circular_overlap_single_subpixel( */ __pyx_t_16 = (__pyx_v_dx * __pyx_v_dy); if (unlikely(__pyx_t_16 == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "float division"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } /* "photutils/geometry/circular_overlap.pyx":107 * # sampling: * if use_exact: * frac[j, i] = circular_overlap_single_exact( # <<<<<<<<<<<<<< * pxmin, pymin, pxmax, pymax, r) / (dx * dy) * else: */ __pyx_t_17 = __pyx_v_j; __pyx_t_18 = __pyx_v_i; __pyx_t_15 = -1; if (unlikely(__pyx_t_17 >= (size_t)__pyx_pybuffernd_frac.diminfo[0].shape)) __pyx_t_15 = 0; if (unlikely(__pyx_t_18 >= (size_t)__pyx_pybuffernd_frac.diminfo[1].shape)) __pyx_t_15 = 1; if (unlikely(__pyx_t_15 != -1)) { __Pyx_RaiseBufferIndexError(__pyx_t_15); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } *__Pyx_BufPtrStrided2d(__pyx_t_9photutils_8geometry_16circular_overlap_DTYPE_t *, __pyx_pybuffernd_frac.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_frac.diminfo[0].strides, __pyx_t_18, __pyx_pybuffernd_frac.diminfo[1].strides) = (__pyx_t_6 / __pyx_t_16); /* "photutils/geometry/circular_overlap.pyx":106 * # Either do exact calculation or use subpixel * # sampling: * if use_exact: # <<<<<<<<<<<<<< * frac[j, i] = circular_overlap_single_exact( * pxmin, pymin, pxmax, pymax, r) / (dx * dy) */ goto __pyx_L14; } /* "photutils/geometry/circular_overlap.pyx":110 * pxmin, pymin, pxmax, pymax, r) / (dx * dy) * else: * frac[j, i] = circular_overlap_single_subpixel( # <<<<<<<<<<<<<< * pxmin, pymin, pxmax, pymax, r, subpixels) * */ /*else*/ { /* "photutils/geometry/circular_overlap.pyx":111 * else: * frac[j, i] = circular_overlap_single_subpixel( * pxmin, pymin, pxmax, pymax, r, subpixels) # <<<<<<<<<<<<<< * * # Otherwise, it is fully outside circle. */ __pyx_t_19 = __pyx_v_j; __pyx_t_20 = __pyx_v_i; __pyx_t_15 = -1; if (unlikely(__pyx_t_19 >= (size_t)__pyx_pybuffernd_frac.diminfo[0].shape)) __pyx_t_15 = 0; if (unlikely(__pyx_t_20 >= (size_t)__pyx_pybuffernd_frac.diminfo[1].shape)) __pyx_t_15 = 1; if (unlikely(__pyx_t_15 != -1)) { __Pyx_RaiseBufferIndexError(__pyx_t_15); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } *__Pyx_BufPtrStrided2d(__pyx_t_9photutils_8geometry_16circular_overlap_DTYPE_t *, __pyx_pybuffernd_frac.rcbuffer->pybuffer.buf, __pyx_t_19, __pyx_pybuffernd_frac.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_frac.diminfo[1].strides) = __pyx_f_9photutils_8geometry_16circular_overlap_circular_overlap_single_subpixel(__pyx_v_pxmin, __pyx_v_pymin, __pyx_v_pxmax, __pyx_v_pymax, __pyx_v_r, __pyx_v_subpixels); } __pyx_L14:; /* "photutils/geometry/circular_overlap.pyx":102 * # If pixel center is "close" to circle border, find * # overlap. * elif d < r + pixel_radius: # <<<<<<<<<<<<<< * * # Either do exact calculation or use subpixel */ } __pyx_L13:; /* "photutils/geometry/circular_overlap.pyx":90 * pycen = pymin + dy * 0.5 * pymax = pymin + dy * if pymax > bymin and pymin < bymax: # <<<<<<<<<<<<<< * * # Distance from circle center to pixel center. */ } } /* "photutils/geometry/circular_overlap.pyx":85 * pxcen = pxmin + dx * 0.5 * pxmax = pxmin + dx # upper end of pixel * if pxmax > bxmin and pxmin < bxmax: # <<<<<<<<<<<<<< * for j in range(ny): * pymin = ymin + j * dy */ } } /* "photutils/geometry/circular_overlap.pyx":116 * # No action needed. * * return frac # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(((PyObject *)__pyx_v_frac)); __pyx_r = ((PyObject *)__pyx_v_frac); goto __pyx_L0; /* "photutils/geometry/circular_overlap.pyx":29 * * * def circular_overlap_grid(double xmin, double xmax, double ymin, double ymax, # <<<<<<<<<<<<<< * int nx, int ny, double r, int use_exact, * int subpixels): */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_frac.rcbuffer->pybuffer); __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} __Pyx_AddTraceback("photutils.geometry.circular_overlap.circular_overlap_grid", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; goto __pyx_L2; __pyx_L0:; __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_frac.rcbuffer->pybuffer); __pyx_L2:; __Pyx_XDECREF((PyObject *)__pyx_v_frac); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "photutils/geometry/circular_overlap.pyx":125 * * * cdef double circular_overlap_single_subpixel(double x0, double y0, # <<<<<<<<<<<<<< * double x1, double y1, * double r, int subpixels): */ static double __pyx_f_9photutils_8geometry_16circular_overlap_circular_overlap_single_subpixel(double __pyx_v_x0, double __pyx_v_y0, double __pyx_v_x1, double __pyx_v_y1, double __pyx_v_r, int __pyx_v_subpixels) { CYTHON_UNUSED unsigned int __pyx_v_i; CYTHON_UNUSED unsigned int __pyx_v_j; double __pyx_v_x; double __pyx_v_y; double __pyx_v_dx; double __pyx_v_dy; double __pyx_v_r_squared; double __pyx_v_frac; double __pyx_r; __Pyx_RefNannyDeclarations double __pyx_t_1; int __pyx_t_2; unsigned int __pyx_t_3; int __pyx_t_4; unsigned int __pyx_t_5; int __pyx_t_6; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("circular_overlap_single_subpixel", 0); /* "photutils/geometry/circular_overlap.pyx":133 * cdef unsigned int i, j * cdef double x, y, dx, dy, r_squared * cdef double frac = 0. # Accumulator. # <<<<<<<<<<<<<< * * dx = (x1 - x0) / subpixels */ __pyx_v_frac = 0.; /* "photutils/geometry/circular_overlap.pyx":135 * cdef double frac = 0. # Accumulator. * * dx = (x1 - x0) / subpixels # <<<<<<<<<<<<<< * dy = (y1 - y0) / subpixels * r_squared = r ** 2 */ __pyx_t_1 = (__pyx_v_x1 - __pyx_v_x0); if (unlikely(__pyx_v_subpixels == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "float division"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_v_dx = (__pyx_t_1 / ((double)__pyx_v_subpixels)); /* "photutils/geometry/circular_overlap.pyx":136 * * dx = (x1 - x0) / subpixels * dy = (y1 - y0) / subpixels # <<<<<<<<<<<<<< * r_squared = r ** 2 * */ __pyx_t_1 = (__pyx_v_y1 - __pyx_v_y0); if (unlikely(__pyx_v_subpixels == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "float division"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_v_dy = (__pyx_t_1 / ((double)__pyx_v_subpixels)); /* "photutils/geometry/circular_overlap.pyx":137 * dx = (x1 - x0) / subpixels * dy = (y1 - y0) / subpixels * r_squared = r ** 2 # <<<<<<<<<<<<<< * * x = x0 - 0.5 * dx */ __pyx_v_r_squared = pow(__pyx_v_r, 2.0); /* "photutils/geometry/circular_overlap.pyx":139 * r_squared = r ** 2 * * x = x0 - 0.5 * dx # <<<<<<<<<<<<<< * for i in range(subpixels): * x += dx */ __pyx_v_x = (__pyx_v_x0 - (0.5 * __pyx_v_dx)); /* "photutils/geometry/circular_overlap.pyx":140 * * x = x0 - 0.5 * dx * for i in range(subpixels): # <<<<<<<<<<<<<< * x += dx * y = y0 - 0.5 * dy */ __pyx_t_2 = __pyx_v_subpixels; for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) { __pyx_v_i = __pyx_t_3; /* "photutils/geometry/circular_overlap.pyx":141 * x = x0 - 0.5 * dx * for i in range(subpixels): * x += dx # <<<<<<<<<<<<<< * y = y0 - 0.5 * dy * for j in range(subpixels): */ __pyx_v_x = (__pyx_v_x + __pyx_v_dx); /* "photutils/geometry/circular_overlap.pyx":142 * for i in range(subpixels): * x += dx * y = y0 - 0.5 * dy # <<<<<<<<<<<<<< * for j in range(subpixels): * y += dy */ __pyx_v_y = (__pyx_v_y0 - (0.5 * __pyx_v_dy)); /* "photutils/geometry/circular_overlap.pyx":143 * x += dx * y = y0 - 0.5 * dy * for j in range(subpixels): # <<<<<<<<<<<<<< * y += dy * if x * x + y * y < r_squared: */ __pyx_t_4 = __pyx_v_subpixels; for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) { __pyx_v_j = __pyx_t_5; /* "photutils/geometry/circular_overlap.pyx":144 * y = y0 - 0.5 * dy * for j in range(subpixels): * y += dy # <<<<<<<<<<<<<< * if x * x + y * y < r_squared: * frac += 1. */ __pyx_v_y = (__pyx_v_y + __pyx_v_dy); /* "photutils/geometry/circular_overlap.pyx":145 * for j in range(subpixels): * y += dy * if x * x + y * y < r_squared: # <<<<<<<<<<<<<< * frac += 1. * */ __pyx_t_6 = ((((__pyx_v_x * __pyx_v_x) + (__pyx_v_y * __pyx_v_y)) < __pyx_v_r_squared) != 0); if (__pyx_t_6) { /* "photutils/geometry/circular_overlap.pyx":146 * y += dy * if x * x + y * y < r_squared: * frac += 1. # <<<<<<<<<<<<<< * * return frac / (subpixels * subpixels) */ __pyx_v_frac = (__pyx_v_frac + 1.); /* "photutils/geometry/circular_overlap.pyx":145 * for j in range(subpixels): * y += dy * if x * x + y * y < r_squared: # <<<<<<<<<<<<<< * frac += 1. * */ } } } /* "photutils/geometry/circular_overlap.pyx":148 * frac += 1. * * return frac / (subpixels * subpixels) # <<<<<<<<<<<<<< * * */ __pyx_t_2 = (__pyx_v_subpixels * __pyx_v_subpixels); if (unlikely(__pyx_t_2 == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "float division"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_r = (__pyx_v_frac / ((double)__pyx_t_2)); goto __pyx_L0; /* "photutils/geometry/circular_overlap.pyx":125 * * * cdef double circular_overlap_single_subpixel(double x0, double y0, # <<<<<<<<<<<<<< * double x1, double y1, * double r, int subpixels): */ /* function exit code */ __pyx_L1_error:; __Pyx_WriteUnraisable("photutils.geometry.circular_overlap.circular_overlap_single_subpixel", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0); __pyx_r = 0; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "photutils/geometry/circular_overlap.pyx":151 * * * cdef double circular_overlap_single_exact(double xmin, double ymin, # <<<<<<<<<<<<<< * double xmax, double ymax, * double r): */ static double __pyx_f_9photutils_8geometry_16circular_overlap_circular_overlap_single_exact(double __pyx_v_xmin, double __pyx_v_ymin, double __pyx_v_xmax, double __pyx_v_ymax, double __pyx_v_r) { double __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; PyObject *__pyx_t_7 = NULL; PyObject *__pyx_t_8 = NULL; PyObject *__pyx_t_9 = NULL; Py_ssize_t __pyx_t_10; PyObject *__pyx_t_11 = NULL; double __pyx_t_12; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("circular_overlap_single_exact", 0); /* "photutils/geometry/circular_overlap.pyx":157 * Area of overlap of a rectangle and a circle * """ * if 0. <= xmin: # <<<<<<<<<<<<<< * if 0. <= ymin: * return circular_overlap_core(xmin, ymin, xmax, ymax, r) */ __pyx_t_1 = ((0. <= __pyx_v_xmin) != 0); if (__pyx_t_1) { /* "photutils/geometry/circular_overlap.pyx":158 * """ * if 0. <= xmin: * if 0. <= ymin: # <<<<<<<<<<<<<< * return circular_overlap_core(xmin, ymin, xmax, ymax, r) * elif 0. >= ymax: */ __pyx_t_1 = ((0. <= __pyx_v_ymin) != 0); if (__pyx_t_1) { /* "photutils/geometry/circular_overlap.pyx":159 * if 0. <= xmin: * if 0. <= ymin: * return circular_overlap_core(xmin, ymin, xmax, ymax, r) # <<<<<<<<<<<<<< * elif 0. >= ymax: * return circular_overlap_core(-ymax, xmin, -ymin, xmax, r) */ __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_circular_overlap_core); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyFloat_FromDouble(__pyx_v_xmin); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = PyFloat_FromDouble(__pyx_v_ymin); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = PyFloat_FromDouble(__pyx_v_xmax); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = PyFloat_FromDouble(__pyx_v_ymax); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __pyx_t_8 = PyFloat_FromDouble(__pyx_v_r); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); __pyx_t_9 = NULL; __pyx_t_10 = 0; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_10 = 1; } } __pyx_t_11 = PyTuple_New(5+__pyx_t_10); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_11); if (__pyx_t_9) { __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_9); __pyx_t_9 = NULL; } __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_10, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_10, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_10, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_11, 3+__pyx_t_10, __pyx_t_7); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_11, 4+__pyx_t_10, __pyx_t_8); __pyx_t_4 = 0; __pyx_t_5 = 0; __pyx_t_6 = 0; __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_11, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_12 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_12 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_12; goto __pyx_L0; /* "photutils/geometry/circular_overlap.pyx":158 * """ * if 0. <= xmin: * if 0. <= ymin: # <<<<<<<<<<<<<< * return circular_overlap_core(xmin, ymin, xmax, ymax, r) * elif 0. >= ymax: */ } /* "photutils/geometry/circular_overlap.pyx":160 * if 0. <= ymin: * return circular_overlap_core(xmin, ymin, xmax, ymax, r) * elif 0. >= ymax: # <<<<<<<<<<<<<< * return circular_overlap_core(-ymax, xmin, -ymin, xmax, r) * else: */ __pyx_t_1 = ((0. >= __pyx_v_ymax) != 0); if (__pyx_t_1) { /* "photutils/geometry/circular_overlap.pyx":161 * return circular_overlap_core(xmin, ymin, xmax, ymax, r) * elif 0. >= ymax: * return circular_overlap_core(-ymax, xmin, -ymin, xmax, r) # <<<<<<<<<<<<<< * else: * return circular_overlap_single_exact(xmin, ymin, xmax, 0., r) \ */ __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_circular_overlap_core); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_11 = PyFloat_FromDouble((-__pyx_v_ymax)); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_11); __pyx_t_8 = PyFloat_FromDouble(__pyx_v_xmin); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); __pyx_t_7 = PyFloat_FromDouble((-__pyx_v_ymin)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __pyx_t_6 = PyFloat_FromDouble(__pyx_v_xmax); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __pyx_t_5 = PyFloat_FromDouble(__pyx_v_r); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __pyx_t_4 = NULL; __pyx_t_10 = 0; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_10 = 1; } } __pyx_t_9 = PyTuple_New(5+__pyx_t_10); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_9); if (__pyx_t_4) { __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_4); __pyx_t_4 = NULL; } __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_10, __pyx_t_11); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_10, __pyx_t_8); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 2+__pyx_t_10, __pyx_t_7); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_9, 3+__pyx_t_10, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_9, 4+__pyx_t_10, __pyx_t_5); __pyx_t_11 = 0; __pyx_t_8 = 0; __pyx_t_7 = 0; __pyx_t_6 = 0; __pyx_t_5 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_9, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_12 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_12 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_12; goto __pyx_L0; /* "photutils/geometry/circular_overlap.pyx":160 * if 0. <= ymin: * return circular_overlap_core(xmin, ymin, xmax, ymax, r) * elif 0. >= ymax: # <<<<<<<<<<<<<< * return circular_overlap_core(-ymax, xmin, -ymin, xmax, r) * else: */ } /* "photutils/geometry/circular_overlap.pyx":163 * return circular_overlap_core(-ymax, xmin, -ymin, xmax, r) * else: * return circular_overlap_single_exact(xmin, ymin, xmax, 0., r) \ # <<<<<<<<<<<<<< * + circular_overlap_single_exact(xmin, 0., xmax, ymax, r) * elif 0. >= xmax: */ /*else*/ { /* "photutils/geometry/circular_overlap.pyx":164 * else: * return circular_overlap_single_exact(xmin, ymin, xmax, 0., r) \ * + circular_overlap_single_exact(xmin, 0., xmax, ymax, r) # <<<<<<<<<<<<<< * elif 0. >= xmax: * if 0. <= ymin: */ __pyx_r = (__pyx_f_9photutils_8geometry_16circular_overlap_circular_overlap_single_exact(__pyx_v_xmin, __pyx_v_ymin, __pyx_v_xmax, 0., __pyx_v_r) + __pyx_f_9photutils_8geometry_16circular_overlap_circular_overlap_single_exact(__pyx_v_xmin, 0., __pyx_v_xmax, __pyx_v_ymax, __pyx_v_r)); goto __pyx_L0; } /* "photutils/geometry/circular_overlap.pyx":157 * Area of overlap of a rectangle and a circle * """ * if 0. <= xmin: # <<<<<<<<<<<<<< * if 0. <= ymin: * return circular_overlap_core(xmin, ymin, xmax, ymax, r) */ } /* "photutils/geometry/circular_overlap.pyx":165 * return circular_overlap_single_exact(xmin, ymin, xmax, 0., r) \ * + circular_overlap_single_exact(xmin, 0., xmax, ymax, r) * elif 0. >= xmax: # <<<<<<<<<<<<<< * if 0. <= ymin: * return circular_overlap_core(-xmax, ymin, -xmin, ymax, r) */ __pyx_t_1 = ((0. >= __pyx_v_xmax) != 0); if (__pyx_t_1) { /* "photutils/geometry/circular_overlap.pyx":166 * + circular_overlap_single_exact(xmin, 0., xmax, ymax, r) * elif 0. >= xmax: * if 0. <= ymin: # <<<<<<<<<<<<<< * return circular_overlap_core(-xmax, ymin, -xmin, ymax, r) * elif 0. >= ymax: */ __pyx_t_1 = ((0. <= __pyx_v_ymin) != 0); if (__pyx_t_1) { /* "photutils/geometry/circular_overlap.pyx":167 * elif 0. >= xmax: * if 0. <= ymin: * return circular_overlap_core(-xmax, ymin, -xmin, ymax, r) # <<<<<<<<<<<<<< * elif 0. >= ymax: * return circular_overlap_core(-xmax, -ymax, -xmin, -ymin, r) */ __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_circular_overlap_core); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_9 = PyFloat_FromDouble((-__pyx_v_xmax)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_9); __pyx_t_5 = PyFloat_FromDouble(__pyx_v_ymin); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = PyFloat_FromDouble((-__pyx_v_xmin)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = PyFloat_FromDouble(__pyx_v_ymax); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __pyx_t_8 = PyFloat_FromDouble(__pyx_v_r); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); __pyx_t_11 = NULL; __pyx_t_10 = 0; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_11)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_11); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_10 = 1; } } __pyx_t_4 = PyTuple_New(5+__pyx_t_10); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); if (__pyx_t_11) { __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_11); __pyx_t_11 = NULL; } __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_10, __pyx_t_9); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_10, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 2+__pyx_t_10, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_4, 3+__pyx_t_10, __pyx_t_7); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_4, 4+__pyx_t_10, __pyx_t_8); __pyx_t_9 = 0; __pyx_t_5 = 0; __pyx_t_6 = 0; __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_12 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_12 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_12; goto __pyx_L0; /* "photutils/geometry/circular_overlap.pyx":166 * + circular_overlap_single_exact(xmin, 0., xmax, ymax, r) * elif 0. >= xmax: * if 0. <= ymin: # <<<<<<<<<<<<<< * return circular_overlap_core(-xmax, ymin, -xmin, ymax, r) * elif 0. >= ymax: */ } /* "photutils/geometry/circular_overlap.pyx":168 * if 0. <= ymin: * return circular_overlap_core(-xmax, ymin, -xmin, ymax, r) * elif 0. >= ymax: # <<<<<<<<<<<<<< * return circular_overlap_core(-xmax, -ymax, -xmin, -ymin, r) * else: */ __pyx_t_1 = ((0. >= __pyx_v_ymax) != 0); if (__pyx_t_1) { /* "photutils/geometry/circular_overlap.pyx":169 * return circular_overlap_core(-xmax, ymin, -xmin, ymax, r) * elif 0. >= ymax: * return circular_overlap_core(-xmax, -ymax, -xmin, -ymin, r) # <<<<<<<<<<<<<< * else: * return circular_overlap_single_exact(xmin, ymin, xmax, 0., r) \ */ __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_circular_overlap_core); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyFloat_FromDouble((-__pyx_v_xmax)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_8 = PyFloat_FromDouble((-__pyx_v_ymax)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); __pyx_t_7 = PyFloat_FromDouble((-__pyx_v_xmin)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __pyx_t_6 = PyFloat_FromDouble((-__pyx_v_ymin)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __pyx_t_5 = PyFloat_FromDouble(__pyx_v_r); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __pyx_t_9 = NULL; __pyx_t_10 = 0; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_10 = 1; } } __pyx_t_11 = PyTuple_New(5+__pyx_t_10); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_11); if (__pyx_t_9) { __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_9); __pyx_t_9 = NULL; } __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_10, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_10, __pyx_t_8); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_10, __pyx_t_7); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_11, 3+__pyx_t_10, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_11, 4+__pyx_t_10, __pyx_t_5); __pyx_t_4 = 0; __pyx_t_8 = 0; __pyx_t_7 = 0; __pyx_t_6 = 0; __pyx_t_5 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_11, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_12 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_12 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_12; goto __pyx_L0; /* "photutils/geometry/circular_overlap.pyx":168 * if 0. <= ymin: * return circular_overlap_core(-xmax, ymin, -xmin, ymax, r) * elif 0. >= ymax: # <<<<<<<<<<<<<< * return circular_overlap_core(-xmax, -ymax, -xmin, -ymin, r) * else: */ } /* "photutils/geometry/circular_overlap.pyx":171 * return circular_overlap_core(-xmax, -ymax, -xmin, -ymin, r) * else: * return circular_overlap_single_exact(xmin, ymin, xmax, 0., r) \ # <<<<<<<<<<<<<< * + circular_overlap_single_exact(xmin, 0., xmax, ymax, r) * else: */ /*else*/ { /* "photutils/geometry/circular_overlap.pyx":172 * else: * return circular_overlap_single_exact(xmin, ymin, xmax, 0., r) \ * + circular_overlap_single_exact(xmin, 0., xmax, ymax, r) # <<<<<<<<<<<<<< * else: * if 0. <= ymin: */ __pyx_r = (__pyx_f_9photutils_8geometry_16circular_overlap_circular_overlap_single_exact(__pyx_v_xmin, __pyx_v_ymin, __pyx_v_xmax, 0., __pyx_v_r) + __pyx_f_9photutils_8geometry_16circular_overlap_circular_overlap_single_exact(__pyx_v_xmin, 0., __pyx_v_xmax, __pyx_v_ymax, __pyx_v_r)); goto __pyx_L0; } /* "photutils/geometry/circular_overlap.pyx":165 * return circular_overlap_single_exact(xmin, ymin, xmax, 0., r) \ * + circular_overlap_single_exact(xmin, 0., xmax, ymax, r) * elif 0. >= xmax: # <<<<<<<<<<<<<< * if 0. <= ymin: * return circular_overlap_core(-xmax, ymin, -xmin, ymax, r) */ } /* "photutils/geometry/circular_overlap.pyx":174 * + circular_overlap_single_exact(xmin, 0., xmax, ymax, r) * else: * if 0. <= ymin: # <<<<<<<<<<<<<< * return circular_overlap_single_exact(xmin, ymin, 0., ymax, r) \ * + circular_overlap_single_exact(0., ymin, xmax, ymax, r) */ /*else*/ { __pyx_t_1 = ((0. <= __pyx_v_ymin) != 0); if (__pyx_t_1) { /* "photutils/geometry/circular_overlap.pyx":176 * if 0. <= ymin: * return circular_overlap_single_exact(xmin, ymin, 0., ymax, r) \ * + circular_overlap_single_exact(0., ymin, xmax, ymax, r) # <<<<<<<<<<<<<< * if 0. >= ymax: * return circular_overlap_single_exact(xmin, ymin, 0., ymax, r) \ */ __pyx_r = (__pyx_f_9photutils_8geometry_16circular_overlap_circular_overlap_single_exact(__pyx_v_xmin, __pyx_v_ymin, 0., __pyx_v_ymax, __pyx_v_r) + __pyx_f_9photutils_8geometry_16circular_overlap_circular_overlap_single_exact(0., __pyx_v_ymin, __pyx_v_xmax, __pyx_v_ymax, __pyx_v_r)); goto __pyx_L0; /* "photutils/geometry/circular_overlap.pyx":174 * + circular_overlap_single_exact(xmin, 0., xmax, ymax, r) * else: * if 0. <= ymin: # <<<<<<<<<<<<<< * return circular_overlap_single_exact(xmin, ymin, 0., ymax, r) \ * + circular_overlap_single_exact(0., ymin, xmax, ymax, r) */ } /* "photutils/geometry/circular_overlap.pyx":177 * return circular_overlap_single_exact(xmin, ymin, 0., ymax, r) \ * + circular_overlap_single_exact(0., ymin, xmax, ymax, r) * if 0. >= ymax: # <<<<<<<<<<<<<< * return circular_overlap_single_exact(xmin, ymin, 0., ymax, r) \ * + circular_overlap_single_exact(0., ymin, xmax, ymax, r) */ __pyx_t_1 = ((0. >= __pyx_v_ymax) != 0); if (__pyx_t_1) { /* "photutils/geometry/circular_overlap.pyx":179 * if 0. >= ymax: * return circular_overlap_single_exact(xmin, ymin, 0., ymax, r) \ * + circular_overlap_single_exact(0., ymin, xmax, ymax, r) # <<<<<<<<<<<<<< * else: * return circular_overlap_single_exact(xmin, ymin, 0., 0., r) \ */ __pyx_r = (__pyx_f_9photutils_8geometry_16circular_overlap_circular_overlap_single_exact(__pyx_v_xmin, __pyx_v_ymin, 0., __pyx_v_ymax, __pyx_v_r) + __pyx_f_9photutils_8geometry_16circular_overlap_circular_overlap_single_exact(0., __pyx_v_ymin, __pyx_v_xmax, __pyx_v_ymax, __pyx_v_r)); goto __pyx_L0; /* "photutils/geometry/circular_overlap.pyx":177 * return circular_overlap_single_exact(xmin, ymin, 0., ymax, r) \ * + circular_overlap_single_exact(0., ymin, xmax, ymax, r) * if 0. >= ymax: # <<<<<<<<<<<<<< * return circular_overlap_single_exact(xmin, ymin, 0., ymax, r) \ * + circular_overlap_single_exact(0., ymin, xmax, ymax, r) */ } /* "photutils/geometry/circular_overlap.pyx":181 * + circular_overlap_single_exact(0., ymin, xmax, ymax, r) * else: * return circular_overlap_single_exact(xmin, ymin, 0., 0., r) \ # <<<<<<<<<<<<<< * + circular_overlap_single_exact(0., ymin, xmax, 0., r) \ * + circular_overlap_single_exact(xmin, 0., 0., ymax, r) \ */ /*else*/ { /* "photutils/geometry/circular_overlap.pyx":184 * + circular_overlap_single_exact(0., ymin, xmax, 0., r) \ * + circular_overlap_single_exact(xmin, 0., 0., ymax, r) \ * + circular_overlap_single_exact(0., 0., xmax, ymax, r) # <<<<<<<<<<<<<< * * */ __pyx_r = (((__pyx_f_9photutils_8geometry_16circular_overlap_circular_overlap_single_exact(__pyx_v_xmin, __pyx_v_ymin, 0., 0., __pyx_v_r) + __pyx_f_9photutils_8geometry_16circular_overlap_circular_overlap_single_exact(0., __pyx_v_ymin, __pyx_v_xmax, 0., __pyx_v_r)) + __pyx_f_9photutils_8geometry_16circular_overlap_circular_overlap_single_exact(__pyx_v_xmin, 0., 0., __pyx_v_ymax, __pyx_v_r)) + __pyx_f_9photutils_8geometry_16circular_overlap_circular_overlap_single_exact(0., 0., __pyx_v_xmax, __pyx_v_ymax, __pyx_v_r)); goto __pyx_L0; } } /* "photutils/geometry/circular_overlap.pyx":151 * * * cdef double circular_overlap_single_exact(double xmin, double ymin, # <<<<<<<<<<<<<< * double xmax, double ymax, * double r): */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_11); __Pyx_WriteUnraisable("photutils.geometry.circular_overlap.circular_overlap_single_exact", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0); __pyx_r = 0; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "photutils/geometry/circular_overlap.pyx":187 * * * def circular_overlap_core(double xmin, double ymin, double xmax, double ymax, # <<<<<<<<<<<<<< * double r): * """Assumes that the center of the circle is <= xmin, */ /* Python wrapper */ static PyObject *__pyx_pw_9photutils_8geometry_16circular_overlap_3circular_overlap_core(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_9photutils_8geometry_16circular_overlap_2circular_overlap_core[] = "Assumes that the center of the circle is <= xmin,\n ymin (can always modify input to conform to this).\n "; static PyMethodDef __pyx_mdef_9photutils_8geometry_16circular_overlap_3circular_overlap_core = {"circular_overlap_core", (PyCFunction)__pyx_pw_9photutils_8geometry_16circular_overlap_3circular_overlap_core, METH_VARARGS|METH_KEYWORDS, __pyx_doc_9photutils_8geometry_16circular_overlap_2circular_overlap_core}; static PyObject *__pyx_pw_9photutils_8geometry_16circular_overlap_3circular_overlap_core(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { double __pyx_v_xmin; double __pyx_v_ymin; double __pyx_v_xmax; double __pyx_v_ymax; double __pyx_v_r; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("circular_overlap_core (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_xmin,&__pyx_n_s_ymin,&__pyx_n_s_xmax,&__pyx_n_s_ymax,&__pyx_n_s_r,0}; PyObject* values[5] = {0,0,0,0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_xmin)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ymin)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("circular_overlap_core", 1, 5, 5, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_xmax)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("circular_overlap_core", 1, 5, 5, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 3: if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ymax)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("circular_overlap_core", 1, 5, 5, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 4: if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_r)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("circular_overlap_core", 1, 5, 5, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "circular_overlap_core") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 5) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[2] = PyTuple_GET_ITEM(__pyx_args, 2); values[3] = PyTuple_GET_ITEM(__pyx_args, 3); values[4] = PyTuple_GET_ITEM(__pyx_args, 4); } __pyx_v_xmin = __pyx_PyFloat_AsDouble(values[0]); if (unlikely((__pyx_v_xmin == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_ymin = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_ymin == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_xmax = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_xmax == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_ymax = __pyx_PyFloat_AsDouble(values[3]); if (unlikely((__pyx_v_ymax == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_r = __pyx_PyFloat_AsDouble(values[4]); if (unlikely((__pyx_v_r == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("circular_overlap_core", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("photutils.geometry.circular_overlap.circular_overlap_core", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_9photutils_8geometry_16circular_overlap_2circular_overlap_core(__pyx_self, __pyx_v_xmin, __pyx_v_ymin, __pyx_v_xmax, __pyx_v_ymax, __pyx_v_r); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_9photutils_8geometry_16circular_overlap_2circular_overlap_core(CYTHON_UNUSED PyObject *__pyx_self, double __pyx_v_xmin, double __pyx_v_ymin, double __pyx_v_xmax, double __pyx_v_ymax, double __pyx_v_r) { double __pyx_v_area; double __pyx_v_d1; double __pyx_v_d2; double __pyx_v_x1; double __pyx_v_x2; double __pyx_v_y1; double __pyx_v_y2; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; double __pyx_t_3; double __pyx_t_4; PyObject *__pyx_t_5 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("circular_overlap_core", 0); /* "photutils/geometry/circular_overlap.pyx":195 * cdef double area, d1, d2, x1, x2, y1, y2 * * if xmin * xmin + ymin * ymin > r * r: # <<<<<<<<<<<<<< * area = 0. * elif xmax * xmax + ymax * ymax < r * r: */ __pyx_t_1 = ((((__pyx_v_xmin * __pyx_v_xmin) + (__pyx_v_ymin * __pyx_v_ymin)) > (__pyx_v_r * __pyx_v_r)) != 0); if (__pyx_t_1) { /* "photutils/geometry/circular_overlap.pyx":196 * * if xmin * xmin + ymin * ymin > r * r: * area = 0. # <<<<<<<<<<<<<< * elif xmax * xmax + ymax * ymax < r * r: * area = (xmax - xmin) * (ymax - ymin) */ __pyx_v_area = 0.; /* "photutils/geometry/circular_overlap.pyx":195 * cdef double area, d1, d2, x1, x2, y1, y2 * * if xmin * xmin + ymin * ymin > r * r: # <<<<<<<<<<<<<< * area = 0. * elif xmax * xmax + ymax * ymax < r * r: */ goto __pyx_L3; } /* "photutils/geometry/circular_overlap.pyx":197 * if xmin * xmin + ymin * ymin > r * r: * area = 0. * elif xmax * xmax + ymax * ymax < r * r: # <<<<<<<<<<<<<< * area = (xmax - xmin) * (ymax - ymin) * else: */ __pyx_t_1 = ((((__pyx_v_xmax * __pyx_v_xmax) + (__pyx_v_ymax * __pyx_v_ymax)) < (__pyx_v_r * __pyx_v_r)) != 0); if (__pyx_t_1) { /* "photutils/geometry/circular_overlap.pyx":198 * area = 0. * elif xmax * xmax + ymax * ymax < r * r: * area = (xmax - xmin) * (ymax - ymin) # <<<<<<<<<<<<<< * else: * area = 0. */ __pyx_v_area = ((__pyx_v_xmax - __pyx_v_xmin) * (__pyx_v_ymax - __pyx_v_ymin)); /* "photutils/geometry/circular_overlap.pyx":197 * if xmin * xmin + ymin * ymin > r * r: * area = 0. * elif xmax * xmax + ymax * ymax < r * r: # <<<<<<<<<<<<<< * area = (xmax - xmin) * (ymax - ymin) * else: */ goto __pyx_L3; } /* "photutils/geometry/circular_overlap.pyx":200 * area = (xmax - xmin) * (ymax - ymin) * else: * area = 0. # <<<<<<<<<<<<<< * d1 = sqrt(xmax * xmax + ymin * ymin) * d2 = sqrt(xmin * xmin + ymax * ymax) */ /*else*/ { __pyx_v_area = 0.; /* "photutils/geometry/circular_overlap.pyx":201 * else: * area = 0. * d1 = sqrt(xmax * xmax + ymin * ymin) # <<<<<<<<<<<<<< * d2 = sqrt(xmin * xmin + ymax * ymax) * if d1 < r and d2 < r: */ __pyx_v_d1 = sqrt(((__pyx_v_xmax * __pyx_v_xmax) + (__pyx_v_ymin * __pyx_v_ymin))); /* "photutils/geometry/circular_overlap.pyx":202 * area = 0. * d1 = sqrt(xmax * xmax + ymin * ymin) * d2 = sqrt(xmin * xmin + ymax * ymax) # <<<<<<<<<<<<<< * if d1 < r and d2 < r: * x1, y1 = sqrt(r * r - ymax * ymax), ymax */ __pyx_v_d2 = sqrt(((__pyx_v_xmin * __pyx_v_xmin) + (__pyx_v_ymax * __pyx_v_ymax))); /* "photutils/geometry/circular_overlap.pyx":203 * d1 = sqrt(xmax * xmax + ymin * ymin) * d2 = sqrt(xmin * xmin + ymax * ymax) * if d1 < r and d2 < r: # <<<<<<<<<<<<<< * x1, y1 = sqrt(r * r - ymax * ymax), ymax * x2, y2 = xmax, sqrt(r * r - xmax * xmax) */ __pyx_t_2 = ((__pyx_v_d1 < __pyx_v_r) != 0); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L5_bool_binop_done; } __pyx_t_2 = ((__pyx_v_d2 < __pyx_v_r) != 0); __pyx_t_1 = __pyx_t_2; __pyx_L5_bool_binop_done:; if (__pyx_t_1) { /* "photutils/geometry/circular_overlap.pyx":204 * d2 = sqrt(xmin * xmin + ymax * ymax) * if d1 < r and d2 < r: * x1, y1 = sqrt(r * r - ymax * ymax), ymax # <<<<<<<<<<<<<< * x2, y2 = xmax, sqrt(r * r - xmax * xmax) * area = ((xmax - xmin) * (ymax - ymin) - */ __pyx_t_3 = sqrt(((__pyx_v_r * __pyx_v_r) - (__pyx_v_ymax * __pyx_v_ymax))); __pyx_t_4 = __pyx_v_ymax; __pyx_v_x1 = __pyx_t_3; __pyx_v_y1 = __pyx_t_4; /* "photutils/geometry/circular_overlap.pyx":205 * if d1 < r and d2 < r: * x1, y1 = sqrt(r * r - ymax * ymax), ymax * x2, y2 = xmax, sqrt(r * r - xmax * xmax) # <<<<<<<<<<<<<< * area = ((xmax - xmin) * (ymax - ymin) - * area_triangle(x1, y1, x2, y2, xmax, ymax) + */ __pyx_t_4 = __pyx_v_xmax; __pyx_t_3 = sqrt(((__pyx_v_r * __pyx_v_r) - (__pyx_v_xmax * __pyx_v_xmax))); __pyx_v_x2 = __pyx_t_4; __pyx_v_y2 = __pyx_t_3; /* "photutils/geometry/circular_overlap.pyx":207 * x2, y2 = xmax, sqrt(r * r - xmax * xmax) * area = ((xmax - xmin) * (ymax - ymin) - * area_triangle(x1, y1, x2, y2, xmax, ymax) + # <<<<<<<<<<<<<< * area_arc(x1, y1, x2, y2, r)) * elif d1 < r: */ __pyx_v_area = ((((__pyx_v_xmax - __pyx_v_xmin) * (__pyx_v_ymax - __pyx_v_ymin)) - __pyx_f_9photutils_8geometry_4core_area_triangle(__pyx_v_x1, __pyx_v_y1, __pyx_v_x2, __pyx_v_y2, __pyx_v_xmax, __pyx_v_ymax)) + __pyx_f_9photutils_8geometry_4core_area_arc(__pyx_v_x1, __pyx_v_y1, __pyx_v_x2, __pyx_v_y2, __pyx_v_r)); /* "photutils/geometry/circular_overlap.pyx":203 * d1 = sqrt(xmax * xmax + ymin * ymin) * d2 = sqrt(xmin * xmin + ymax * ymax) * if d1 < r and d2 < r: # <<<<<<<<<<<<<< * x1, y1 = sqrt(r * r - ymax * ymax), ymax * x2, y2 = xmax, sqrt(r * r - xmax * xmax) */ goto __pyx_L4; } /* "photutils/geometry/circular_overlap.pyx":209 * area_triangle(x1, y1, x2, y2, xmax, ymax) + * area_arc(x1, y1, x2, y2, r)) * elif d1 < r: # <<<<<<<<<<<<<< * x1, y1 = xmin, sqrt(r * r - xmin * xmin) * x2, y2 = xmax, sqrt(r * r - xmax * xmax) */ __pyx_t_1 = ((__pyx_v_d1 < __pyx_v_r) != 0); if (__pyx_t_1) { /* "photutils/geometry/circular_overlap.pyx":210 * area_arc(x1, y1, x2, y2, r)) * elif d1 < r: * x1, y1 = xmin, sqrt(r * r - xmin * xmin) # <<<<<<<<<<<<<< * x2, y2 = xmax, sqrt(r * r - xmax * xmax) * area = (area_arc(x1, y1, x2, y2, r) + */ __pyx_t_3 = __pyx_v_xmin; __pyx_t_4 = sqrt(((__pyx_v_r * __pyx_v_r) - (__pyx_v_xmin * __pyx_v_xmin))); __pyx_v_x1 = __pyx_t_3; __pyx_v_y1 = __pyx_t_4; /* "photutils/geometry/circular_overlap.pyx":211 * elif d1 < r: * x1, y1 = xmin, sqrt(r * r - xmin * xmin) * x2, y2 = xmax, sqrt(r * r - xmax * xmax) # <<<<<<<<<<<<<< * area = (area_arc(x1, y1, x2, y2, r) + * area_triangle(x1, y1, x1, ymin, xmax, ymin) + */ __pyx_t_4 = __pyx_v_xmax; __pyx_t_3 = sqrt(((__pyx_v_r * __pyx_v_r) - (__pyx_v_xmax * __pyx_v_xmax))); __pyx_v_x2 = __pyx_t_4; __pyx_v_y2 = __pyx_t_3; /* "photutils/geometry/circular_overlap.pyx":213 * x2, y2 = xmax, sqrt(r * r - xmax * xmax) * area = (area_arc(x1, y1, x2, y2, r) + * area_triangle(x1, y1, x1, ymin, xmax, ymin) + # <<<<<<<<<<<<<< * area_triangle(x1, y1, x2, ymin, x2, y2)) * elif d2 < r: */ __pyx_v_area = ((__pyx_f_9photutils_8geometry_4core_area_arc(__pyx_v_x1, __pyx_v_y1, __pyx_v_x2, __pyx_v_y2, __pyx_v_r) + __pyx_f_9photutils_8geometry_4core_area_triangle(__pyx_v_x1, __pyx_v_y1, __pyx_v_x1, __pyx_v_ymin, __pyx_v_xmax, __pyx_v_ymin)) + __pyx_f_9photutils_8geometry_4core_area_triangle(__pyx_v_x1, __pyx_v_y1, __pyx_v_x2, __pyx_v_ymin, __pyx_v_x2, __pyx_v_y2)); /* "photutils/geometry/circular_overlap.pyx":209 * area_triangle(x1, y1, x2, y2, xmax, ymax) + * area_arc(x1, y1, x2, y2, r)) * elif d1 < r: # <<<<<<<<<<<<<< * x1, y1 = xmin, sqrt(r * r - xmin * xmin) * x2, y2 = xmax, sqrt(r * r - xmax * xmax) */ goto __pyx_L4; } /* "photutils/geometry/circular_overlap.pyx":215 * area_triangle(x1, y1, x1, ymin, xmax, ymin) + * area_triangle(x1, y1, x2, ymin, x2, y2)) * elif d2 < r: # <<<<<<<<<<<<<< * x1, y1 = sqrt(r * r - ymin * ymin), ymin * x2, y2 = sqrt(r * r - ymax * ymax), ymax */ __pyx_t_1 = ((__pyx_v_d2 < __pyx_v_r) != 0); if (__pyx_t_1) { /* "photutils/geometry/circular_overlap.pyx":216 * area_triangle(x1, y1, x2, ymin, x2, y2)) * elif d2 < r: * x1, y1 = sqrt(r * r - ymin * ymin), ymin # <<<<<<<<<<<<<< * x2, y2 = sqrt(r * r - ymax * ymax), ymax * area = (area_arc(x1, y1, x2, y2, r) + */ __pyx_t_3 = sqrt(((__pyx_v_r * __pyx_v_r) - (__pyx_v_ymin * __pyx_v_ymin))); __pyx_t_4 = __pyx_v_ymin; __pyx_v_x1 = __pyx_t_3; __pyx_v_y1 = __pyx_t_4; /* "photutils/geometry/circular_overlap.pyx":217 * elif d2 < r: * x1, y1 = sqrt(r * r - ymin * ymin), ymin * x2, y2 = sqrt(r * r - ymax * ymax), ymax # <<<<<<<<<<<<<< * area = (area_arc(x1, y1, x2, y2, r) + * area_triangle(x1, y1, xmin, y1, xmin, ymax) + */ __pyx_t_4 = sqrt(((__pyx_v_r * __pyx_v_r) - (__pyx_v_ymax * __pyx_v_ymax))); __pyx_t_3 = __pyx_v_ymax; __pyx_v_x2 = __pyx_t_4; __pyx_v_y2 = __pyx_t_3; /* "photutils/geometry/circular_overlap.pyx":219 * x2, y2 = sqrt(r * r - ymax * ymax), ymax * area = (area_arc(x1, y1, x2, y2, r) + * area_triangle(x1, y1, xmin, y1, xmin, ymax) + # <<<<<<<<<<<<<< * area_triangle(x1, y1, xmin, y2, x2, y2)) * else: */ __pyx_v_area = ((__pyx_f_9photutils_8geometry_4core_area_arc(__pyx_v_x1, __pyx_v_y1, __pyx_v_x2, __pyx_v_y2, __pyx_v_r) + __pyx_f_9photutils_8geometry_4core_area_triangle(__pyx_v_x1, __pyx_v_y1, __pyx_v_xmin, __pyx_v_y1, __pyx_v_xmin, __pyx_v_ymax)) + __pyx_f_9photutils_8geometry_4core_area_triangle(__pyx_v_x1, __pyx_v_y1, __pyx_v_xmin, __pyx_v_y2, __pyx_v_x2, __pyx_v_y2)); /* "photutils/geometry/circular_overlap.pyx":215 * area_triangle(x1, y1, x1, ymin, xmax, ymin) + * area_triangle(x1, y1, x2, ymin, x2, y2)) * elif d2 < r: # <<<<<<<<<<<<<< * x1, y1 = sqrt(r * r - ymin * ymin), ymin * x2, y2 = sqrt(r * r - ymax * ymax), ymax */ goto __pyx_L4; } /* "photutils/geometry/circular_overlap.pyx":222 * area_triangle(x1, y1, xmin, y2, x2, y2)) * else: * x1, y1 = sqrt(r * r - ymin * ymin), ymin # <<<<<<<<<<<<<< * x2, y2 = xmin, sqrt(r * r - xmin * xmin) * area = (area_arc(x1, y1, x2, y2, r) + */ /*else*/ { __pyx_t_3 = sqrt(((__pyx_v_r * __pyx_v_r) - (__pyx_v_ymin * __pyx_v_ymin))); __pyx_t_4 = __pyx_v_ymin; __pyx_v_x1 = __pyx_t_3; __pyx_v_y1 = __pyx_t_4; /* "photutils/geometry/circular_overlap.pyx":223 * else: * x1, y1 = sqrt(r * r - ymin * ymin), ymin * x2, y2 = xmin, sqrt(r * r - xmin * xmin) # <<<<<<<<<<<<<< * area = (area_arc(x1, y1, x2, y2, r) + * area_triangle(x1, y1, x2, y2, xmin, ymin)) */ __pyx_t_4 = __pyx_v_xmin; __pyx_t_3 = sqrt(((__pyx_v_r * __pyx_v_r) - (__pyx_v_xmin * __pyx_v_xmin))); __pyx_v_x2 = __pyx_t_4; __pyx_v_y2 = __pyx_t_3; /* "photutils/geometry/circular_overlap.pyx":224 * x1, y1 = sqrt(r * r - ymin * ymin), ymin * x2, y2 = xmin, sqrt(r * r - xmin * xmin) * area = (area_arc(x1, y1, x2, y2, r) + # <<<<<<<<<<<<<< * area_triangle(x1, y1, x2, y2, xmin, ymin)) * */ __pyx_v_area = (__pyx_f_9photutils_8geometry_4core_area_arc(__pyx_v_x1, __pyx_v_y1, __pyx_v_x2, __pyx_v_y2, __pyx_v_r) + __pyx_f_9photutils_8geometry_4core_area_triangle(__pyx_v_x1, __pyx_v_y1, __pyx_v_x2, __pyx_v_y2, __pyx_v_xmin, __pyx_v_ymin)); } __pyx_L4:; } __pyx_L3:; /* "photutils/geometry/circular_overlap.pyx":227 * area_triangle(x1, y1, x2, y2, xmin, ymin)) * * return area # <<<<<<<<<<<<<< */ __Pyx_XDECREF(__pyx_r); __pyx_t_5 = PyFloat_FromDouble(__pyx_v_area); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L0; /* "photutils/geometry/circular_overlap.pyx":187 * * * def circular_overlap_core(double xmin, double ymin, double xmax, double ymax, # <<<<<<<<<<<<<< * double r): * """Assumes that the center of the circle is <= xmin, */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("photutils.geometry.circular_overlap.circular_overlap_core", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":197 * # experimental exception made for __getbuffer__ and __releasebuffer__ * # -- the details of this may change. * def __getbuffer__(ndarray self, Py_buffer* info, int flags): # <<<<<<<<<<<<<< * # This implementation of getbuffer is geared towards Cython * # requirements, and does not yet fullfill the PEP. */ /* Python wrapper */ static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/ static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0); __pyx_r = __pyx_pf_5numpy_7ndarray___getbuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { int __pyx_v_copy_shape; int __pyx_v_i; int __pyx_v_ndim; int __pyx_v_endian_detector; int __pyx_v_little_endian; int __pyx_v_t; char *__pyx_v_f; PyArray_Descr *__pyx_v_descr = 0; int __pyx_v_offset; int __pyx_v_hasfields; int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; PyObject *__pyx_t_3 = NULL; int __pyx_t_4; int __pyx_t_5; PyObject *__pyx_t_6 = NULL; char *__pyx_t_7; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__getbuffer__", 0); if (__pyx_v_info != NULL) { __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None); __Pyx_GIVEREF(__pyx_v_info->obj); } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":203 * # of flags * * if info == NULL: return # <<<<<<<<<<<<<< * * cdef int copy_shape, i, ndim */ __pyx_t_1 = ((__pyx_v_info == NULL) != 0); if (__pyx_t_1) { __pyx_r = 0; goto __pyx_L0; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":206 * * cdef int copy_shape, i, ndim * cdef int endian_detector = 1 # <<<<<<<<<<<<<< * cdef bint little_endian = ((&endian_detector)[0] != 0) * */ __pyx_v_endian_detector = 1; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":207 * cdef int copy_shape, i, ndim * cdef int endian_detector = 1 * cdef bint little_endian = ((&endian_detector)[0] != 0) # <<<<<<<<<<<<<< * * ndim = PyArray_NDIM(self) */ __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":209 * cdef bint little_endian = ((&endian_detector)[0] != 0) * * ndim = PyArray_NDIM(self) # <<<<<<<<<<<<<< * * if sizeof(npy_intp) != sizeof(Py_ssize_t): */ __pyx_v_ndim = PyArray_NDIM(__pyx_v_self); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":211 * ndim = PyArray_NDIM(self) * * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< * copy_shape = 1 * else: */ __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0); if (__pyx_t_1) { /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":212 * * if sizeof(npy_intp) != sizeof(Py_ssize_t): * copy_shape = 1 # <<<<<<<<<<<<<< * else: * copy_shape = 0 */ __pyx_v_copy_shape = 1; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":211 * ndim = PyArray_NDIM(self) * * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< * copy_shape = 1 * else: */ goto __pyx_L4; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":214 * copy_shape = 1 * else: * copy_shape = 0 # <<<<<<<<<<<<<< * * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) */ /*else*/ { __pyx_v_copy_shape = 0; } __pyx_L4:; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":216 * copy_shape = 0 * * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): * raise ValueError(u"ndarray is not C contiguous") */ __pyx_t_2 = (((__pyx_v_flags & PyBUF_C_CONTIGUOUS) == PyBUF_C_CONTIGUOUS) != 0); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L6_bool_binop_done; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":217 * * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): # <<<<<<<<<<<<<< * raise ValueError(u"ndarray is not C contiguous") * */ __pyx_t_2 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_C_CONTIGUOUS) != 0)) != 0); __pyx_t_1 = __pyx_t_2; __pyx_L6_bool_binop_done:; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":216 * copy_shape = 0 * * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): * raise ValueError(u"ndarray is not C contiguous") */ if (__pyx_t_1) { /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":218 * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<< * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) */ __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; {__pyx_filename = __pyx_f[1]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":216 * copy_shape = 0 * * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): * raise ValueError(u"ndarray is not C contiguous") */ } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":220 * raise ValueError(u"ndarray is not C contiguous") * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): * raise ValueError(u"ndarray is not Fortran contiguous") */ __pyx_t_2 = (((__pyx_v_flags & PyBUF_F_CONTIGUOUS) == PyBUF_F_CONTIGUOUS) != 0); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L9_bool_binop_done; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":221 * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): # <<<<<<<<<<<<<< * raise ValueError(u"ndarray is not Fortran contiguous") * */ __pyx_t_2 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_F_CONTIGUOUS) != 0)) != 0); __pyx_t_1 = __pyx_t_2; __pyx_L9_bool_binop_done:; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":220 * raise ValueError(u"ndarray is not C contiguous") * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): * raise ValueError(u"ndarray is not Fortran contiguous") */ if (__pyx_t_1) { /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":222 * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<< * * info.buf = PyArray_DATA(self) */ __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; {__pyx_filename = __pyx_f[1]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":220 * raise ValueError(u"ndarray is not C contiguous") * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): * raise ValueError(u"ndarray is not Fortran contiguous") */ } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":224 * raise ValueError(u"ndarray is not Fortran contiguous") * * info.buf = PyArray_DATA(self) # <<<<<<<<<<<<<< * info.ndim = ndim * if copy_shape: */ __pyx_v_info->buf = PyArray_DATA(__pyx_v_self); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":225 * * info.buf = PyArray_DATA(self) * info.ndim = ndim # <<<<<<<<<<<<<< * if copy_shape: * # Allocate new buffer for strides and shape info. */ __pyx_v_info->ndim = __pyx_v_ndim; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":226 * info.buf = PyArray_DATA(self) * info.ndim = ndim * if copy_shape: # <<<<<<<<<<<<<< * # Allocate new buffer for strides and shape info. * # This is allocated as one block, strides first. */ __pyx_t_1 = (__pyx_v_copy_shape != 0); if (__pyx_t_1) { /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":229 * # Allocate new buffer for strides and shape info. * # This is allocated as one block, strides first. * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) # <<<<<<<<<<<<<< * info.shape = info.strides + ndim * for i in range(ndim): */ __pyx_v_info->strides = ((Py_ssize_t *)malloc((((sizeof(Py_ssize_t)) * ((size_t)__pyx_v_ndim)) * 2))); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":230 * # This is allocated as one block, strides first. * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) * info.shape = info.strides + ndim # <<<<<<<<<<<<<< * for i in range(ndim): * info.strides[i] = PyArray_STRIDES(self)[i] */ __pyx_v_info->shape = (__pyx_v_info->strides + __pyx_v_ndim); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":231 * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) * info.shape = info.strides + ndim * for i in range(ndim): # <<<<<<<<<<<<<< * info.strides[i] = PyArray_STRIDES(self)[i] * info.shape[i] = PyArray_DIMS(self)[i] */ __pyx_t_4 = __pyx_v_ndim; for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) { __pyx_v_i = __pyx_t_5; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":232 * info.shape = info.strides + ndim * for i in range(ndim): * info.strides[i] = PyArray_STRIDES(self)[i] # <<<<<<<<<<<<<< * info.shape[i] = PyArray_DIMS(self)[i] * else: */ (__pyx_v_info->strides[__pyx_v_i]) = (PyArray_STRIDES(__pyx_v_self)[__pyx_v_i]); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":233 * for i in range(ndim): * info.strides[i] = PyArray_STRIDES(self)[i] * info.shape[i] = PyArray_DIMS(self)[i] # <<<<<<<<<<<<<< * else: * info.strides = PyArray_STRIDES(self) */ (__pyx_v_info->shape[__pyx_v_i]) = (PyArray_DIMS(__pyx_v_self)[__pyx_v_i]); } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":226 * info.buf = PyArray_DATA(self) * info.ndim = ndim * if copy_shape: # <<<<<<<<<<<<<< * # Allocate new buffer for strides and shape info. * # This is allocated as one block, strides first. */ goto __pyx_L11; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":235 * info.shape[i] = PyArray_DIMS(self)[i] * else: * info.strides = PyArray_STRIDES(self) # <<<<<<<<<<<<<< * info.shape = PyArray_DIMS(self) * info.suboffsets = NULL */ /*else*/ { __pyx_v_info->strides = ((Py_ssize_t *)PyArray_STRIDES(__pyx_v_self)); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":236 * else: * info.strides = PyArray_STRIDES(self) * info.shape = PyArray_DIMS(self) # <<<<<<<<<<<<<< * info.suboffsets = NULL * info.itemsize = PyArray_ITEMSIZE(self) */ __pyx_v_info->shape = ((Py_ssize_t *)PyArray_DIMS(__pyx_v_self)); } __pyx_L11:; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":237 * info.strides = PyArray_STRIDES(self) * info.shape = PyArray_DIMS(self) * info.suboffsets = NULL # <<<<<<<<<<<<<< * info.itemsize = PyArray_ITEMSIZE(self) * info.readonly = not PyArray_ISWRITEABLE(self) */ __pyx_v_info->suboffsets = NULL; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":238 * info.shape = PyArray_DIMS(self) * info.suboffsets = NULL * info.itemsize = PyArray_ITEMSIZE(self) # <<<<<<<<<<<<<< * info.readonly = not PyArray_ISWRITEABLE(self) * */ __pyx_v_info->itemsize = PyArray_ITEMSIZE(__pyx_v_self); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":239 * info.suboffsets = NULL * info.itemsize = PyArray_ITEMSIZE(self) * info.readonly = not PyArray_ISWRITEABLE(self) # <<<<<<<<<<<<<< * * cdef int t */ __pyx_v_info->readonly = (!(PyArray_ISWRITEABLE(__pyx_v_self) != 0)); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":242 * * cdef int t * cdef char* f = NULL # <<<<<<<<<<<<<< * cdef dtype descr = self.descr * cdef int offset */ __pyx_v_f = NULL; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":243 * cdef int t * cdef char* f = NULL * cdef dtype descr = self.descr # <<<<<<<<<<<<<< * cdef int offset * */ __pyx_t_3 = ((PyObject *)__pyx_v_self->descr); __Pyx_INCREF(__pyx_t_3); __pyx_v_descr = ((PyArray_Descr *)__pyx_t_3); __pyx_t_3 = 0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":246 * cdef int offset * * cdef bint hasfields = PyDataType_HASFIELDS(descr) # <<<<<<<<<<<<<< * * if not hasfields and not copy_shape: */ __pyx_v_hasfields = PyDataType_HASFIELDS(__pyx_v_descr); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":248 * cdef bint hasfields = PyDataType_HASFIELDS(descr) * * if not hasfields and not copy_shape: # <<<<<<<<<<<<<< * # do not call releasebuffer * info.obj = None */ __pyx_t_2 = ((!(__pyx_v_hasfields != 0)) != 0); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L15_bool_binop_done; } __pyx_t_2 = ((!(__pyx_v_copy_shape != 0)) != 0); __pyx_t_1 = __pyx_t_2; __pyx_L15_bool_binop_done:; if (__pyx_t_1) { /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":250 * if not hasfields and not copy_shape: * # do not call releasebuffer * info.obj = None # <<<<<<<<<<<<<< * else: * # need to call releasebuffer */ __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_info->obj); __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = Py_None; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":248 * cdef bint hasfields = PyDataType_HASFIELDS(descr) * * if not hasfields and not copy_shape: # <<<<<<<<<<<<<< * # do not call releasebuffer * info.obj = None */ goto __pyx_L14; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":253 * else: * # need to call releasebuffer * info.obj = self # <<<<<<<<<<<<<< * * if not hasfields: */ /*else*/ { __Pyx_INCREF(((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); __Pyx_GOTREF(__pyx_v_info->obj); __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = ((PyObject *)__pyx_v_self); } __pyx_L14:; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":255 * info.obj = self * * if not hasfields: # <<<<<<<<<<<<<< * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or */ __pyx_t_1 = ((!(__pyx_v_hasfields != 0)) != 0); if (__pyx_t_1) { /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":256 * * if not hasfields: * t = descr.type_num # <<<<<<<<<<<<<< * if ((descr.byteorder == c'>' and little_endian) or * (descr.byteorder == c'<' and not little_endian)): */ __pyx_t_4 = __pyx_v_descr->type_num; __pyx_v_t = __pyx_t_4; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":257 * if not hasfields: * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< * (descr.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") */ __pyx_t_2 = ((__pyx_v_descr->byteorder == '>') != 0); if (!__pyx_t_2) { goto __pyx_L20_next_or; } else { } __pyx_t_2 = (__pyx_v_little_endian != 0); if (!__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L19_bool_binop_done; } __pyx_L20_next_or:; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":258 * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or * (descr.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<< * raise ValueError(u"Non-native byte order not supported") * if t == NPY_BYTE: f = "b" */ __pyx_t_2 = ((__pyx_v_descr->byteorder == '<') != 0); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L19_bool_binop_done; } __pyx_t_2 = ((!(__pyx_v_little_endian != 0)) != 0); __pyx_t_1 = __pyx_t_2; __pyx_L19_bool_binop_done:; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":257 * if not hasfields: * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< * (descr.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") */ if (__pyx_t_1) { /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":259 * if ((descr.byteorder == c'>' and little_endian) or * (descr.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< * if t == NPY_BYTE: f = "b" * elif t == NPY_UBYTE: f = "B" */ __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; {__pyx_filename = __pyx_f[1]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":257 * if not hasfields: * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< * (descr.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") */ } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":260 * (descr.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") * if t == NPY_BYTE: f = "b" # <<<<<<<<<<<<<< * elif t == NPY_UBYTE: f = "B" * elif t == NPY_SHORT: f = "h" */ switch (__pyx_v_t) { case NPY_BYTE: __pyx_v_f = __pyx_k_b; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":261 * raise ValueError(u"Non-native byte order not supported") * if t == NPY_BYTE: f = "b" * elif t == NPY_UBYTE: f = "B" # <<<<<<<<<<<<<< * elif t == NPY_SHORT: f = "h" * elif t == NPY_USHORT: f = "H" */ case NPY_UBYTE: __pyx_v_f = __pyx_k_B; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":262 * if t == NPY_BYTE: f = "b" * elif t == NPY_UBYTE: f = "B" * elif t == NPY_SHORT: f = "h" # <<<<<<<<<<<<<< * elif t == NPY_USHORT: f = "H" * elif t == NPY_INT: f = "i" */ case NPY_SHORT: __pyx_v_f = __pyx_k_h; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":263 * elif t == NPY_UBYTE: f = "B" * elif t == NPY_SHORT: f = "h" * elif t == NPY_USHORT: f = "H" # <<<<<<<<<<<<<< * elif t == NPY_INT: f = "i" * elif t == NPY_UINT: f = "I" */ case NPY_USHORT: __pyx_v_f = __pyx_k_H; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":264 * elif t == NPY_SHORT: f = "h" * elif t == NPY_USHORT: f = "H" * elif t == NPY_INT: f = "i" # <<<<<<<<<<<<<< * elif t == NPY_UINT: f = "I" * elif t == NPY_LONG: f = "l" */ case NPY_INT: __pyx_v_f = __pyx_k_i; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":265 * elif t == NPY_USHORT: f = "H" * elif t == NPY_INT: f = "i" * elif t == NPY_UINT: f = "I" # <<<<<<<<<<<<<< * elif t == NPY_LONG: f = "l" * elif t == NPY_ULONG: f = "L" */ case NPY_UINT: __pyx_v_f = __pyx_k_I; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":266 * elif t == NPY_INT: f = "i" * elif t == NPY_UINT: f = "I" * elif t == NPY_LONG: f = "l" # <<<<<<<<<<<<<< * elif t == NPY_ULONG: f = "L" * elif t == NPY_LONGLONG: f = "q" */ case NPY_LONG: __pyx_v_f = __pyx_k_l; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":267 * elif t == NPY_UINT: f = "I" * elif t == NPY_LONG: f = "l" * elif t == NPY_ULONG: f = "L" # <<<<<<<<<<<<<< * elif t == NPY_LONGLONG: f = "q" * elif t == NPY_ULONGLONG: f = "Q" */ case NPY_ULONG: __pyx_v_f = __pyx_k_L; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":268 * elif t == NPY_LONG: f = "l" * elif t == NPY_ULONG: f = "L" * elif t == NPY_LONGLONG: f = "q" # <<<<<<<<<<<<<< * elif t == NPY_ULONGLONG: f = "Q" * elif t == NPY_FLOAT: f = "f" */ case NPY_LONGLONG: __pyx_v_f = __pyx_k_q; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":269 * elif t == NPY_ULONG: f = "L" * elif t == NPY_LONGLONG: f = "q" * elif t == NPY_ULONGLONG: f = "Q" # <<<<<<<<<<<<<< * elif t == NPY_FLOAT: f = "f" * elif t == NPY_DOUBLE: f = "d" */ case NPY_ULONGLONG: __pyx_v_f = __pyx_k_Q; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":270 * elif t == NPY_LONGLONG: f = "q" * elif t == NPY_ULONGLONG: f = "Q" * elif t == NPY_FLOAT: f = "f" # <<<<<<<<<<<<<< * elif t == NPY_DOUBLE: f = "d" * elif t == NPY_LONGDOUBLE: f = "g" */ case NPY_FLOAT: __pyx_v_f = __pyx_k_f; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":271 * elif t == NPY_ULONGLONG: f = "Q" * elif t == NPY_FLOAT: f = "f" * elif t == NPY_DOUBLE: f = "d" # <<<<<<<<<<<<<< * elif t == NPY_LONGDOUBLE: f = "g" * elif t == NPY_CFLOAT: f = "Zf" */ case NPY_DOUBLE: __pyx_v_f = __pyx_k_d; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":272 * elif t == NPY_FLOAT: f = "f" * elif t == NPY_DOUBLE: f = "d" * elif t == NPY_LONGDOUBLE: f = "g" # <<<<<<<<<<<<<< * elif t == NPY_CFLOAT: f = "Zf" * elif t == NPY_CDOUBLE: f = "Zd" */ case NPY_LONGDOUBLE: __pyx_v_f = __pyx_k_g; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":273 * elif t == NPY_DOUBLE: f = "d" * elif t == NPY_LONGDOUBLE: f = "g" * elif t == NPY_CFLOAT: f = "Zf" # <<<<<<<<<<<<<< * elif t == NPY_CDOUBLE: f = "Zd" * elif t == NPY_CLONGDOUBLE: f = "Zg" */ case NPY_CFLOAT: __pyx_v_f = __pyx_k_Zf; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":274 * elif t == NPY_LONGDOUBLE: f = "g" * elif t == NPY_CFLOAT: f = "Zf" * elif t == NPY_CDOUBLE: f = "Zd" # <<<<<<<<<<<<<< * elif t == NPY_CLONGDOUBLE: f = "Zg" * elif t == NPY_OBJECT: f = "O" */ case NPY_CDOUBLE: __pyx_v_f = __pyx_k_Zd; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":275 * elif t == NPY_CFLOAT: f = "Zf" * elif t == NPY_CDOUBLE: f = "Zd" * elif t == NPY_CLONGDOUBLE: f = "Zg" # <<<<<<<<<<<<<< * elif t == NPY_OBJECT: f = "O" * else: */ case NPY_CLONGDOUBLE: __pyx_v_f = __pyx_k_Zg; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":276 * elif t == NPY_CDOUBLE: f = "Zd" * elif t == NPY_CLONGDOUBLE: f = "Zg" * elif t == NPY_OBJECT: f = "O" # <<<<<<<<<<<<<< * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) */ case NPY_OBJECT: __pyx_v_f = __pyx_k_O; break; default: /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":278 * elif t == NPY_OBJECT: f = "O" * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< * info.format = f * return */ __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_t); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = PyUnicode_Format(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_t_3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_6, 0, 0, 0); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; {__pyx_filename = __pyx_f[1]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L1_error;} break; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":279 * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) * info.format = f # <<<<<<<<<<<<<< * return * else: */ __pyx_v_info->format = __pyx_v_f; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":280 * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) * info.format = f * return # <<<<<<<<<<<<<< * else: * info.format = stdlib.malloc(_buffer_format_string_len) */ __pyx_r = 0; goto __pyx_L0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":255 * info.obj = self * * if not hasfields: # <<<<<<<<<<<<<< * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or */ } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":282 * return * else: * info.format = stdlib.malloc(_buffer_format_string_len) # <<<<<<<<<<<<<< * info.format[0] = c'^' # Native data types, manual alignment * offset = 0 */ /*else*/ { __pyx_v_info->format = ((char *)malloc(0xFF)); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":283 * else: * info.format = stdlib.malloc(_buffer_format_string_len) * info.format[0] = c'^' # Native data types, manual alignment # <<<<<<<<<<<<<< * offset = 0 * f = _util_dtypestring(descr, info.format + 1, */ (__pyx_v_info->format[0]) = '^'; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":284 * info.format = stdlib.malloc(_buffer_format_string_len) * info.format[0] = c'^' # Native data types, manual alignment * offset = 0 # <<<<<<<<<<<<<< * f = _util_dtypestring(descr, info.format + 1, * info.format + _buffer_format_string_len, */ __pyx_v_offset = 0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":285 * info.format[0] = c'^' # Native data types, manual alignment * offset = 0 * f = _util_dtypestring(descr, info.format + 1, # <<<<<<<<<<<<<< * info.format + _buffer_format_string_len, * &offset) */ __pyx_t_7 = __pyx_f_5numpy__util_dtypestring(__pyx_v_descr, (__pyx_v_info->format + 1), (__pyx_v_info->format + 0xFF), (&__pyx_v_offset)); if (unlikely(__pyx_t_7 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_f = __pyx_t_7; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":288 * info.format + _buffer_format_string_len, * &offset) * f[0] = c'\0' # Terminate format string # <<<<<<<<<<<<<< * * def __releasebuffer__(ndarray self, Py_buffer* info): */ (__pyx_v_f[0]) = '\x00'; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":197 * # experimental exception made for __getbuffer__ and __releasebuffer__ * # -- the details of this may change. * def __getbuffer__(ndarray self, Py_buffer* info, int flags): # <<<<<<<<<<<<<< * # This implementation of getbuffer is geared towards Cython * # requirements, and does not yet fullfill the PEP. */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_6); __Pyx_AddTraceback("numpy.ndarray.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; if (__pyx_v_info != NULL && __pyx_v_info->obj != NULL) { __Pyx_GOTREF(__pyx_v_info->obj); __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = NULL; } goto __pyx_L2; __pyx_L0:; if (__pyx_v_info != NULL && __pyx_v_info->obj == Py_None) { __Pyx_GOTREF(Py_None); __Pyx_DECREF(Py_None); __pyx_v_info->obj = NULL; } __pyx_L2:; __Pyx_XDECREF((PyObject *)__pyx_v_descr); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":290 * f[0] = c'\0' # Terminate format string * * def __releasebuffer__(ndarray self, Py_buffer* info): # <<<<<<<<<<<<<< * if PyArray_HASFIELDS(self): * stdlib.free(info.format) */ /* Python wrapper */ static CYTHON_UNUSED void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info); /*proto*/ static CYTHON_UNUSED void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__releasebuffer__ (wrapper)", 0); __pyx_pf_5numpy_7ndarray_2__releasebuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info)); /* function exit code */ __Pyx_RefNannyFinishContext(); } static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info) { __Pyx_RefNannyDeclarations int __pyx_t_1; __Pyx_RefNannySetupContext("__releasebuffer__", 0); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":291 * * def __releasebuffer__(ndarray self, Py_buffer* info): * if PyArray_HASFIELDS(self): # <<<<<<<<<<<<<< * stdlib.free(info.format) * if sizeof(npy_intp) != sizeof(Py_ssize_t): */ __pyx_t_1 = (PyArray_HASFIELDS(__pyx_v_self) != 0); if (__pyx_t_1) { /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":292 * def __releasebuffer__(ndarray self, Py_buffer* info): * if PyArray_HASFIELDS(self): * stdlib.free(info.format) # <<<<<<<<<<<<<< * if sizeof(npy_intp) != sizeof(Py_ssize_t): * stdlib.free(info.strides) */ free(__pyx_v_info->format); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":291 * * def __releasebuffer__(ndarray self, Py_buffer* info): * if PyArray_HASFIELDS(self): # <<<<<<<<<<<<<< * stdlib.free(info.format) * if sizeof(npy_intp) != sizeof(Py_ssize_t): */ } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":293 * if PyArray_HASFIELDS(self): * stdlib.free(info.format) * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< * stdlib.free(info.strides) * # info.shape was stored after info.strides in the same block */ __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0); if (__pyx_t_1) { /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":294 * stdlib.free(info.format) * if sizeof(npy_intp) != sizeof(Py_ssize_t): * stdlib.free(info.strides) # <<<<<<<<<<<<<< * # info.shape was stored after info.strides in the same block * */ free(__pyx_v_info->strides); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":293 * if PyArray_HASFIELDS(self): * stdlib.free(info.format) * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< * stdlib.free(info.strides) * # info.shape was stored after info.strides in the same block */ } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":290 * f[0] = c'\0' # Terminate format string * * def __releasebuffer__(ndarray self, Py_buffer* info): # <<<<<<<<<<<<<< * if PyArray_HASFIELDS(self): * stdlib.free(info.format) */ /* function exit code */ __Pyx_RefNannyFinishContext(); } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":770 * ctypedef npy_cdouble complex_t * * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< * return PyArray_MultiIterNew(1, a) * */ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__pyx_v_a) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("PyArray_MultiIterNew1", 0); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":771 * * cdef inline object PyArray_MultiIterNew1(a): * return PyArray_MultiIterNew(1, a) # <<<<<<<<<<<<<< * * cdef inline object PyArray_MultiIterNew2(a, b): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyArray_MultiIterNew(1, ((void *)__pyx_v_a)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 771; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":770 * ctypedef npy_cdouble complex_t * * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< * return PyArray_MultiIterNew(1, a) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("numpy.PyArray_MultiIterNew1", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":773 * return PyArray_MultiIterNew(1, a) * * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< * return PyArray_MultiIterNew(2, a, b) * */ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__pyx_v_a, PyObject *__pyx_v_b) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("PyArray_MultiIterNew2", 0); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":774 * * cdef inline object PyArray_MultiIterNew2(a, b): * return PyArray_MultiIterNew(2, a, b) # <<<<<<<<<<<<<< * * cdef inline object PyArray_MultiIterNew3(a, b, c): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyArray_MultiIterNew(2, ((void *)__pyx_v_a), ((void *)__pyx_v_b)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 774; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":773 * return PyArray_MultiIterNew(1, a) * * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< * return PyArray_MultiIterNew(2, a, b) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("numpy.PyArray_MultiIterNew2", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":776 * return PyArray_MultiIterNew(2, a, b) * * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< * return PyArray_MultiIterNew(3, a, b, c) * */ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("PyArray_MultiIterNew3", 0); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":777 * * cdef inline object PyArray_MultiIterNew3(a, b, c): * return PyArray_MultiIterNew(3, a, b, c) # <<<<<<<<<<<<<< * * cdef inline object PyArray_MultiIterNew4(a, b, c, d): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyArray_MultiIterNew(3, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 777; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":776 * return PyArray_MultiIterNew(2, a, b) * * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< * return PyArray_MultiIterNew(3, a, b, c) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("numpy.PyArray_MultiIterNew3", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":779 * return PyArray_MultiIterNew(3, a, b, c) * * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< * return PyArray_MultiIterNew(4, a, b, c, d) * */ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("PyArray_MultiIterNew4", 0); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":780 * * cdef inline object PyArray_MultiIterNew4(a, b, c, d): * return PyArray_MultiIterNew(4, a, b, c, d) # <<<<<<<<<<<<<< * * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyArray_MultiIterNew(4, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 780; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":779 * return PyArray_MultiIterNew(3, a, b, c) * * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< * return PyArray_MultiIterNew(4, a, b, c, d) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("numpy.PyArray_MultiIterNew4", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":782 * return PyArray_MultiIterNew(4, a, b, c, d) * * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< * return PyArray_MultiIterNew(5, a, b, c, d, e) * */ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d, PyObject *__pyx_v_e) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("PyArray_MultiIterNew5", 0); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":783 * * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): * return PyArray_MultiIterNew(5, a, b, c, d, e) # <<<<<<<<<<<<<< * * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyArray_MultiIterNew(5, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d), ((void *)__pyx_v_e)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 783; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":782 * return PyArray_MultiIterNew(4, a, b, c, d) * * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< * return PyArray_MultiIterNew(5, a, b, c, d, e) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("numpy.PyArray_MultiIterNew5", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":785 * return PyArray_MultiIterNew(5, a, b, c, d, e) * * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: # <<<<<<<<<<<<<< * # Recursive utility function used in __getbuffer__ to get format * # string. The new location in the format string is returned. */ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_descr, char *__pyx_v_f, char *__pyx_v_end, int *__pyx_v_offset) { PyArray_Descr *__pyx_v_child = 0; int __pyx_v_endian_detector; int __pyx_v_little_endian; PyObject *__pyx_v_fields = 0; PyObject *__pyx_v_childname = NULL; PyObject *__pyx_v_new_offset = NULL; PyObject *__pyx_v_t = NULL; char *__pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; Py_ssize_t __pyx_t_2; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; int __pyx_t_5; int __pyx_t_6; int __pyx_t_7; long __pyx_t_8; char *__pyx_t_9; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("_util_dtypestring", 0); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":790 * * cdef dtype child * cdef int endian_detector = 1 # <<<<<<<<<<<<<< * cdef bint little_endian = ((&endian_detector)[0] != 0) * cdef tuple fields */ __pyx_v_endian_detector = 1; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":791 * cdef dtype child * cdef int endian_detector = 1 * cdef bint little_endian = ((&endian_detector)[0] != 0) # <<<<<<<<<<<<<< * cdef tuple fields * */ __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":794 * cdef tuple fields * * for childname in descr.names: # <<<<<<<<<<<<<< * fields = descr.fields[childname] * child, new_offset = fields */ if (unlikely(__pyx_v_descr->names == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_t_1 = __pyx_v_descr->names; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; for (;;) { if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); #endif __Pyx_XDECREF_SET(__pyx_v_childname, __pyx_t_3); __pyx_t_3 = 0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":795 * * for childname in descr.names: * fields = descr.fields[childname] # <<<<<<<<<<<<<< * child, new_offset = fields * */ if (unlikely(__pyx_v_descr->fields == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_t_3 = __Pyx_PyDict_GetItem(__pyx_v_descr->fields, __pyx_v_childname); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; __Pyx_GOTREF(__pyx_t_3); if (!(likely(PyTuple_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_XDECREF_SET(__pyx_v_fields, ((PyObject*)__pyx_t_3)); __pyx_t_3 = 0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":796 * for childname in descr.names: * fields = descr.fields[childname] * child, new_offset = fields # <<<<<<<<<<<<<< * * if (end - f) - (new_offset - offset[0]) < 15: */ if (likely(__pyx_v_fields != Py_None)) { PyObject* sequence = __pyx_v_fields; #if CYTHON_COMPILING_IN_CPYTHON Py_ssize_t size = Py_SIZE(sequence); #else Py_ssize_t size = PySequence_Size(sequence); #endif if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); #else __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); #endif } else { __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_dtype))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_XDECREF_SET(__pyx_v_child, ((PyArray_Descr *)__pyx_t_3)); __pyx_t_3 = 0; __Pyx_XDECREF_SET(__pyx_v_new_offset, __pyx_t_4); __pyx_t_4 = 0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":798 * child, new_offset = fields * * if (end - f) - (new_offset - offset[0]) < 15: # <<<<<<<<<<<<<< * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") * */ __pyx_t_4 = __Pyx_PyInt_From_int((__pyx_v_offset[0])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyNumber_Subtract(__pyx_v_new_offset, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = ((((__pyx_v_end - __pyx_v_f) - ((int)__pyx_t_5)) < 15) != 0); if (__pyx_t_6) { /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":799 * * if (end - f) - (new_offset - offset[0]) < 15: * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<< * * if ((child.byteorder == c'>' and little_endian) or */ __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":798 * child, new_offset = fields * * if (end - f) - (new_offset - offset[0]) < 15: # <<<<<<<<<<<<<< * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") * */ } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":801 * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") * * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< * (child.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") */ __pyx_t_7 = ((__pyx_v_child->byteorder == '>') != 0); if (!__pyx_t_7) { goto __pyx_L8_next_or; } else { } __pyx_t_7 = (__pyx_v_little_endian != 0); if (!__pyx_t_7) { } else { __pyx_t_6 = __pyx_t_7; goto __pyx_L7_bool_binop_done; } __pyx_L8_next_or:; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":802 * * if ((child.byteorder == c'>' and little_endian) or * (child.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<< * raise ValueError(u"Non-native byte order not supported") * # One could encode it in the format string and have Cython */ __pyx_t_7 = ((__pyx_v_child->byteorder == '<') != 0); if (__pyx_t_7) { } else { __pyx_t_6 = __pyx_t_7; goto __pyx_L7_bool_binop_done; } __pyx_t_7 = ((!(__pyx_v_little_endian != 0)) != 0); __pyx_t_6 = __pyx_t_7; __pyx_L7_bool_binop_done:; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":801 * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") * * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< * (child.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") */ if (__pyx_t_6) { /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":803 * if ((child.byteorder == c'>' and little_endian) or * (child.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< * # One could encode it in the format string and have Cython * # complain instead, BUT: < and > in format strings also imply */ __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; {__pyx_filename = __pyx_f[1]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":801 * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") * * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< * (child.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") */ } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":813 * * # Output padding bytes * while offset[0] < new_offset: # <<<<<<<<<<<<<< * f[0] = 120 # "x"; pad byte * f += 1 */ while (1) { __pyx_t_3 = __Pyx_PyInt_From_int((__pyx_v_offset[0])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyObject_RichCompare(__pyx_t_3, __pyx_v_new_offset, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (!__pyx_t_6) break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":814 * # Output padding bytes * while offset[0] < new_offset: * f[0] = 120 # "x"; pad byte # <<<<<<<<<<<<<< * f += 1 * offset[0] += 1 */ (__pyx_v_f[0]) = 0x78; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":815 * while offset[0] < new_offset: * f[0] = 120 # "x"; pad byte * f += 1 # <<<<<<<<<<<<<< * offset[0] += 1 * */ __pyx_v_f = (__pyx_v_f + 1); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":816 * f[0] = 120 # "x"; pad byte * f += 1 * offset[0] += 1 # <<<<<<<<<<<<<< * * offset[0] += child.itemsize */ __pyx_t_8 = 0; (__pyx_v_offset[__pyx_t_8]) = ((__pyx_v_offset[__pyx_t_8]) + 1); } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":818 * offset[0] += 1 * * offset[0] += child.itemsize # <<<<<<<<<<<<<< * * if not PyDataType_HASFIELDS(child): */ __pyx_t_8 = 0; (__pyx_v_offset[__pyx_t_8]) = ((__pyx_v_offset[__pyx_t_8]) + __pyx_v_child->elsize); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":820 * offset[0] += child.itemsize * * if not PyDataType_HASFIELDS(child): # <<<<<<<<<<<<<< * t = child.type_num * if end - f < 5: */ __pyx_t_6 = ((!(PyDataType_HASFIELDS(__pyx_v_child) != 0)) != 0); if (__pyx_t_6) { /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":821 * * if not PyDataType_HASFIELDS(child): * t = child.type_num # <<<<<<<<<<<<<< * if end - f < 5: * raise RuntimeError(u"Format string allocated too short.") */ __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_child->type_num); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_4); __pyx_t_4 = 0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":822 * if not PyDataType_HASFIELDS(child): * t = child.type_num * if end - f < 5: # <<<<<<<<<<<<<< * raise RuntimeError(u"Format string allocated too short.") * */ __pyx_t_6 = (((__pyx_v_end - __pyx_v_f) < 5) != 0); if (__pyx_t_6) { /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":823 * t = child.type_num * if end - f < 5: * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<< * * # Until ticket #99 is fixed, use integers to avoid warnings */ __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; {__pyx_filename = __pyx_f[1]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":822 * if not PyDataType_HASFIELDS(child): * t = child.type_num * if end - f < 5: # <<<<<<<<<<<<<< * raise RuntimeError(u"Format string allocated too short.") * */ } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":826 * * # Until ticket #99 is fixed, use integers to avoid warnings * if t == NPY_BYTE: f[0] = 98 #"b" # <<<<<<<<<<<<<< * elif t == NPY_UBYTE: f[0] = 66 #"B" * elif t == NPY_SHORT: f[0] = 104 #"h" */ __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_BYTE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 98; goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":827 * # Until ticket #99 is fixed, use integers to avoid warnings * if t == NPY_BYTE: f[0] = 98 #"b" * elif t == NPY_UBYTE: f[0] = 66 #"B" # <<<<<<<<<<<<<< * elif t == NPY_SHORT: f[0] = 104 #"h" * elif t == NPY_USHORT: f[0] = 72 #"H" */ __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_UBYTE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 66; goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":828 * if t == NPY_BYTE: f[0] = 98 #"b" * elif t == NPY_UBYTE: f[0] = 66 #"B" * elif t == NPY_SHORT: f[0] = 104 #"h" # <<<<<<<<<<<<<< * elif t == NPY_USHORT: f[0] = 72 #"H" * elif t == NPY_INT: f[0] = 105 #"i" */ __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_SHORT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 0x68; goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":829 * elif t == NPY_UBYTE: f[0] = 66 #"B" * elif t == NPY_SHORT: f[0] = 104 #"h" * elif t == NPY_USHORT: f[0] = 72 #"H" # <<<<<<<<<<<<<< * elif t == NPY_INT: f[0] = 105 #"i" * elif t == NPY_UINT: f[0] = 73 #"I" */ __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_USHORT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 72; goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":830 * elif t == NPY_SHORT: f[0] = 104 #"h" * elif t == NPY_USHORT: f[0] = 72 #"H" * elif t == NPY_INT: f[0] = 105 #"i" # <<<<<<<<<<<<<< * elif t == NPY_UINT: f[0] = 73 #"I" * elif t == NPY_LONG: f[0] = 108 #"l" */ __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_INT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 0x69; goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":831 * elif t == NPY_USHORT: f[0] = 72 #"H" * elif t == NPY_INT: f[0] = 105 #"i" * elif t == NPY_UINT: f[0] = 73 #"I" # <<<<<<<<<<<<<< * elif t == NPY_LONG: f[0] = 108 #"l" * elif t == NPY_ULONG: f[0] = 76 #"L" */ __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_UINT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 73; goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":832 * elif t == NPY_INT: f[0] = 105 #"i" * elif t == NPY_UINT: f[0] = 73 #"I" * elif t == NPY_LONG: f[0] = 108 #"l" # <<<<<<<<<<<<<< * elif t == NPY_ULONG: f[0] = 76 #"L" * elif t == NPY_LONGLONG: f[0] = 113 #"q" */ __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONG); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 0x6C; goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":833 * elif t == NPY_UINT: f[0] = 73 #"I" * elif t == NPY_LONG: f[0] = 108 #"l" * elif t == NPY_ULONG: f[0] = 76 #"L" # <<<<<<<<<<<<<< * elif t == NPY_LONGLONG: f[0] = 113 #"q" * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" */ __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_ULONG); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 76; goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":834 * elif t == NPY_LONG: f[0] = 108 #"l" * elif t == NPY_ULONG: f[0] = 76 #"L" * elif t == NPY_LONGLONG: f[0] = 113 #"q" # <<<<<<<<<<<<<< * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" * elif t == NPY_FLOAT: f[0] = 102 #"f" */ __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONGLONG); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 0x71; goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":835 * elif t == NPY_ULONG: f[0] = 76 #"L" * elif t == NPY_LONGLONG: f[0] = 113 #"q" * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" # <<<<<<<<<<<<<< * elif t == NPY_FLOAT: f[0] = 102 #"f" * elif t == NPY_DOUBLE: f[0] = 100 #"d" */ __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_ULONGLONG); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 81; goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":836 * elif t == NPY_LONGLONG: f[0] = 113 #"q" * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" * elif t == NPY_FLOAT: f[0] = 102 #"f" # <<<<<<<<<<<<<< * elif t == NPY_DOUBLE: f[0] = 100 #"d" * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" */ __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_FLOAT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 0x66; goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":837 * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" * elif t == NPY_FLOAT: f[0] = 102 #"f" * elif t == NPY_DOUBLE: f[0] = 100 #"d" # <<<<<<<<<<<<<< * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf */ __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_DOUBLE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 0x64; goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":838 * elif t == NPY_FLOAT: f[0] = 102 #"f" * elif t == NPY_DOUBLE: f[0] = 100 #"d" * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" # <<<<<<<<<<<<<< * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd */ __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONGDOUBLE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 0x67; goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":839 * elif t == NPY_DOUBLE: f[0] = 100 #"d" * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf # <<<<<<<<<<<<<< * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg */ __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CFLOAT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 90; (__pyx_v_f[1]) = 0x66; __pyx_v_f = (__pyx_v_f + 1); goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":840 * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd # <<<<<<<<<<<<<< * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg * elif t == NPY_OBJECT: f[0] = 79 #"O" */ __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CDOUBLE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 90; (__pyx_v_f[1]) = 0x64; __pyx_v_f = (__pyx_v_f + 1); goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":841 * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg # <<<<<<<<<<<<<< * elif t == NPY_OBJECT: f[0] = 79 #"O" * else: */ __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CLONGDOUBLE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 90; (__pyx_v_f[1]) = 0x67; __pyx_v_f = (__pyx_v_f + 1); goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":842 * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg * elif t == NPY_OBJECT: f[0] = 79 #"O" # <<<<<<<<<<<<<< * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) */ __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_OBJECT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 79; goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":844 * elif t == NPY_OBJECT: f[0] = 79 #"O" * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< * f += 1 * else: */ /*else*/ { __pyx_t_3 = PyUnicode_Format(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_v_t); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; {__pyx_filename = __pyx_f[1]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_L15:; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":845 * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) * f += 1 # <<<<<<<<<<<<<< * else: * # Cython ignores struct boundary information ("T{...}"), */ __pyx_v_f = (__pyx_v_f + 1); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":820 * offset[0] += child.itemsize * * if not PyDataType_HASFIELDS(child): # <<<<<<<<<<<<<< * t = child.type_num * if end - f < 5: */ goto __pyx_L13; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":849 * # Cython ignores struct boundary information ("T{...}"), * # so don't output it * f = _util_dtypestring(child, f, end, offset) # <<<<<<<<<<<<<< * return f * */ /*else*/ { __pyx_t_9 = __pyx_f_5numpy__util_dtypestring(__pyx_v_child, __pyx_v_f, __pyx_v_end, __pyx_v_offset); if (unlikely(__pyx_t_9 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 849; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_f = __pyx_t_9; } __pyx_L13:; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":794 * cdef tuple fields * * for childname in descr.names: # <<<<<<<<<<<<<< * fields = descr.fields[childname] * child, new_offset = fields */ } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":850 * # so don't output it * f = _util_dtypestring(child, f, end, offset) * return f # <<<<<<<<<<<<<< * * */ __pyx_r = __pyx_v_f; goto __pyx_L0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":785 * return PyArray_MultiIterNew(5, a, b, c, d, e) * * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: # <<<<<<<<<<<<<< * # Recursive utility function used in __getbuffer__ to get format * # string. The new location in the format string is returned. */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("numpy._util_dtypestring", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF((PyObject *)__pyx_v_child); __Pyx_XDECREF(__pyx_v_fields); __Pyx_XDECREF(__pyx_v_childname); __Pyx_XDECREF(__pyx_v_new_offset); __Pyx_XDECREF(__pyx_v_t); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":966 * * * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< * cdef PyObject* baseptr * if base is None: */ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_arr, PyObject *__pyx_v_base) { PyObject *__pyx_v_baseptr; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; __Pyx_RefNannySetupContext("set_array_base", 0); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":968 * cdef inline void set_array_base(ndarray arr, object base): * cdef PyObject* baseptr * if base is None: # <<<<<<<<<<<<<< * baseptr = NULL * else: */ __pyx_t_1 = (__pyx_v_base == Py_None); __pyx_t_2 = (__pyx_t_1 != 0); if (__pyx_t_2) { /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":969 * cdef PyObject* baseptr * if base is None: * baseptr = NULL # <<<<<<<<<<<<<< * else: * Py_INCREF(base) # important to do this before decref below! */ __pyx_v_baseptr = NULL; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":968 * cdef inline void set_array_base(ndarray arr, object base): * cdef PyObject* baseptr * if base is None: # <<<<<<<<<<<<<< * baseptr = NULL * else: */ goto __pyx_L3; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":971 * baseptr = NULL * else: * Py_INCREF(base) # important to do this before decref below! # <<<<<<<<<<<<<< * baseptr = base * Py_XDECREF(arr.base) */ /*else*/ { Py_INCREF(__pyx_v_base); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":972 * else: * Py_INCREF(base) # important to do this before decref below! * baseptr = base # <<<<<<<<<<<<<< * Py_XDECREF(arr.base) * arr.base = baseptr */ __pyx_v_baseptr = ((PyObject *)__pyx_v_base); } __pyx_L3:; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":973 * Py_INCREF(base) # important to do this before decref below! * baseptr = base * Py_XDECREF(arr.base) # <<<<<<<<<<<<<< * arr.base = baseptr * */ Py_XDECREF(__pyx_v_arr->base); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":974 * baseptr = base * Py_XDECREF(arr.base) * arr.base = baseptr # <<<<<<<<<<<<<< * * cdef inline object get_array_base(ndarray arr): */ __pyx_v_arr->base = __pyx_v_baseptr; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":966 * * * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< * cdef PyObject* baseptr * if base is None: */ /* function exit code */ __Pyx_RefNannyFinishContext(); } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":976 * arr.base = baseptr * * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< * if arr.base is NULL: * return None */ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__pyx_v_arr) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; __Pyx_RefNannySetupContext("get_array_base", 0); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":977 * * cdef inline object get_array_base(ndarray arr): * if arr.base is NULL: # <<<<<<<<<<<<<< * return None * else: */ __pyx_t_1 = ((__pyx_v_arr->base == NULL) != 0); if (__pyx_t_1) { /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":978 * cdef inline object get_array_base(ndarray arr): * if arr.base is NULL: * return None # <<<<<<<<<<<<<< * else: * return arr.base */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(Py_None); __pyx_r = Py_None; goto __pyx_L0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":977 * * cdef inline object get_array_base(ndarray arr): * if arr.base is NULL: # <<<<<<<<<<<<<< * return None * else: */ } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":980 * return None * else: * return arr.base # <<<<<<<<<<<<<< */ /*else*/ { __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(((PyObject *)__pyx_v_arr->base)); __pyx_r = ((PyObject *)__pyx_v_arr->base); goto __pyx_L0; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":976 * arr.base = baseptr * * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< * if arr.base is NULL: * return None */ /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyMethodDef __pyx_methods[] = { {0, 0, 0, 0} }; #if PY_MAJOR_VERSION >= 3 static struct PyModuleDef __pyx_moduledef = { #if PY_VERSION_HEX < 0x03020000 { PyObject_HEAD_INIT(NULL) NULL, 0, NULL }, #else PyModuleDef_HEAD_INIT, #endif "circular_overlap", 0, /* m_doc */ -1, /* m_size */ __pyx_methods /* m_methods */, NULL, /* m_reload */ NULL, /* m_traverse */ NULL, /* m_clear */ NULL /* m_free */ }; #endif static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_DTYPE, __pyx_k_DTYPE, sizeof(__pyx_k_DTYPE), 0, 0, 1, 1}, {&__pyx_kp_u_Format_string_allocated_too_shor, __pyx_k_Format_string_allocated_too_shor, sizeof(__pyx_k_Format_string_allocated_too_shor), 0, 1, 0, 0}, {&__pyx_kp_u_Format_string_allocated_too_shor_2, __pyx_k_Format_string_allocated_too_shor_2, sizeof(__pyx_k_Format_string_allocated_too_shor_2), 0, 1, 0, 0}, {&__pyx_kp_u_Non_native_byte_order_not_suppor, __pyx_k_Non_native_byte_order_not_suppor, sizeof(__pyx_k_Non_native_byte_order_not_suppor), 0, 1, 0, 0}, {&__pyx_n_s_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 0, 0, 1, 1}, {&__pyx_kp_s_Users_lbradley_Dropbox_softw_de, __pyx_k_Users_lbradley_Dropbox_softw_de, sizeof(__pyx_k_Users_lbradley_Dropbox_softw_de), 0, 0, 1, 0}, {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1}, {&__pyx_n_s_all, __pyx_k_all, sizeof(__pyx_k_all), 0, 0, 1, 1}, {&__pyx_n_s_area, __pyx_k_area, sizeof(__pyx_k_area), 0, 0, 1, 1}, {&__pyx_n_s_bxmax, __pyx_k_bxmax, sizeof(__pyx_k_bxmax), 0, 0, 1, 1}, {&__pyx_n_s_bxmin, __pyx_k_bxmin, sizeof(__pyx_k_bxmin), 0, 0, 1, 1}, {&__pyx_n_s_bymax, __pyx_k_bymax, sizeof(__pyx_k_bymax), 0, 0, 1, 1}, {&__pyx_n_s_bymin, __pyx_k_bymin, sizeof(__pyx_k_bymin), 0, 0, 1, 1}, {&__pyx_n_s_circular_overlap_core, __pyx_k_circular_overlap_core, sizeof(__pyx_k_circular_overlap_core), 0, 0, 1, 1}, {&__pyx_n_s_circular_overlap_grid, __pyx_k_circular_overlap_grid, sizeof(__pyx_k_circular_overlap_grid), 0, 0, 1, 1}, {&__pyx_n_u_circular_overlap_grid, __pyx_k_circular_overlap_grid, sizeof(__pyx_k_circular_overlap_grid), 0, 1, 0, 1}, {&__pyx_n_s_d, __pyx_k_d, sizeof(__pyx_k_d), 0, 0, 1, 1}, {&__pyx_n_s_d1, __pyx_k_d1, sizeof(__pyx_k_d1), 0, 0, 1, 1}, {&__pyx_n_s_d2, __pyx_k_d2, sizeof(__pyx_k_d2), 0, 0, 1, 1}, {&__pyx_n_s_dtype, __pyx_k_dtype, sizeof(__pyx_k_dtype), 0, 0, 1, 1}, {&__pyx_n_s_dx, __pyx_k_dx, sizeof(__pyx_k_dx), 0, 0, 1, 1}, {&__pyx_n_s_dy, __pyx_k_dy, sizeof(__pyx_k_dy), 0, 0, 1, 1}, {&__pyx_n_s_float64, __pyx_k_float64, sizeof(__pyx_k_float64), 0, 0, 1, 1}, {&__pyx_n_s_frac, __pyx_k_frac, sizeof(__pyx_k_frac), 0, 0, 1, 1}, {&__pyx_n_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 1}, {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1}, {&__pyx_n_s_j, __pyx_k_j, sizeof(__pyx_k_j), 0, 0, 1, 1}, {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, {&__pyx_kp_u_ndarray_is_not_C_contiguous, __pyx_k_ndarray_is_not_C_contiguous, sizeof(__pyx_k_ndarray_is_not_C_contiguous), 0, 1, 0, 0}, {&__pyx_kp_u_ndarray_is_not_Fortran_contiguou, __pyx_k_ndarray_is_not_Fortran_contiguou, sizeof(__pyx_k_ndarray_is_not_Fortran_contiguou), 0, 1, 0, 0}, {&__pyx_n_s_np, __pyx_k_np, sizeof(__pyx_k_np), 0, 0, 1, 1}, {&__pyx_n_s_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 0, 0, 1, 1}, {&__pyx_n_s_nx, __pyx_k_nx, sizeof(__pyx_k_nx), 0, 0, 1, 1}, {&__pyx_n_s_ny, __pyx_k_ny, sizeof(__pyx_k_ny), 0, 0, 1, 1}, {&__pyx_n_s_photutils_geometry_circular_over, __pyx_k_photutils_geometry_circular_over, sizeof(__pyx_k_photutils_geometry_circular_over), 0, 0, 1, 1}, {&__pyx_n_s_pixel_radius, __pyx_k_pixel_radius, sizeof(__pyx_k_pixel_radius), 0, 0, 1, 1}, {&__pyx_n_s_pxcen, __pyx_k_pxcen, sizeof(__pyx_k_pxcen), 0, 0, 1, 1}, {&__pyx_n_s_pxmax, __pyx_k_pxmax, sizeof(__pyx_k_pxmax), 0, 0, 1, 1}, {&__pyx_n_s_pxmin, __pyx_k_pxmin, sizeof(__pyx_k_pxmin), 0, 0, 1, 1}, {&__pyx_n_s_pycen, __pyx_k_pycen, sizeof(__pyx_k_pycen), 0, 0, 1, 1}, {&__pyx_n_s_pymax, __pyx_k_pymax, sizeof(__pyx_k_pymax), 0, 0, 1, 1}, {&__pyx_n_s_pymin, __pyx_k_pymin, sizeof(__pyx_k_pymin), 0, 0, 1, 1}, {&__pyx_n_s_r, __pyx_k_r, sizeof(__pyx_k_r), 0, 0, 1, 1}, {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1}, {&__pyx_n_s_subpixels, __pyx_k_subpixels, sizeof(__pyx_k_subpixels), 0, 0, 1, 1}, {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, {&__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_k_unknown_dtype_code_in_numpy_pxd, sizeof(__pyx_k_unknown_dtype_code_in_numpy_pxd), 0, 1, 0, 0}, {&__pyx_n_s_use_exact, __pyx_k_use_exact, sizeof(__pyx_k_use_exact), 0, 0, 1, 1}, {&__pyx_n_s_x, __pyx_k_x, sizeof(__pyx_k_x), 0, 0, 1, 1}, {&__pyx_n_s_x1, __pyx_k_x1, sizeof(__pyx_k_x1), 0, 0, 1, 1}, {&__pyx_n_s_x2, __pyx_k_x2, sizeof(__pyx_k_x2), 0, 0, 1, 1}, {&__pyx_n_s_xmax, __pyx_k_xmax, sizeof(__pyx_k_xmax), 0, 0, 1, 1}, {&__pyx_n_s_xmin, __pyx_k_xmin, sizeof(__pyx_k_xmin), 0, 0, 1, 1}, {&__pyx_n_s_y, __pyx_k_y, sizeof(__pyx_k_y), 0, 0, 1, 1}, {&__pyx_n_s_y1, __pyx_k_y1, sizeof(__pyx_k_y1), 0, 0, 1, 1}, {&__pyx_n_s_y2, __pyx_k_y2, sizeof(__pyx_k_y2), 0, 0, 1, 1}, {&__pyx_n_s_ymax, __pyx_k_ymax, sizeof(__pyx_k_ymax), 0, 0, 1, 1}, {&__pyx_n_s_ymin, __pyx_k_ymin, sizeof(__pyx_k_ymin), 0, 0, 1, 1}, {&__pyx_n_s_zeros, __pyx_k_zeros, sizeof(__pyx_k_zeros), 0, 0, 1, 1}, {0, 0, 0, 0, 0, 0, 0} }; static int __Pyx_InitCachedBuiltins(void) { __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} return 0; __pyx_L1_error:; return -1; } static int __Pyx_InitCachedConstants(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":218 * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<< * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) */ __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_C_contiguous); if (unlikely(!__pyx_tuple_)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple_); __Pyx_GIVEREF(__pyx_tuple_); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":222 * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<< * * info.buf = PyArray_DATA(self) */ __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_Fortran_contiguou); if (unlikely(!__pyx_tuple__2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__2); __Pyx_GIVEREF(__pyx_tuple__2); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":259 * if ((descr.byteorder == c'>' and little_endian) or * (descr.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< * if t == NPY_BYTE: f = "b" * elif t == NPY_UBYTE: f = "B" */ __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__3); __Pyx_GIVEREF(__pyx_tuple__3); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":799 * * if (end - f) - (new_offset - offset[0]) < 15: * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<< * * if ((child.byteorder == c'>' and little_endian) or */ __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor); if (unlikely(!__pyx_tuple__4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__4); __Pyx_GIVEREF(__pyx_tuple__4); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":803 * if ((child.byteorder == c'>' and little_endian) or * (child.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< * # One could encode it in the format string and have Cython * # complain instead, BUT: < and > in format strings also imply */ __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__5); __Pyx_GIVEREF(__pyx_tuple__5); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":823 * t = child.type_num * if end - f < 5: * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<< * * # Until ticket #99 is fixed, use integers to avoid warnings */ __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor_2); if (unlikely(!__pyx_tuple__6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__6); __Pyx_GIVEREF(__pyx_tuple__6); /* "photutils/geometry/circular_overlap.pyx":29 * * * def circular_overlap_grid(double xmin, double xmax, double ymin, double ymax, # <<<<<<<<<<<<<< * int nx, int ny, double r, int use_exact, * int subpixels): */ __pyx_tuple__7 = PyTuple_Pack(28, __pyx_n_s_xmin, __pyx_n_s_xmax, __pyx_n_s_ymin, __pyx_n_s_ymax, __pyx_n_s_nx, __pyx_n_s_ny, __pyx_n_s_r, __pyx_n_s_use_exact, __pyx_n_s_subpixels, __pyx_n_s_i, __pyx_n_s_j, __pyx_n_s_x, __pyx_n_s_y, __pyx_n_s_dx, __pyx_n_s_dy, __pyx_n_s_d, __pyx_n_s_pixel_radius, __pyx_n_s_bxmin, __pyx_n_s_bxmax, __pyx_n_s_bymin, __pyx_n_s_bymax, __pyx_n_s_pxmin, __pyx_n_s_pxcen, __pyx_n_s_pxmax, __pyx_n_s_pymin, __pyx_n_s_pycen, __pyx_n_s_pymax, __pyx_n_s_frac); if (unlikely(!__pyx_tuple__7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__7); __Pyx_GIVEREF(__pyx_tuple__7); __pyx_codeobj__8 = (PyObject*)__Pyx_PyCode_New(9, 0, 28, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__7, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_lbradley_Dropbox_softw_de, __pyx_n_s_circular_overlap_grid, 29, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "photutils/geometry/circular_overlap.pyx":187 * * * def circular_overlap_core(double xmin, double ymin, double xmax, double ymax, # <<<<<<<<<<<<<< * double r): * """Assumes that the center of the circle is <= xmin, */ __pyx_tuple__9 = PyTuple_Pack(12, __pyx_n_s_xmin, __pyx_n_s_ymin, __pyx_n_s_xmax, __pyx_n_s_ymax, __pyx_n_s_r, __pyx_n_s_area, __pyx_n_s_d1, __pyx_n_s_d2, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_y1, __pyx_n_s_y2); if (unlikely(!__pyx_tuple__9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__9); __Pyx_GIVEREF(__pyx_tuple__9); __pyx_codeobj__10 = (PyObject*)__Pyx_PyCode_New(5, 0, 12, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__9, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_lbradley_Dropbox_softw_de, __pyx_n_s_circular_overlap_core, 187, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; __Pyx_RefNannyFinishContext(); return -1; } static int __Pyx_InitGlobals(void) { if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; return 0; __pyx_L1_error:; return -1; } #if PY_MAJOR_VERSION < 3 PyMODINIT_FUNC initcircular_overlap(void); /*proto*/ PyMODINIT_FUNC initcircular_overlap(void) #else PyMODINIT_FUNC PyInit_circular_overlap(void); /*proto*/ PyMODINIT_FUNC PyInit_circular_overlap(void) #endif { PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannyDeclarations #if CYTHON_REFNANNY __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); if (!__Pyx_RefNanny) { PyErr_Clear(); __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny"); if (!__Pyx_RefNanny) Py_FatalError("failed to import 'refnanny' module"); } #endif __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit_circular_overlap(void)", 0); if (__Pyx_check_binary_version() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #ifdef __Pyx_CyFunction_USED if (__pyx_CyFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif #ifdef __Pyx_FusedFunction_USED if (__pyx_FusedFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif #ifdef __Pyx_Coroutine_USED if (__pyx_Coroutine_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif #ifdef __Pyx_Generator_USED if (__pyx_Generator_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif #ifdef __Pyx_StopAsyncIteration_USED if (__pyx_StopAsyncIteration_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /*--- Library function declarations ---*/ /*--- Threads initialization code ---*/ #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS #ifdef WITH_THREAD /* Python build with threading support? */ PyEval_InitThreads(); #endif #endif /*--- Module creation code ---*/ #if PY_MAJOR_VERSION < 3 __pyx_m = Py_InitModule4("circular_overlap", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); #else __pyx_m = PyModule_Create(&__pyx_moduledef); #endif if (unlikely(!__pyx_m)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_INCREF(__pyx_d); __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #if CYTHON_COMPILING_IN_PYPY Py_INCREF(__pyx_b); #endif if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; /*--- Initialize various global constants etc. ---*/ if (__Pyx_InitGlobals() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) if (__Pyx_init_sys_getdefaultencoding_params() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif if (__pyx_module_is_main_photutils__geometry__circular_overlap) { if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } #if PY_MAJOR_VERSION >= 3 { PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (!PyDict_GetItemString(modules, "photutils.geometry.circular_overlap")) { if (unlikely(PyDict_SetItemString(modules, "photutils.geometry.circular_overlap", __pyx_m) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } } #endif /*--- Builtin init code ---*/ if (__Pyx_InitCachedBuiltins() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /*--- Constants init code ---*/ if (__Pyx_InitCachedConstants() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /*--- Global init code ---*/ /*--- Variable export code ---*/ /*--- Function export code ---*/ /*--- Type init code ---*/ /*--- Type import code ---*/ __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "type", #if CYTHON_COMPILING_IN_PYPY sizeof(PyTypeObject), #else sizeof(PyHeapTypeObject), #endif 0); if (unlikely(!__pyx_ptype_7cpython_4type_type)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5numpy_dtype = __Pyx_ImportType("numpy", "dtype", sizeof(PyArray_Descr), 0); if (unlikely(!__pyx_ptype_5numpy_dtype)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5numpy_flatiter = __Pyx_ImportType("numpy", "flatiter", sizeof(PyArrayIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_flatiter)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5numpy_broadcast = __Pyx_ImportType("numpy", "broadcast", sizeof(PyArrayMultiIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_broadcast)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5numpy_ndarray = __Pyx_ImportType("numpy", "ndarray", sizeof(PyArrayObject), 0); if (unlikely(!__pyx_ptype_5numpy_ndarray)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5numpy_ufunc = __Pyx_ImportType("numpy", "ufunc", sizeof(PyUFuncObject), 0); if (unlikely(!__pyx_ptype_5numpy_ufunc)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 861; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /*--- Variable import code ---*/ /*--- Function import code ---*/ __pyx_t_1 = __Pyx_ImportModule("photutils.geometry.core"); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__Pyx_ImportFunction(__pyx_t_1, "area_arc", (void (**)(void))&__pyx_f_9photutils_8geometry_4core_area_arc, "double (double, double, double, double, double)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__Pyx_ImportFunction(__pyx_t_1, "area_triangle", (void (**)(void))&__pyx_f_9photutils_8geometry_4core_area_triangle, "double (double, double, double, double, double, double)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_t_1); __pyx_t_1 = 0; /*--- Execution code ---*/ #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) if (__Pyx_patch_abc() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* "photutils/geometry/circular_overlap.pyx":8 * from __future__ import (absolute_import, division, print_function, * unicode_literals) * import numpy as np # <<<<<<<<<<<<<< * cimport numpy as np * */ __pyx_t_2 = __Pyx_Import(__pyx_n_s_numpy, 0, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "photutils/geometry/circular_overlap.pyx":11 * cimport numpy as np * * __all__ = ['circular_overlap_grid'] # <<<<<<<<<<<<<< * * cdef extern from "math.h": */ __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_u_circular_overlap_grid); __Pyx_GIVEREF(__pyx_n_u_circular_overlap_grid); PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_u_circular_overlap_grid); if (PyDict_SetItem(__pyx_d, __pyx_n_s_all, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "photutils/geometry/circular_overlap.pyx":20 * * * DTYPE = np.float64 # <<<<<<<<<<<<<< * ctypedef np.float64_t DTYPE_t * */ __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_float64); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_DTYPE, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "photutils/geometry/circular_overlap.pyx":29 * * * def circular_overlap_grid(double xmin, double xmax, double ymin, double ymax, # <<<<<<<<<<<<<< * int nx, int ny, double r, int use_exact, * int subpixels): */ __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_9photutils_8geometry_16circular_overlap_1circular_overlap_grid, NULL, __pyx_n_s_photutils_geometry_circular_over); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_circular_overlap_grid, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "photutils/geometry/circular_overlap.pyx":187 * * * def circular_overlap_core(double xmin, double ymin, double xmax, double ymax, # <<<<<<<<<<<<<< * double r): * """Assumes that the center of the circle is <= xmin, */ __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_9photutils_8geometry_16circular_overlap_3circular_overlap_core, NULL, __pyx_n_s_photutils_geometry_circular_over); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_circular_overlap_core, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "photutils/geometry/circular_overlap.pyx":1 * # Licensed under a 3-clause BSD style license - see LICENSE.rst # <<<<<<<<<<<<<< * * # The functions defined here allow one to determine the exact area of */ __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":976 * arr.base = baseptr * * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< * if arr.base is NULL: * return None */ /*--- Wrapped vars code ---*/ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); if (__pyx_m) { if (__pyx_d) { __Pyx_AddTraceback("init photutils.geometry.circular_overlap", __pyx_clineno, __pyx_lineno, __pyx_filename); } Py_DECREF(__pyx_m); __pyx_m = 0; } else if (!PyErr_Occurred()) { PyErr_SetString(PyExc_ImportError, "init photutils.geometry.circular_overlap"); } __pyx_L0:; __Pyx_RefNannyFinishContext(); #if PY_MAJOR_VERSION < 3 return; #else return __pyx_m; #endif } /* --- Runtime support code --- */ #if CYTHON_REFNANNY static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { PyObject *m = NULL, *p = NULL; void *r = NULL; m = PyImport_ImportModule((char *)modname); if (!m) goto end; p = PyObject_GetAttrString(m, (char *)"RefNannyAPI"); if (!p) goto end; r = PyLong_AsVoidPtr(p); end: Py_XDECREF(p); Py_XDECREF(m); return (__Pyx_RefNannyAPIStruct *)r; } #endif static PyObject *__Pyx_GetBuiltinName(PyObject *name) { PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name); if (unlikely(!result)) { PyErr_Format(PyExc_NameError, #if PY_MAJOR_VERSION >= 3 "name '%U' is not defined", name); #else "name '%.200s' is not defined", PyString_AS_STRING(name)); #endif } return result; } static void __Pyx_RaiseArgtupleInvalid( const char* func_name, int exact, Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found) { Py_ssize_t num_expected; const char *more_or_less; if (num_found < num_min) { num_expected = num_min; more_or_less = "at least"; } else { num_expected = num_max; more_or_less = "at most"; } if (exact) { more_or_less = "exactly"; } PyErr_Format(PyExc_TypeError, "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)", func_name, more_or_less, num_expected, (num_expected == 1) ? "" : "s", num_found); } static void __Pyx_RaiseDoubleKeywordsError( const char* func_name, PyObject* kw_name) { PyErr_Format(PyExc_TypeError, #if PY_MAJOR_VERSION >= 3 "%s() got multiple values for keyword argument '%U'", func_name, kw_name); #else "%s() got multiple values for keyword argument '%s'", func_name, PyString_AsString(kw_name)); #endif } static int __Pyx_ParseOptionalKeywords( PyObject *kwds, PyObject **argnames[], PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, const char* function_name) { PyObject *key = 0, *value = 0; Py_ssize_t pos = 0; PyObject*** name; PyObject*** first_kw_arg = argnames + num_pos_args; while (PyDict_Next(kwds, &pos, &key, &value)) { name = first_kw_arg; while (*name && (**name != key)) name++; if (*name) { values[name-argnames] = value; continue; } name = first_kw_arg; #if PY_MAJOR_VERSION < 3 if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) { while (*name) { if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key)) && _PyString_Eq(**name, key)) { values[name-argnames] = value; break; } name++; } if (*name) continue; else { PyObject*** argname = argnames; while (argname != first_kw_arg) { if ((**argname == key) || ( (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key)) && _PyString_Eq(**argname, key))) { goto arg_passed_twice; } argname++; } } } else #endif if (likely(PyUnicode_Check(key))) { while (*name) { int cmp = (**name == key) ? 0 : #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 : #endif PyUnicode_Compare(**name, key); if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; if (cmp == 0) { values[name-argnames] = value; break; } name++; } if (*name) continue; else { PyObject*** argname = argnames; while (argname != first_kw_arg) { int cmp = (**argname == key) ? 0 : #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 : #endif PyUnicode_Compare(**argname, key); if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; if (cmp == 0) goto arg_passed_twice; argname++; } } } else goto invalid_keyword_type; if (kwds2) { if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad; } else { goto invalid_keyword; } } return 0; arg_passed_twice: __Pyx_RaiseDoubleKeywordsError(function_name, key); goto bad; invalid_keyword_type: PyErr_Format(PyExc_TypeError, "%.200s() keywords must be strings", function_name); goto bad; invalid_keyword: PyErr_Format(PyExc_TypeError, #if PY_MAJOR_VERSION < 3 "%.200s() got an unexpected keyword argument '%.200s'", function_name, PyString_AsString(key)); #else "%s() got an unexpected keyword argument '%U'", function_name, key); #endif bad: return -1; } static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) { PyObject *result; #if CYTHON_COMPILING_IN_CPYTHON result = PyDict_GetItem(__pyx_d, name); if (likely(result)) { Py_INCREF(result); } else { #else result = PyObject_GetItem(__pyx_d, name); if (!result) { PyErr_Clear(); #endif result = __Pyx_GetBuiltinName(name); } return result; } #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) { PyObject *result; ternaryfunc call = func->ob_type->tp_call; if (unlikely(!call)) return PyObject_Call(func, arg, kw); if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) return NULL; result = (*call)(func, arg, kw); Py_LeaveRecursiveCall(); if (unlikely(!result) && unlikely(!PyErr_Occurred())) { PyErr_SetString( PyExc_SystemError, "NULL result without error in PyObject_Call"); } return result; } #endif static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { if (unlikely(!type)) { PyErr_SetString(PyExc_SystemError, "Missing type object"); return 0; } if (likely(PyObject_TypeCheck(obj, type))) return 1; PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s", Py_TYPE(obj)->tp_name, type->tp_name); return 0; } static CYTHON_INLINE int __Pyx_IsLittleEndian(void) { unsigned int n = 1; return *(unsigned char*)(&n) != 0; } static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx, __Pyx_BufFmt_StackElem* stack, __Pyx_TypeInfo* type) { stack[0].field = &ctx->root; stack[0].parent_offset = 0; ctx->root.type = type; ctx->root.name = "buffer dtype"; ctx->root.offset = 0; ctx->head = stack; ctx->head->field = &ctx->root; ctx->fmt_offset = 0; ctx->head->parent_offset = 0; ctx->new_packmode = '@'; ctx->enc_packmode = '@'; ctx->new_count = 1; ctx->enc_count = 0; ctx->enc_type = 0; ctx->is_complex = 0; ctx->is_valid_array = 0; ctx->struct_alignment = 0; while (type->typegroup == 'S') { ++ctx->head; ctx->head->field = type->fields; ctx->head->parent_offset = 0; type = type->fields->type; } } static int __Pyx_BufFmt_ParseNumber(const char** ts) { int count; const char* t = *ts; if (*t < '0' || *t > '9') { return -1; } else { count = *t++ - '0'; while (*t >= '0' && *t < '9') { count *= 10; count += *t++ - '0'; } } *ts = t; return count; } static int __Pyx_BufFmt_ExpectNumber(const char **ts) { int number = __Pyx_BufFmt_ParseNumber(ts); if (number == -1) PyErr_Format(PyExc_ValueError,\ "Does not understand character buffer dtype format string ('%c')", **ts); return number; } static void __Pyx_BufFmt_RaiseUnexpectedChar(char ch) { PyErr_Format(PyExc_ValueError, "Unexpected format string character: '%c'", ch); } static const char* __Pyx_BufFmt_DescribeTypeChar(char ch, int is_complex) { switch (ch) { case 'c': return "'char'"; case 'b': return "'signed char'"; case 'B': return "'unsigned char'"; case 'h': return "'short'"; case 'H': return "'unsigned short'"; case 'i': return "'int'"; case 'I': return "'unsigned int'"; case 'l': return "'long'"; case 'L': return "'unsigned long'"; case 'q': return "'long long'"; case 'Q': return "'unsigned long long'"; case 'f': return (is_complex ? "'complex float'" : "'float'"); case 'd': return (is_complex ? "'complex double'" : "'double'"); case 'g': return (is_complex ? "'complex long double'" : "'long double'"); case 'T': return "a struct"; case 'O': return "Python object"; case 'P': return "a pointer"; case 's': case 'p': return "a string"; case 0: return "end"; default: return "unparseable format string"; } } static size_t __Pyx_BufFmt_TypeCharToStandardSize(char ch, int is_complex) { switch (ch) { case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; case 'h': case 'H': return 2; case 'i': case 'I': case 'l': case 'L': return 4; case 'q': case 'Q': return 8; case 'f': return (is_complex ? 8 : 4); case 'd': return (is_complex ? 16 : 8); case 'g': { PyErr_SetString(PyExc_ValueError, "Python does not define a standard format string size for long double ('g').."); return 0; } case 'O': case 'P': return sizeof(void*); default: __Pyx_BufFmt_RaiseUnexpectedChar(ch); return 0; } } static size_t __Pyx_BufFmt_TypeCharToNativeSize(char ch, int is_complex) { switch (ch) { case 'c': case 'b': case 'B': case 's': case 'p': return 1; case 'h': case 'H': return sizeof(short); case 'i': case 'I': return sizeof(int); case 'l': case 'L': return sizeof(long); #ifdef HAVE_LONG_LONG case 'q': case 'Q': return sizeof(PY_LONG_LONG); #endif case 'f': return sizeof(float) * (is_complex ? 2 : 1); case 'd': return sizeof(double) * (is_complex ? 2 : 1); case 'g': return sizeof(long double) * (is_complex ? 2 : 1); case 'O': case 'P': return sizeof(void*); default: { __Pyx_BufFmt_RaiseUnexpectedChar(ch); return 0; } } } typedef struct { char c; short x; } __Pyx_st_short; typedef struct { char c; int x; } __Pyx_st_int; typedef struct { char c; long x; } __Pyx_st_long; typedef struct { char c; float x; } __Pyx_st_float; typedef struct { char c; double x; } __Pyx_st_double; typedef struct { char c; long double x; } __Pyx_st_longdouble; typedef struct { char c; void *x; } __Pyx_st_void_p; #ifdef HAVE_LONG_LONG typedef struct { char c; PY_LONG_LONG x; } __Pyx_st_longlong; #endif static size_t __Pyx_BufFmt_TypeCharToAlignment(char ch, CYTHON_UNUSED int is_complex) { switch (ch) { case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; case 'h': case 'H': return sizeof(__Pyx_st_short) - sizeof(short); case 'i': case 'I': return sizeof(__Pyx_st_int) - sizeof(int); case 'l': case 'L': return sizeof(__Pyx_st_long) - sizeof(long); #ifdef HAVE_LONG_LONG case 'q': case 'Q': return sizeof(__Pyx_st_longlong) - sizeof(PY_LONG_LONG); #endif case 'f': return sizeof(__Pyx_st_float) - sizeof(float); case 'd': return sizeof(__Pyx_st_double) - sizeof(double); case 'g': return sizeof(__Pyx_st_longdouble) - sizeof(long double); case 'P': case 'O': return sizeof(__Pyx_st_void_p) - sizeof(void*); default: __Pyx_BufFmt_RaiseUnexpectedChar(ch); return 0; } } /* These are for computing the padding at the end of the struct to align on the first member of the struct. This will probably the same as above, but we don't have any guarantees. */ typedef struct { short x; char c; } __Pyx_pad_short; typedef struct { int x; char c; } __Pyx_pad_int; typedef struct { long x; char c; } __Pyx_pad_long; typedef struct { float x; char c; } __Pyx_pad_float; typedef struct { double x; char c; } __Pyx_pad_double; typedef struct { long double x; char c; } __Pyx_pad_longdouble; typedef struct { void *x; char c; } __Pyx_pad_void_p; #ifdef HAVE_LONG_LONG typedef struct { PY_LONG_LONG x; char c; } __Pyx_pad_longlong; #endif static size_t __Pyx_BufFmt_TypeCharToPadding(char ch, CYTHON_UNUSED int is_complex) { switch (ch) { case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; case 'h': case 'H': return sizeof(__Pyx_pad_short) - sizeof(short); case 'i': case 'I': return sizeof(__Pyx_pad_int) - sizeof(int); case 'l': case 'L': return sizeof(__Pyx_pad_long) - sizeof(long); #ifdef HAVE_LONG_LONG case 'q': case 'Q': return sizeof(__Pyx_pad_longlong) - sizeof(PY_LONG_LONG); #endif case 'f': return sizeof(__Pyx_pad_float) - sizeof(float); case 'd': return sizeof(__Pyx_pad_double) - sizeof(double); case 'g': return sizeof(__Pyx_pad_longdouble) - sizeof(long double); case 'P': case 'O': return sizeof(__Pyx_pad_void_p) - sizeof(void*); default: __Pyx_BufFmt_RaiseUnexpectedChar(ch); return 0; } } static char __Pyx_BufFmt_TypeCharToGroup(char ch, int is_complex) { switch (ch) { case 'c': return 'H'; case 'b': case 'h': case 'i': case 'l': case 'q': case 's': case 'p': return 'I'; case 'B': case 'H': case 'I': case 'L': case 'Q': return 'U'; case 'f': case 'd': case 'g': return (is_complex ? 'C' : 'R'); case 'O': return 'O'; case 'P': return 'P'; default: { __Pyx_BufFmt_RaiseUnexpectedChar(ch); return 0; } } } static void __Pyx_BufFmt_RaiseExpected(__Pyx_BufFmt_Context* ctx) { if (ctx->head == NULL || ctx->head->field == &ctx->root) { const char* expected; const char* quote; if (ctx->head == NULL) { expected = "end"; quote = ""; } else { expected = ctx->head->field->type->name; quote = "'"; } PyErr_Format(PyExc_ValueError, "Buffer dtype mismatch, expected %s%s%s but got %s", quote, expected, quote, __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex)); } else { __Pyx_StructField* field = ctx->head->field; __Pyx_StructField* parent = (ctx->head - 1)->field; PyErr_Format(PyExc_ValueError, "Buffer dtype mismatch, expected '%s' but got %s in '%s.%s'", field->type->name, __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex), parent->type->name, field->name); } } static int __Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context* ctx) { char group; size_t size, offset, arraysize = 1; if (ctx->enc_type == 0) return 0; if (ctx->head->field->type->arraysize[0]) { int i, ndim = 0; if (ctx->enc_type == 's' || ctx->enc_type == 'p') { ctx->is_valid_array = ctx->head->field->type->ndim == 1; ndim = 1; if (ctx->enc_count != ctx->head->field->type->arraysize[0]) { PyErr_Format(PyExc_ValueError, "Expected a dimension of size %zu, got %zu", ctx->head->field->type->arraysize[0], ctx->enc_count); return -1; } } if (!ctx->is_valid_array) { PyErr_Format(PyExc_ValueError, "Expected %d dimensions, got %d", ctx->head->field->type->ndim, ndim); return -1; } for (i = 0; i < ctx->head->field->type->ndim; i++) { arraysize *= ctx->head->field->type->arraysize[i]; } ctx->is_valid_array = 0; ctx->enc_count = 1; } group = __Pyx_BufFmt_TypeCharToGroup(ctx->enc_type, ctx->is_complex); do { __Pyx_StructField* field = ctx->head->field; __Pyx_TypeInfo* type = field->type; if (ctx->enc_packmode == '@' || ctx->enc_packmode == '^') { size = __Pyx_BufFmt_TypeCharToNativeSize(ctx->enc_type, ctx->is_complex); } else { size = __Pyx_BufFmt_TypeCharToStandardSize(ctx->enc_type, ctx->is_complex); } if (ctx->enc_packmode == '@') { size_t align_at = __Pyx_BufFmt_TypeCharToAlignment(ctx->enc_type, ctx->is_complex); size_t align_mod_offset; if (align_at == 0) return -1; align_mod_offset = ctx->fmt_offset % align_at; if (align_mod_offset > 0) ctx->fmt_offset += align_at - align_mod_offset; if (ctx->struct_alignment == 0) ctx->struct_alignment = __Pyx_BufFmt_TypeCharToPadding(ctx->enc_type, ctx->is_complex); } if (type->size != size || type->typegroup != group) { if (type->typegroup == 'C' && type->fields != NULL) { size_t parent_offset = ctx->head->parent_offset + field->offset; ++ctx->head; ctx->head->field = type->fields; ctx->head->parent_offset = parent_offset; continue; } if ((type->typegroup == 'H' || group == 'H') && type->size == size) { } else { __Pyx_BufFmt_RaiseExpected(ctx); return -1; } } offset = ctx->head->parent_offset + field->offset; if (ctx->fmt_offset != offset) { PyErr_Format(PyExc_ValueError, "Buffer dtype mismatch; next field is at offset %" CYTHON_FORMAT_SSIZE_T "d but %" CYTHON_FORMAT_SSIZE_T "d expected", (Py_ssize_t)ctx->fmt_offset, (Py_ssize_t)offset); return -1; } ctx->fmt_offset += size; if (arraysize) ctx->fmt_offset += (arraysize - 1) * size; --ctx->enc_count; while (1) { if (field == &ctx->root) { ctx->head = NULL; if (ctx->enc_count != 0) { __Pyx_BufFmt_RaiseExpected(ctx); return -1; } break; } ctx->head->field = ++field; if (field->type == NULL) { --ctx->head; field = ctx->head->field; continue; } else if (field->type->typegroup == 'S') { size_t parent_offset = ctx->head->parent_offset + field->offset; if (field->type->fields->type == NULL) continue; field = field->type->fields; ++ctx->head; ctx->head->field = field; ctx->head->parent_offset = parent_offset; break; } else { break; } } } while (ctx->enc_count); ctx->enc_type = 0; ctx->is_complex = 0; return 0; } static CYTHON_INLINE PyObject * __pyx_buffmt_parse_array(__Pyx_BufFmt_Context* ctx, const char** tsp) { const char *ts = *tsp; int i = 0, number; int ndim = ctx->head->field->type->ndim; ; ++ts; if (ctx->new_count != 1) { PyErr_SetString(PyExc_ValueError, "Cannot handle repeated arrays in format string"); return NULL; } if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; while (*ts && *ts != ')') { switch (*ts) { case ' ': case '\f': case '\r': case '\n': case '\t': case '\v': continue; default: break; } number = __Pyx_BufFmt_ExpectNumber(&ts); if (number == -1) return NULL; if (i < ndim && (size_t) number != ctx->head->field->type->arraysize[i]) return PyErr_Format(PyExc_ValueError, "Expected a dimension of size %zu, got %d", ctx->head->field->type->arraysize[i], number); if (*ts != ',' && *ts != ')') return PyErr_Format(PyExc_ValueError, "Expected a comma in format string, got '%c'", *ts); if (*ts == ',') ts++; i++; } if (i != ndim) return PyErr_Format(PyExc_ValueError, "Expected %d dimension(s), got %d", ctx->head->field->type->ndim, i); if (!*ts) { PyErr_SetString(PyExc_ValueError, "Unexpected end of format string, expected ')'"); return NULL; } ctx->is_valid_array = 1; ctx->new_count = 1; *tsp = ++ts; return Py_None; } static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts) { int got_Z = 0; while (1) { switch(*ts) { case 0: if (ctx->enc_type != 0 && ctx->head == NULL) { __Pyx_BufFmt_RaiseExpected(ctx); return NULL; } if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; if (ctx->head != NULL) { __Pyx_BufFmt_RaiseExpected(ctx); return NULL; } return ts; case ' ': case '\r': case '\n': ++ts; break; case '<': if (!__Pyx_IsLittleEndian()) { PyErr_SetString(PyExc_ValueError, "Little-endian buffer not supported on big-endian compiler"); return NULL; } ctx->new_packmode = '='; ++ts; break; case '>': case '!': if (__Pyx_IsLittleEndian()) { PyErr_SetString(PyExc_ValueError, "Big-endian buffer not supported on little-endian compiler"); return NULL; } ctx->new_packmode = '='; ++ts; break; case '=': case '@': case '^': ctx->new_packmode = *ts++; break; case 'T': { const char* ts_after_sub; size_t i, struct_count = ctx->new_count; size_t struct_alignment = ctx->struct_alignment; ctx->new_count = 1; ++ts; if (*ts != '{') { PyErr_SetString(PyExc_ValueError, "Buffer acquisition: Expected '{' after 'T'"); return NULL; } if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; ctx->enc_type = 0; ctx->enc_count = 0; ctx->struct_alignment = 0; ++ts; ts_after_sub = ts; for (i = 0; i != struct_count; ++i) { ts_after_sub = __Pyx_BufFmt_CheckString(ctx, ts); if (!ts_after_sub) return NULL; } ts = ts_after_sub; if (struct_alignment) ctx->struct_alignment = struct_alignment; } break; case '}': { size_t alignment = ctx->struct_alignment; ++ts; if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; ctx->enc_type = 0; if (alignment && ctx->fmt_offset % alignment) { ctx->fmt_offset += alignment - (ctx->fmt_offset % alignment); } } return ts; case 'x': if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; ctx->fmt_offset += ctx->new_count; ctx->new_count = 1; ctx->enc_count = 0; ctx->enc_type = 0; ctx->enc_packmode = ctx->new_packmode; ++ts; break; case 'Z': got_Z = 1; ++ts; if (*ts != 'f' && *ts != 'd' && *ts != 'g') { __Pyx_BufFmt_RaiseUnexpectedChar('Z'); return NULL; } case 'c': case 'b': case 'B': case 'h': case 'H': case 'i': case 'I': case 'l': case 'L': case 'q': case 'Q': case 'f': case 'd': case 'g': case 'O': case 'p': if (ctx->enc_type == *ts && got_Z == ctx->is_complex && ctx->enc_packmode == ctx->new_packmode) { ctx->enc_count += ctx->new_count; ctx->new_count = 1; got_Z = 0; ++ts; break; } case 's': if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; ctx->enc_count = ctx->new_count; ctx->enc_packmode = ctx->new_packmode; ctx->enc_type = *ts; ctx->is_complex = got_Z; ++ts; ctx->new_count = 1; got_Z = 0; break; case ':': ++ts; while(*ts != ':') ++ts; ++ts; break; case '(': if (!__pyx_buffmt_parse_array(ctx, &ts)) return NULL; break; default: { int number = __Pyx_BufFmt_ExpectNumber(&ts); if (number == -1) return NULL; ctx->new_count = (size_t)number; } } } } static CYTHON_INLINE void __Pyx_ZeroBuffer(Py_buffer* buf) { buf->buf = NULL; buf->obj = NULL; buf->strides = __Pyx_zeros; buf->shape = __Pyx_zeros; buf->suboffsets = __Pyx_minusones; } static CYTHON_INLINE int __Pyx_GetBufferAndValidate( Py_buffer* buf, PyObject* obj, __Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack) { if (obj == Py_None || obj == NULL) { __Pyx_ZeroBuffer(buf); return 0; } buf->buf = NULL; if (__Pyx_GetBuffer(obj, buf, flags) == -1) goto fail; if (buf->ndim != nd) { PyErr_Format(PyExc_ValueError, "Buffer has wrong number of dimensions (expected %d, got %d)", nd, buf->ndim); goto fail; } if (!cast) { __Pyx_BufFmt_Context ctx; __Pyx_BufFmt_Init(&ctx, stack, dtype); if (!__Pyx_BufFmt_CheckString(&ctx, buf->format)) goto fail; } if ((unsigned)buf->itemsize != dtype->size) { PyErr_Format(PyExc_ValueError, "Item size of buffer (%" CYTHON_FORMAT_SSIZE_T "d byte%s) does not match size of '%s' (%" CYTHON_FORMAT_SSIZE_T "d byte%s)", buf->itemsize, (buf->itemsize > 1) ? "s" : "", dtype->name, (Py_ssize_t)dtype->size, (dtype->size > 1) ? "s" : ""); goto fail; } if (buf->suboffsets == NULL) buf->suboffsets = __Pyx_minusones; return 0; fail:; __Pyx_ZeroBuffer(buf); return -1; } static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info) { if (info->buf == NULL) return; if (info->suboffsets == __Pyx_minusones) info->suboffsets = NULL; __Pyx_ReleaseBuffer(info); } static void __Pyx_RaiseBufferIndexError(int axis) { PyErr_Format(PyExc_IndexError, "Out of bounds on buffer access (axis %d)", axis); } static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) { #if CYTHON_COMPILING_IN_CPYTHON PyObject *tmp_type, *tmp_value, *tmp_tb; PyThreadState *tstate = PyThreadState_GET(); tmp_type = tstate->curexc_type; tmp_value = tstate->curexc_value; tmp_tb = tstate->curexc_traceback; tstate->curexc_type = type; tstate->curexc_value = value; tstate->curexc_traceback = tb; Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); #else PyErr_Restore(type, value, tb); #endif } static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) { #if CYTHON_COMPILING_IN_CPYTHON PyThreadState *tstate = PyThreadState_GET(); *type = tstate->curexc_type; *value = tstate->curexc_value; *tb = tstate->curexc_traceback; tstate->curexc_type = 0; tstate->curexc_value = 0; tstate->curexc_traceback = 0; #else PyErr_Fetch(type, value, tb); #endif } static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno, CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename, int full_traceback, CYTHON_UNUSED int nogil) { PyObject *old_exc, *old_val, *old_tb; PyObject *ctx; #ifdef WITH_THREAD PyGILState_STATE state; if (nogil) state = PyGILState_Ensure(); #endif __Pyx_ErrFetch(&old_exc, &old_val, &old_tb); if (full_traceback) { Py_XINCREF(old_exc); Py_XINCREF(old_val); Py_XINCREF(old_tb); __Pyx_ErrRestore(old_exc, old_val, old_tb); PyErr_PrintEx(1); } #if PY_MAJOR_VERSION < 3 ctx = PyString_FromString(name); #else ctx = PyUnicode_FromString(name); #endif __Pyx_ErrRestore(old_exc, old_val, old_tb); if (!ctx) { PyErr_WriteUnraisable(Py_None); } else { PyErr_WriteUnraisable(ctx); Py_DECREF(ctx); } #ifdef WITH_THREAD if (nogil) PyGILState_Release(state); #endif } #if PY_MAJOR_VERSION < 3 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, CYTHON_UNUSED PyObject *cause) { Py_XINCREF(type); if (!value || value == Py_None) value = NULL; else Py_INCREF(value); if (!tb || tb == Py_None) tb = NULL; else { Py_INCREF(tb); if (!PyTraceBack_Check(tb)) { PyErr_SetString(PyExc_TypeError, "raise: arg 3 must be a traceback or None"); goto raise_error; } } if (PyType_Check(type)) { #if CYTHON_COMPILING_IN_PYPY if (!value) { Py_INCREF(Py_None); value = Py_None; } #endif PyErr_NormalizeException(&type, &value, &tb); } else { if (value) { PyErr_SetString(PyExc_TypeError, "instance exception may not have a separate value"); goto raise_error; } value = type; type = (PyObject*) Py_TYPE(type); Py_INCREF(type); if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) { PyErr_SetString(PyExc_TypeError, "raise: exception class must be a subclass of BaseException"); goto raise_error; } } __Pyx_ErrRestore(type, value, tb); return; raise_error: Py_XDECREF(value); Py_XDECREF(type); Py_XDECREF(tb); return; } #else static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) { PyObject* owned_instance = NULL; if (tb == Py_None) { tb = 0; } else if (tb && !PyTraceBack_Check(tb)) { PyErr_SetString(PyExc_TypeError, "raise: arg 3 must be a traceback or None"); goto bad; } if (value == Py_None) value = 0; if (PyExceptionInstance_Check(type)) { if (value) { PyErr_SetString(PyExc_TypeError, "instance exception may not have a separate value"); goto bad; } value = type; type = (PyObject*) Py_TYPE(value); } else if (PyExceptionClass_Check(type)) { PyObject *instance_class = NULL; if (value && PyExceptionInstance_Check(value)) { instance_class = (PyObject*) Py_TYPE(value); if (instance_class != type) { int is_subclass = PyObject_IsSubclass(instance_class, type); if (!is_subclass) { instance_class = NULL; } else if (unlikely(is_subclass == -1)) { goto bad; } else { type = instance_class; } } } if (!instance_class) { PyObject *args; if (!value) args = PyTuple_New(0); else if (PyTuple_Check(value)) { Py_INCREF(value); args = value; } else args = PyTuple_Pack(1, value); if (!args) goto bad; owned_instance = PyObject_Call(type, args, NULL); Py_DECREF(args); if (!owned_instance) goto bad; value = owned_instance; if (!PyExceptionInstance_Check(value)) { PyErr_Format(PyExc_TypeError, "calling %R should have returned an instance of " "BaseException, not %R", type, Py_TYPE(value)); goto bad; } } } else { PyErr_SetString(PyExc_TypeError, "raise: exception class must be a subclass of BaseException"); goto bad; } #if PY_VERSION_HEX >= 0x03030000 if (cause) { #else if (cause && cause != Py_None) { #endif PyObject *fixed_cause; if (cause == Py_None) { fixed_cause = NULL; } else if (PyExceptionClass_Check(cause)) { fixed_cause = PyObject_CallObject(cause, NULL); if (fixed_cause == NULL) goto bad; } else if (PyExceptionInstance_Check(cause)) { fixed_cause = cause; Py_INCREF(fixed_cause); } else { PyErr_SetString(PyExc_TypeError, "exception causes must derive from " "BaseException"); goto bad; } PyException_SetCause(value, fixed_cause); } PyErr_SetObject(type, value); if (tb) { #if CYTHON_COMPILING_IN_PYPY PyObject *tmp_type, *tmp_value, *tmp_tb; PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb); Py_INCREF(tb); PyErr_Restore(tmp_type, tmp_value, tb); Py_XDECREF(tmp_tb); #else PyThreadState *tstate = PyThreadState_GET(); PyObject* tmp_tb = tstate->curexc_traceback; if (tb != tmp_tb) { Py_INCREF(tb); tstate->curexc_traceback = tb; Py_XDECREF(tmp_tb); } #endif } bad: Py_XDECREF(owned_instance); return; } #endif static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) { PyErr_Format(PyExc_ValueError, "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected); } static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) { PyErr_Format(PyExc_ValueError, "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack", index, (index == 1) ? "" : "s"); } static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); } static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) { PyObject *empty_list = 0; PyObject *module = 0; PyObject *global_dict = 0; PyObject *empty_dict = 0; PyObject *list; #if PY_VERSION_HEX < 0x03030000 PyObject *py_import; py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import); if (!py_import) goto bad; #endif if (from_list) list = from_list; else { empty_list = PyList_New(0); if (!empty_list) goto bad; list = empty_list; } global_dict = PyModule_GetDict(__pyx_m); if (!global_dict) goto bad; empty_dict = PyDict_New(); if (!empty_dict) goto bad; { #if PY_MAJOR_VERSION >= 3 if (level == -1) { if (strchr(__Pyx_MODULE_NAME, '.')) { #if PY_VERSION_HEX < 0x03030000 PyObject *py_level = PyInt_FromLong(1); if (!py_level) goto bad; module = PyObject_CallFunctionObjArgs(py_import, name, global_dict, empty_dict, list, py_level, NULL); Py_DECREF(py_level); #else module = PyImport_ImportModuleLevelObject( name, global_dict, empty_dict, list, 1); #endif if (!module) { if (!PyErr_ExceptionMatches(PyExc_ImportError)) goto bad; PyErr_Clear(); } } level = 0; } #endif if (!module) { #if PY_VERSION_HEX < 0x03030000 PyObject *py_level = PyInt_FromLong(level); if (!py_level) goto bad; module = PyObject_CallFunctionObjArgs(py_import, name, global_dict, empty_dict, list, py_level, NULL); Py_DECREF(py_level); #else module = PyImport_ImportModuleLevelObject( name, global_dict, empty_dict, list, level); #endif } } bad: #if PY_VERSION_HEX < 0x03030000 Py_XDECREF(py_import); #endif Py_XDECREF(empty_list); Py_XDECREF(empty_dict); return module; } static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { int start = 0, mid = 0, end = count - 1; if (end >= 0 && code_line > entries[end].code_line) { return count; } while (start < end) { mid = start + (end - start) / 2; if (code_line < entries[mid].code_line) { end = mid; } else if (code_line > entries[mid].code_line) { start = mid + 1; } else { return mid; } } if (code_line <= entries[mid].code_line) { return mid; } else { return mid + 1; } } static PyCodeObject *__pyx_find_code_object(int code_line) { PyCodeObject* code_object; int pos; if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) { return NULL; } pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) { return NULL; } code_object = __pyx_code_cache.entries[pos].code_object; Py_INCREF(code_object); return code_object; } static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { int pos, i; __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries; if (unlikely(!code_line)) { return; } if (unlikely(!entries)) { entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry)); if (likely(entries)) { __pyx_code_cache.entries = entries; __pyx_code_cache.max_count = 64; __pyx_code_cache.count = 1; entries[0].code_line = code_line; entries[0].code_object = code_object; Py_INCREF(code_object); } return; } pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) { PyCodeObject* tmp = entries[pos].code_object; entries[pos].code_object = code_object; Py_DECREF(tmp); return; } if (__pyx_code_cache.count == __pyx_code_cache.max_count) { int new_max = __pyx_code_cache.max_count + 64; entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc( __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry)); if (unlikely(!entries)) { return; } __pyx_code_cache.entries = entries; __pyx_code_cache.max_count = new_max; } for (i=__pyx_code_cache.count; i>pos; i--) { entries[i] = entries[i-1]; } entries[pos].code_line = code_line; entries[pos].code_object = code_object; __pyx_code_cache.count++; Py_INCREF(code_object); } #include "compile.h" #include "frameobject.h" #include "traceback.h" static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( const char *funcname, int c_line, int py_line, const char *filename) { PyCodeObject *py_code = 0; PyObject *py_srcfile = 0; PyObject *py_funcname = 0; #if PY_MAJOR_VERSION < 3 py_srcfile = PyString_FromString(filename); #else py_srcfile = PyUnicode_FromString(filename); #endif if (!py_srcfile) goto bad; if (c_line) { #if PY_MAJOR_VERSION < 3 py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); #else py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); #endif } else { #if PY_MAJOR_VERSION < 3 py_funcname = PyString_FromString(funcname); #else py_funcname = PyUnicode_FromString(funcname); #endif } if (!py_funcname) goto bad; py_code = __Pyx_PyCode_New( 0, 0, 0, 0, 0, __pyx_empty_bytes, /*PyObject *code,*/ __pyx_empty_tuple, /*PyObject *consts,*/ __pyx_empty_tuple, /*PyObject *names,*/ __pyx_empty_tuple, /*PyObject *varnames,*/ __pyx_empty_tuple, /*PyObject *freevars,*/ __pyx_empty_tuple, /*PyObject *cellvars,*/ py_srcfile, /*PyObject *filename,*/ py_funcname, /*PyObject *name,*/ py_line, __pyx_empty_bytes /*PyObject *lnotab*/ ); Py_DECREF(py_srcfile); Py_DECREF(py_funcname); return py_code; bad: Py_XDECREF(py_srcfile); Py_XDECREF(py_funcname); return NULL; } static void __Pyx_AddTraceback(const char *funcname, int c_line, int py_line, const char *filename) { PyCodeObject *py_code = 0; PyFrameObject *py_frame = 0; py_code = __pyx_find_code_object(c_line ? c_line : py_line); if (!py_code) { py_code = __Pyx_CreateCodeObjectForTraceback( funcname, c_line, py_line, filename); if (!py_code) goto bad; __pyx_insert_code_object(c_line ? c_line : py_line, py_code); } py_frame = PyFrame_New( PyThreadState_GET(), /*PyThreadState *tstate,*/ py_code, /*PyCodeObject *code,*/ __pyx_d, /*PyObject *globals,*/ 0 /*PyObject *locals*/ ); if (!py_frame) goto bad; py_frame->f_lineno = py_line; PyTraceBack_Here(py_frame); bad: Py_XDECREF(py_code); Py_XDECREF(py_frame); } #if PY_MAJOR_VERSION < 3 static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) { if (PyObject_CheckBuffer(obj)) return PyObject_GetBuffer(obj, view, flags); if (PyObject_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) return __pyx_pw_5numpy_7ndarray_1__getbuffer__(obj, view, flags); PyErr_Format(PyExc_TypeError, "'%.200s' does not have the buffer interface", Py_TYPE(obj)->tp_name); return -1; } static void __Pyx_ReleaseBuffer(Py_buffer *view) { PyObject *obj = view->obj; if (!obj) return; if (PyObject_CheckBuffer(obj)) { PyBuffer_Release(view); return; } if (PyObject_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) { __pyx_pw_5numpy_7ndarray_3__releasebuffer__(obj, view); return; } Py_DECREF(obj); view->obj = NULL; } #endif #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\ __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0) #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\ __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1) #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\ {\ func_type value = func_value;\ if (sizeof(target_type) < sizeof(func_type)) {\ if (unlikely(value != (func_type) (target_type) value)) {\ func_type zero = 0;\ if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\ return (target_type) -1;\ if (is_unsigned && unlikely(value < zero))\ goto raise_neg_overflow;\ else\ goto raise_overflow;\ }\ }\ return (target_type) value;\ } #if CYTHON_USE_PYLONG_INTERNALS #include "longintrepr.h" #endif static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { const int neg_one = (int) -1, const_zero = (int) 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { if (sizeof(int) < sizeof(long)) { __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x)) } else { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { goto raise_neg_overflow; } return (int) val; } } else #endif if (likely(PyLong_Check(x))) { if (is_unsigned) { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (int) 0; case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0]) case 2: if (8 * sizeof(int) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) { return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; case 3: if (8 * sizeof(int) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) { return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; case 4: if (8 * sizeof(int) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) { return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; } #endif #if CYTHON_COMPILING_IN_CPYTHON if (unlikely(Py_SIZE(x) < 0)) { goto raise_neg_overflow; } #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (int) -1; if (unlikely(result == 1)) goto raise_neg_overflow; } #endif if (sizeof(int) <= sizeof(unsigned long)) { __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x)) } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) } } else { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (int) 0; case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, -(sdigit) digits[0]) case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0]) case -2: if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 2: if (8 * sizeof(int) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case -3: if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 3: if (8 * sizeof(int) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case -4: if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 4: if (8 * sizeof(int) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; } #endif if (sizeof(int) <= sizeof(long)) { __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x)) } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x)) } } { #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) PyErr_SetString(PyExc_RuntimeError, "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); #else int val; PyObject *v = __Pyx_PyNumber_Int(x); #if PY_MAJOR_VERSION < 3 if (likely(v) && !PyLong_Check(v)) { PyObject *tmp = v; v = PyNumber_Long(tmp); Py_DECREF(tmp); } #endif if (likely(v)) { int one = 1; int is_little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&val; int ret = _PyLong_AsByteArray((PyLongObject *)v, bytes, sizeof(val), is_little, !is_unsigned); Py_DECREF(v); if (likely(!ret)) return val; } #endif return (int) -1; } } else { int val; PyObject *tmp = __Pyx_PyNumber_Int(x); if (!tmp) return (int) -1; val = __Pyx_PyInt_As_int(tmp); Py_DECREF(tmp); return val; } raise_overflow: PyErr_SetString(PyExc_OverflowError, "value too large to convert to int"); return (int) -1; raise_neg_overflow: PyErr_SetString(PyExc_OverflowError, "can't convert negative value to int"); return (int) -1; } static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { const int neg_one = (int) -1, const_zero = (int) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { if (sizeof(int) < sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(int) <= sizeof(unsigned long)) { return PyLong_FromUnsignedLong((unsigned long) value); } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); } } else { if (sizeof(int) <= sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { return PyLong_FromLongLong((PY_LONG_LONG) value); } } { int one = 1; int little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&value; return _PyLong_FromByteArray(bytes, sizeof(int), little, !is_unsigned); } } static CYTHON_INLINE unsigned int __Pyx_PyInt_As_unsigned_int(PyObject *x) { const unsigned int neg_one = (unsigned int) -1, const_zero = (unsigned int) 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { if (sizeof(unsigned int) < sizeof(long)) { __PYX_VERIFY_RETURN_INT(unsigned int, long, PyInt_AS_LONG(x)) } else { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { goto raise_neg_overflow; } return (unsigned int) val; } } else #endif if (likely(PyLong_Check(x))) { if (is_unsigned) { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (unsigned int) 0; case 1: __PYX_VERIFY_RETURN_INT(unsigned int, digit, digits[0]) case 2: if (8 * sizeof(unsigned int) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(unsigned int) >= 2 * PyLong_SHIFT) { return (unsigned int) (((((unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])); } } break; case 3: if (8 * sizeof(unsigned int) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(unsigned int) >= 3 * PyLong_SHIFT) { return (unsigned int) (((((((unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])); } } break; case 4: if (8 * sizeof(unsigned int) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(unsigned int) >= 4 * PyLong_SHIFT) { return (unsigned int) (((((((((unsigned int)digits[3]) << PyLong_SHIFT) | (unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])); } } break; } #endif #if CYTHON_COMPILING_IN_CPYTHON if (unlikely(Py_SIZE(x) < 0)) { goto raise_neg_overflow; } #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (unsigned int) -1; if (unlikely(result == 1)) goto raise_neg_overflow; } #endif if (sizeof(unsigned int) <= sizeof(unsigned long)) { __PYX_VERIFY_RETURN_INT_EXC(unsigned int, unsigned long, PyLong_AsUnsignedLong(x)) } else if (sizeof(unsigned int) <= sizeof(unsigned PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(unsigned int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) } } else { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (unsigned int) 0; case -1: __PYX_VERIFY_RETURN_INT(unsigned int, sdigit, -(sdigit) digits[0]) case 1: __PYX_VERIFY_RETURN_INT(unsigned int, digit, +digits[0]) case -2: if (8 * sizeof(unsigned int) - 1 > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(unsigned int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(unsigned int) - 1 > 2 * PyLong_SHIFT) { return (unsigned int) (((unsigned int)-1)*(((((unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]))); } } break; case 2: if (8 * sizeof(unsigned int) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(unsigned int) - 1 > 2 * PyLong_SHIFT) { return (unsigned int) ((((((unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]))); } } break; case -3: if (8 * sizeof(unsigned int) - 1 > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(unsigned int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(unsigned int) - 1 > 3 * PyLong_SHIFT) { return (unsigned int) (((unsigned int)-1)*(((((((unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]))); } } break; case 3: if (8 * sizeof(unsigned int) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(unsigned int) - 1 > 3 * PyLong_SHIFT) { return (unsigned int) ((((((((unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]))); } } break; case -4: if (8 * sizeof(unsigned int) - 1 > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(unsigned int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(unsigned int) - 1 > 4 * PyLong_SHIFT) { return (unsigned int) (((unsigned int)-1)*(((((((((unsigned int)digits[3]) << PyLong_SHIFT) | (unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]))); } } break; case 4: if (8 * sizeof(unsigned int) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(unsigned int) - 1 > 4 * PyLong_SHIFT) { return (unsigned int) ((((((((((unsigned int)digits[3]) << PyLong_SHIFT) | (unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]))); } } break; } #endif if (sizeof(unsigned int) <= sizeof(long)) { __PYX_VERIFY_RETURN_INT_EXC(unsigned int, long, PyLong_AsLong(x)) } else if (sizeof(unsigned int) <= sizeof(PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(unsigned int, PY_LONG_LONG, PyLong_AsLongLong(x)) } } { #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) PyErr_SetString(PyExc_RuntimeError, "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); #else unsigned int val; PyObject *v = __Pyx_PyNumber_Int(x); #if PY_MAJOR_VERSION < 3 if (likely(v) && !PyLong_Check(v)) { PyObject *tmp = v; v = PyNumber_Long(tmp); Py_DECREF(tmp); } #endif if (likely(v)) { int one = 1; int is_little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&val; int ret = _PyLong_AsByteArray((PyLongObject *)v, bytes, sizeof(val), is_little, !is_unsigned); Py_DECREF(v); if (likely(!ret)) return val; } #endif return (unsigned int) -1; } } else { unsigned int val; PyObject *tmp = __Pyx_PyNumber_Int(x); if (!tmp) return (unsigned int) -1; val = __Pyx_PyInt_As_unsigned_int(tmp); Py_DECREF(tmp); return val; } raise_overflow: PyErr_SetString(PyExc_OverflowError, "value too large to convert to unsigned int"); return (unsigned int) -1; raise_neg_overflow: PyErr_SetString(PyExc_OverflowError, "can't convert negative value to unsigned int"); return (unsigned int) -1; } #if CYTHON_CCOMPLEX #ifdef __cplusplus static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { return ::std::complex< float >(x, y); } #else static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { return x + y*(__pyx_t_float_complex)_Complex_I; } #endif #else static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { __pyx_t_float_complex z; z.real = x; z.imag = y; return z; } #endif #if CYTHON_CCOMPLEX #else static CYTHON_INLINE int __Pyx_c_eqf(__pyx_t_float_complex a, __pyx_t_float_complex b) { return (a.real == b.real) && (a.imag == b.imag); } static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sumf(__pyx_t_float_complex a, __pyx_t_float_complex b) { __pyx_t_float_complex z; z.real = a.real + b.real; z.imag = a.imag + b.imag; return z; } static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_difff(__pyx_t_float_complex a, __pyx_t_float_complex b) { __pyx_t_float_complex z; z.real = a.real - b.real; z.imag = a.imag - b.imag; return z; } static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prodf(__pyx_t_float_complex a, __pyx_t_float_complex b) { __pyx_t_float_complex z; z.real = a.real * b.real - a.imag * b.imag; z.imag = a.real * b.imag + a.imag * b.real; return z; } static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quotf(__pyx_t_float_complex a, __pyx_t_float_complex b) { __pyx_t_float_complex z; float denom = b.real * b.real + b.imag * b.imag; z.real = (a.real * b.real + a.imag * b.imag) / denom; z.imag = (a.imag * b.real - a.real * b.imag) / denom; return z; } static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_negf(__pyx_t_float_complex a) { __pyx_t_float_complex z; z.real = -a.real; z.imag = -a.imag; return z; } static CYTHON_INLINE int __Pyx_c_is_zerof(__pyx_t_float_complex a) { return (a.real == 0) && (a.imag == 0); } static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conjf(__pyx_t_float_complex a) { __pyx_t_float_complex z; z.real = a.real; z.imag = -a.imag; return z; } #if 1 static CYTHON_INLINE float __Pyx_c_absf(__pyx_t_float_complex z) { #if !defined(HAVE_HYPOT) || defined(_MSC_VER) return sqrtf(z.real*z.real + z.imag*z.imag); #else return hypotf(z.real, z.imag); #endif } static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_powf(__pyx_t_float_complex a, __pyx_t_float_complex b) { __pyx_t_float_complex z; float r, lnr, theta, z_r, z_theta; if (b.imag == 0 && b.real == (int)b.real) { if (b.real < 0) { float denom = a.real * a.real + a.imag * a.imag; a.real = a.real / denom; a.imag = -a.imag / denom; b.real = -b.real; } switch ((int)b.real) { case 0: z.real = 1; z.imag = 0; return z; case 1: return a; case 2: z = __Pyx_c_prodf(a, a); return __Pyx_c_prodf(a, a); case 3: z = __Pyx_c_prodf(a, a); return __Pyx_c_prodf(z, a); case 4: z = __Pyx_c_prodf(a, a); return __Pyx_c_prodf(z, z); } } if (a.imag == 0) { if (a.real == 0) { return a; } r = a.real; theta = 0; } else { r = __Pyx_c_absf(a); theta = atan2f(a.imag, a.real); } lnr = logf(r); z_r = expf(lnr * b.real - theta * b.imag); z_theta = theta * b.real + lnr * b.imag; z.real = z_r * cosf(z_theta); z.imag = z_r * sinf(z_theta); return z; } #endif #endif #if CYTHON_CCOMPLEX #ifdef __cplusplus static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { return ::std::complex< double >(x, y); } #else static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { return x + y*(__pyx_t_double_complex)_Complex_I; } #endif #else static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { __pyx_t_double_complex z; z.real = x; z.imag = y; return z; } #endif #if CYTHON_CCOMPLEX #else static CYTHON_INLINE int __Pyx_c_eq(__pyx_t_double_complex a, __pyx_t_double_complex b) { return (a.real == b.real) && (a.imag == b.imag); } static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum(__pyx_t_double_complex a, __pyx_t_double_complex b) { __pyx_t_double_complex z; z.real = a.real + b.real; z.imag = a.imag + b.imag; return z; } static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff(__pyx_t_double_complex a, __pyx_t_double_complex b) { __pyx_t_double_complex z; z.real = a.real - b.real; z.imag = a.imag - b.imag; return z; } static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod(__pyx_t_double_complex a, __pyx_t_double_complex b) { __pyx_t_double_complex z; z.real = a.real * b.real - a.imag * b.imag; z.imag = a.real * b.imag + a.imag * b.real; return z; } static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot(__pyx_t_double_complex a, __pyx_t_double_complex b) { __pyx_t_double_complex z; double denom = b.real * b.real + b.imag * b.imag; z.real = (a.real * b.real + a.imag * b.imag) / denom; z.imag = (a.imag * b.real - a.real * b.imag) / denom; return z; } static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg(__pyx_t_double_complex a) { __pyx_t_double_complex z; z.real = -a.real; z.imag = -a.imag; return z; } static CYTHON_INLINE int __Pyx_c_is_zero(__pyx_t_double_complex a) { return (a.real == 0) && (a.imag == 0); } static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj(__pyx_t_double_complex a) { __pyx_t_double_complex z; z.real = a.real; z.imag = -a.imag; return z; } #if 1 static CYTHON_INLINE double __Pyx_c_abs(__pyx_t_double_complex z) { #if !defined(HAVE_HYPOT) || defined(_MSC_VER) return sqrt(z.real*z.real + z.imag*z.imag); #else return hypot(z.real, z.imag); #endif } static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow(__pyx_t_double_complex a, __pyx_t_double_complex b) { __pyx_t_double_complex z; double r, lnr, theta, z_r, z_theta; if (b.imag == 0 && b.real == (int)b.real) { if (b.real < 0) { double denom = a.real * a.real + a.imag * a.imag; a.real = a.real / denom; a.imag = -a.imag / denom; b.real = -b.real; } switch ((int)b.real) { case 0: z.real = 1; z.imag = 0; return z; case 1: return a; case 2: z = __Pyx_c_prod(a, a); return __Pyx_c_prod(a, a); case 3: z = __Pyx_c_prod(a, a); return __Pyx_c_prod(z, a); case 4: z = __Pyx_c_prod(a, a); return __Pyx_c_prod(z, z); } } if (a.imag == 0) { if (a.real == 0) { return a; } r = a.real; theta = 0; } else { r = __Pyx_c_abs(a); theta = atan2(a.imag, a.real); } lnr = log(r); z_r = exp(lnr * b.real - theta * b.imag); z_theta = theta * b.real + lnr * b.imag; z.real = z_r * cos(z_theta); z.imag = z_r * sin(z_theta); return z; } #endif #endif static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum__NPY_TYPES(enum NPY_TYPES value) { const enum NPY_TYPES neg_one = (enum NPY_TYPES) -1, const_zero = (enum NPY_TYPES) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { if (sizeof(enum NPY_TYPES) < sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(enum NPY_TYPES) <= sizeof(unsigned long)) { return PyLong_FromUnsignedLong((unsigned long) value); } else if (sizeof(enum NPY_TYPES) <= sizeof(unsigned PY_LONG_LONG)) { return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); } } else { if (sizeof(enum NPY_TYPES) <= sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(enum NPY_TYPES) <= sizeof(PY_LONG_LONG)) { return PyLong_FromLongLong((PY_LONG_LONG) value); } } { int one = 1; int little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&value; return _PyLong_FromByteArray(bytes, sizeof(enum NPY_TYPES), little, !is_unsigned); } } static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { const long neg_one = (long) -1, const_zero = (long) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { if (sizeof(long) < sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(long) <= sizeof(unsigned long)) { return PyLong_FromUnsignedLong((unsigned long) value); } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); } } else { if (sizeof(long) <= sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { return PyLong_FromLongLong((PY_LONG_LONG) value); } } { int one = 1; int little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&value; return _PyLong_FromByteArray(bytes, sizeof(long), little, !is_unsigned); } } static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { const long neg_one = (long) -1, const_zero = (long) 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { if (sizeof(long) < sizeof(long)) { __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x)) } else { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { goto raise_neg_overflow; } return (long) val; } } else #endif if (likely(PyLong_Check(x))) { if (is_unsigned) { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (long) 0; case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0]) case 2: if (8 * sizeof(long) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) { return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; case 3: if (8 * sizeof(long) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) { return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; case 4: if (8 * sizeof(long) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) { return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; } #endif #if CYTHON_COMPILING_IN_CPYTHON if (unlikely(Py_SIZE(x) < 0)) { goto raise_neg_overflow; } #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (long) -1; if (unlikely(result == 1)) goto raise_neg_overflow; } #endif if (sizeof(long) <= sizeof(unsigned long)) { __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x)) } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) } } else { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (long) 0; case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, -(sdigit) digits[0]) case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0]) case -2: if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case 2: if (8 * sizeof(long) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case -3: if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case 3: if (8 * sizeof(long) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case -4: if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case 4: if (8 * sizeof(long) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; } #endif if (sizeof(long) <= sizeof(long)) { __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x)) } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x)) } } { #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) PyErr_SetString(PyExc_RuntimeError, "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); #else long val; PyObject *v = __Pyx_PyNumber_Int(x); #if PY_MAJOR_VERSION < 3 if (likely(v) && !PyLong_Check(v)) { PyObject *tmp = v; v = PyNumber_Long(tmp); Py_DECREF(tmp); } #endif if (likely(v)) { int one = 1; int is_little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&val; int ret = _PyLong_AsByteArray((PyLongObject *)v, bytes, sizeof(val), is_little, !is_unsigned); Py_DECREF(v); if (likely(!ret)) return val; } #endif return (long) -1; } } else { long val; PyObject *tmp = __Pyx_PyNumber_Int(x); if (!tmp) return (long) -1; val = __Pyx_PyInt_As_long(tmp); Py_DECREF(tmp); return val; } raise_overflow: PyErr_SetString(PyExc_OverflowError, "value too large to convert to long"); return (long) -1; raise_neg_overflow: PyErr_SetString(PyExc_OverflowError, "can't convert negative value to long"); return (long) -1; } static int __Pyx_check_binary_version(void) { char ctversion[4], rtversion[4]; PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION); PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion()); if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) { char message[200]; PyOS_snprintf(message, sizeof(message), "compiletime version %s of module '%.100s' " "does not match runtime version %s", ctversion, __Pyx_MODULE_NAME, rtversion); return PyErr_WarnEx(NULL, message, 1); } return 0; } #ifndef __PYX_HAVE_RT_ImportModule #define __PYX_HAVE_RT_ImportModule static PyObject *__Pyx_ImportModule(const char *name) { PyObject *py_name = 0; PyObject *py_module = 0; py_name = __Pyx_PyIdentifier_FromString(name); if (!py_name) goto bad; py_module = PyImport_Import(py_name); Py_DECREF(py_name); return py_module; bad: Py_XDECREF(py_name); return 0; } #endif #ifndef __PYX_HAVE_RT_ImportType #define __PYX_HAVE_RT_ImportType static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict) { PyObject *py_module = 0; PyObject *result = 0; PyObject *py_name = 0; char warning[200]; Py_ssize_t basicsize; #ifdef Py_LIMITED_API PyObject *py_basicsize; #endif py_module = __Pyx_ImportModule(module_name); if (!py_module) goto bad; py_name = __Pyx_PyIdentifier_FromString(class_name); if (!py_name) goto bad; result = PyObject_GetAttr(py_module, py_name); Py_DECREF(py_name); py_name = 0; Py_DECREF(py_module); py_module = 0; if (!result) goto bad; if (!PyType_Check(result)) { PyErr_Format(PyExc_TypeError, "%.200s.%.200s is not a type object", module_name, class_name); goto bad; } #ifndef Py_LIMITED_API basicsize = ((PyTypeObject *)result)->tp_basicsize; #else py_basicsize = PyObject_GetAttrString(result, "__basicsize__"); if (!py_basicsize) goto bad; basicsize = PyLong_AsSsize_t(py_basicsize); Py_DECREF(py_basicsize); py_basicsize = 0; if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred()) goto bad; #endif if (!strict && (size_t)basicsize > size) { PyOS_snprintf(warning, sizeof(warning), "%s.%s size changed, may indicate binary incompatibility", module_name, class_name); if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad; } else if ((size_t)basicsize != size) { PyErr_Format(PyExc_ValueError, "%.200s.%.200s has the wrong size, try recompiling", module_name, class_name); goto bad; } return (PyTypeObject *)result; bad: Py_XDECREF(py_module); Py_XDECREF(result); return NULL; } #endif #ifndef __PYX_HAVE_RT_ImportFunction #define __PYX_HAVE_RT_ImportFunction static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) { PyObject *d = 0; PyObject *cobj = 0; union { void (*fp)(void); void *p; } tmp; d = PyObject_GetAttrString(module, (char *)"__pyx_capi__"); if (!d) goto bad; cobj = PyDict_GetItemString(d, funcname); if (!cobj) { PyErr_Format(PyExc_ImportError, "%.200s does not export expected C function %.200s", PyModule_GetName(module), funcname); goto bad; } #if PY_VERSION_HEX >= 0x02070000 if (!PyCapsule_IsValid(cobj, sig)) { PyErr_Format(PyExc_TypeError, "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)", PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj)); goto bad; } tmp.p = PyCapsule_GetPointer(cobj, sig); #else {const char *desc, *s1, *s2; desc = (const char *)PyCObject_GetDesc(cobj); if (!desc) goto bad; s1 = desc; s2 = sig; while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; } if (*s1 != *s2) { PyErr_Format(PyExc_TypeError, "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)", PyModule_GetName(module), funcname, sig, desc); goto bad; } tmp.p = PyCObject_AsVoidPtr(cobj);} #endif *f = tmp.fp; if (!(*f)) goto bad; Py_DECREF(d); return 0; bad: Py_XDECREF(d); return -1; } #endif static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { while (t->p) { #if PY_MAJOR_VERSION < 3 if (t->is_unicode) { *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL); } else if (t->intern) { *t->p = PyString_InternFromString(t->s); } else { *t->p = PyString_FromStringAndSize(t->s, t->n - 1); } #else if (t->is_unicode | t->is_str) { if (t->intern) { *t->p = PyUnicode_InternFromString(t->s); } else if (t->encoding) { *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL); } else { *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1); } } else { *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1); } #endif if (!*t->p) return -1; ++t; } return 0; } static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) { return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str)); } static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) { Py_ssize_t ignore; return __Pyx_PyObject_AsStringAndSize(o, &ignore); } static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { #if CYTHON_COMPILING_IN_CPYTHON && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) if ( #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII __Pyx_sys_getdefaultencoding_not_ascii && #endif PyUnicode_Check(o)) { #if PY_VERSION_HEX < 0x03030000 char* defenc_c; PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); if (!defenc) return NULL; defenc_c = PyBytes_AS_STRING(defenc); #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII { char* end = defenc_c + PyBytes_GET_SIZE(defenc); char* c; for (c = defenc_c; c < end; c++) { if ((unsigned char) (*c) >= 128) { PyUnicode_AsASCIIString(o); return NULL; } } } #endif *length = PyBytes_GET_SIZE(defenc); return defenc_c; #else if (__Pyx_PyUnicode_READY(o) == -1) return NULL; #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII if (PyUnicode_IS_ASCII(o)) { *length = PyUnicode_GET_LENGTH(o); return PyUnicode_AsUTF8(o); } else { PyUnicode_AsASCIIString(o); return NULL; } #else return PyUnicode_AsUTF8AndSize(o, length); #endif #endif } else #endif #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE)) if (PyByteArray_Check(o)) { *length = PyByteArray_GET_SIZE(o); return PyByteArray_AS_STRING(o); } else #endif { char* result; int r = PyBytes_AsStringAndSize(o, &result, length); if (unlikely(r < 0)) { return NULL; } else { return result; } } } static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { int is_true = x == Py_True; if (is_true | (x == Py_False) | (x == Py_None)) return is_true; else return PyObject_IsTrue(x); } static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) { PyNumberMethods *m; const char *name = NULL; PyObject *res = NULL; #if PY_MAJOR_VERSION < 3 if (PyInt_Check(x) || PyLong_Check(x)) #else if (PyLong_Check(x)) #endif return __Pyx_NewRef(x); m = Py_TYPE(x)->tp_as_number; #if PY_MAJOR_VERSION < 3 if (m && m->nb_int) { name = "int"; res = PyNumber_Int(x); } else if (m && m->nb_long) { name = "long"; res = PyNumber_Long(x); } #else if (m && m->nb_int) { name = "int"; res = PyNumber_Long(x); } #endif if (res) { #if PY_MAJOR_VERSION < 3 if (!PyInt_Check(res) && !PyLong_Check(res)) { #else if (!PyLong_Check(res)) { #endif PyErr_Format(PyExc_TypeError, "__%.4s__ returned non-%.4s (type %.200s)", name, name, Py_TYPE(res)->tp_name); Py_DECREF(res); return NULL; } } else if (!PyErr_Occurred()) { PyErr_SetString(PyExc_TypeError, "an integer is required"); } return res; } static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { Py_ssize_t ival; PyObject *x; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_CheckExact(b))) { if (sizeof(Py_ssize_t) >= sizeof(long)) return PyInt_AS_LONG(b); else return PyInt_AsSsize_t(x); } #endif if (likely(PyLong_CheckExact(b))) { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)b)->ob_digit; const Py_ssize_t size = Py_SIZE(b); if (likely(__Pyx_sst_abs(size) <= 1)) { ival = likely(size) ? digits[0] : 0; if (size == -1) ival = -ival; return ival; } else { switch (size) { case 2: if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case -2: if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case 3: if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case -3: if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case 4: if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case -4: if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; } } #endif return PyLong_AsSsize_t(b); } x = PyNumber_Index(b); if (!x) return -1; ival = PyInt_AsSsize_t(x); Py_DECREF(x); return ival; } static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { return PyInt_FromSize_t(ival); } #endif /* Py_PYTHON_H */ photutils-0.2.1/photutils/geometry/circular_overlap.pyx0000600000214200020070000002024712627615324025721 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst # The functions defined here allow one to determine the exact area of # overlap of a rectangle and a circle (written by Thomas Robitaille). from __future__ import (absolute_import, division, print_function, unicode_literals) import numpy as np cimport numpy as np __all__ = ['circular_overlap_grid'] cdef extern from "math.h": double asin(double x) double sin(double x) double sqrt(double x) DTYPE = np.float64 ctypedef np.float64_t DTYPE_t # NOTE: Here we need to make sure we use cimport to import the C functions from # core (since these were defined with cdef). This also requires the core.pxd # file to exist with the function signatures. from .core cimport area_arc, area_triangle def circular_overlap_grid(double xmin, double xmax, double ymin, double ymax, int nx, int ny, double r, int use_exact, int subpixels): """ circular_overlap_grid(xmin, xmax, ymin, ymax, nx, ny, r, use_exact, subpixels) Area of overlap between a circle and a pixel grid. The circle is centered on the origin. Parameters ---------- xmin, xmax, ymin, ymax : float Extent of the grid in the x and y direction. nx, ny : int Grid dimensions. r : float The radius of the circle. use_exact : 0 or 1 If ``1`` calculates exact overlap, if ``0`` uses ``subpixel`` number of subpixels to calculate the overlap. subpixels : int Each pixel resampled by this factor in each dimension, thus each pixel is divided into ``subpixels ** 2`` subpixels. Returns ------- frac : `~numpy.ndarray` (float) 2-d array of shape (ny, nx) giving the fraction of the overlap. """ cdef unsigned int i, j cdef double x, y, dx, dy, d, pixel_radius cdef double bxmin, bxmax, bymin, bymax cdef double pxmin, pxcen, pxmax, pymin, pycen, pymax # Define output array cdef np.ndarray[DTYPE_t, ndim=2] frac = np.zeros([ny, nx], dtype=DTYPE) # Find the width of each element in x and y dx = (xmax - xmin) / nx dy = (ymax - ymin) / ny # Find the radius of a single pixel pixel_radius = 0.5 * sqrt(dx * dx + dy * dy) # Define bounding box bxmin = -r - 0.5 * dx bxmax = +r + 0.5 * dx bymin = -r - 0.5 * dy bymax = +r + 0.5 * dy for i in range(nx): pxmin = xmin + i * dx # lower end of pixel pxcen = pxmin + dx * 0.5 pxmax = pxmin + dx # upper end of pixel if pxmax > bxmin and pxmin < bxmax: for j in range(ny): pymin = ymin + j * dy pycen = pymin + dy * 0.5 pymax = pymin + dy if pymax > bymin and pymin < bymax: # Distance from circle center to pixel center. d = sqrt(pxcen * pxcen + pycen * pycen) # If pixel center is "well within" circle, count full # pixel. if d < r - pixel_radius: frac[j, i] = 1. # If pixel center is "close" to circle border, find # overlap. elif d < r + pixel_radius: # Either do exact calculation or use subpixel # sampling: if use_exact: frac[j, i] = circular_overlap_single_exact( pxmin, pymin, pxmax, pymax, r) / (dx * dy) else: frac[j, i] = circular_overlap_single_subpixel( pxmin, pymin, pxmax, pymax, r, subpixels) # Otherwise, it is fully outside circle. # No action needed. return frac # NOTE: The following two functions use cdef because they are not # intended to be called from the Python code. Using def makes them # callable from outside, but also slower. In any case, these aren't useful # to call from outside because they only operate on a single pixel. cdef double circular_overlap_single_subpixel(double x0, double y0, double x1, double y1, double r, int subpixels): """Return the fraction of overlap between a circle and a single pixel with given extent, using a sub-pixel sampling method.""" cdef unsigned int i, j cdef double x, y, dx, dy, r_squared cdef double frac = 0. # Accumulator. dx = (x1 - x0) / subpixels dy = (y1 - y0) / subpixels r_squared = r ** 2 x = x0 - 0.5 * dx for i in range(subpixels): x += dx y = y0 - 0.5 * dy for j in range(subpixels): y += dy if x * x + y * y < r_squared: frac += 1. return frac / (subpixels * subpixels) cdef double circular_overlap_single_exact(double xmin, double ymin, double xmax, double ymax, double r): """ Area of overlap of a rectangle and a circle """ if 0. <= xmin: if 0. <= ymin: return circular_overlap_core(xmin, ymin, xmax, ymax, r) elif 0. >= ymax: return circular_overlap_core(-ymax, xmin, -ymin, xmax, r) else: return circular_overlap_single_exact(xmin, ymin, xmax, 0., r) \ + circular_overlap_single_exact(xmin, 0., xmax, ymax, r) elif 0. >= xmax: if 0. <= ymin: return circular_overlap_core(-xmax, ymin, -xmin, ymax, r) elif 0. >= ymax: return circular_overlap_core(-xmax, -ymax, -xmin, -ymin, r) else: return circular_overlap_single_exact(xmin, ymin, xmax, 0., r) \ + circular_overlap_single_exact(xmin, 0., xmax, ymax, r) else: if 0. <= ymin: return circular_overlap_single_exact(xmin, ymin, 0., ymax, r) \ + circular_overlap_single_exact(0., ymin, xmax, ymax, r) if 0. >= ymax: return circular_overlap_single_exact(xmin, ymin, 0., ymax, r) \ + circular_overlap_single_exact(0., ymin, xmax, ymax, r) else: return circular_overlap_single_exact(xmin, ymin, 0., 0., r) \ + circular_overlap_single_exact(0., ymin, xmax, 0., r) \ + circular_overlap_single_exact(xmin, 0., 0., ymax, r) \ + circular_overlap_single_exact(0., 0., xmax, ymax, r) def circular_overlap_core(double xmin, double ymin, double xmax, double ymax, double r): """Assumes that the center of the circle is <= xmin, ymin (can always modify input to conform to this). """ cdef double area, d1, d2, x1, x2, y1, y2 if xmin * xmin + ymin * ymin > r * r: area = 0. elif xmax * xmax + ymax * ymax < r * r: area = (xmax - xmin) * (ymax - ymin) else: area = 0. d1 = sqrt(xmax * xmax + ymin * ymin) d2 = sqrt(xmin * xmin + ymax * ymax) if d1 < r and d2 < r: x1, y1 = sqrt(r * r - ymax * ymax), ymax x2, y2 = xmax, sqrt(r * r - xmax * xmax) area = ((xmax - xmin) * (ymax - ymin) - area_triangle(x1, y1, x2, y2, xmax, ymax) + area_arc(x1, y1, x2, y2, r)) elif d1 < r: x1, y1 = xmin, sqrt(r * r - xmin * xmin) x2, y2 = xmax, sqrt(r * r - xmax * xmax) area = (area_arc(x1, y1, x2, y2, r) + area_triangle(x1, y1, x1, ymin, xmax, ymin) + area_triangle(x1, y1, x2, ymin, x2, y2)) elif d2 < r: x1, y1 = sqrt(r * r - ymin * ymin), ymin x2, y2 = sqrt(r * r - ymax * ymax), ymax area = (area_arc(x1, y1, x2, y2, r) + area_triangle(x1, y1, xmin, y1, xmin, ymax) + area_triangle(x1, y1, xmin, y2, x2, y2)) else: x1, y1 = sqrt(r * r - ymin * ymin), ymin x2, y2 = xmin, sqrt(r * r - xmin * xmin) area = (area_arc(x1, y1, x2, y2, r) + area_triangle(x1, y1, x2, y2, xmin, ymin)) return area photutils-0.2.1/photutils/geometry/core.c0000600000214200020070000116042112646264030022712 0ustar lbradleySTSCI\science00000000000000/* Generated by Cython 0.23.4 */ #define PY_SSIZE_T_CLEAN #include "Python.h" #ifndef Py_PYTHON_H #error Python headers needed to compile C extensions, please install development version of Python. #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000) #error Cython requires Python 2.6+ or Python 3.2+. #else #define CYTHON_ABI "0_23_4" #include #ifndef offsetof #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) #endif #if !defined(WIN32) && !defined(MS_WINDOWS) #ifndef __stdcall #define __stdcall #endif #ifndef __cdecl #define __cdecl #endif #ifndef __fastcall #define __fastcall #endif #endif #ifndef DL_IMPORT #define DL_IMPORT(t) t #endif #ifndef DL_EXPORT #define DL_EXPORT(t) t #endif #ifndef PY_LONG_LONG #define PY_LONG_LONG LONG_LONG #endif #ifndef Py_HUGE_VAL #define Py_HUGE_VAL HUGE_VAL #endif #ifdef PYPY_VERSION #define CYTHON_COMPILING_IN_PYPY 1 #define CYTHON_COMPILING_IN_CPYTHON 0 #else #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_CPYTHON 1 #endif #if !defined(CYTHON_USE_PYLONG_INTERNALS) && CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x02070000 #define CYTHON_USE_PYLONG_INTERNALS 1 #endif #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag) #define Py_OptimizeFlag 0 #endif #define __PYX_BUILD_PY_SSIZE_T "n" #define CYTHON_FORMAT_SSIZE_T "z" #if PY_MAJOR_VERSION < 3 #define __Pyx_BUILTIN_MODULE_NAME "__builtin__" #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) #define __Pyx_DefaultClassType PyClass_Type #else #define __Pyx_BUILTIN_MODULE_NAME "builtins" #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) #define __Pyx_DefaultClassType PyType_Type #endif #ifndef Py_TPFLAGS_CHECKTYPES #define Py_TPFLAGS_CHECKTYPES 0 #endif #ifndef Py_TPFLAGS_HAVE_INDEX #define Py_TPFLAGS_HAVE_INDEX 0 #endif #ifndef Py_TPFLAGS_HAVE_NEWBUFFER #define Py_TPFLAGS_HAVE_NEWBUFFER 0 #endif #ifndef Py_TPFLAGS_HAVE_FINALIZE #define Py_TPFLAGS_HAVE_FINALIZE 0 #endif #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) #define CYTHON_PEP393_ENABLED 1 #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\ 0 : _PyUnicode_Ready((PyObject *)(op))) #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u) #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i) #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u) #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u) #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i) #else #define CYTHON_PEP393_ENABLED 0 #define __Pyx_PyUnicode_READY(op) (0) #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u) #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i])) #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE)) #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u)) #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i])) #endif #if CYTHON_COMPILING_IN_PYPY #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b) #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b) #else #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b) #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\ PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b)) #endif #if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains) #define PyUnicode_Contains(u, s) PySequence_Contains(u, s) #endif #define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b)) #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b)) #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b) #else #define __Pyx_PyString_Format(a, b) PyString_Format(a, b) #endif #if PY_MAJOR_VERSION >= 3 #define PyBaseString_Type PyUnicode_Type #define PyStringObject PyUnicodeObject #define PyString_Type PyUnicode_Type #define PyString_Check PyUnicode_Check #define PyString_CheckExact PyUnicode_CheckExact #endif #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj) #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj) #else #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj)) #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj)) #endif #ifndef PySet_CheckExact #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) #endif #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) #if PY_MAJOR_VERSION >= 3 #define PyIntObject PyLongObject #define PyInt_Type PyLong_Type #define PyInt_Check(op) PyLong_Check(op) #define PyInt_CheckExact(op) PyLong_CheckExact(op) #define PyInt_FromString PyLong_FromString #define PyInt_FromUnicode PyLong_FromUnicode #define PyInt_FromLong PyLong_FromLong #define PyInt_FromSize_t PyLong_FromSize_t #define PyInt_FromSsize_t PyLong_FromSsize_t #define PyInt_AsLong PyLong_AsLong #define PyInt_AS_LONG PyLong_AS_LONG #define PyInt_AsSsize_t PyLong_AsSsize_t #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask #define PyNumber_Int PyNumber_Long #endif #if PY_MAJOR_VERSION >= 3 #define PyBoolObject PyLongObject #endif #if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY #ifndef PyUnicode_InternFromString #define PyUnicode_InternFromString(s) PyUnicode_FromString(s) #endif #endif #if PY_VERSION_HEX < 0x030200A4 typedef long Py_hash_t; #define __Pyx_PyInt_FromHash_t PyInt_FromLong #define __Pyx_PyInt_AsHash_t PyInt_AsLong #else #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t #endif #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func)) #else #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass) #endif #if PY_VERSION_HEX >= 0x030500B1 #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async) #elif CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 typedef struct { unaryfunc am_await; unaryfunc am_aiter; unaryfunc am_anext; } __Pyx_PyAsyncMethodsStruct; #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved)) #else #define __Pyx_PyType_AsAsync(obj) NULL #endif #ifndef CYTHON_RESTRICT #if defined(__GNUC__) #define CYTHON_RESTRICT __restrict__ #elif defined(_MSC_VER) && _MSC_VER >= 1400 #define CYTHON_RESTRICT __restrict #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define CYTHON_RESTRICT restrict #else #define CYTHON_RESTRICT #endif #endif #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None) #ifndef CYTHON_INLINE #if defined(__GNUC__) #define CYTHON_INLINE __inline__ #elif defined(_MSC_VER) #define CYTHON_INLINE __inline #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define CYTHON_INLINE inline #else #define CYTHON_INLINE #endif #endif #if defined(WIN32) || defined(MS_WINDOWS) #define _USE_MATH_DEFINES #endif #include #ifdef NAN #define __PYX_NAN() ((float) NAN) #else static CYTHON_INLINE float __PYX_NAN() { float value; memset(&value, 0xFF, sizeof(value)); return value; } #endif #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) #else #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) #endif #ifndef __PYX_EXTERN_C #ifdef __cplusplus #define __PYX_EXTERN_C extern "C" #else #define __PYX_EXTERN_C extern #endif #endif #define __PYX_HAVE__photutils__geometry__core #define __PYX_HAVE_API__photutils__geometry__core #include "string.h" #include "stdio.h" #include "stdlib.h" #include "numpy/arrayobject.h" #include "numpy/ufuncobject.h" #include "math.h" #include "pythread.h" #ifdef _OPENMP #include #endif /* _OPENMP */ #ifdef PYREX_WITHOUT_ASSERTIONS #define CYTHON_WITHOUT_ASSERTIONS #endif #ifndef CYTHON_UNUSED # if defined(__GNUC__) # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) # define CYTHON_UNUSED __attribute__ ((__unused__)) # else # define CYTHON_UNUSED # endif # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER)) # define CYTHON_UNUSED __attribute__ ((__unused__)) # else # define CYTHON_UNUSED # endif #endif #ifndef CYTHON_NCP_UNUSED # if CYTHON_COMPILING_IN_CPYTHON # define CYTHON_NCP_UNUSED # else # define CYTHON_NCP_UNUSED CYTHON_UNUSED # endif #endif typedef struct {PyObject **p; char *s; const Py_ssize_t n; const char* encoding; const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0 #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0 #define __PYX_DEFAULT_STRING_ENCODING "" #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize #define __Pyx_uchar_cast(c) ((unsigned char)c) #define __Pyx_long_cast(x) ((long)x) #define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\ (sizeof(type) < sizeof(Py_ssize_t)) ||\ (sizeof(type) > sizeof(Py_ssize_t) &&\ likely(v < (type)PY_SSIZE_T_MAX ||\ v == (type)PY_SSIZE_T_MAX) &&\ (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\ v == (type)PY_SSIZE_T_MIN))) ||\ (sizeof(type) == sizeof(Py_ssize_t) &&\ (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\ v == (type)PY_SSIZE_T_MAX))) ) #if defined (__cplusplus) && __cplusplus >= 201103L #include #define __Pyx_sst_abs(value) std::abs(value) #elif SIZEOF_INT >= SIZEOF_SIZE_T #define __Pyx_sst_abs(value) abs(value) #elif SIZEOF_LONG >= SIZEOF_SIZE_T #define __Pyx_sst_abs(value) labs(value) #elif defined (_MSC_VER) && defined (_M_X64) #define __Pyx_sst_abs(value) _abs64(value) #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define __Pyx_sst_abs(value) llabs(value) #elif defined (__GNUC__) #define __Pyx_sst_abs(value) __builtin_llabs(value) #else #define __Pyx_sst_abs(value) ((value<0) ? -value : value) #endif static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*); static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s)) #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l) #define __Pyx_PyBytes_FromString PyBytes_FromString #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); #if PY_MAJOR_VERSION < 3 #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize #else #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize #endif #define __Pyx_PyObject_AsSString(s) ((signed char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s) #define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s) #define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s) #define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s) #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s) #if PY_MAJOR_VERSION < 3 static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) { const Py_UNICODE *u_end = u; while (*u_end++) ; return (size_t)(u_end - u - 1); } #else #define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen #endif #define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u)) #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj) #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None) #define __Pyx_PyBool_FromLong(b) ((b) ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False)) static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x); static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); #if CYTHON_COMPILING_IN_CPYTHON #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x)) #else #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x) #endif #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x)) #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII static int __Pyx_sys_getdefaultencoding_not_ascii; static int __Pyx_init_sys_getdefaultencoding_params(void) { PyObject* sys; PyObject* default_encoding = NULL; PyObject* ascii_chars_u = NULL; PyObject* ascii_chars_b = NULL; const char* default_encoding_c; sys = PyImport_ImportModule("sys"); if (!sys) goto bad; default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL); Py_DECREF(sys); if (!default_encoding) goto bad; default_encoding_c = PyBytes_AsString(default_encoding); if (!default_encoding_c) goto bad; if (strcmp(default_encoding_c, "ascii") == 0) { __Pyx_sys_getdefaultencoding_not_ascii = 0; } else { char ascii_chars[128]; int c; for (c = 0; c < 128; c++) { ascii_chars[c] = c; } __Pyx_sys_getdefaultencoding_not_ascii = 1; ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL); if (!ascii_chars_u) goto bad; ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL); if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) { PyErr_Format( PyExc_ValueError, "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.", default_encoding_c); goto bad; } Py_DECREF(ascii_chars_u); Py_DECREF(ascii_chars_b); } Py_DECREF(default_encoding); return 0; bad: Py_XDECREF(default_encoding); Py_XDECREF(ascii_chars_u); Py_XDECREF(ascii_chars_b); return -1; } #endif #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL) #else #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL) #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT static char* __PYX_DEFAULT_STRING_ENCODING; static int __Pyx_init_sys_getdefaultencoding_params(void) { PyObject* sys; PyObject* default_encoding = NULL; char* default_encoding_c; sys = PyImport_ImportModule("sys"); if (!sys) goto bad; default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL); Py_DECREF(sys); if (!default_encoding) goto bad; default_encoding_c = PyBytes_AsString(default_encoding); if (!default_encoding_c) goto bad; __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c)); if (!__PYX_DEFAULT_STRING_ENCODING) goto bad; strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c); Py_DECREF(default_encoding); return 0; bad: Py_XDECREF(default_encoding); return -1; } #endif #endif /* Test for GCC > 2.95 */ #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))) #define likely(x) __builtin_expect(!!(x), 1) #define unlikely(x) __builtin_expect(!!(x), 0) #else /* !__GNUC__ or GCC < 2.95 */ #define likely(x) (x) #define unlikely(x) (x) #endif /* __GNUC__ */ static PyObject *__pyx_m; static PyObject *__pyx_d; static PyObject *__pyx_b; static PyObject *__pyx_empty_tuple; static PyObject *__pyx_empty_bytes; static int __pyx_lineno; static int __pyx_clineno = 0; static const char * __pyx_cfilenm= __FILE__; static const char *__pyx_filename; #if !defined(CYTHON_CCOMPLEX) #if defined(__cplusplus) #define CYTHON_CCOMPLEX 1 #elif defined(_Complex_I) #define CYTHON_CCOMPLEX 1 #else #define CYTHON_CCOMPLEX 0 #endif #endif #if CYTHON_CCOMPLEX #ifdef __cplusplus #include #else #include #endif #endif #if CYTHON_CCOMPLEX && !defined(__cplusplus) && defined(__sun__) && defined(__GNUC__) #undef _Complex_I #define _Complex_I 1.0fj #endif static const char *__pyx_f[] = { "photutils/geometry/core.pyx", "__init__.pxd", "type.pxd", "bool.pxd", "complex.pxd", }; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":725 * # in Cython to enable them only on the right systems. * * ctypedef npy_int8 int8_t # <<<<<<<<<<<<<< * ctypedef npy_int16 int16_t * ctypedef npy_int32 int32_t */ typedef npy_int8 __pyx_t_5numpy_int8_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":726 * * ctypedef npy_int8 int8_t * ctypedef npy_int16 int16_t # <<<<<<<<<<<<<< * ctypedef npy_int32 int32_t * ctypedef npy_int64 int64_t */ typedef npy_int16 __pyx_t_5numpy_int16_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":727 * ctypedef npy_int8 int8_t * ctypedef npy_int16 int16_t * ctypedef npy_int32 int32_t # <<<<<<<<<<<<<< * ctypedef npy_int64 int64_t * #ctypedef npy_int96 int96_t */ typedef npy_int32 __pyx_t_5numpy_int32_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":728 * ctypedef npy_int16 int16_t * ctypedef npy_int32 int32_t * ctypedef npy_int64 int64_t # <<<<<<<<<<<<<< * #ctypedef npy_int96 int96_t * #ctypedef npy_int128 int128_t */ typedef npy_int64 __pyx_t_5numpy_int64_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":732 * #ctypedef npy_int128 int128_t * * ctypedef npy_uint8 uint8_t # <<<<<<<<<<<<<< * ctypedef npy_uint16 uint16_t * ctypedef npy_uint32 uint32_t */ typedef npy_uint8 __pyx_t_5numpy_uint8_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":733 * * ctypedef npy_uint8 uint8_t * ctypedef npy_uint16 uint16_t # <<<<<<<<<<<<<< * ctypedef npy_uint32 uint32_t * ctypedef npy_uint64 uint64_t */ typedef npy_uint16 __pyx_t_5numpy_uint16_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":734 * ctypedef npy_uint8 uint8_t * ctypedef npy_uint16 uint16_t * ctypedef npy_uint32 uint32_t # <<<<<<<<<<<<<< * ctypedef npy_uint64 uint64_t * #ctypedef npy_uint96 uint96_t */ typedef npy_uint32 __pyx_t_5numpy_uint32_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":735 * ctypedef npy_uint16 uint16_t * ctypedef npy_uint32 uint32_t * ctypedef npy_uint64 uint64_t # <<<<<<<<<<<<<< * #ctypedef npy_uint96 uint96_t * #ctypedef npy_uint128 uint128_t */ typedef npy_uint64 __pyx_t_5numpy_uint64_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":739 * #ctypedef npy_uint128 uint128_t * * ctypedef npy_float32 float32_t # <<<<<<<<<<<<<< * ctypedef npy_float64 float64_t * #ctypedef npy_float80 float80_t */ typedef npy_float32 __pyx_t_5numpy_float32_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":740 * * ctypedef npy_float32 float32_t * ctypedef npy_float64 float64_t # <<<<<<<<<<<<<< * #ctypedef npy_float80 float80_t * #ctypedef npy_float128 float128_t */ typedef npy_float64 __pyx_t_5numpy_float64_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":749 * # The int types are mapped a bit surprising -- * # numpy.int corresponds to 'l' and numpy.long to 'q' * ctypedef npy_long int_t # <<<<<<<<<<<<<< * ctypedef npy_longlong long_t * ctypedef npy_longlong longlong_t */ typedef npy_long __pyx_t_5numpy_int_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":750 * # numpy.int corresponds to 'l' and numpy.long to 'q' * ctypedef npy_long int_t * ctypedef npy_longlong long_t # <<<<<<<<<<<<<< * ctypedef npy_longlong longlong_t * */ typedef npy_longlong __pyx_t_5numpy_long_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":751 * ctypedef npy_long int_t * ctypedef npy_longlong long_t * ctypedef npy_longlong longlong_t # <<<<<<<<<<<<<< * * ctypedef npy_ulong uint_t */ typedef npy_longlong __pyx_t_5numpy_longlong_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":753 * ctypedef npy_longlong longlong_t * * ctypedef npy_ulong uint_t # <<<<<<<<<<<<<< * ctypedef npy_ulonglong ulong_t * ctypedef npy_ulonglong ulonglong_t */ typedef npy_ulong __pyx_t_5numpy_uint_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":754 * * ctypedef npy_ulong uint_t * ctypedef npy_ulonglong ulong_t # <<<<<<<<<<<<<< * ctypedef npy_ulonglong ulonglong_t * */ typedef npy_ulonglong __pyx_t_5numpy_ulong_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":755 * ctypedef npy_ulong uint_t * ctypedef npy_ulonglong ulong_t * ctypedef npy_ulonglong ulonglong_t # <<<<<<<<<<<<<< * * ctypedef npy_intp intp_t */ typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":757 * ctypedef npy_ulonglong ulonglong_t * * ctypedef npy_intp intp_t # <<<<<<<<<<<<<< * ctypedef npy_uintp uintp_t * */ typedef npy_intp __pyx_t_5numpy_intp_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":758 * * ctypedef npy_intp intp_t * ctypedef npy_uintp uintp_t # <<<<<<<<<<<<<< * * ctypedef npy_double float_t */ typedef npy_uintp __pyx_t_5numpy_uintp_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":760 * ctypedef npy_uintp uintp_t * * ctypedef npy_double float_t # <<<<<<<<<<<<<< * ctypedef npy_double double_t * ctypedef npy_longdouble longdouble_t */ typedef npy_double __pyx_t_5numpy_float_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":761 * * ctypedef npy_double float_t * ctypedef npy_double double_t # <<<<<<<<<<<<<< * ctypedef npy_longdouble longdouble_t * */ typedef npy_double __pyx_t_5numpy_double_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":762 * ctypedef npy_double float_t * ctypedef npy_double double_t * ctypedef npy_longdouble longdouble_t # <<<<<<<<<<<<<< * * ctypedef npy_cfloat cfloat_t */ typedef npy_longdouble __pyx_t_5numpy_longdouble_t; /* "photutils/geometry/core.pyx":22 * * DTYPE = np.float64 * ctypedef np.float64_t DTYPE_t # <<<<<<<<<<<<<< * * cimport cython */ typedef __pyx_t_5numpy_float64_t __pyx_t_9photutils_8geometry_4core_DTYPE_t; #if CYTHON_CCOMPLEX #ifdef __cplusplus typedef ::std::complex< float > __pyx_t_float_complex; #else typedef float _Complex __pyx_t_float_complex; #endif #else typedef struct { float real, imag; } __pyx_t_float_complex; #endif #if CYTHON_CCOMPLEX #ifdef __cplusplus typedef ::std::complex< double > __pyx_t_double_complex; #else typedef double _Complex __pyx_t_double_complex; #endif #else typedef struct { double real, imag; } __pyx_t_double_complex; #endif /*--- Type declarations ---*/ /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":764 * ctypedef npy_longdouble longdouble_t * * ctypedef npy_cfloat cfloat_t # <<<<<<<<<<<<<< * ctypedef npy_cdouble cdouble_t * ctypedef npy_clongdouble clongdouble_t */ typedef npy_cfloat __pyx_t_5numpy_cfloat_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":765 * * ctypedef npy_cfloat cfloat_t * ctypedef npy_cdouble cdouble_t # <<<<<<<<<<<<<< * ctypedef npy_clongdouble clongdouble_t * */ typedef npy_cdouble __pyx_t_5numpy_cdouble_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":766 * ctypedef npy_cfloat cfloat_t * ctypedef npy_cdouble cdouble_t * ctypedef npy_clongdouble clongdouble_t # <<<<<<<<<<<<<< * * ctypedef npy_cdouble complex_t */ typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":768 * ctypedef npy_clongdouble clongdouble_t * * ctypedef npy_cdouble complex_t # <<<<<<<<<<<<<< * * cdef inline object PyArray_MultiIterNew1(a): */ typedef npy_cdouble __pyx_t_5numpy_complex_t; struct __pyx_t_9photutils_8geometry_4core_point; typedef struct __pyx_t_9photutils_8geometry_4core_point __pyx_t_9photutils_8geometry_4core_point; struct __pyx_t_9photutils_8geometry_4core_intersections; typedef struct __pyx_t_9photutils_8geometry_4core_intersections __pyx_t_9photutils_8geometry_4core_intersections; /* "photutils/geometry/core.pyx":27 * * * ctypedef struct point: # <<<<<<<<<<<<<< * double x * double y */ struct __pyx_t_9photutils_8geometry_4core_point { double x; double y; }; /* "photutils/geometry/core.pyx":32 * * * ctypedef struct intersections: # <<<<<<<<<<<<<< * point p1 * point p2 */ struct __pyx_t_9photutils_8geometry_4core_intersections { __pyx_t_9photutils_8geometry_4core_point p1; __pyx_t_9photutils_8geometry_4core_point p2; }; /* --- Runtime support code (head) --- */ #ifndef CYTHON_REFNANNY #define CYTHON_REFNANNY 0 #endif #if CYTHON_REFNANNY typedef struct { void (*INCREF)(void*, PyObject*, int); void (*DECREF)(void*, PyObject*, int); void (*GOTREF)(void*, PyObject*, int); void (*GIVEREF)(void*, PyObject*, int); void* (*SetupContext)(const char*, int, const char*); void (*FinishContext)(void**); } __Pyx_RefNannyAPIStruct; static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL; static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL; #ifdef WITH_THREAD #define __Pyx_RefNannySetupContext(name, acquire_gil)\ if (acquire_gil) {\ PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\ __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\ PyGILState_Release(__pyx_gilstate_save);\ } else {\ __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\ } #else #define __Pyx_RefNannySetupContext(name, acquire_gil)\ __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__) #endif #define __Pyx_RefNannyFinishContext()\ __Pyx_RefNanny->FinishContext(&__pyx_refnanny) #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__) #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__) #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__) #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__) #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0) #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0) #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0) #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0) #else #define __Pyx_RefNannyDeclarations #define __Pyx_RefNannySetupContext(name, acquire_gil) #define __Pyx_RefNannyFinishContext() #define __Pyx_INCREF(r) Py_INCREF(r) #define __Pyx_DECREF(r) Py_DECREF(r) #define __Pyx_GOTREF(r) #define __Pyx_GIVEREF(r) #define __Pyx_XINCREF(r) Py_XINCREF(r) #define __Pyx_XDECREF(r) Py_XDECREF(r) #define __Pyx_XGOTREF(r) #define __Pyx_XGIVEREF(r) #endif #define __Pyx_XDECREF_SET(r, v) do {\ PyObject *tmp = (PyObject *) r;\ r = v; __Pyx_XDECREF(tmp);\ } while (0) #define __Pyx_DECREF_SET(r, v) do {\ PyObject *tmp = (PyObject *) r;\ r = v; __Pyx_DECREF(tmp);\ } while (0) #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0) #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0) #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) { PyTypeObject* tp = Py_TYPE(obj); if (likely(tp->tp_getattro)) return tp->tp_getattro(obj, attr_name); #if PY_MAJOR_VERSION < 3 if (likely(tp->tp_getattr)) return tp->tp_getattr(obj, PyString_AS_STRING(attr_name)); #endif return PyObject_GetAttr(obj, attr_name); } #else #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n) #endif static PyObject *__Pyx_GetBuiltinName(PyObject *name); static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); static void __Pyx_WriteUnraisable(const char *name, int clineno, int lineno, const char *filename, int full_traceback, int nogil); static CYTHON_INLINE long __Pyx_mod_long(long, long); static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name); #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw); #else #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw) #endif static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) { PyObject *value; value = PyDict_GetItemWithError(d, key); if (unlikely(!value)) { if (!PyErr_Occurred()) { PyObject* args = PyTuple_Pack(1, key); if (likely(args)) PyErr_SetObject(PyExc_KeyError, args); Py_XDECREF(args); } return NULL; } Py_INCREF(value); return value; } #else #define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key) #endif static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected); static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index); static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void); static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); typedef struct { int code_line; PyCodeObject* code_object; } __Pyx_CodeObjectCacheEntry; struct __Pyx_CodeObjectCache { int count; int max_count; __Pyx_CodeObjectCacheEntry* entries; }; static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL}; static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line); static PyCodeObject *__pyx_find_code_object(int code_line); static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object); static void __Pyx_AddTraceback(const char *funcname, int c_line, int py_line, const char *filename); #if CYTHON_CCOMPLEX #ifdef __cplusplus #define __Pyx_CREAL(z) ((z).real()) #define __Pyx_CIMAG(z) ((z).imag()) #else #define __Pyx_CREAL(z) (__real__(z)) #define __Pyx_CIMAG(z) (__imag__(z)) #endif #else #define __Pyx_CREAL(z) ((z).real) #define __Pyx_CIMAG(z) ((z).imag) #endif #if (defined(_WIN32) || defined(__clang__)) && defined(__cplusplus) && CYTHON_CCOMPLEX #define __Pyx_SET_CREAL(z,x) ((z).real(x)) #define __Pyx_SET_CIMAG(z,y) ((z).imag(y)) #else #define __Pyx_SET_CREAL(z,x) __Pyx_CREAL(z) = (x) #define __Pyx_SET_CIMAG(z,y) __Pyx_CIMAG(z) = (y) #endif static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float, float); #if CYTHON_CCOMPLEX #define __Pyx_c_eqf(a, b) ((a)==(b)) #define __Pyx_c_sumf(a, b) ((a)+(b)) #define __Pyx_c_difff(a, b) ((a)-(b)) #define __Pyx_c_prodf(a, b) ((a)*(b)) #define __Pyx_c_quotf(a, b) ((a)/(b)) #define __Pyx_c_negf(a) (-(a)) #ifdef __cplusplus #define __Pyx_c_is_zerof(z) ((z)==(float)0) #define __Pyx_c_conjf(z) (::std::conj(z)) #if 1 #define __Pyx_c_absf(z) (::std::abs(z)) #define __Pyx_c_powf(a, b) (::std::pow(a, b)) #endif #else #define __Pyx_c_is_zerof(z) ((z)==0) #define __Pyx_c_conjf(z) (conjf(z)) #if 1 #define __Pyx_c_absf(z) (cabsf(z)) #define __Pyx_c_powf(a, b) (cpowf(a, b)) #endif #endif #else static CYTHON_INLINE int __Pyx_c_eqf(__pyx_t_float_complex, __pyx_t_float_complex); static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sumf(__pyx_t_float_complex, __pyx_t_float_complex); static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_difff(__pyx_t_float_complex, __pyx_t_float_complex); static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prodf(__pyx_t_float_complex, __pyx_t_float_complex); static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quotf(__pyx_t_float_complex, __pyx_t_float_complex); static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_negf(__pyx_t_float_complex); static CYTHON_INLINE int __Pyx_c_is_zerof(__pyx_t_float_complex); static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conjf(__pyx_t_float_complex); #if 1 static CYTHON_INLINE float __Pyx_c_absf(__pyx_t_float_complex); static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_powf(__pyx_t_float_complex, __pyx_t_float_complex); #endif #endif static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double, double); #if CYTHON_CCOMPLEX #define __Pyx_c_eq(a, b) ((a)==(b)) #define __Pyx_c_sum(a, b) ((a)+(b)) #define __Pyx_c_diff(a, b) ((a)-(b)) #define __Pyx_c_prod(a, b) ((a)*(b)) #define __Pyx_c_quot(a, b) ((a)/(b)) #define __Pyx_c_neg(a) (-(a)) #ifdef __cplusplus #define __Pyx_c_is_zero(z) ((z)==(double)0) #define __Pyx_c_conj(z) (::std::conj(z)) #if 1 #define __Pyx_c_abs(z) (::std::abs(z)) #define __Pyx_c_pow(a, b) (::std::pow(a, b)) #endif #else #define __Pyx_c_is_zero(z) ((z)==0) #define __Pyx_c_conj(z) (conj(z)) #if 1 #define __Pyx_c_abs(z) (cabs(z)) #define __Pyx_c_pow(a, b) (cpow(a, b)) #endif #endif #else static CYTHON_INLINE int __Pyx_c_eq(__pyx_t_double_complex, __pyx_t_double_complex); static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum(__pyx_t_double_complex, __pyx_t_double_complex); static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff(__pyx_t_double_complex, __pyx_t_double_complex); static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod(__pyx_t_double_complex, __pyx_t_double_complex); static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot(__pyx_t_double_complex, __pyx_t_double_complex); static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg(__pyx_t_double_complex); static CYTHON_INLINE int __Pyx_c_is_zero(__pyx_t_double_complex); static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj(__pyx_t_double_complex); #if 1 static CYTHON_INLINE double __Pyx_c_abs(__pyx_t_double_complex); static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow(__pyx_t_double_complex, __pyx_t_double_complex); #endif #endif static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value); static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum__NPY_TYPES(enum NPY_TYPES value); static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); static int __Pyx_check_binary_version(void); static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig); #if !defined(__Pyx_PyIdentifier_FromString) #if PY_MAJOR_VERSION < 3 #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s) #else #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s) #endif #endif static PyObject *__Pyx_ImportModule(const char *name); static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict); static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /* Module declarations from 'cpython.buffer' */ /* Module declarations from 'libc.string' */ /* Module declarations from 'libc.stdio' */ /* Module declarations from '__builtin__' */ /* Module declarations from 'cpython.type' */ static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0; /* Module declarations from 'cpython.version' */ /* Module declarations from 'cpython.exc' */ /* Module declarations from 'cpython.module' */ /* Module declarations from 'cpython.mem' */ /* Module declarations from 'cpython.tuple' */ /* Module declarations from 'cpython.list' */ /* Module declarations from 'cpython.sequence' */ /* Module declarations from 'cpython.mapping' */ /* Module declarations from 'cpython.iterator' */ /* Module declarations from 'cpython.number' */ /* Module declarations from 'cpython.int' */ /* Module declarations from '__builtin__' */ /* Module declarations from 'cpython.bool' */ static PyTypeObject *__pyx_ptype_7cpython_4bool_bool = 0; /* Module declarations from 'cpython.long' */ /* Module declarations from 'cpython.float' */ /* Module declarations from '__builtin__' */ /* Module declarations from 'cpython.complex' */ static PyTypeObject *__pyx_ptype_7cpython_7complex_complex = 0; /* Module declarations from 'cpython.string' */ /* Module declarations from 'cpython.unicode' */ /* Module declarations from 'cpython.dict' */ /* Module declarations from 'cpython.instance' */ /* Module declarations from 'cpython.function' */ /* Module declarations from 'cpython.method' */ /* Module declarations from 'cpython.weakref' */ /* Module declarations from 'cpython.getargs' */ /* Module declarations from 'cpython.pythread' */ /* Module declarations from 'cpython.pystate' */ /* Module declarations from 'cpython.cobject' */ /* Module declarations from 'cpython.oldbuffer' */ /* Module declarations from 'cpython.set' */ /* Module declarations from 'cpython.bytes' */ /* Module declarations from 'cpython.pycapsule' */ /* Module declarations from 'cpython' */ /* Module declarations from 'cpython.object' */ /* Module declarations from 'cpython.ref' */ /* Module declarations from 'libc.stdlib' */ /* Module declarations from 'numpy' */ /* Module declarations from 'numpy' */ static PyTypeObject *__pyx_ptype_5numpy_dtype = 0; static PyTypeObject *__pyx_ptype_5numpy_flatiter = 0; static PyTypeObject *__pyx_ptype_5numpy_broadcast = 0; static PyTypeObject *__pyx_ptype_5numpy_ndarray = 0; static PyTypeObject *__pyx_ptype_5numpy_ufunc = 0; static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *, char *, char *, int *); /*proto*/ /* Module declarations from 'cython' */ /* Module declarations from 'photutils.geometry.core' */ static double __pyx_f_9photutils_8geometry_4core_distance(double, double, double, double); /*proto*/ static double __pyx_f_9photutils_8geometry_4core_area_triangle(double, double, double, double, double, double); /*proto*/ static double __pyx_f_9photutils_8geometry_4core_area_arc_unit(double, double, double, double); /*proto*/ static int __pyx_f_9photutils_8geometry_4core_in_triangle(double, double, double, double, double, double, double, double); /*proto*/ static double __pyx_f_9photutils_8geometry_4core_overlap_area_triangle_unit_circle(double, double, double, double, double, double); /*proto*/ static __pyx_t_9photutils_8geometry_4core_intersections __pyx_f_9photutils_8geometry_4core_circle_line(double, double, double, double); /*proto*/ static __pyx_t_9photutils_8geometry_4core_point __pyx_f_9photutils_8geometry_4core_circle_segment_single2(double, double, double, double); /*proto*/ static __pyx_t_9photutils_8geometry_4core_intersections __pyx_f_9photutils_8geometry_4core_circle_segment(double, double, double, double); /*proto*/ #define __Pyx_MODULE_NAME "photutils.geometry.core" int __pyx_module_is_main_photutils__geometry__core = 0; /* Implementation of 'photutils.geometry.core' */ static PyObject *__pyx_builtin_Exception; static PyObject *__pyx_builtin_ValueError; static PyObject *__pyx_builtin_range; static PyObject *__pyx_builtin_RuntimeError; static char __pyx_k_B[] = "B"; static char __pyx_k_H[] = "H"; static char __pyx_k_I[] = "I"; static char __pyx_k_L[] = "L"; static char __pyx_k_O[] = "O"; static char __pyx_k_Q[] = "Q"; static char __pyx_k_b[] = "b"; static char __pyx_k_d[] = "d"; static char __pyx_k_f[] = "f"; static char __pyx_k_g[] = "g"; static char __pyx_k_h[] = "h"; static char __pyx_k_i[] = "i"; static char __pyx_k_l[] = "l"; static char __pyx_k_q[] = "q"; static char __pyx_k_Zd[] = "Zd"; static char __pyx_k_Zf[] = "Zf"; static char __pyx_k_Zg[] = "Zg"; static char __pyx_k_np[] = "np"; static char __pyx_k_pi[] = "pi"; static char __pyx_k_all[] = "__all__"; static char __pyx_k_main[] = "__main__"; static char __pyx_k_test[] = "__test__"; static char __pyx_k_DTYPE[] = "DTYPE"; static char __pyx_k_numpy[] = "numpy"; static char __pyx_k_range[] = "range"; static char __pyx_k_import[] = "__import__"; static char __pyx_k_float64[] = "float64"; static char __pyx_k_Exception[] = "Exception"; static char __pyx_k_ValueError[] = "ValueError"; static char __pyx_k_RuntimeError[] = "RuntimeError"; static char __pyx_k_elliptical_overlap_grid[] = "elliptical_overlap_grid"; static char __pyx_k_ndarray_is_not_C_contiguous[] = "ndarray is not C contiguous"; static char __pyx_k_unknown_dtype_code_in_numpy_pxd[] = "unknown dtype code in numpy.pxd (%d)"; static char __pyx_k_ERROR_vertices_did_not_sort_corr[] = "ERROR: vertices did not sort correctly"; static char __pyx_k_Format_string_allocated_too_shor[] = "Format string allocated too short, see comment in numpy.pxd"; static char __pyx_k_Non_native_byte_order_not_suppor[] = "Non-native byte order not supported"; static char __pyx_k_ndarray_is_not_Fortran_contiguou[] = "ndarray is not Fortran contiguous"; static char __pyx_k_Format_string_allocated_too_shor_2[] = "Format string allocated too short."; static PyObject *__pyx_n_s_DTYPE; static PyObject *__pyx_kp_u_ERROR_vertices_did_not_sort_corr; static PyObject *__pyx_n_s_Exception; static PyObject *__pyx_kp_u_Format_string_allocated_too_shor; static PyObject *__pyx_kp_u_Format_string_allocated_too_shor_2; static PyObject *__pyx_kp_u_Non_native_byte_order_not_suppor; static PyObject *__pyx_n_s_RuntimeError; static PyObject *__pyx_n_s_ValueError; static PyObject *__pyx_n_s_all; static PyObject *__pyx_n_u_elliptical_overlap_grid; static PyObject *__pyx_n_s_float64; static PyObject *__pyx_n_s_import; static PyObject *__pyx_n_s_main; static PyObject *__pyx_kp_u_ndarray_is_not_C_contiguous; static PyObject *__pyx_kp_u_ndarray_is_not_Fortran_contiguou; static PyObject *__pyx_n_s_np; static PyObject *__pyx_n_s_numpy; static PyObject *__pyx_n_s_pi; static PyObject *__pyx_n_s_range; static PyObject *__pyx_n_s_test; static PyObject *__pyx_kp_u_unknown_dtype_code_in_numpy_pxd; static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /* proto */ static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info); /* proto */ static PyObject *__pyx_tuple_; static PyObject *__pyx_tuple__2; static PyObject *__pyx_tuple__3; static PyObject *__pyx_tuple__4; static PyObject *__pyx_tuple__5; static PyObject *__pyx_tuple__6; static PyObject *__pyx_tuple__7; /* "photutils/geometry/core.pyx":43 * * * cdef double distance(double x1, double y1, double x2, double y2): # <<<<<<<<<<<<<< * """ * Distance between two points in two dimensions. */ static double __pyx_f_9photutils_8geometry_4core_distance(double __pyx_v_x1, double __pyx_v_y1, double __pyx_v_x2, double __pyx_v_y2) { double __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("distance", 0); /* "photutils/geometry/core.pyx":60 * """ * * return sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2) # <<<<<<<<<<<<<< * * */ __pyx_r = sqrt((pow((__pyx_v_x2 - __pyx_v_x1), 2.0) + pow((__pyx_v_y2 - __pyx_v_y1), 2.0))); goto __pyx_L0; /* "photutils/geometry/core.pyx":43 * * * cdef double distance(double x1, double y1, double x2, double y2): # <<<<<<<<<<<<<< * """ * Distance between two points in two dimensions. */ /* function exit code */ __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "photutils/geometry/core.pyx":63 * * * cdef double area_arc(double x1, double y1, double x2, double y2, double r): # <<<<<<<<<<<<<< * """ * Area of a circle arc with radius r between points (x1, y1) and (x2, y2). */ static double __pyx_f_9photutils_8geometry_4core_area_arc(double __pyx_v_x1, double __pyx_v_y1, double __pyx_v_x2, double __pyx_v_y2, double __pyx_v_r) { double __pyx_v_a; double __pyx_v_theta; double __pyx_r; __Pyx_RefNannyDeclarations double __pyx_t_1; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("area_arc", 0); /* "photutils/geometry/core.pyx":73 * * cdef double a, theta * a = distance(x1, y1, x2, y2) # <<<<<<<<<<<<<< * theta = 2. * asin(0.5 * a / r) * return 0.5 * r * r * (theta - sin(theta)) */ __pyx_v_a = __pyx_f_9photutils_8geometry_4core_distance(__pyx_v_x1, __pyx_v_y1, __pyx_v_x2, __pyx_v_y2); /* "photutils/geometry/core.pyx":74 * cdef double a, theta * a = distance(x1, y1, x2, y2) * theta = 2. * asin(0.5 * a / r) # <<<<<<<<<<<<<< * return 0.5 * r * r * (theta - sin(theta)) * */ __pyx_t_1 = (0.5 * __pyx_v_a); if (unlikely(__pyx_v_r == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "float division"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_v_theta = (2. * asin((__pyx_t_1 / __pyx_v_r))); /* "photutils/geometry/core.pyx":75 * a = distance(x1, y1, x2, y2) * theta = 2. * asin(0.5 * a / r) * return 0.5 * r * r * (theta - sin(theta)) # <<<<<<<<<<<<<< * * */ __pyx_r = (((0.5 * __pyx_v_r) * __pyx_v_r) * (__pyx_v_theta - sin(__pyx_v_theta))); goto __pyx_L0; /* "photutils/geometry/core.pyx":63 * * * cdef double area_arc(double x1, double y1, double x2, double y2, double r): # <<<<<<<<<<<<<< * """ * Area of a circle arc with radius r between points (x1, y1) and (x2, y2). */ /* function exit code */ __pyx_L1_error:; __Pyx_WriteUnraisable("photutils.geometry.core.area_arc", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0); __pyx_r = 0; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "photutils/geometry/core.pyx":78 * * * cdef double area_triangle(double x1, double y1, double x2, double y2, double x3, # <<<<<<<<<<<<<< * double y3): * """ */ static double __pyx_f_9photutils_8geometry_4core_area_triangle(double __pyx_v_x1, double __pyx_v_y1, double __pyx_v_x2, double __pyx_v_y2, double __pyx_v_x3, double __pyx_v_y3) { double __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("area_triangle", 0); /* "photutils/geometry/core.pyx":83 * Area of a triangle defined by three vertices. * """ * return 0.5 * abs(x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2)) # <<<<<<<<<<<<<< * * */ __pyx_r = (0.5 * fabs((((__pyx_v_x1 * (__pyx_v_y2 - __pyx_v_y3)) + (__pyx_v_x2 * (__pyx_v_y3 - __pyx_v_y1))) + (__pyx_v_x3 * (__pyx_v_y1 - __pyx_v_y2))))); goto __pyx_L0; /* "photutils/geometry/core.pyx":78 * * * cdef double area_triangle(double x1, double y1, double x2, double y2, double x3, # <<<<<<<<<<<<<< * double y3): * """ */ /* function exit code */ __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "photutils/geometry/core.pyx":86 * * * cdef double area_arc_unit(double x1, double y1, double x2, double y2): # <<<<<<<<<<<<<< * """ * Area of a circle arc with radius R between points (x1, y1) and (x2, y2) */ static double __pyx_f_9photutils_8geometry_4core_area_arc_unit(double __pyx_v_x1, double __pyx_v_y1, double __pyx_v_x2, double __pyx_v_y2) { double __pyx_v_a; double __pyx_v_theta; double __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("area_arc_unit", 0); /* "photutils/geometry/core.pyx":95 * """ * cdef double a, theta * a = distance(x1, y1, x2, y2) # <<<<<<<<<<<<<< * theta = 2. * asin(0.5 * a) * return 0.5 * (theta - sin(theta)) */ __pyx_v_a = __pyx_f_9photutils_8geometry_4core_distance(__pyx_v_x1, __pyx_v_y1, __pyx_v_x2, __pyx_v_y2); /* "photutils/geometry/core.pyx":96 * cdef double a, theta * a = distance(x1, y1, x2, y2) * theta = 2. * asin(0.5 * a) # <<<<<<<<<<<<<< * return 0.5 * (theta - sin(theta)) * */ __pyx_v_theta = (2. * asin((0.5 * __pyx_v_a))); /* "photutils/geometry/core.pyx":97 * a = distance(x1, y1, x2, y2) * theta = 2. * asin(0.5 * a) * return 0.5 * (theta - sin(theta)) # <<<<<<<<<<<<<< * * */ __pyx_r = (0.5 * (__pyx_v_theta - sin(__pyx_v_theta))); goto __pyx_L0; /* "photutils/geometry/core.pyx":86 * * * cdef double area_arc_unit(double x1, double y1, double x2, double y2): # <<<<<<<<<<<<<< * """ * Area of a circle arc with radius R between points (x1, y1) and (x2, y2) */ /* function exit code */ __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "photutils/geometry/core.pyx":100 * * * cdef int in_triangle(double x, double y, double x1, double y1, double x2, double y2, double x3, double y3): # <<<<<<<<<<<<<< * """ * Check if a point (x,y) is inside a triangle */ static int __pyx_f_9photutils_8geometry_4core_in_triangle(double __pyx_v_x, double __pyx_v_y, double __pyx_v_x1, double __pyx_v_y1, double __pyx_v_x2, double __pyx_v_y2, double __pyx_v_x3, double __pyx_v_y3) { int __pyx_v_c; int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; double __pyx_t_3; double __pyx_t_4; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("in_triangle", 0); /* "photutils/geometry/core.pyx":104 * Check if a point (x,y) is inside a triangle * """ * cdef int c = 0 # <<<<<<<<<<<<<< * * c += ((y1 > y) != (y2 > y) and x < (x2 - x1) * (y - y1) / (y2 - y1) + x1) */ __pyx_v_c = 0; /* "photutils/geometry/core.pyx":106 * cdef int c = 0 * * c += ((y1 > y) != (y2 > y) and x < (x2 - x1) * (y - y1) / (y2 - y1) + x1) # <<<<<<<<<<<<<< * c += ((y2 > y) != (y3 > y) and x < (x3 - x2) * (y - y2) / (y3 - y2) + x2) * c += ((y3 > y) != (y1 > y) and x < (x1 - x3) * (y - y3) / (y1 - y3) + x3) */ __pyx_t_2 = ((__pyx_v_y1 > __pyx_v_y) != (__pyx_v_y2 > __pyx_v_y)); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L3_bool_binop_done; } __pyx_t_3 = ((__pyx_v_x2 - __pyx_v_x1) * (__pyx_v_y - __pyx_v_y1)); __pyx_t_4 = (__pyx_v_y2 - __pyx_v_y1); if (unlikely(__pyx_t_4 == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "float division"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_t_2 = (__pyx_v_x < ((__pyx_t_3 / __pyx_t_4) + __pyx_v_x1)); __pyx_t_1 = __pyx_t_2; __pyx_L3_bool_binop_done:; __pyx_v_c = (__pyx_v_c + __pyx_t_1); /* "photutils/geometry/core.pyx":107 * * c += ((y1 > y) != (y2 > y) and x < (x2 - x1) * (y - y1) / (y2 - y1) + x1) * c += ((y2 > y) != (y3 > y) and x < (x3 - x2) * (y - y2) / (y3 - y2) + x2) # <<<<<<<<<<<<<< * c += ((y3 > y) != (y1 > y) and x < (x1 - x3) * (y - y3) / (y1 - y3) + x3) * */ __pyx_t_2 = ((__pyx_v_y2 > __pyx_v_y) != (__pyx_v_y3 > __pyx_v_y)); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L5_bool_binop_done; } __pyx_t_4 = ((__pyx_v_x3 - __pyx_v_x2) * (__pyx_v_y - __pyx_v_y2)); __pyx_t_3 = (__pyx_v_y3 - __pyx_v_y2); if (unlikely(__pyx_t_3 == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "float division"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_t_2 = (__pyx_v_x < ((__pyx_t_4 / __pyx_t_3) + __pyx_v_x2)); __pyx_t_1 = __pyx_t_2; __pyx_L5_bool_binop_done:; __pyx_v_c = (__pyx_v_c + __pyx_t_1); /* "photutils/geometry/core.pyx":108 * c += ((y1 > y) != (y2 > y) and x < (x2 - x1) * (y - y1) / (y2 - y1) + x1) * c += ((y2 > y) != (y3 > y) and x < (x3 - x2) * (y - y2) / (y3 - y2) + x2) * c += ((y3 > y) != (y1 > y) and x < (x1 - x3) * (y - y3) / (y1 - y3) + x3) # <<<<<<<<<<<<<< * * return c % 2 == 1 */ __pyx_t_2 = ((__pyx_v_y3 > __pyx_v_y) != (__pyx_v_y1 > __pyx_v_y)); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L7_bool_binop_done; } __pyx_t_3 = ((__pyx_v_x1 - __pyx_v_x3) * (__pyx_v_y - __pyx_v_y3)); __pyx_t_4 = (__pyx_v_y1 - __pyx_v_y3); if (unlikely(__pyx_t_4 == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "float division"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_t_2 = (__pyx_v_x < ((__pyx_t_3 / __pyx_t_4) + __pyx_v_x3)); __pyx_t_1 = __pyx_t_2; __pyx_L7_bool_binop_done:; __pyx_v_c = (__pyx_v_c + __pyx_t_1); /* "photutils/geometry/core.pyx":110 * c += ((y3 > y) != (y1 > y) and x < (x1 - x3) * (y - y3) / (y1 - y3) + x3) * * return c % 2 == 1 # <<<<<<<<<<<<<< * * */ __pyx_r = (__Pyx_mod_long(__pyx_v_c, 2) == 1); goto __pyx_L0; /* "photutils/geometry/core.pyx":100 * * * cdef int in_triangle(double x, double y, double x1, double y1, double x2, double y2, double x3, double y3): # <<<<<<<<<<<<<< * """ * Check if a point (x,y) is inside a triangle */ /* function exit code */ __pyx_L1_error:; __Pyx_WriteUnraisable("photutils.geometry.core.in_triangle", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0); __pyx_r = 0; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "photutils/geometry/core.pyx":113 * * * cdef intersections circle_line(double x1, double y1, double x2, double y2): # <<<<<<<<<<<<<< * """Intersection of a line defined by two points with a unit circle""" * */ static __pyx_t_9photutils_8geometry_4core_intersections __pyx_f_9photutils_8geometry_4core_circle_line(double __pyx_v_x1, double __pyx_v_y1, double __pyx_v_x2, double __pyx_v_y2) { double __pyx_v_a; double __pyx_v_b; double __pyx_v_delta; double __pyx_v_dx; double __pyx_v_dy; double __pyx_v_tolerance; __pyx_t_9photutils_8geometry_4core_intersections __pyx_v_inter; __pyx_t_9photutils_8geometry_4core_intersections __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; double __pyx_t_3; double __pyx_t_4; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("circle_line", 0); /* "photutils/geometry/core.pyx":117 * * cdef double a, b, delta, dx, dy * cdef double tolerance = 1.e-10 # <<<<<<<<<<<<<< * cdef intersections inter * */ __pyx_v_tolerance = 1.e-10; /* "photutils/geometry/core.pyx":120 * cdef intersections inter * * dx = x2 - x1 # <<<<<<<<<<<<<< * dy = y2 - y1 * */ __pyx_v_dx = (__pyx_v_x2 - __pyx_v_x1); /* "photutils/geometry/core.pyx":121 * * dx = x2 - x1 * dy = y2 - y1 # <<<<<<<<<<<<<< * * if fabs(dx) < tolerance and fabs(dy) < tolerance: */ __pyx_v_dy = (__pyx_v_y2 - __pyx_v_y1); /* "photutils/geometry/core.pyx":123 * dy = y2 - y1 * * if fabs(dx) < tolerance and fabs(dy) < tolerance: # <<<<<<<<<<<<<< * inter.p1.x = 2. * inter.p1.y = 2. */ __pyx_t_2 = ((fabs(__pyx_v_dx) < __pyx_v_tolerance) != 0); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L4_bool_binop_done; } __pyx_t_2 = ((fabs(__pyx_v_dy) < __pyx_v_tolerance) != 0); __pyx_t_1 = __pyx_t_2; __pyx_L4_bool_binop_done:; if (__pyx_t_1) { /* "photutils/geometry/core.pyx":124 * * if fabs(dx) < tolerance and fabs(dy) < tolerance: * inter.p1.x = 2. # <<<<<<<<<<<<<< * inter.p1.y = 2. * inter.p2.x = 2. */ __pyx_v_inter.p1.x = 2.; /* "photutils/geometry/core.pyx":125 * if fabs(dx) < tolerance and fabs(dy) < tolerance: * inter.p1.x = 2. * inter.p1.y = 2. # <<<<<<<<<<<<<< * inter.p2.x = 2. * inter.p2.y = 2. */ __pyx_v_inter.p1.y = 2.; /* "photutils/geometry/core.pyx":126 * inter.p1.x = 2. * inter.p1.y = 2. * inter.p2.x = 2. # <<<<<<<<<<<<<< * inter.p2.y = 2. * */ __pyx_v_inter.p2.x = 2.; /* "photutils/geometry/core.pyx":127 * inter.p1.y = 2. * inter.p2.x = 2. * inter.p2.y = 2. # <<<<<<<<<<<<<< * * elif fabs(dx) > fabs(dy): */ __pyx_v_inter.p2.y = 2.; /* "photutils/geometry/core.pyx":123 * dy = y2 - y1 * * if fabs(dx) < tolerance and fabs(dy) < tolerance: # <<<<<<<<<<<<<< * inter.p1.x = 2. * inter.p1.y = 2. */ goto __pyx_L3; } /* "photutils/geometry/core.pyx":129 * inter.p2.y = 2. * * elif fabs(dx) > fabs(dy): # <<<<<<<<<<<<<< * * # Find the slope and intercept of the line */ __pyx_t_1 = ((fabs(__pyx_v_dx) > fabs(__pyx_v_dy)) != 0); if (__pyx_t_1) { /* "photutils/geometry/core.pyx":132 * * # Find the slope and intercept of the line * a = dy / dx # <<<<<<<<<<<<<< * b = y1 - a * x1 * */ if (unlikely(__pyx_v_dx == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "float division"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_v_a = (__pyx_v_dy / __pyx_v_dx); /* "photutils/geometry/core.pyx":133 * # Find the slope and intercept of the line * a = dy / dx * b = y1 - a * x1 # <<<<<<<<<<<<<< * * # Find the determinant of the quadratic equation */ __pyx_v_b = (__pyx_v_y1 - (__pyx_v_a * __pyx_v_x1)); /* "photutils/geometry/core.pyx":136 * * # Find the determinant of the quadratic equation * delta = 1. + a * a - b * b # <<<<<<<<<<<<<< * if delta > 0.: # solutions exist * */ __pyx_v_delta = ((1. + (__pyx_v_a * __pyx_v_a)) - (__pyx_v_b * __pyx_v_b)); /* "photutils/geometry/core.pyx":137 * # Find the determinant of the quadratic equation * delta = 1. + a * a - b * b * if delta > 0.: # solutions exist # <<<<<<<<<<<<<< * * delta = sqrt(delta) */ __pyx_t_1 = ((__pyx_v_delta > 0.) != 0); if (__pyx_t_1) { /* "photutils/geometry/core.pyx":139 * if delta > 0.: # solutions exist * * delta = sqrt(delta) # <<<<<<<<<<<<<< * * inter.p1.x = (- a * b - delta) / (1. + a * a) */ __pyx_v_delta = sqrt(__pyx_v_delta); /* "photutils/geometry/core.pyx":141 * delta = sqrt(delta) * * inter.p1.x = (- a * b - delta) / (1. + a * a) # <<<<<<<<<<<<<< * inter.p1.y = a * inter.p1.x + b * inter.p2.x = (- a * b + delta) / (1. + a * a) */ __pyx_t_3 = (((-__pyx_v_a) * __pyx_v_b) - __pyx_v_delta); __pyx_t_4 = (1. + (__pyx_v_a * __pyx_v_a)); if (unlikely(__pyx_t_4 == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "float division"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_v_inter.p1.x = (__pyx_t_3 / __pyx_t_4); /* "photutils/geometry/core.pyx":142 * * inter.p1.x = (- a * b - delta) / (1. + a * a) * inter.p1.y = a * inter.p1.x + b # <<<<<<<<<<<<<< * inter.p2.x = (- a * b + delta) / (1. + a * a) * inter.p2.y = a * inter.p2.x + b */ __pyx_v_inter.p1.y = ((__pyx_v_a * __pyx_v_inter.p1.x) + __pyx_v_b); /* "photutils/geometry/core.pyx":143 * inter.p1.x = (- a * b - delta) / (1. + a * a) * inter.p1.y = a * inter.p1.x + b * inter.p2.x = (- a * b + delta) / (1. + a * a) # <<<<<<<<<<<<<< * inter.p2.y = a * inter.p2.x + b * */ __pyx_t_4 = (((-__pyx_v_a) * __pyx_v_b) + __pyx_v_delta); __pyx_t_3 = (1. + (__pyx_v_a * __pyx_v_a)); if (unlikely(__pyx_t_3 == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "float division"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_v_inter.p2.x = (__pyx_t_4 / __pyx_t_3); /* "photutils/geometry/core.pyx":144 * inter.p1.y = a * inter.p1.x + b * inter.p2.x = (- a * b + delta) / (1. + a * a) * inter.p2.y = a * inter.p2.x + b # <<<<<<<<<<<<<< * * else: # no solution, return values > 1 */ __pyx_v_inter.p2.y = ((__pyx_v_a * __pyx_v_inter.p2.x) + __pyx_v_b); /* "photutils/geometry/core.pyx":137 * # Find the determinant of the quadratic equation * delta = 1. + a * a - b * b * if delta > 0.: # solutions exist # <<<<<<<<<<<<<< * * delta = sqrt(delta) */ goto __pyx_L6; } /* "photutils/geometry/core.pyx":147 * * else: # no solution, return values > 1 * inter.p1.x = 2. # <<<<<<<<<<<<<< * inter.p1.y = 2. * inter.p2.x = 2. */ /*else*/ { __pyx_v_inter.p1.x = 2.; /* "photutils/geometry/core.pyx":148 * else: # no solution, return values > 1 * inter.p1.x = 2. * inter.p1.y = 2. # <<<<<<<<<<<<<< * inter.p2.x = 2. * inter.p2.y = 2. */ __pyx_v_inter.p1.y = 2.; /* "photutils/geometry/core.pyx":149 * inter.p1.x = 2. * inter.p1.y = 2. * inter.p2.x = 2. # <<<<<<<<<<<<<< * inter.p2.y = 2. * */ __pyx_v_inter.p2.x = 2.; /* "photutils/geometry/core.pyx":150 * inter.p1.y = 2. * inter.p2.x = 2. * inter.p2.y = 2. # <<<<<<<<<<<<<< * * else: */ __pyx_v_inter.p2.y = 2.; } __pyx_L6:; /* "photutils/geometry/core.pyx":129 * inter.p2.y = 2. * * elif fabs(dx) > fabs(dy): # <<<<<<<<<<<<<< * * # Find the slope and intercept of the line */ goto __pyx_L3; } /* "photutils/geometry/core.pyx":155 * * # Find the slope and intercept of the line * a = dx / dy # <<<<<<<<<<<<<< * b = x1 - a * y1 * */ /*else*/ { if (unlikely(__pyx_v_dy == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "float division"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_v_a = (__pyx_v_dx / __pyx_v_dy); /* "photutils/geometry/core.pyx":156 * # Find the slope and intercept of the line * a = dx / dy * b = x1 - a * y1 # <<<<<<<<<<<<<< * * # Find the determinant of the quadratic equation */ __pyx_v_b = (__pyx_v_x1 - (__pyx_v_a * __pyx_v_y1)); /* "photutils/geometry/core.pyx":159 * * # Find the determinant of the quadratic equation * delta = 1. + a * a - b * b # <<<<<<<<<<<<<< * * if delta > 0.: # solutions exist */ __pyx_v_delta = ((1. + (__pyx_v_a * __pyx_v_a)) - (__pyx_v_b * __pyx_v_b)); /* "photutils/geometry/core.pyx":161 * delta = 1. + a * a - b * b * * if delta > 0.: # solutions exist # <<<<<<<<<<<<<< * * delta = sqrt(delta) */ __pyx_t_1 = ((__pyx_v_delta > 0.) != 0); if (__pyx_t_1) { /* "photutils/geometry/core.pyx":163 * if delta > 0.: # solutions exist * * delta = sqrt(delta) # <<<<<<<<<<<<<< * * inter.p1.y = (- a * b - delta) / (1. + a * a) */ __pyx_v_delta = sqrt(__pyx_v_delta); /* "photutils/geometry/core.pyx":165 * delta = sqrt(delta) * * inter.p1.y = (- a * b - delta) / (1. + a * a) # <<<<<<<<<<<<<< * inter.p1.x = a * inter.p1.y + b * inter.p2.y = (- a * b + delta) / (1. + a * a) */ __pyx_t_3 = (((-__pyx_v_a) * __pyx_v_b) - __pyx_v_delta); __pyx_t_4 = (1. + (__pyx_v_a * __pyx_v_a)); if (unlikely(__pyx_t_4 == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "float division"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_v_inter.p1.y = (__pyx_t_3 / __pyx_t_4); /* "photutils/geometry/core.pyx":166 * * inter.p1.y = (- a * b - delta) / (1. + a * a) * inter.p1.x = a * inter.p1.y + b # <<<<<<<<<<<<<< * inter.p2.y = (- a * b + delta) / (1. + a * a) * inter.p2.x = a * inter.p2.y + b */ __pyx_v_inter.p1.x = ((__pyx_v_a * __pyx_v_inter.p1.y) + __pyx_v_b); /* "photutils/geometry/core.pyx":167 * inter.p1.y = (- a * b - delta) / (1. + a * a) * inter.p1.x = a * inter.p1.y + b * inter.p2.y = (- a * b + delta) / (1. + a * a) # <<<<<<<<<<<<<< * inter.p2.x = a * inter.p2.y + b * */ __pyx_t_4 = (((-__pyx_v_a) * __pyx_v_b) + __pyx_v_delta); __pyx_t_3 = (1. + (__pyx_v_a * __pyx_v_a)); if (unlikely(__pyx_t_3 == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "float division"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_v_inter.p2.y = (__pyx_t_4 / __pyx_t_3); /* "photutils/geometry/core.pyx":168 * inter.p1.x = a * inter.p1.y + b * inter.p2.y = (- a * b + delta) / (1. + a * a) * inter.p2.x = a * inter.p2.y + b # <<<<<<<<<<<<<< * * else: # no solution, return values > 1 */ __pyx_v_inter.p2.x = ((__pyx_v_a * __pyx_v_inter.p2.y) + __pyx_v_b); /* "photutils/geometry/core.pyx":161 * delta = 1. + a * a - b * b * * if delta > 0.: # solutions exist # <<<<<<<<<<<<<< * * delta = sqrt(delta) */ goto __pyx_L7; } /* "photutils/geometry/core.pyx":171 * * else: # no solution, return values > 1 * inter.p1.x = 2. # <<<<<<<<<<<<<< * inter.p1.y = 2. * inter.p2.x = 2. */ /*else*/ { __pyx_v_inter.p1.x = 2.; /* "photutils/geometry/core.pyx":172 * else: # no solution, return values > 1 * inter.p1.x = 2. * inter.p1.y = 2. # <<<<<<<<<<<<<< * inter.p2.x = 2. * inter.p2.y = 2. */ __pyx_v_inter.p1.y = 2.; /* "photutils/geometry/core.pyx":173 * inter.p1.x = 2. * inter.p1.y = 2. * inter.p2.x = 2. # <<<<<<<<<<<<<< * inter.p2.y = 2. * */ __pyx_v_inter.p2.x = 2.; /* "photutils/geometry/core.pyx":174 * inter.p1.y = 2. * inter.p2.x = 2. * inter.p2.y = 2. # <<<<<<<<<<<<<< * * return inter */ __pyx_v_inter.p2.y = 2.; } __pyx_L7:; } __pyx_L3:; /* "photutils/geometry/core.pyx":176 * inter.p2.y = 2. * * return inter # <<<<<<<<<<<<<< * * */ __pyx_r = __pyx_v_inter; goto __pyx_L0; /* "photutils/geometry/core.pyx":113 * * * cdef intersections circle_line(double x1, double y1, double x2, double y2): # <<<<<<<<<<<<<< * """Intersection of a line defined by two points with a unit circle""" * */ /* function exit code */ __pyx_L1_error:; __Pyx_WriteUnraisable("photutils.geometry.core.circle_line", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0); __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "photutils/geometry/core.pyx":179 * * * cdef point circle_segment_single2(double x1, double y1, double x2, double y2): # <<<<<<<<<<<<<< * """ * The intersection of a line with the unit circle. The intersection the */ static __pyx_t_9photutils_8geometry_4core_point __pyx_f_9photutils_8geometry_4core_circle_segment_single2(double __pyx_v_x1, double __pyx_v_y1, double __pyx_v_x2, double __pyx_v_y2) { double __pyx_v_dx1; double __pyx_v_dy1; double __pyx_v_dx2; double __pyx_v_dy2; __pyx_t_9photutils_8geometry_4core_intersections __pyx_v_inter; __pyx_t_9photutils_8geometry_4core_point __pyx_v_pt1; __pyx_t_9photutils_8geometry_4core_point __pyx_v_pt2; __pyx_t_9photutils_8geometry_4core_point __pyx_v_pt; __pyx_t_9photutils_8geometry_4core_point __pyx_r; __Pyx_RefNannyDeclarations __pyx_t_9photutils_8geometry_4core_point __pyx_t_1; int __pyx_t_2; __Pyx_RefNannySetupContext("circle_segment_single2", 0); /* "photutils/geometry/core.pyx":189 * cdef point pt1, pt2, pt * * inter = circle_line(x1, y1, x2, y2) # <<<<<<<<<<<<<< * * pt1 = inter.p1 */ __pyx_v_inter = __pyx_f_9photutils_8geometry_4core_circle_line(__pyx_v_x1, __pyx_v_y1, __pyx_v_x2, __pyx_v_y2); /* "photutils/geometry/core.pyx":191 * inter = circle_line(x1, y1, x2, y2) * * pt1 = inter.p1 # <<<<<<<<<<<<<< * pt2 = inter.p2 * */ __pyx_t_1 = __pyx_v_inter.p1; __pyx_v_pt1 = __pyx_t_1; /* "photutils/geometry/core.pyx":192 * * pt1 = inter.p1 * pt2 = inter.p2 # <<<<<<<<<<<<<< * * # Can be optimized, but just checking for correctness right now */ __pyx_t_1 = __pyx_v_inter.p2; __pyx_v_pt2 = __pyx_t_1; /* "photutils/geometry/core.pyx":195 * * # Can be optimized, but just checking for correctness right now * dx1 = fabs(pt1.x - x2) # <<<<<<<<<<<<<< * dy1 = fabs(pt1.y - y2) * dx2 = fabs(pt2.x - x2) */ __pyx_v_dx1 = fabs((__pyx_v_pt1.x - __pyx_v_x2)); /* "photutils/geometry/core.pyx":196 * # Can be optimized, but just checking for correctness right now * dx1 = fabs(pt1.x - x2) * dy1 = fabs(pt1.y - y2) # <<<<<<<<<<<<<< * dx2 = fabs(pt2.x - x2) * dy2 = fabs(pt2.y - y2) */ __pyx_v_dy1 = fabs((__pyx_v_pt1.y - __pyx_v_y2)); /* "photutils/geometry/core.pyx":197 * dx1 = fabs(pt1.x - x2) * dy1 = fabs(pt1.y - y2) * dx2 = fabs(pt2.x - x2) # <<<<<<<<<<<<<< * dy2 = fabs(pt2.y - y2) * */ __pyx_v_dx2 = fabs((__pyx_v_pt2.x - __pyx_v_x2)); /* "photutils/geometry/core.pyx":198 * dy1 = fabs(pt1.y - y2) * dx2 = fabs(pt2.x - x2) * dy2 = fabs(pt2.y - y2) # <<<<<<<<<<<<<< * * if dx1 > dy1: # compare based on x-axis */ __pyx_v_dy2 = fabs((__pyx_v_pt2.y - __pyx_v_y2)); /* "photutils/geometry/core.pyx":200 * dy2 = fabs(pt2.y - y2) * * if dx1 > dy1: # compare based on x-axis # <<<<<<<<<<<<<< * if dx1 > dx2: * pt = pt2 */ __pyx_t_2 = ((__pyx_v_dx1 > __pyx_v_dy1) != 0); if (__pyx_t_2) { /* "photutils/geometry/core.pyx":201 * * if dx1 > dy1: # compare based on x-axis * if dx1 > dx2: # <<<<<<<<<<<<<< * pt = pt2 * else: */ __pyx_t_2 = ((__pyx_v_dx1 > __pyx_v_dx2) != 0); if (__pyx_t_2) { /* "photutils/geometry/core.pyx":202 * if dx1 > dy1: # compare based on x-axis * if dx1 > dx2: * pt = pt2 # <<<<<<<<<<<<<< * else: * pt = pt1 */ __pyx_v_pt = __pyx_v_pt2; /* "photutils/geometry/core.pyx":201 * * if dx1 > dy1: # compare based on x-axis * if dx1 > dx2: # <<<<<<<<<<<<<< * pt = pt2 * else: */ goto __pyx_L4; } /* "photutils/geometry/core.pyx":204 * pt = pt2 * else: * pt = pt1 # <<<<<<<<<<<<<< * else: * if dy1 > dy2: */ /*else*/ { __pyx_v_pt = __pyx_v_pt1; } __pyx_L4:; /* "photutils/geometry/core.pyx":200 * dy2 = fabs(pt2.y - y2) * * if dx1 > dy1: # compare based on x-axis # <<<<<<<<<<<<<< * if dx1 > dx2: * pt = pt2 */ goto __pyx_L3; } /* "photutils/geometry/core.pyx":206 * pt = pt1 * else: * if dy1 > dy2: # <<<<<<<<<<<<<< * pt = pt2 * else: */ /*else*/ { __pyx_t_2 = ((__pyx_v_dy1 > __pyx_v_dy2) != 0); if (__pyx_t_2) { /* "photutils/geometry/core.pyx":207 * else: * if dy1 > dy2: * pt = pt2 # <<<<<<<<<<<<<< * else: * pt = pt1 */ __pyx_v_pt = __pyx_v_pt2; /* "photutils/geometry/core.pyx":206 * pt = pt1 * else: * if dy1 > dy2: # <<<<<<<<<<<<<< * pt = pt2 * else: */ goto __pyx_L5; } /* "photutils/geometry/core.pyx":209 * pt = pt2 * else: * pt = pt1 # <<<<<<<<<<<<<< * * return pt */ /*else*/ { __pyx_v_pt = __pyx_v_pt1; } __pyx_L5:; } __pyx_L3:; /* "photutils/geometry/core.pyx":211 * pt = pt1 * * return pt # <<<<<<<<<<<<<< * * */ __pyx_r = __pyx_v_pt; goto __pyx_L0; /* "photutils/geometry/core.pyx":179 * * * cdef point circle_segment_single2(double x1, double y1, double x2, double y2): # <<<<<<<<<<<<<< * """ * The intersection of a line with the unit circle. The intersection the */ /* function exit code */ __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "photutils/geometry/core.pyx":214 * * * cdef intersections circle_segment(double x1, double y1, double x2, double y2): # <<<<<<<<<<<<<< * """ * Intersection(s) of a segment with the unit circle. Discard any */ static __pyx_t_9photutils_8geometry_4core_intersections __pyx_f_9photutils_8geometry_4core_circle_segment(double __pyx_v_x1, double __pyx_v_y1, double __pyx_v_x2, double __pyx_v_y2) { __pyx_t_9photutils_8geometry_4core_intersections __pyx_v_inter; __pyx_t_9photutils_8geometry_4core_intersections __pyx_v_inter_new; __pyx_t_9photutils_8geometry_4core_point __pyx_v_pt1; __pyx_t_9photutils_8geometry_4core_point __pyx_v_pt2; __pyx_t_9photutils_8geometry_4core_intersections __pyx_r; __Pyx_RefNannyDeclarations __pyx_t_9photutils_8geometry_4core_point __pyx_t_1; int __pyx_t_2; int __pyx_t_3; double __pyx_t_4; double __pyx_t_5; __Pyx_RefNannySetupContext("circle_segment", 0); /* "photutils/geometry/core.pyx":223 * cdef point pt1, pt2 * * inter = circle_line(x1, y1, x2, y2) # <<<<<<<<<<<<<< * * pt1 = inter.p1 */ __pyx_v_inter = __pyx_f_9photutils_8geometry_4core_circle_line(__pyx_v_x1, __pyx_v_y1, __pyx_v_x2, __pyx_v_y2); /* "photutils/geometry/core.pyx":225 * inter = circle_line(x1, y1, x2, y2) * * pt1 = inter.p1 # <<<<<<<<<<<<<< * pt2 = inter.p2 * */ __pyx_t_1 = __pyx_v_inter.p1; __pyx_v_pt1 = __pyx_t_1; /* "photutils/geometry/core.pyx":226 * * pt1 = inter.p1 * pt2 = inter.p2 # <<<<<<<<<<<<<< * * if (pt1.x > x1 and pt1.x > x2) or (pt1.x < x1 and pt1.x < x2) or (pt1.y > y1 and pt1.y > y2) or (pt1.y < y1 and pt1.y < y2): */ __pyx_t_1 = __pyx_v_inter.p2; __pyx_v_pt2 = __pyx_t_1; /* "photutils/geometry/core.pyx":228 * pt2 = inter.p2 * * if (pt1.x > x1 and pt1.x > x2) or (pt1.x < x1 and pt1.x < x2) or (pt1.y > y1 and pt1.y > y2) or (pt1.y < y1 and pt1.y < y2): # <<<<<<<<<<<<<< * pt1.x, pt1.y = 2., 2. * if (pt2.x > x1 and pt2.x > x2) or (pt2.x < x1 and pt2.x < x2) or (pt2.y > y1 and pt2.y > y2) or (pt2.y < y1 and pt2.y < y2): */ __pyx_t_3 = ((__pyx_v_pt1.x > __pyx_v_x1) != 0); if (!__pyx_t_3) { goto __pyx_L5_next_or; } else { } __pyx_t_3 = ((__pyx_v_pt1.x > __pyx_v_x2) != 0); if (!__pyx_t_3) { } else { __pyx_t_2 = __pyx_t_3; goto __pyx_L4_bool_binop_done; } __pyx_L5_next_or:; __pyx_t_3 = ((__pyx_v_pt1.x < __pyx_v_x1) != 0); if (!__pyx_t_3) { goto __pyx_L7_next_or; } else { } __pyx_t_3 = ((__pyx_v_pt1.x < __pyx_v_x2) != 0); if (!__pyx_t_3) { } else { __pyx_t_2 = __pyx_t_3; goto __pyx_L4_bool_binop_done; } __pyx_L7_next_or:; __pyx_t_3 = ((__pyx_v_pt1.y > __pyx_v_y1) != 0); if (!__pyx_t_3) { goto __pyx_L9_next_or; } else { } __pyx_t_3 = ((__pyx_v_pt1.y > __pyx_v_y2) != 0); if (!__pyx_t_3) { } else { __pyx_t_2 = __pyx_t_3; goto __pyx_L4_bool_binop_done; } __pyx_L9_next_or:; __pyx_t_3 = ((__pyx_v_pt1.y < __pyx_v_y1) != 0); if (__pyx_t_3) { } else { __pyx_t_2 = __pyx_t_3; goto __pyx_L4_bool_binop_done; } __pyx_t_3 = ((__pyx_v_pt1.y < __pyx_v_y2) != 0); __pyx_t_2 = __pyx_t_3; __pyx_L4_bool_binop_done:; if (__pyx_t_2) { /* "photutils/geometry/core.pyx":229 * * if (pt1.x > x1 and pt1.x > x2) or (pt1.x < x1 and pt1.x < x2) or (pt1.y > y1 and pt1.y > y2) or (pt1.y < y1 and pt1.y < y2): * pt1.x, pt1.y = 2., 2. # <<<<<<<<<<<<<< * if (pt2.x > x1 and pt2.x > x2) or (pt2.x < x1 and pt2.x < x2) or (pt2.y > y1 and pt2.y > y2) or (pt2.y < y1 and pt2.y < y2): * pt2.x, pt2.y = 2., 2. */ __pyx_t_4 = 2.; __pyx_t_5 = 2.; __pyx_v_pt1.x = __pyx_t_4; __pyx_v_pt1.y = __pyx_t_5; /* "photutils/geometry/core.pyx":228 * pt2 = inter.p2 * * if (pt1.x > x1 and pt1.x > x2) or (pt1.x < x1 and pt1.x < x2) or (pt1.y > y1 and pt1.y > y2) or (pt1.y < y1 and pt1.y < y2): # <<<<<<<<<<<<<< * pt1.x, pt1.y = 2., 2. * if (pt2.x > x1 and pt2.x > x2) or (pt2.x < x1 and pt2.x < x2) or (pt2.y > y1 and pt2.y > y2) or (pt2.y < y1 and pt2.y < y2): */ } /* "photutils/geometry/core.pyx":230 * if (pt1.x > x1 and pt1.x > x2) or (pt1.x < x1 and pt1.x < x2) or (pt1.y > y1 and pt1.y > y2) or (pt1.y < y1 and pt1.y < y2): * pt1.x, pt1.y = 2., 2. * if (pt2.x > x1 and pt2.x > x2) or (pt2.x < x1 and pt2.x < x2) or (pt2.y > y1 and pt2.y > y2) or (pt2.y < y1 and pt2.y < y2): # <<<<<<<<<<<<<< * pt2.x, pt2.y = 2., 2. * */ __pyx_t_3 = ((__pyx_v_pt2.x > __pyx_v_x1) != 0); if (!__pyx_t_3) { goto __pyx_L14_next_or; } else { } __pyx_t_3 = ((__pyx_v_pt2.x > __pyx_v_x2) != 0); if (!__pyx_t_3) { } else { __pyx_t_2 = __pyx_t_3; goto __pyx_L13_bool_binop_done; } __pyx_L14_next_or:; __pyx_t_3 = ((__pyx_v_pt2.x < __pyx_v_x1) != 0); if (!__pyx_t_3) { goto __pyx_L16_next_or; } else { } __pyx_t_3 = ((__pyx_v_pt2.x < __pyx_v_x2) != 0); if (!__pyx_t_3) { } else { __pyx_t_2 = __pyx_t_3; goto __pyx_L13_bool_binop_done; } __pyx_L16_next_or:; __pyx_t_3 = ((__pyx_v_pt2.y > __pyx_v_y1) != 0); if (!__pyx_t_3) { goto __pyx_L18_next_or; } else { } __pyx_t_3 = ((__pyx_v_pt2.y > __pyx_v_y2) != 0); if (!__pyx_t_3) { } else { __pyx_t_2 = __pyx_t_3; goto __pyx_L13_bool_binop_done; } __pyx_L18_next_or:; __pyx_t_3 = ((__pyx_v_pt2.y < __pyx_v_y1) != 0); if (__pyx_t_3) { } else { __pyx_t_2 = __pyx_t_3; goto __pyx_L13_bool_binop_done; } __pyx_t_3 = ((__pyx_v_pt2.y < __pyx_v_y2) != 0); __pyx_t_2 = __pyx_t_3; __pyx_L13_bool_binop_done:; if (__pyx_t_2) { /* "photutils/geometry/core.pyx":231 * pt1.x, pt1.y = 2., 2. * if (pt2.x > x1 and pt2.x > x2) or (pt2.x < x1 and pt2.x < x2) or (pt2.y > y1 and pt2.y > y2) or (pt2.y < y1 and pt2.y < y2): * pt2.x, pt2.y = 2., 2. # <<<<<<<<<<<<<< * * if pt1.x > 1. and pt2.x < 2.: */ __pyx_t_5 = 2.; __pyx_t_4 = 2.; __pyx_v_pt2.x = __pyx_t_5; __pyx_v_pt2.y = __pyx_t_4; /* "photutils/geometry/core.pyx":230 * if (pt1.x > x1 and pt1.x > x2) or (pt1.x < x1 and pt1.x < x2) or (pt1.y > y1 and pt1.y > y2) or (pt1.y < y1 and pt1.y < y2): * pt1.x, pt1.y = 2., 2. * if (pt2.x > x1 and pt2.x > x2) or (pt2.x < x1 and pt2.x < x2) or (pt2.y > y1 and pt2.y > y2) or (pt2.y < y1 and pt2.y < y2): # <<<<<<<<<<<<<< * pt2.x, pt2.y = 2., 2. * */ } /* "photutils/geometry/core.pyx":233 * pt2.x, pt2.y = 2., 2. * * if pt1.x > 1. and pt2.x < 2.: # <<<<<<<<<<<<<< * inter_new.p1 = pt1 * inter_new.p2 = pt2 */ __pyx_t_3 = ((__pyx_v_pt1.x > 1.) != 0); if (__pyx_t_3) { } else { __pyx_t_2 = __pyx_t_3; goto __pyx_L22_bool_binop_done; } __pyx_t_3 = ((__pyx_v_pt2.x < 2.) != 0); __pyx_t_2 = __pyx_t_3; __pyx_L22_bool_binop_done:; if (__pyx_t_2) { /* "photutils/geometry/core.pyx":234 * * if pt1.x > 1. and pt2.x < 2.: * inter_new.p1 = pt1 # <<<<<<<<<<<<<< * inter_new.p2 = pt2 * else: */ __pyx_v_inter_new.p1 = __pyx_v_pt1; /* "photutils/geometry/core.pyx":235 * if pt1.x > 1. and pt2.x < 2.: * inter_new.p1 = pt1 * inter_new.p2 = pt2 # <<<<<<<<<<<<<< * else: * inter_new.p1 = pt2 */ __pyx_v_inter_new.p2 = __pyx_v_pt2; /* "photutils/geometry/core.pyx":233 * pt2.x, pt2.y = 2., 2. * * if pt1.x > 1. and pt2.x < 2.: # <<<<<<<<<<<<<< * inter_new.p1 = pt1 * inter_new.p2 = pt2 */ goto __pyx_L21; } /* "photutils/geometry/core.pyx":237 * inter_new.p2 = pt2 * else: * inter_new.p1 = pt2 # <<<<<<<<<<<<<< * inter_new.p2 = pt1 * */ /*else*/ { __pyx_v_inter_new.p1 = __pyx_v_pt2; /* "photutils/geometry/core.pyx":238 * else: * inter_new.p1 = pt2 * inter_new.p2 = pt1 # <<<<<<<<<<<<<< * * return inter_new */ __pyx_v_inter_new.p2 = __pyx_v_pt1; } __pyx_L21:; /* "photutils/geometry/core.pyx":240 * inter_new.p2 = pt1 * * return inter_new # <<<<<<<<<<<<<< * * */ __pyx_r = __pyx_v_inter_new; goto __pyx_L0; /* "photutils/geometry/core.pyx":214 * * * cdef intersections circle_segment(double x1, double y1, double x2, double y2): # <<<<<<<<<<<<<< * """ * Intersection(s) of a segment with the unit circle. Discard any */ /* function exit code */ __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "photutils/geometry/core.pyx":243 * * * cdef double overlap_area_triangle_unit_circle(double x1, double y1, double x2, double y2, double x3, double y3): # <<<<<<<<<<<<<< * """ * Given a triangle defined by three points (x1, y1), (x2, y2), and */ static double __pyx_f_9photutils_8geometry_4core_overlap_area_triangle_unit_circle(double __pyx_v_x1, double __pyx_v_y1, double __pyx_v_x2, double __pyx_v_y2, double __pyx_v_x3, double __pyx_v_y3) { double __pyx_v_d1; double __pyx_v_d2; double __pyx_v_d3; PyBoolObject *__pyx_v_in1 = 0; PyBoolObject *__pyx_v_in2 = 0; PyBoolObject *__pyx_v_in3 = 0; PyBoolObject *__pyx_v_on1 = 0; PyBoolObject *__pyx_v_on2 = 0; PyBoolObject *__pyx_v_on3 = 0; double __pyx_v_area; double __pyx_v_PI; __pyx_t_9photutils_8geometry_4core_intersections __pyx_v_inter; __pyx_t_9photutils_8geometry_4core_point __pyx_v_pt1; __pyx_t_9photutils_8geometry_4core_point __pyx_v_pt2; __pyx_t_9photutils_8geometry_4core_point __pyx_v_pt3; __pyx_t_9photutils_8geometry_4core_point __pyx_v_pt4; __pyx_t_9photutils_8geometry_4core_point __pyx_v_pt5; __pyx_t_9photutils_8geometry_4core_point __pyx_v_pt6; PyObject *__pyx_v_intersect13 = NULL; PyObject *__pyx_v_intersect23 = NULL; double __pyx_v_xp; double __pyx_v_yp; double __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; double __pyx_t_3; int __pyx_t_4; double __pyx_t_5; double __pyx_t_6; double __pyx_t_7; double __pyx_t_8; double __pyx_t_9; double __pyx_t_10; double __pyx_t_11; double __pyx_t_12; int __pyx_t_13; int __pyx_t_14; __pyx_t_9photutils_8geometry_4core_point __pyx_t_15; __pyx_t_9photutils_8geometry_4core_point __pyx_t_16; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("overlap_area_triangle_unit_circle", 0); /* "photutils/geometry/core.pyx":253 * cdef bool on1, on2, on3 * cdef double area * cdef double PI = np.pi # <<<<<<<<<<<<<< * cdef intersections inter * cdef point pt1, pt2, pt3, pt4, pt5, pt6, pt_tmp */ __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_pi); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_3 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_PI = __pyx_t_3; /* "photutils/geometry/core.pyx":258 * * # Find distance of all vertices to circle center * d1 = x1 * x1 + y1 * y1 # <<<<<<<<<<<<<< * d2 = x2 * x2 + y2 * y2 * d3 = x3 * x3 + y3 * y3 */ __pyx_v_d1 = ((__pyx_v_x1 * __pyx_v_x1) + (__pyx_v_y1 * __pyx_v_y1)); /* "photutils/geometry/core.pyx":259 * # Find distance of all vertices to circle center * d1 = x1 * x1 + y1 * y1 * d2 = x2 * x2 + y2 * y2 # <<<<<<<<<<<<<< * d3 = x3 * x3 + y3 * y3 * */ __pyx_v_d2 = ((__pyx_v_x2 * __pyx_v_x2) + (__pyx_v_y2 * __pyx_v_y2)); /* "photutils/geometry/core.pyx":260 * d1 = x1 * x1 + y1 * y1 * d2 = x2 * x2 + y2 * y2 * d3 = x3 * x3 + y3 * y3 # <<<<<<<<<<<<<< * * # Order vertices by distance from origin */ __pyx_v_d3 = ((__pyx_v_x3 * __pyx_v_x3) + (__pyx_v_y3 * __pyx_v_y3)); /* "photutils/geometry/core.pyx":263 * * # Order vertices by distance from origin * if d1 < d2: # <<<<<<<<<<<<<< * if d2 < d3: * pass */ __pyx_t_4 = ((__pyx_v_d1 < __pyx_v_d2) != 0); if (__pyx_t_4) { /* "photutils/geometry/core.pyx":264 * # Order vertices by distance from origin * if d1 < d2: * if d2 < d3: # <<<<<<<<<<<<<< * pass * elif d1 < d3: */ __pyx_t_4 = ((__pyx_v_d2 < __pyx_v_d3) != 0); if (__pyx_t_4) { goto __pyx_L4; } /* "photutils/geometry/core.pyx":266 * if d2 < d3: * pass * elif d1 < d3: # <<<<<<<<<<<<<< * x2, y2, d2, x3, y3, d3 = x3, y3, d3, x2, y2, d2 * else: */ __pyx_t_4 = ((__pyx_v_d1 < __pyx_v_d3) != 0); if (__pyx_t_4) { /* "photutils/geometry/core.pyx":267 * pass * elif d1 < d3: * x2, y2, d2, x3, y3, d3 = x3, y3, d3, x2, y2, d2 # <<<<<<<<<<<<<< * else: * x1, y1, d1, x2, y2, d2, x3, y3, d3 = x3, y3, d3, x1, y1, d1, x2, y2, d2 */ __pyx_t_3 = __pyx_v_x3; __pyx_t_5 = __pyx_v_y3; __pyx_t_6 = __pyx_v_d3; __pyx_t_7 = __pyx_v_x2; __pyx_t_8 = __pyx_v_y2; __pyx_t_9 = __pyx_v_d2; __pyx_v_x2 = __pyx_t_3; __pyx_v_y2 = __pyx_t_5; __pyx_v_d2 = __pyx_t_6; __pyx_v_x3 = __pyx_t_7; __pyx_v_y3 = __pyx_t_8; __pyx_v_d3 = __pyx_t_9; /* "photutils/geometry/core.pyx":266 * if d2 < d3: * pass * elif d1 < d3: # <<<<<<<<<<<<<< * x2, y2, d2, x3, y3, d3 = x3, y3, d3, x2, y2, d2 * else: */ goto __pyx_L4; } /* "photutils/geometry/core.pyx":269 * x2, y2, d2, x3, y3, d3 = x3, y3, d3, x2, y2, d2 * else: * x1, y1, d1, x2, y2, d2, x3, y3, d3 = x3, y3, d3, x1, y1, d1, x2, y2, d2 # <<<<<<<<<<<<<< * * else: */ /*else*/ { __pyx_t_9 = __pyx_v_x3; __pyx_t_8 = __pyx_v_y3; __pyx_t_7 = __pyx_v_d3; __pyx_t_6 = __pyx_v_x1; __pyx_t_5 = __pyx_v_y1; __pyx_t_3 = __pyx_v_d1; __pyx_t_10 = __pyx_v_x2; __pyx_t_11 = __pyx_v_y2; __pyx_t_12 = __pyx_v_d2; __pyx_v_x1 = __pyx_t_9; __pyx_v_y1 = __pyx_t_8; __pyx_v_d1 = __pyx_t_7; __pyx_v_x2 = __pyx_t_6; __pyx_v_y2 = __pyx_t_5; __pyx_v_d2 = __pyx_t_3; __pyx_v_x3 = __pyx_t_10; __pyx_v_y3 = __pyx_t_11; __pyx_v_d3 = __pyx_t_12; } __pyx_L4:; /* "photutils/geometry/core.pyx":263 * * # Order vertices by distance from origin * if d1 < d2: # <<<<<<<<<<<<<< * if d2 < d3: * pass */ goto __pyx_L3; } /* "photutils/geometry/core.pyx":272 * * else: * if d1 < d3: # <<<<<<<<<<<<<< * x1, y1, d1, x2, y2, d2 = x2, y2, d2, x1, y1, d1 * elif d2 < d3: */ /*else*/ { __pyx_t_4 = ((__pyx_v_d1 < __pyx_v_d3) != 0); if (__pyx_t_4) { /* "photutils/geometry/core.pyx":273 * else: * if d1 < d3: * x1, y1, d1, x2, y2, d2 = x2, y2, d2, x1, y1, d1 # <<<<<<<<<<<<<< * elif d2 < d3: * x1, y1, d1, x2, y2, d2, x3, y3, d3 = x2, y2, d2, x3, y3, d3, x1, y1, d1 */ __pyx_t_12 = __pyx_v_x2; __pyx_t_11 = __pyx_v_y2; __pyx_t_10 = __pyx_v_d2; __pyx_t_3 = __pyx_v_x1; __pyx_t_5 = __pyx_v_y1; __pyx_t_6 = __pyx_v_d1; __pyx_v_x1 = __pyx_t_12; __pyx_v_y1 = __pyx_t_11; __pyx_v_d1 = __pyx_t_10; __pyx_v_x2 = __pyx_t_3; __pyx_v_y2 = __pyx_t_5; __pyx_v_d2 = __pyx_t_6; /* "photutils/geometry/core.pyx":272 * * else: * if d1 < d3: # <<<<<<<<<<<<<< * x1, y1, d1, x2, y2, d2 = x2, y2, d2, x1, y1, d1 * elif d2 < d3: */ goto __pyx_L5; } /* "photutils/geometry/core.pyx":274 * if d1 < d3: * x1, y1, d1, x2, y2, d2 = x2, y2, d2, x1, y1, d1 * elif d2 < d3: # <<<<<<<<<<<<<< * x1, y1, d1, x2, y2, d2, x3, y3, d3 = x2, y2, d2, x3, y3, d3, x1, y1, d1 * else: */ __pyx_t_4 = ((__pyx_v_d2 < __pyx_v_d3) != 0); if (__pyx_t_4) { /* "photutils/geometry/core.pyx":275 * x1, y1, d1, x2, y2, d2 = x2, y2, d2, x1, y1, d1 * elif d2 < d3: * x1, y1, d1, x2, y2, d2, x3, y3, d3 = x2, y2, d2, x3, y3, d3, x1, y1, d1 # <<<<<<<<<<<<<< * else: * x1, y1, d1, x2, y2, d2, x3, y3, d3 = x3, y3, d3, x2, y2, d2, x1, y1, d1 */ __pyx_t_6 = __pyx_v_x2; __pyx_t_5 = __pyx_v_y2; __pyx_t_3 = __pyx_v_d2; __pyx_t_10 = __pyx_v_x3; __pyx_t_11 = __pyx_v_y3; __pyx_t_12 = __pyx_v_d3; __pyx_t_7 = __pyx_v_x1; __pyx_t_8 = __pyx_v_y1; __pyx_t_9 = __pyx_v_d1; __pyx_v_x1 = __pyx_t_6; __pyx_v_y1 = __pyx_t_5; __pyx_v_d1 = __pyx_t_3; __pyx_v_x2 = __pyx_t_10; __pyx_v_y2 = __pyx_t_11; __pyx_v_d2 = __pyx_t_12; __pyx_v_x3 = __pyx_t_7; __pyx_v_y3 = __pyx_t_8; __pyx_v_d3 = __pyx_t_9; /* "photutils/geometry/core.pyx":274 * if d1 < d3: * x1, y1, d1, x2, y2, d2 = x2, y2, d2, x1, y1, d1 * elif d2 < d3: # <<<<<<<<<<<<<< * x1, y1, d1, x2, y2, d2, x3, y3, d3 = x2, y2, d2, x3, y3, d3, x1, y1, d1 * else: */ goto __pyx_L5; } /* "photutils/geometry/core.pyx":277 * x1, y1, d1, x2, y2, d2, x3, y3, d3 = x2, y2, d2, x3, y3, d3, x1, y1, d1 * else: * x1, y1, d1, x2, y2, d2, x3, y3, d3 = x3, y3, d3, x2, y2, d2, x1, y1, d1 # <<<<<<<<<<<<<< * * if d1 > d2 or d2 > d3 or d1 > d3: */ /*else*/ { __pyx_t_9 = __pyx_v_x3; __pyx_t_8 = __pyx_v_y3; __pyx_t_7 = __pyx_v_d3; __pyx_t_12 = __pyx_v_x2; __pyx_t_11 = __pyx_v_y2; __pyx_t_10 = __pyx_v_d2; __pyx_t_3 = __pyx_v_x1; __pyx_t_5 = __pyx_v_y1; __pyx_t_6 = __pyx_v_d1; __pyx_v_x1 = __pyx_t_9; __pyx_v_y1 = __pyx_t_8; __pyx_v_d1 = __pyx_t_7; __pyx_v_x2 = __pyx_t_12; __pyx_v_y2 = __pyx_t_11; __pyx_v_d2 = __pyx_t_10; __pyx_v_x3 = __pyx_t_3; __pyx_v_y3 = __pyx_t_5; __pyx_v_d3 = __pyx_t_6; } __pyx_L5:; } __pyx_L3:; /* "photutils/geometry/core.pyx":279 * x1, y1, d1, x2, y2, d2, x3, y3, d3 = x3, y3, d3, x2, y2, d2, x1, y1, d1 * * if d1 > d2 or d2 > d3 or d1 > d3: # <<<<<<<<<<<<<< * raise Exception("ERROR: vertices did not sort correctly") * */ __pyx_t_13 = ((__pyx_v_d1 > __pyx_v_d2) != 0); if (!__pyx_t_13) { } else { __pyx_t_4 = __pyx_t_13; goto __pyx_L7_bool_binop_done; } __pyx_t_13 = ((__pyx_v_d2 > __pyx_v_d3) != 0); if (!__pyx_t_13) { } else { __pyx_t_4 = __pyx_t_13; goto __pyx_L7_bool_binop_done; } __pyx_t_13 = ((__pyx_v_d1 > __pyx_v_d3) != 0); __pyx_t_4 = __pyx_t_13; __pyx_L7_bool_binop_done:; if (__pyx_t_4) { /* "photutils/geometry/core.pyx":280 * * if d1 > d2 or d2 > d3 or d1 > d3: * raise Exception("ERROR: vertices did not sort correctly") # <<<<<<<<<<<<<< * * # Determine number of vertices inside circle */ __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_Exception, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 280; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 280; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "photutils/geometry/core.pyx":279 * x1, y1, d1, x2, y2, d2, x3, y3, d3 = x3, y3, d3, x2, y2, d2, x1, y1, d1 * * if d1 > d2 or d2 > d3 or d1 > d3: # <<<<<<<<<<<<<< * raise Exception("ERROR: vertices did not sort correctly") * */ } /* "photutils/geometry/core.pyx":283 * * # Determine number of vertices inside circle * in1 = d1 < 1 # <<<<<<<<<<<<<< * in2 = d2 < 1 * in3 = d3 < 1 */ __pyx_t_2 = __Pyx_PyBool_FromLong((__pyx_v_d1 < 1.0)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (!(likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_7cpython_4bool_bool)))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_in1 = ((PyBoolObject *)__pyx_t_2); __pyx_t_2 = 0; /* "photutils/geometry/core.pyx":284 * # Determine number of vertices inside circle * in1 = d1 < 1 * in2 = d2 < 1 # <<<<<<<<<<<<<< * in3 = d3 < 1 * */ __pyx_t_2 = __Pyx_PyBool_FromLong((__pyx_v_d2 < 1.0)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (!(likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_7cpython_4bool_bool)))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_in2 = ((PyBoolObject *)__pyx_t_2); __pyx_t_2 = 0; /* "photutils/geometry/core.pyx":285 * in1 = d1 < 1 * in2 = d2 < 1 * in3 = d3 < 1 # <<<<<<<<<<<<<< * * # Determine which vertices are on the circle */ __pyx_t_2 = __Pyx_PyBool_FromLong((__pyx_v_d3 < 1.0)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (!(likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_7cpython_4bool_bool)))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_in3 = ((PyBoolObject *)__pyx_t_2); __pyx_t_2 = 0; /* "photutils/geometry/core.pyx":288 * * # Determine which vertices are on the circle * on1 = fabs(d1 - 1) < 1.e-10 # <<<<<<<<<<<<<< * on2 = fabs(d2 - 1) < 1.e-10 * on3 = fabs(d3 - 1) < 1.e-10 */ __pyx_t_2 = __Pyx_PyBool_FromLong((fabs((__pyx_v_d1 - 1.0)) < 1.e-10)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (!(likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_7cpython_4bool_bool)))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_on1 = ((PyBoolObject *)__pyx_t_2); __pyx_t_2 = 0; /* "photutils/geometry/core.pyx":289 * # Determine which vertices are on the circle * on1 = fabs(d1 - 1) < 1.e-10 * on2 = fabs(d2 - 1) < 1.e-10 # <<<<<<<<<<<<<< * on3 = fabs(d3 - 1) < 1.e-10 * */ __pyx_t_2 = __Pyx_PyBool_FromLong((fabs((__pyx_v_d2 - 1.0)) < 1.e-10)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (!(likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_7cpython_4bool_bool)))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_on2 = ((PyBoolObject *)__pyx_t_2); __pyx_t_2 = 0; /* "photutils/geometry/core.pyx":290 * on1 = fabs(d1 - 1) < 1.e-10 * on2 = fabs(d2 - 1) < 1.e-10 * on3 = fabs(d3 - 1) < 1.e-10 # <<<<<<<<<<<<<< * * if on3 or in3: # triangle is completely in circle */ __pyx_t_2 = __Pyx_PyBool_FromLong((fabs((__pyx_v_d3 - 1.0)) < 1.e-10)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (!(likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_7cpython_4bool_bool)))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_on3 = ((PyBoolObject *)__pyx_t_2); __pyx_t_2 = 0; /* "photutils/geometry/core.pyx":292 * on3 = fabs(d3 - 1) < 1.e-10 * * if on3 or in3: # triangle is completely in circle # <<<<<<<<<<<<<< * * area = area_triangle(x1, y1, x2, y2, x3, y3) */ __pyx_t_13 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_on3)); if (unlikely(__pyx_t_13 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (!__pyx_t_13) { } else { __pyx_t_4 = __pyx_t_13; goto __pyx_L11_bool_binop_done; } __pyx_t_13 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_in3)); if (unlikely(__pyx_t_13 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_4 = __pyx_t_13; __pyx_L11_bool_binop_done:; if (__pyx_t_4) { /* "photutils/geometry/core.pyx":294 * if on3 or in3: # triangle is completely in circle * * area = area_triangle(x1, y1, x2, y2, x3, y3) # <<<<<<<<<<<<<< * * elif in2 or on2: */ __pyx_v_area = __pyx_f_9photutils_8geometry_4core_area_triangle(__pyx_v_x1, __pyx_v_y1, __pyx_v_x2, __pyx_v_y2, __pyx_v_x3, __pyx_v_y3); /* "photutils/geometry/core.pyx":292 * on3 = fabs(d3 - 1) < 1.e-10 * * if on3 or in3: # triangle is completely in circle # <<<<<<<<<<<<<< * * area = area_triangle(x1, y1, x2, y2, x3, y3) */ goto __pyx_L10; } /* "photutils/geometry/core.pyx":296 * area = area_triangle(x1, y1, x2, y2, x3, y3) * * elif in2 or on2: # <<<<<<<<<<<<<< * # If vertex 1 or 2 are on the edge of the circle, then we use the dot * # product to vertex 3 to determine whether an intersection takes place. */ __pyx_t_13 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_in2)); if (unlikely(__pyx_t_13 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (!__pyx_t_13) { } else { __pyx_t_4 = __pyx_t_13; goto __pyx_L13_bool_binop_done; } __pyx_t_13 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_on2)); if (unlikely(__pyx_t_13 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_4 = __pyx_t_13; __pyx_L13_bool_binop_done:; if (__pyx_t_4) { /* "photutils/geometry/core.pyx":299 * # If vertex 1 or 2 are on the edge of the circle, then we use the dot * # product to vertex 3 to determine whether an intersection takes place. * intersect13 = not on1 or x1 * (x3 - x1) + y1 * (y3 - y1) < 0. # <<<<<<<<<<<<<< * intersect23 = not on2 or x2 * (x3 - x2) + y2 * (y3 - y2) < 0. * if intersect13 and intersect23 and not on2: */ __pyx_t_4 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_on1)); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_13 = (!__pyx_t_4); if (!__pyx_t_13) { } else { __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_t_13); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L15_bool_binop_done; } __pyx_t_13 = (((__pyx_v_x1 * (__pyx_v_x3 - __pyx_v_x1)) + (__pyx_v_y1 * (__pyx_v_y3 - __pyx_v_y1))) < 0.); __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_t_13); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __pyx_t_1; __pyx_t_1 = 0; __pyx_L15_bool_binop_done:; __pyx_v_intersect13 = __pyx_t_2; __pyx_t_2 = 0; /* "photutils/geometry/core.pyx":300 * # product to vertex 3 to determine whether an intersection takes place. * intersect13 = not on1 or x1 * (x3 - x1) + y1 * (y3 - y1) < 0. * intersect23 = not on2 or x2 * (x3 - x2) + y2 * (y3 - y2) < 0. # <<<<<<<<<<<<<< * if intersect13 and intersect23 and not on2: * pt1 = circle_segment_single2(x1, y1, x3, y3) */ __pyx_t_13 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_on2)); if (unlikely(__pyx_t_13 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_4 = (!__pyx_t_13); if (!__pyx_t_4) { } else { __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L17_bool_binop_done; } __pyx_t_4 = (((__pyx_v_x2 * (__pyx_v_x3 - __pyx_v_x2)) + (__pyx_v_y2 * (__pyx_v_y3 - __pyx_v_y2))) < 0.); __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __pyx_t_1; __pyx_t_1 = 0; __pyx_L17_bool_binop_done:; __pyx_v_intersect23 = __pyx_t_2; __pyx_t_2 = 0; /* "photutils/geometry/core.pyx":301 * intersect13 = not on1 or x1 * (x3 - x1) + y1 * (y3 - y1) < 0. * intersect23 = not on2 or x2 * (x3 - x2) + y2 * (y3 - y2) < 0. * if intersect13 and intersect23 and not on2: # <<<<<<<<<<<<<< * pt1 = circle_segment_single2(x1, y1, x3, y3) * pt2 = circle_segment_single2(x2, y2, x3, y3) */ __pyx_t_13 = __Pyx_PyObject_IsTrue(__pyx_v_intersect13); if (unlikely(__pyx_t_13 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__pyx_t_13) { } else { __pyx_t_4 = __pyx_t_13; goto __pyx_L20_bool_binop_done; } __pyx_t_13 = __Pyx_PyObject_IsTrue(__pyx_v_intersect23); if (unlikely(__pyx_t_13 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__pyx_t_13) { } else { __pyx_t_4 = __pyx_t_13; goto __pyx_L20_bool_binop_done; } __pyx_t_13 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_on2)); if (unlikely(__pyx_t_13 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_14 = ((!__pyx_t_13) != 0); __pyx_t_4 = __pyx_t_14; __pyx_L20_bool_binop_done:; if (__pyx_t_4) { /* "photutils/geometry/core.pyx":302 * intersect23 = not on2 or x2 * (x3 - x2) + y2 * (y3 - y2) < 0. * if intersect13 and intersect23 and not on2: * pt1 = circle_segment_single2(x1, y1, x3, y3) # <<<<<<<<<<<<<< * pt2 = circle_segment_single2(x2, y2, x3, y3) * area = area_triangle(x1, y1, x2, y2, pt1.x, pt1.y) \ */ __pyx_v_pt1 = __pyx_f_9photutils_8geometry_4core_circle_segment_single2(__pyx_v_x1, __pyx_v_y1, __pyx_v_x3, __pyx_v_y3); /* "photutils/geometry/core.pyx":303 * if intersect13 and intersect23 and not on2: * pt1 = circle_segment_single2(x1, y1, x3, y3) * pt2 = circle_segment_single2(x2, y2, x3, y3) # <<<<<<<<<<<<<< * area = area_triangle(x1, y1, x2, y2, pt1.x, pt1.y) \ * + area_triangle(x2, y2, pt1.x, pt1.y, pt2.x, pt2.y) \ */ __pyx_v_pt2 = __pyx_f_9photutils_8geometry_4core_circle_segment_single2(__pyx_v_x2, __pyx_v_y2, __pyx_v_x3, __pyx_v_y3); /* "photutils/geometry/core.pyx":306 * area = area_triangle(x1, y1, x2, y2, pt1.x, pt1.y) \ * + area_triangle(x2, y2, pt1.x, pt1.y, pt2.x, pt2.y) \ * + area_arc_unit(pt1.x, pt1.y, pt2.x, pt2.y) # <<<<<<<<<<<<<< * elif intersect13: * pt1 = circle_segment_single2(x1, y1, x3, y3) */ __pyx_v_area = ((__pyx_f_9photutils_8geometry_4core_area_triangle(__pyx_v_x1, __pyx_v_y1, __pyx_v_x2, __pyx_v_y2, __pyx_v_pt1.x, __pyx_v_pt1.y) + __pyx_f_9photutils_8geometry_4core_area_triangle(__pyx_v_x2, __pyx_v_y2, __pyx_v_pt1.x, __pyx_v_pt1.y, __pyx_v_pt2.x, __pyx_v_pt2.y)) + __pyx_f_9photutils_8geometry_4core_area_arc_unit(__pyx_v_pt1.x, __pyx_v_pt1.y, __pyx_v_pt2.x, __pyx_v_pt2.y)); /* "photutils/geometry/core.pyx":301 * intersect13 = not on1 or x1 * (x3 - x1) + y1 * (y3 - y1) < 0. * intersect23 = not on2 or x2 * (x3 - x2) + y2 * (y3 - y2) < 0. * if intersect13 and intersect23 and not on2: # <<<<<<<<<<<<<< * pt1 = circle_segment_single2(x1, y1, x3, y3) * pt2 = circle_segment_single2(x2, y2, x3, y3) */ goto __pyx_L19; } /* "photutils/geometry/core.pyx":307 * + area_triangle(x2, y2, pt1.x, pt1.y, pt2.x, pt2.y) \ * + area_arc_unit(pt1.x, pt1.y, pt2.x, pt2.y) * elif intersect13: # <<<<<<<<<<<<<< * pt1 = circle_segment_single2(x1, y1, x3, y3) * area = area_triangle(x1, y1, x2, y2, pt1.x, pt1.y) \ */ __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_intersect13); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__pyx_t_4) { /* "photutils/geometry/core.pyx":308 * + area_arc_unit(pt1.x, pt1.y, pt2.x, pt2.y) * elif intersect13: * pt1 = circle_segment_single2(x1, y1, x3, y3) # <<<<<<<<<<<<<< * area = area_triangle(x1, y1, x2, y2, pt1.x, pt1.y) \ * + area_arc_unit(x2, y2, pt1.x, pt1.y) */ __pyx_v_pt1 = __pyx_f_9photutils_8geometry_4core_circle_segment_single2(__pyx_v_x1, __pyx_v_y1, __pyx_v_x3, __pyx_v_y3); /* "photutils/geometry/core.pyx":310 * pt1 = circle_segment_single2(x1, y1, x3, y3) * area = area_triangle(x1, y1, x2, y2, pt1.x, pt1.y) \ * + area_arc_unit(x2, y2, pt1.x, pt1.y) # <<<<<<<<<<<<<< * elif intersect23: * pt2 = circle_segment_single2(x2, y2, x3, y3) */ __pyx_v_area = (__pyx_f_9photutils_8geometry_4core_area_triangle(__pyx_v_x1, __pyx_v_y1, __pyx_v_x2, __pyx_v_y2, __pyx_v_pt1.x, __pyx_v_pt1.y) + __pyx_f_9photutils_8geometry_4core_area_arc_unit(__pyx_v_x2, __pyx_v_y2, __pyx_v_pt1.x, __pyx_v_pt1.y)); /* "photutils/geometry/core.pyx":307 * + area_triangle(x2, y2, pt1.x, pt1.y, pt2.x, pt2.y) \ * + area_arc_unit(pt1.x, pt1.y, pt2.x, pt2.y) * elif intersect13: # <<<<<<<<<<<<<< * pt1 = circle_segment_single2(x1, y1, x3, y3) * area = area_triangle(x1, y1, x2, y2, pt1.x, pt1.y) \ */ goto __pyx_L19; } /* "photutils/geometry/core.pyx":311 * area = area_triangle(x1, y1, x2, y2, pt1.x, pt1.y) \ * + area_arc_unit(x2, y2, pt1.x, pt1.y) * elif intersect23: # <<<<<<<<<<<<<< * pt2 = circle_segment_single2(x2, y2, x3, y3) * area = area_triangle(x1, y1, x2, y2, pt2.x, pt2.y) \ */ __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_intersect23); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__pyx_t_4) { /* "photutils/geometry/core.pyx":312 * + area_arc_unit(x2, y2, pt1.x, pt1.y) * elif intersect23: * pt2 = circle_segment_single2(x2, y2, x3, y3) # <<<<<<<<<<<<<< * area = area_triangle(x1, y1, x2, y2, pt2.x, pt2.y) \ * + area_arc_unit(x1, y1, pt2.x, pt2.y) */ __pyx_v_pt2 = __pyx_f_9photutils_8geometry_4core_circle_segment_single2(__pyx_v_x2, __pyx_v_y2, __pyx_v_x3, __pyx_v_y3); /* "photutils/geometry/core.pyx":314 * pt2 = circle_segment_single2(x2, y2, x3, y3) * area = area_triangle(x1, y1, x2, y2, pt2.x, pt2.y) \ * + area_arc_unit(x1, y1, pt2.x, pt2.y) # <<<<<<<<<<<<<< * else: * area = area_arc_unit(x1, y1, x2, y2) */ __pyx_v_area = (__pyx_f_9photutils_8geometry_4core_area_triangle(__pyx_v_x1, __pyx_v_y1, __pyx_v_x2, __pyx_v_y2, __pyx_v_pt2.x, __pyx_v_pt2.y) + __pyx_f_9photutils_8geometry_4core_area_arc_unit(__pyx_v_x1, __pyx_v_y1, __pyx_v_pt2.x, __pyx_v_pt2.y)); /* "photutils/geometry/core.pyx":311 * area = area_triangle(x1, y1, x2, y2, pt1.x, pt1.y) \ * + area_arc_unit(x2, y2, pt1.x, pt1.y) * elif intersect23: # <<<<<<<<<<<<<< * pt2 = circle_segment_single2(x2, y2, x3, y3) * area = area_triangle(x1, y1, x2, y2, pt2.x, pt2.y) \ */ goto __pyx_L19; } /* "photutils/geometry/core.pyx":316 * + area_arc_unit(x1, y1, pt2.x, pt2.y) * else: * area = area_arc_unit(x1, y1, x2, y2) # <<<<<<<<<<<<<< * * elif on1: */ /*else*/ { __pyx_v_area = __pyx_f_9photutils_8geometry_4core_area_arc_unit(__pyx_v_x1, __pyx_v_y1, __pyx_v_x2, __pyx_v_y2); } __pyx_L19:; /* "photutils/geometry/core.pyx":296 * area = area_triangle(x1, y1, x2, y2, x3, y3) * * elif in2 or on2: # <<<<<<<<<<<<<< * # If vertex 1 or 2 are on the edge of the circle, then we use the dot * # product to vertex 3 to determine whether an intersection takes place. */ goto __pyx_L10; } /* "photutils/geometry/core.pyx":318 * area = area_arc_unit(x1, y1, x2, y2) * * elif on1: # <<<<<<<<<<<<<< * # The triangle is outside the circle * area = 0.0 */ __pyx_t_4 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_on1)); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__pyx_t_4) { /* "photutils/geometry/core.pyx":320 * elif on1: * # The triangle is outside the circle * area = 0.0 # <<<<<<<<<<<<<< * elif in1: * # Check for intersections of far side with circle */ __pyx_v_area = 0.0; /* "photutils/geometry/core.pyx":318 * area = area_arc_unit(x1, y1, x2, y2) * * elif on1: # <<<<<<<<<<<<<< * # The triangle is outside the circle * area = 0.0 */ goto __pyx_L10; } /* "photutils/geometry/core.pyx":321 * # The triangle is outside the circle * area = 0.0 * elif in1: # <<<<<<<<<<<<<< * # Check for intersections of far side with circle * inter = circle_segment(x2, y2, x3, y3) */ __pyx_t_4 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_in1)); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__pyx_t_4) { /* "photutils/geometry/core.pyx":323 * elif in1: * # Check for intersections of far side with circle * inter = circle_segment(x2, y2, x3, y3) # <<<<<<<<<<<<<< * pt1 = inter.p1 * pt2 = inter.p2 */ __pyx_v_inter = __pyx_f_9photutils_8geometry_4core_circle_segment(__pyx_v_x2, __pyx_v_y2, __pyx_v_x3, __pyx_v_y3); /* "photutils/geometry/core.pyx":324 * # Check for intersections of far side with circle * inter = circle_segment(x2, y2, x3, y3) * pt1 = inter.p1 # <<<<<<<<<<<<<< * pt2 = inter.p2 * pt3 = circle_segment_single2(x1, y1, x2, y2) */ __pyx_t_15 = __pyx_v_inter.p1; __pyx_v_pt1 = __pyx_t_15; /* "photutils/geometry/core.pyx":325 * inter = circle_segment(x2, y2, x3, y3) * pt1 = inter.p1 * pt2 = inter.p2 # <<<<<<<<<<<<<< * pt3 = circle_segment_single2(x1, y1, x2, y2) * pt4 = circle_segment_single2(x1, y1, x3, y3) */ __pyx_t_15 = __pyx_v_inter.p2; __pyx_v_pt2 = __pyx_t_15; /* "photutils/geometry/core.pyx":326 * pt1 = inter.p1 * pt2 = inter.p2 * pt3 = circle_segment_single2(x1, y1, x2, y2) # <<<<<<<<<<<<<< * pt4 = circle_segment_single2(x1, y1, x3, y3) * if pt1.x > 1.: # indicates no intersection */ __pyx_v_pt3 = __pyx_f_9photutils_8geometry_4core_circle_segment_single2(__pyx_v_x1, __pyx_v_y1, __pyx_v_x2, __pyx_v_y2); /* "photutils/geometry/core.pyx":327 * pt2 = inter.p2 * pt3 = circle_segment_single2(x1, y1, x2, y2) * pt4 = circle_segment_single2(x1, y1, x3, y3) # <<<<<<<<<<<<<< * if pt1.x > 1.: # indicates no intersection * # Code taken from `sep.h`. */ __pyx_v_pt4 = __pyx_f_9photutils_8geometry_4core_circle_segment_single2(__pyx_v_x1, __pyx_v_y1, __pyx_v_x3, __pyx_v_y3); /* "photutils/geometry/core.pyx":328 * pt3 = circle_segment_single2(x1, y1, x2, y2) * pt4 = circle_segment_single2(x1, y1, x3, y3) * if pt1.x > 1.: # indicates no intersection # <<<<<<<<<<<<<< * # Code taken from `sep.h`. * # TODO: use `sep` and get rid of this Cython code. */ __pyx_t_4 = ((__pyx_v_pt1.x > 1.) != 0); if (__pyx_t_4) { /* "photutils/geometry/core.pyx":331 * # Code taken from `sep.h`. * # TODO: use `sep` and get rid of this Cython code. * if (((0.-pt3.y) * (pt4.x-pt3.x) > (pt4.y-pt3.y) * (0.-pt3.x)) != # <<<<<<<<<<<<<< * ((y1-pt3.y) * (pt4.x-pt3.x) > (pt4.y-pt3.y) * (x1-pt3.x))): * area = area_triangle(x1, y1, pt3.x, pt3.y, pt4.x, pt4.y) \ */ __pyx_t_4 = (((((0. - __pyx_v_pt3.y) * (__pyx_v_pt4.x - __pyx_v_pt3.x)) > ((__pyx_v_pt4.y - __pyx_v_pt3.y) * (0. - __pyx_v_pt3.x))) != (((__pyx_v_y1 - __pyx_v_pt3.y) * (__pyx_v_pt4.x - __pyx_v_pt3.x)) > ((__pyx_v_pt4.y - __pyx_v_pt3.y) * (__pyx_v_x1 - __pyx_v_pt3.x)))) != 0); if (__pyx_t_4) { /* "photutils/geometry/core.pyx":334 * ((y1-pt3.y) * (pt4.x-pt3.x) > (pt4.y-pt3.y) * (x1-pt3.x))): * area = area_triangle(x1, y1, pt3.x, pt3.y, pt4.x, pt4.y) \ * + (PI - area_arc_unit(pt3.x, pt3.y, pt4.x, pt4.y)) # <<<<<<<<<<<<<< * else: * area = area_triangle(x1, y1, pt3.x, pt3.y, pt4.x, pt4.y) \ */ __pyx_v_area = (__pyx_f_9photutils_8geometry_4core_area_triangle(__pyx_v_x1, __pyx_v_y1, __pyx_v_pt3.x, __pyx_v_pt3.y, __pyx_v_pt4.x, __pyx_v_pt4.y) + (__pyx_v_PI - __pyx_f_9photutils_8geometry_4core_area_arc_unit(__pyx_v_pt3.x, __pyx_v_pt3.y, __pyx_v_pt4.x, __pyx_v_pt4.y))); /* "photutils/geometry/core.pyx":331 * # Code taken from `sep.h`. * # TODO: use `sep` and get rid of this Cython code. * if (((0.-pt3.y) * (pt4.x-pt3.x) > (pt4.y-pt3.y) * (0.-pt3.x)) != # <<<<<<<<<<<<<< * ((y1-pt3.y) * (pt4.x-pt3.x) > (pt4.y-pt3.y) * (x1-pt3.x))): * area = area_triangle(x1, y1, pt3.x, pt3.y, pt4.x, pt4.y) \ */ goto __pyx_L24; } /* "photutils/geometry/core.pyx":337 * else: * area = area_triangle(x1, y1, pt3.x, pt3.y, pt4.x, pt4.y) \ * + area_arc_unit(pt3.x, pt3.y, pt4.x, pt4.y) # <<<<<<<<<<<<<< * else: * if (pt2.x - x2)**2 + (pt2.y - y2)**2 < (pt1.x - x2)**2 + (pt1.y - y2)**2: */ /*else*/ { /* "photutils/geometry/core.pyx":336 * + (PI - area_arc_unit(pt3.x, pt3.y, pt4.x, pt4.y)) * else: * area = area_triangle(x1, y1, pt3.x, pt3.y, pt4.x, pt4.y) \ # <<<<<<<<<<<<<< * + area_arc_unit(pt3.x, pt3.y, pt4.x, pt4.y) * else: */ __pyx_v_area = (__pyx_f_9photutils_8geometry_4core_area_triangle(__pyx_v_x1, __pyx_v_y1, __pyx_v_pt3.x, __pyx_v_pt3.y, __pyx_v_pt4.x, __pyx_v_pt4.y) + __pyx_f_9photutils_8geometry_4core_area_arc_unit(__pyx_v_pt3.x, __pyx_v_pt3.y, __pyx_v_pt4.x, __pyx_v_pt4.y)); } __pyx_L24:; /* "photutils/geometry/core.pyx":328 * pt3 = circle_segment_single2(x1, y1, x2, y2) * pt4 = circle_segment_single2(x1, y1, x3, y3) * if pt1.x > 1.: # indicates no intersection # <<<<<<<<<<<<<< * # Code taken from `sep.h`. * # TODO: use `sep` and get rid of this Cython code. */ goto __pyx_L23; } /* "photutils/geometry/core.pyx":339 * + area_arc_unit(pt3.x, pt3.y, pt4.x, pt4.y) * else: * if (pt2.x - x2)**2 + (pt2.y - y2)**2 < (pt1.x - x2)**2 + (pt1.y - y2)**2: # <<<<<<<<<<<<<< * pt1, pt2 = pt2, pt1 * area = area_triangle(x1, y1, pt3.x, pt3.y, pt1.x, pt1.y) \ */ /*else*/ { __pyx_t_4 = (((pow((__pyx_v_pt2.x - __pyx_v_x2), 2.0) + pow((__pyx_v_pt2.y - __pyx_v_y2), 2.0)) < (pow((__pyx_v_pt1.x - __pyx_v_x2), 2.0) + pow((__pyx_v_pt1.y - __pyx_v_y2), 2.0))) != 0); if (__pyx_t_4) { /* "photutils/geometry/core.pyx":340 * else: * if (pt2.x - x2)**2 + (pt2.y - y2)**2 < (pt1.x - x2)**2 + (pt1.y - y2)**2: * pt1, pt2 = pt2, pt1 # <<<<<<<<<<<<<< * area = area_triangle(x1, y1, pt3.x, pt3.y, pt1.x, pt1.y) \ * + area_triangle(x1, y1, pt1.x, pt1.y, pt2.x, pt2.y) \ */ __pyx_t_15 = __pyx_v_pt2; __pyx_t_16 = __pyx_v_pt1; __pyx_v_pt1 = __pyx_t_15; __pyx_v_pt2 = __pyx_t_16; /* "photutils/geometry/core.pyx":339 * + area_arc_unit(pt3.x, pt3.y, pt4.x, pt4.y) * else: * if (pt2.x - x2)**2 + (pt2.y - y2)**2 < (pt1.x - x2)**2 + (pt1.y - y2)**2: # <<<<<<<<<<<<<< * pt1, pt2 = pt2, pt1 * area = area_triangle(x1, y1, pt3.x, pt3.y, pt1.x, pt1.y) \ */ } /* "photutils/geometry/core.pyx":345 * + area_triangle(x1, y1, pt2.x, pt2.y, pt4.x, pt4.y) \ * + area_arc_unit(pt1.x, pt1.y, pt3.x, pt3.y) \ * + area_arc_unit(pt2.x, pt2.y, pt4.x, pt4.y) # <<<<<<<<<<<<<< * else: * inter = circle_segment(x1, y1, x2, y2) */ __pyx_v_area = ((((__pyx_f_9photutils_8geometry_4core_area_triangle(__pyx_v_x1, __pyx_v_y1, __pyx_v_pt3.x, __pyx_v_pt3.y, __pyx_v_pt1.x, __pyx_v_pt1.y) + __pyx_f_9photutils_8geometry_4core_area_triangle(__pyx_v_x1, __pyx_v_y1, __pyx_v_pt1.x, __pyx_v_pt1.y, __pyx_v_pt2.x, __pyx_v_pt2.y)) + __pyx_f_9photutils_8geometry_4core_area_triangle(__pyx_v_x1, __pyx_v_y1, __pyx_v_pt2.x, __pyx_v_pt2.y, __pyx_v_pt4.x, __pyx_v_pt4.y)) + __pyx_f_9photutils_8geometry_4core_area_arc_unit(__pyx_v_pt1.x, __pyx_v_pt1.y, __pyx_v_pt3.x, __pyx_v_pt3.y)) + __pyx_f_9photutils_8geometry_4core_area_arc_unit(__pyx_v_pt2.x, __pyx_v_pt2.y, __pyx_v_pt4.x, __pyx_v_pt4.y)); } __pyx_L23:; /* "photutils/geometry/core.pyx":321 * # The triangle is outside the circle * area = 0.0 * elif in1: # <<<<<<<<<<<<<< * # Check for intersections of far side with circle * inter = circle_segment(x2, y2, x3, y3) */ goto __pyx_L10; } /* "photutils/geometry/core.pyx":347 * + area_arc_unit(pt2.x, pt2.y, pt4.x, pt4.y) * else: * inter = circle_segment(x1, y1, x2, y2) # <<<<<<<<<<<<<< * pt1 = inter.p1 * pt2 = inter.p2 */ /*else*/ { __pyx_v_inter = __pyx_f_9photutils_8geometry_4core_circle_segment(__pyx_v_x1, __pyx_v_y1, __pyx_v_x2, __pyx_v_y2); /* "photutils/geometry/core.pyx":348 * else: * inter = circle_segment(x1, y1, x2, y2) * pt1 = inter.p1 # <<<<<<<<<<<<<< * pt2 = inter.p2 * inter = circle_segment(x2, y2, x3, y3) */ __pyx_t_16 = __pyx_v_inter.p1; __pyx_v_pt1 = __pyx_t_16; /* "photutils/geometry/core.pyx":349 * inter = circle_segment(x1, y1, x2, y2) * pt1 = inter.p1 * pt2 = inter.p2 # <<<<<<<<<<<<<< * inter = circle_segment(x2, y2, x3, y3) * pt3 = inter.p1 */ __pyx_t_16 = __pyx_v_inter.p2; __pyx_v_pt2 = __pyx_t_16; /* "photutils/geometry/core.pyx":350 * pt1 = inter.p1 * pt2 = inter.p2 * inter = circle_segment(x2, y2, x3, y3) # <<<<<<<<<<<<<< * pt3 = inter.p1 * pt4 = inter.p2 */ __pyx_v_inter = __pyx_f_9photutils_8geometry_4core_circle_segment(__pyx_v_x2, __pyx_v_y2, __pyx_v_x3, __pyx_v_y3); /* "photutils/geometry/core.pyx":351 * pt2 = inter.p2 * inter = circle_segment(x2, y2, x3, y3) * pt3 = inter.p1 # <<<<<<<<<<<<<< * pt4 = inter.p2 * inter = circle_segment(x3, y3, x1, y1) */ __pyx_t_16 = __pyx_v_inter.p1; __pyx_v_pt3 = __pyx_t_16; /* "photutils/geometry/core.pyx":352 * inter = circle_segment(x2, y2, x3, y3) * pt3 = inter.p1 * pt4 = inter.p2 # <<<<<<<<<<<<<< * inter = circle_segment(x3, y3, x1, y1) * pt5 = inter.p1 */ __pyx_t_16 = __pyx_v_inter.p2; __pyx_v_pt4 = __pyx_t_16; /* "photutils/geometry/core.pyx":353 * pt3 = inter.p1 * pt4 = inter.p2 * inter = circle_segment(x3, y3, x1, y1) # <<<<<<<<<<<<<< * pt5 = inter.p1 * pt6 = inter.p2 */ __pyx_v_inter = __pyx_f_9photutils_8geometry_4core_circle_segment(__pyx_v_x3, __pyx_v_y3, __pyx_v_x1, __pyx_v_y1); /* "photutils/geometry/core.pyx":354 * pt4 = inter.p2 * inter = circle_segment(x3, y3, x1, y1) * pt5 = inter.p1 # <<<<<<<<<<<<<< * pt6 = inter.p2 * if pt1.x <= 1.: */ __pyx_t_16 = __pyx_v_inter.p1; __pyx_v_pt5 = __pyx_t_16; /* "photutils/geometry/core.pyx":355 * inter = circle_segment(x3, y3, x1, y1) * pt5 = inter.p1 * pt6 = inter.p2 # <<<<<<<<<<<<<< * if pt1.x <= 1.: * xp, yp = 0.5 * (pt1.x + pt2.x), 0.5 * (pt1.y + pt2.y) */ __pyx_t_16 = __pyx_v_inter.p2; __pyx_v_pt6 = __pyx_t_16; /* "photutils/geometry/core.pyx":356 * pt5 = inter.p1 * pt6 = inter.p2 * if pt1.x <= 1.: # <<<<<<<<<<<<<< * xp, yp = 0.5 * (pt1.x + pt2.x), 0.5 * (pt1.y + pt2.y) * area = overlap_area_triangle_unit_circle(x1, y1, x3, y3, xp, yp) \ */ __pyx_t_4 = ((__pyx_v_pt1.x <= 1.) != 0); if (__pyx_t_4) { /* "photutils/geometry/core.pyx":357 * pt6 = inter.p2 * if pt1.x <= 1.: * xp, yp = 0.5 * (pt1.x + pt2.x), 0.5 * (pt1.y + pt2.y) # <<<<<<<<<<<<<< * area = overlap_area_triangle_unit_circle(x1, y1, x3, y3, xp, yp) \ * + overlap_area_triangle_unit_circle(x2, y2, x3, y3, xp, yp) */ __pyx_t_6 = (0.5 * (__pyx_v_pt1.x + __pyx_v_pt2.x)); __pyx_t_5 = (0.5 * (__pyx_v_pt1.y + __pyx_v_pt2.y)); __pyx_v_xp = __pyx_t_6; __pyx_v_yp = __pyx_t_5; /* "photutils/geometry/core.pyx":359 * xp, yp = 0.5 * (pt1.x + pt2.x), 0.5 * (pt1.y + pt2.y) * area = overlap_area_triangle_unit_circle(x1, y1, x3, y3, xp, yp) \ * + overlap_area_triangle_unit_circle(x2, y2, x3, y3, xp, yp) # <<<<<<<<<<<<<< * elif pt3.x <= 1.: * xp, yp = 0.5 * (pt3.x + pt4.x), 0.5 * (pt3.y + pt4.y) */ __pyx_v_area = (__pyx_f_9photutils_8geometry_4core_overlap_area_triangle_unit_circle(__pyx_v_x1, __pyx_v_y1, __pyx_v_x3, __pyx_v_y3, __pyx_v_xp, __pyx_v_yp) + __pyx_f_9photutils_8geometry_4core_overlap_area_triangle_unit_circle(__pyx_v_x2, __pyx_v_y2, __pyx_v_x3, __pyx_v_y3, __pyx_v_xp, __pyx_v_yp)); /* "photutils/geometry/core.pyx":356 * pt5 = inter.p1 * pt6 = inter.p2 * if pt1.x <= 1.: # <<<<<<<<<<<<<< * xp, yp = 0.5 * (pt1.x + pt2.x), 0.5 * (pt1.y + pt2.y) * area = overlap_area_triangle_unit_circle(x1, y1, x3, y3, xp, yp) \ */ goto __pyx_L26; } /* "photutils/geometry/core.pyx":360 * area = overlap_area_triangle_unit_circle(x1, y1, x3, y3, xp, yp) \ * + overlap_area_triangle_unit_circle(x2, y2, x3, y3, xp, yp) * elif pt3.x <= 1.: # <<<<<<<<<<<<<< * xp, yp = 0.5 * (pt3.x + pt4.x), 0.5 * (pt3.y + pt4.y) * area = overlap_area_triangle_unit_circle(x3, y3, x1, y1, xp, yp) \ */ __pyx_t_4 = ((__pyx_v_pt3.x <= 1.) != 0); if (__pyx_t_4) { /* "photutils/geometry/core.pyx":361 * + overlap_area_triangle_unit_circle(x2, y2, x3, y3, xp, yp) * elif pt3.x <= 1.: * xp, yp = 0.5 * (pt3.x + pt4.x), 0.5 * (pt3.y + pt4.y) # <<<<<<<<<<<<<< * area = overlap_area_triangle_unit_circle(x3, y3, x1, y1, xp, yp) \ * + overlap_area_triangle_unit_circle(x2, y2, x1, y1, xp, yp) */ __pyx_t_5 = (0.5 * (__pyx_v_pt3.x + __pyx_v_pt4.x)); __pyx_t_6 = (0.5 * (__pyx_v_pt3.y + __pyx_v_pt4.y)); __pyx_v_xp = __pyx_t_5; __pyx_v_yp = __pyx_t_6; /* "photutils/geometry/core.pyx":363 * xp, yp = 0.5 * (pt3.x + pt4.x), 0.5 * (pt3.y + pt4.y) * area = overlap_area_triangle_unit_circle(x3, y3, x1, y1, xp, yp) \ * + overlap_area_triangle_unit_circle(x2, y2, x1, y1, xp, yp) # <<<<<<<<<<<<<< * elif pt5.x <= 1.: * xp, yp = 0.5 * (pt5.x + pt6.x), 0.5 * (pt5.y + pt6.y) */ __pyx_v_area = (__pyx_f_9photutils_8geometry_4core_overlap_area_triangle_unit_circle(__pyx_v_x3, __pyx_v_y3, __pyx_v_x1, __pyx_v_y1, __pyx_v_xp, __pyx_v_yp) + __pyx_f_9photutils_8geometry_4core_overlap_area_triangle_unit_circle(__pyx_v_x2, __pyx_v_y2, __pyx_v_x1, __pyx_v_y1, __pyx_v_xp, __pyx_v_yp)); /* "photutils/geometry/core.pyx":360 * area = overlap_area_triangle_unit_circle(x1, y1, x3, y3, xp, yp) \ * + overlap_area_triangle_unit_circle(x2, y2, x3, y3, xp, yp) * elif pt3.x <= 1.: # <<<<<<<<<<<<<< * xp, yp = 0.5 * (pt3.x + pt4.x), 0.5 * (pt3.y + pt4.y) * area = overlap_area_triangle_unit_circle(x3, y3, x1, y1, xp, yp) \ */ goto __pyx_L26; } /* "photutils/geometry/core.pyx":364 * area = overlap_area_triangle_unit_circle(x3, y3, x1, y1, xp, yp) \ * + overlap_area_triangle_unit_circle(x2, y2, x1, y1, xp, yp) * elif pt5.x <= 1.: # <<<<<<<<<<<<<< * xp, yp = 0.5 * (pt5.x + pt6.x), 0.5 * (pt5.y + pt6.y) * area = overlap_area_triangle_unit_circle(x1, y1, x2, y2, xp, yp) \ */ __pyx_t_4 = ((__pyx_v_pt5.x <= 1.) != 0); if (__pyx_t_4) { /* "photutils/geometry/core.pyx":365 * + overlap_area_triangle_unit_circle(x2, y2, x1, y1, xp, yp) * elif pt5.x <= 1.: * xp, yp = 0.5 * (pt5.x + pt6.x), 0.5 * (pt5.y + pt6.y) # <<<<<<<<<<<<<< * area = overlap_area_triangle_unit_circle(x1, y1, x2, y2, xp, yp) \ * + overlap_area_triangle_unit_circle(x3, y3, x2, y2, xp, yp) */ __pyx_t_6 = (0.5 * (__pyx_v_pt5.x + __pyx_v_pt6.x)); __pyx_t_5 = (0.5 * (__pyx_v_pt5.y + __pyx_v_pt6.y)); __pyx_v_xp = __pyx_t_6; __pyx_v_yp = __pyx_t_5; /* "photutils/geometry/core.pyx":367 * xp, yp = 0.5 * (pt5.x + pt6.x), 0.5 * (pt5.y + pt6.y) * area = overlap_area_triangle_unit_circle(x1, y1, x2, y2, xp, yp) \ * + overlap_area_triangle_unit_circle(x3, y3, x2, y2, xp, yp) # <<<<<<<<<<<<<< * else: # no intersections * if in_triangle(0., 0., x1, y1, x2, y2, x3, y3): */ __pyx_v_area = (__pyx_f_9photutils_8geometry_4core_overlap_area_triangle_unit_circle(__pyx_v_x1, __pyx_v_y1, __pyx_v_x2, __pyx_v_y2, __pyx_v_xp, __pyx_v_yp) + __pyx_f_9photutils_8geometry_4core_overlap_area_triangle_unit_circle(__pyx_v_x3, __pyx_v_y3, __pyx_v_x2, __pyx_v_y2, __pyx_v_xp, __pyx_v_yp)); /* "photutils/geometry/core.pyx":364 * area = overlap_area_triangle_unit_circle(x3, y3, x1, y1, xp, yp) \ * + overlap_area_triangle_unit_circle(x2, y2, x1, y1, xp, yp) * elif pt5.x <= 1.: # <<<<<<<<<<<<<< * xp, yp = 0.5 * (pt5.x + pt6.x), 0.5 * (pt5.y + pt6.y) * area = overlap_area_triangle_unit_circle(x1, y1, x2, y2, xp, yp) \ */ goto __pyx_L26; } /* "photutils/geometry/core.pyx":369 * + overlap_area_triangle_unit_circle(x3, y3, x2, y2, xp, yp) * else: # no intersections * if in_triangle(0., 0., x1, y1, x2, y2, x3, y3): # <<<<<<<<<<<<<< * return PI * else: */ /*else*/ { __pyx_t_4 = (__pyx_f_9photutils_8geometry_4core_in_triangle(0., 0., __pyx_v_x1, __pyx_v_y1, __pyx_v_x2, __pyx_v_y2, __pyx_v_x3, __pyx_v_y3) != 0); if (__pyx_t_4) { /* "photutils/geometry/core.pyx":370 * else: # no intersections * if in_triangle(0., 0., x1, y1, x2, y2, x3, y3): * return PI # <<<<<<<<<<<<<< * else: * return 0. */ __pyx_r = __pyx_v_PI; goto __pyx_L0; /* "photutils/geometry/core.pyx":369 * + overlap_area_triangle_unit_circle(x3, y3, x2, y2, xp, yp) * else: # no intersections * if in_triangle(0., 0., x1, y1, x2, y2, x3, y3): # <<<<<<<<<<<<<< * return PI * else: */ } /* "photutils/geometry/core.pyx":372 * return PI * else: * return 0. # <<<<<<<<<<<<<< * * return area */ /*else*/ { __pyx_r = 0.; goto __pyx_L0; } } __pyx_L26:; } __pyx_L10:; /* "photutils/geometry/core.pyx":374 * return 0. * * return area # <<<<<<<<<<<<<< */ __pyx_r = __pyx_v_area; goto __pyx_L0; /* "photutils/geometry/core.pyx":243 * * * cdef double overlap_area_triangle_unit_circle(double x1, double y1, double x2, double y2, double x3, double y3): # <<<<<<<<<<<<<< * """ * Given a triangle defined by three points (x1, y1), (x2, y2), and */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_WriteUnraisable("photutils.geometry.core.overlap_area_triangle_unit_circle", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF((PyObject *)__pyx_v_in1); __Pyx_XDECREF((PyObject *)__pyx_v_in2); __Pyx_XDECREF((PyObject *)__pyx_v_in3); __Pyx_XDECREF((PyObject *)__pyx_v_on1); __Pyx_XDECREF((PyObject *)__pyx_v_on2); __Pyx_XDECREF((PyObject *)__pyx_v_on3); __Pyx_XDECREF(__pyx_v_intersect13); __Pyx_XDECREF(__pyx_v_intersect23); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":197 * # experimental exception made for __getbuffer__ and __releasebuffer__ * # -- the details of this may change. * def __getbuffer__(ndarray self, Py_buffer* info, int flags): # <<<<<<<<<<<<<< * # This implementation of getbuffer is geared towards Cython * # requirements, and does not yet fullfill the PEP. */ /* Python wrapper */ static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/ static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0); __pyx_r = __pyx_pf_5numpy_7ndarray___getbuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { int __pyx_v_copy_shape; int __pyx_v_i; int __pyx_v_ndim; int __pyx_v_endian_detector; int __pyx_v_little_endian; int __pyx_v_t; char *__pyx_v_f; PyArray_Descr *__pyx_v_descr = 0; int __pyx_v_offset; int __pyx_v_hasfields; int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; PyObject *__pyx_t_3 = NULL; int __pyx_t_4; int __pyx_t_5; PyObject *__pyx_t_6 = NULL; char *__pyx_t_7; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__getbuffer__", 0); if (__pyx_v_info != NULL) { __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None); __Pyx_GIVEREF(__pyx_v_info->obj); } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":203 * # of flags * * if info == NULL: return # <<<<<<<<<<<<<< * * cdef int copy_shape, i, ndim */ __pyx_t_1 = ((__pyx_v_info == NULL) != 0); if (__pyx_t_1) { __pyx_r = 0; goto __pyx_L0; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":206 * * cdef int copy_shape, i, ndim * cdef int endian_detector = 1 # <<<<<<<<<<<<<< * cdef bint little_endian = ((&endian_detector)[0] != 0) * */ __pyx_v_endian_detector = 1; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":207 * cdef int copy_shape, i, ndim * cdef int endian_detector = 1 * cdef bint little_endian = ((&endian_detector)[0] != 0) # <<<<<<<<<<<<<< * * ndim = PyArray_NDIM(self) */ __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":209 * cdef bint little_endian = ((&endian_detector)[0] != 0) * * ndim = PyArray_NDIM(self) # <<<<<<<<<<<<<< * * if sizeof(npy_intp) != sizeof(Py_ssize_t): */ __pyx_v_ndim = PyArray_NDIM(__pyx_v_self); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":211 * ndim = PyArray_NDIM(self) * * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< * copy_shape = 1 * else: */ __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0); if (__pyx_t_1) { /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":212 * * if sizeof(npy_intp) != sizeof(Py_ssize_t): * copy_shape = 1 # <<<<<<<<<<<<<< * else: * copy_shape = 0 */ __pyx_v_copy_shape = 1; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":211 * ndim = PyArray_NDIM(self) * * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< * copy_shape = 1 * else: */ goto __pyx_L4; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":214 * copy_shape = 1 * else: * copy_shape = 0 # <<<<<<<<<<<<<< * * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) */ /*else*/ { __pyx_v_copy_shape = 0; } __pyx_L4:; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":216 * copy_shape = 0 * * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): * raise ValueError(u"ndarray is not C contiguous") */ __pyx_t_2 = (((__pyx_v_flags & PyBUF_C_CONTIGUOUS) == PyBUF_C_CONTIGUOUS) != 0); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L6_bool_binop_done; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":217 * * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): # <<<<<<<<<<<<<< * raise ValueError(u"ndarray is not C contiguous") * */ __pyx_t_2 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_C_CONTIGUOUS) != 0)) != 0); __pyx_t_1 = __pyx_t_2; __pyx_L6_bool_binop_done:; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":216 * copy_shape = 0 * * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): * raise ValueError(u"ndarray is not C contiguous") */ if (__pyx_t_1) { /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":218 * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<< * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) */ __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; {__pyx_filename = __pyx_f[1]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":216 * copy_shape = 0 * * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): * raise ValueError(u"ndarray is not C contiguous") */ } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":220 * raise ValueError(u"ndarray is not C contiguous") * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): * raise ValueError(u"ndarray is not Fortran contiguous") */ __pyx_t_2 = (((__pyx_v_flags & PyBUF_F_CONTIGUOUS) == PyBUF_F_CONTIGUOUS) != 0); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L9_bool_binop_done; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":221 * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): # <<<<<<<<<<<<<< * raise ValueError(u"ndarray is not Fortran contiguous") * */ __pyx_t_2 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_F_CONTIGUOUS) != 0)) != 0); __pyx_t_1 = __pyx_t_2; __pyx_L9_bool_binop_done:; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":220 * raise ValueError(u"ndarray is not C contiguous") * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): * raise ValueError(u"ndarray is not Fortran contiguous") */ if (__pyx_t_1) { /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":222 * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<< * * info.buf = PyArray_DATA(self) */ __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; {__pyx_filename = __pyx_f[1]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":220 * raise ValueError(u"ndarray is not C contiguous") * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): * raise ValueError(u"ndarray is not Fortran contiguous") */ } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":224 * raise ValueError(u"ndarray is not Fortran contiguous") * * info.buf = PyArray_DATA(self) # <<<<<<<<<<<<<< * info.ndim = ndim * if copy_shape: */ __pyx_v_info->buf = PyArray_DATA(__pyx_v_self); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":225 * * info.buf = PyArray_DATA(self) * info.ndim = ndim # <<<<<<<<<<<<<< * if copy_shape: * # Allocate new buffer for strides and shape info. */ __pyx_v_info->ndim = __pyx_v_ndim; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":226 * info.buf = PyArray_DATA(self) * info.ndim = ndim * if copy_shape: # <<<<<<<<<<<<<< * # Allocate new buffer for strides and shape info. * # This is allocated as one block, strides first. */ __pyx_t_1 = (__pyx_v_copy_shape != 0); if (__pyx_t_1) { /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":229 * # Allocate new buffer for strides and shape info. * # This is allocated as one block, strides first. * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) # <<<<<<<<<<<<<< * info.shape = info.strides + ndim * for i in range(ndim): */ __pyx_v_info->strides = ((Py_ssize_t *)malloc((((sizeof(Py_ssize_t)) * ((size_t)__pyx_v_ndim)) * 2))); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":230 * # This is allocated as one block, strides first. * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) * info.shape = info.strides + ndim # <<<<<<<<<<<<<< * for i in range(ndim): * info.strides[i] = PyArray_STRIDES(self)[i] */ __pyx_v_info->shape = (__pyx_v_info->strides + __pyx_v_ndim); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":231 * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) * info.shape = info.strides + ndim * for i in range(ndim): # <<<<<<<<<<<<<< * info.strides[i] = PyArray_STRIDES(self)[i] * info.shape[i] = PyArray_DIMS(self)[i] */ __pyx_t_4 = __pyx_v_ndim; for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) { __pyx_v_i = __pyx_t_5; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":232 * info.shape = info.strides + ndim * for i in range(ndim): * info.strides[i] = PyArray_STRIDES(self)[i] # <<<<<<<<<<<<<< * info.shape[i] = PyArray_DIMS(self)[i] * else: */ (__pyx_v_info->strides[__pyx_v_i]) = (PyArray_STRIDES(__pyx_v_self)[__pyx_v_i]); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":233 * for i in range(ndim): * info.strides[i] = PyArray_STRIDES(self)[i] * info.shape[i] = PyArray_DIMS(self)[i] # <<<<<<<<<<<<<< * else: * info.strides = PyArray_STRIDES(self) */ (__pyx_v_info->shape[__pyx_v_i]) = (PyArray_DIMS(__pyx_v_self)[__pyx_v_i]); } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":226 * info.buf = PyArray_DATA(self) * info.ndim = ndim * if copy_shape: # <<<<<<<<<<<<<< * # Allocate new buffer for strides and shape info. * # This is allocated as one block, strides first. */ goto __pyx_L11; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":235 * info.shape[i] = PyArray_DIMS(self)[i] * else: * info.strides = PyArray_STRIDES(self) # <<<<<<<<<<<<<< * info.shape = PyArray_DIMS(self) * info.suboffsets = NULL */ /*else*/ { __pyx_v_info->strides = ((Py_ssize_t *)PyArray_STRIDES(__pyx_v_self)); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":236 * else: * info.strides = PyArray_STRIDES(self) * info.shape = PyArray_DIMS(self) # <<<<<<<<<<<<<< * info.suboffsets = NULL * info.itemsize = PyArray_ITEMSIZE(self) */ __pyx_v_info->shape = ((Py_ssize_t *)PyArray_DIMS(__pyx_v_self)); } __pyx_L11:; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":237 * info.strides = PyArray_STRIDES(self) * info.shape = PyArray_DIMS(self) * info.suboffsets = NULL # <<<<<<<<<<<<<< * info.itemsize = PyArray_ITEMSIZE(self) * info.readonly = not PyArray_ISWRITEABLE(self) */ __pyx_v_info->suboffsets = NULL; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":238 * info.shape = PyArray_DIMS(self) * info.suboffsets = NULL * info.itemsize = PyArray_ITEMSIZE(self) # <<<<<<<<<<<<<< * info.readonly = not PyArray_ISWRITEABLE(self) * */ __pyx_v_info->itemsize = PyArray_ITEMSIZE(__pyx_v_self); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":239 * info.suboffsets = NULL * info.itemsize = PyArray_ITEMSIZE(self) * info.readonly = not PyArray_ISWRITEABLE(self) # <<<<<<<<<<<<<< * * cdef int t */ __pyx_v_info->readonly = (!(PyArray_ISWRITEABLE(__pyx_v_self) != 0)); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":242 * * cdef int t * cdef char* f = NULL # <<<<<<<<<<<<<< * cdef dtype descr = self.descr * cdef int offset */ __pyx_v_f = NULL; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":243 * cdef int t * cdef char* f = NULL * cdef dtype descr = self.descr # <<<<<<<<<<<<<< * cdef int offset * */ __pyx_t_3 = ((PyObject *)__pyx_v_self->descr); __Pyx_INCREF(__pyx_t_3); __pyx_v_descr = ((PyArray_Descr *)__pyx_t_3); __pyx_t_3 = 0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":246 * cdef int offset * * cdef bint hasfields = PyDataType_HASFIELDS(descr) # <<<<<<<<<<<<<< * * if not hasfields and not copy_shape: */ __pyx_v_hasfields = PyDataType_HASFIELDS(__pyx_v_descr); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":248 * cdef bint hasfields = PyDataType_HASFIELDS(descr) * * if not hasfields and not copy_shape: # <<<<<<<<<<<<<< * # do not call releasebuffer * info.obj = None */ __pyx_t_2 = ((!(__pyx_v_hasfields != 0)) != 0); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L15_bool_binop_done; } __pyx_t_2 = ((!(__pyx_v_copy_shape != 0)) != 0); __pyx_t_1 = __pyx_t_2; __pyx_L15_bool_binop_done:; if (__pyx_t_1) { /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":250 * if not hasfields and not copy_shape: * # do not call releasebuffer * info.obj = None # <<<<<<<<<<<<<< * else: * # need to call releasebuffer */ __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_info->obj); __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = Py_None; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":248 * cdef bint hasfields = PyDataType_HASFIELDS(descr) * * if not hasfields and not copy_shape: # <<<<<<<<<<<<<< * # do not call releasebuffer * info.obj = None */ goto __pyx_L14; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":253 * else: * # need to call releasebuffer * info.obj = self # <<<<<<<<<<<<<< * * if not hasfields: */ /*else*/ { __Pyx_INCREF(((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); __Pyx_GOTREF(__pyx_v_info->obj); __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = ((PyObject *)__pyx_v_self); } __pyx_L14:; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":255 * info.obj = self * * if not hasfields: # <<<<<<<<<<<<<< * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or */ __pyx_t_1 = ((!(__pyx_v_hasfields != 0)) != 0); if (__pyx_t_1) { /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":256 * * if not hasfields: * t = descr.type_num # <<<<<<<<<<<<<< * if ((descr.byteorder == c'>' and little_endian) or * (descr.byteorder == c'<' and not little_endian)): */ __pyx_t_4 = __pyx_v_descr->type_num; __pyx_v_t = __pyx_t_4; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":257 * if not hasfields: * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< * (descr.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") */ __pyx_t_2 = ((__pyx_v_descr->byteorder == '>') != 0); if (!__pyx_t_2) { goto __pyx_L20_next_or; } else { } __pyx_t_2 = (__pyx_v_little_endian != 0); if (!__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L19_bool_binop_done; } __pyx_L20_next_or:; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":258 * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or * (descr.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<< * raise ValueError(u"Non-native byte order not supported") * if t == NPY_BYTE: f = "b" */ __pyx_t_2 = ((__pyx_v_descr->byteorder == '<') != 0); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L19_bool_binop_done; } __pyx_t_2 = ((!(__pyx_v_little_endian != 0)) != 0); __pyx_t_1 = __pyx_t_2; __pyx_L19_bool_binop_done:; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":257 * if not hasfields: * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< * (descr.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") */ if (__pyx_t_1) { /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":259 * if ((descr.byteorder == c'>' and little_endian) or * (descr.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< * if t == NPY_BYTE: f = "b" * elif t == NPY_UBYTE: f = "B" */ __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; {__pyx_filename = __pyx_f[1]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":257 * if not hasfields: * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< * (descr.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") */ } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":260 * (descr.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") * if t == NPY_BYTE: f = "b" # <<<<<<<<<<<<<< * elif t == NPY_UBYTE: f = "B" * elif t == NPY_SHORT: f = "h" */ switch (__pyx_v_t) { case NPY_BYTE: __pyx_v_f = __pyx_k_b; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":261 * raise ValueError(u"Non-native byte order not supported") * if t == NPY_BYTE: f = "b" * elif t == NPY_UBYTE: f = "B" # <<<<<<<<<<<<<< * elif t == NPY_SHORT: f = "h" * elif t == NPY_USHORT: f = "H" */ case NPY_UBYTE: __pyx_v_f = __pyx_k_B; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":262 * if t == NPY_BYTE: f = "b" * elif t == NPY_UBYTE: f = "B" * elif t == NPY_SHORT: f = "h" # <<<<<<<<<<<<<< * elif t == NPY_USHORT: f = "H" * elif t == NPY_INT: f = "i" */ case NPY_SHORT: __pyx_v_f = __pyx_k_h; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":263 * elif t == NPY_UBYTE: f = "B" * elif t == NPY_SHORT: f = "h" * elif t == NPY_USHORT: f = "H" # <<<<<<<<<<<<<< * elif t == NPY_INT: f = "i" * elif t == NPY_UINT: f = "I" */ case NPY_USHORT: __pyx_v_f = __pyx_k_H; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":264 * elif t == NPY_SHORT: f = "h" * elif t == NPY_USHORT: f = "H" * elif t == NPY_INT: f = "i" # <<<<<<<<<<<<<< * elif t == NPY_UINT: f = "I" * elif t == NPY_LONG: f = "l" */ case NPY_INT: __pyx_v_f = __pyx_k_i; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":265 * elif t == NPY_USHORT: f = "H" * elif t == NPY_INT: f = "i" * elif t == NPY_UINT: f = "I" # <<<<<<<<<<<<<< * elif t == NPY_LONG: f = "l" * elif t == NPY_ULONG: f = "L" */ case NPY_UINT: __pyx_v_f = __pyx_k_I; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":266 * elif t == NPY_INT: f = "i" * elif t == NPY_UINT: f = "I" * elif t == NPY_LONG: f = "l" # <<<<<<<<<<<<<< * elif t == NPY_ULONG: f = "L" * elif t == NPY_LONGLONG: f = "q" */ case NPY_LONG: __pyx_v_f = __pyx_k_l; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":267 * elif t == NPY_UINT: f = "I" * elif t == NPY_LONG: f = "l" * elif t == NPY_ULONG: f = "L" # <<<<<<<<<<<<<< * elif t == NPY_LONGLONG: f = "q" * elif t == NPY_ULONGLONG: f = "Q" */ case NPY_ULONG: __pyx_v_f = __pyx_k_L; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":268 * elif t == NPY_LONG: f = "l" * elif t == NPY_ULONG: f = "L" * elif t == NPY_LONGLONG: f = "q" # <<<<<<<<<<<<<< * elif t == NPY_ULONGLONG: f = "Q" * elif t == NPY_FLOAT: f = "f" */ case NPY_LONGLONG: __pyx_v_f = __pyx_k_q; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":269 * elif t == NPY_ULONG: f = "L" * elif t == NPY_LONGLONG: f = "q" * elif t == NPY_ULONGLONG: f = "Q" # <<<<<<<<<<<<<< * elif t == NPY_FLOAT: f = "f" * elif t == NPY_DOUBLE: f = "d" */ case NPY_ULONGLONG: __pyx_v_f = __pyx_k_Q; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":270 * elif t == NPY_LONGLONG: f = "q" * elif t == NPY_ULONGLONG: f = "Q" * elif t == NPY_FLOAT: f = "f" # <<<<<<<<<<<<<< * elif t == NPY_DOUBLE: f = "d" * elif t == NPY_LONGDOUBLE: f = "g" */ case NPY_FLOAT: __pyx_v_f = __pyx_k_f; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":271 * elif t == NPY_ULONGLONG: f = "Q" * elif t == NPY_FLOAT: f = "f" * elif t == NPY_DOUBLE: f = "d" # <<<<<<<<<<<<<< * elif t == NPY_LONGDOUBLE: f = "g" * elif t == NPY_CFLOAT: f = "Zf" */ case NPY_DOUBLE: __pyx_v_f = __pyx_k_d; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":272 * elif t == NPY_FLOAT: f = "f" * elif t == NPY_DOUBLE: f = "d" * elif t == NPY_LONGDOUBLE: f = "g" # <<<<<<<<<<<<<< * elif t == NPY_CFLOAT: f = "Zf" * elif t == NPY_CDOUBLE: f = "Zd" */ case NPY_LONGDOUBLE: __pyx_v_f = __pyx_k_g; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":273 * elif t == NPY_DOUBLE: f = "d" * elif t == NPY_LONGDOUBLE: f = "g" * elif t == NPY_CFLOAT: f = "Zf" # <<<<<<<<<<<<<< * elif t == NPY_CDOUBLE: f = "Zd" * elif t == NPY_CLONGDOUBLE: f = "Zg" */ case NPY_CFLOAT: __pyx_v_f = __pyx_k_Zf; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":274 * elif t == NPY_LONGDOUBLE: f = "g" * elif t == NPY_CFLOAT: f = "Zf" * elif t == NPY_CDOUBLE: f = "Zd" # <<<<<<<<<<<<<< * elif t == NPY_CLONGDOUBLE: f = "Zg" * elif t == NPY_OBJECT: f = "O" */ case NPY_CDOUBLE: __pyx_v_f = __pyx_k_Zd; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":275 * elif t == NPY_CFLOAT: f = "Zf" * elif t == NPY_CDOUBLE: f = "Zd" * elif t == NPY_CLONGDOUBLE: f = "Zg" # <<<<<<<<<<<<<< * elif t == NPY_OBJECT: f = "O" * else: */ case NPY_CLONGDOUBLE: __pyx_v_f = __pyx_k_Zg; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":276 * elif t == NPY_CDOUBLE: f = "Zd" * elif t == NPY_CLONGDOUBLE: f = "Zg" * elif t == NPY_OBJECT: f = "O" # <<<<<<<<<<<<<< * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) */ case NPY_OBJECT: __pyx_v_f = __pyx_k_O; break; default: /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":278 * elif t == NPY_OBJECT: f = "O" * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< * info.format = f * return */ __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_t); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = PyUnicode_Format(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_t_3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_6, 0, 0, 0); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; {__pyx_filename = __pyx_f[1]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L1_error;} break; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":279 * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) * info.format = f # <<<<<<<<<<<<<< * return * else: */ __pyx_v_info->format = __pyx_v_f; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":280 * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) * info.format = f * return # <<<<<<<<<<<<<< * else: * info.format = stdlib.malloc(_buffer_format_string_len) */ __pyx_r = 0; goto __pyx_L0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":255 * info.obj = self * * if not hasfields: # <<<<<<<<<<<<<< * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or */ } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":282 * return * else: * info.format = stdlib.malloc(_buffer_format_string_len) # <<<<<<<<<<<<<< * info.format[0] = c'^' # Native data types, manual alignment * offset = 0 */ /*else*/ { __pyx_v_info->format = ((char *)malloc(0xFF)); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":283 * else: * info.format = stdlib.malloc(_buffer_format_string_len) * info.format[0] = c'^' # Native data types, manual alignment # <<<<<<<<<<<<<< * offset = 0 * f = _util_dtypestring(descr, info.format + 1, */ (__pyx_v_info->format[0]) = '^'; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":284 * info.format = stdlib.malloc(_buffer_format_string_len) * info.format[0] = c'^' # Native data types, manual alignment * offset = 0 # <<<<<<<<<<<<<< * f = _util_dtypestring(descr, info.format + 1, * info.format + _buffer_format_string_len, */ __pyx_v_offset = 0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":285 * info.format[0] = c'^' # Native data types, manual alignment * offset = 0 * f = _util_dtypestring(descr, info.format + 1, # <<<<<<<<<<<<<< * info.format + _buffer_format_string_len, * &offset) */ __pyx_t_7 = __pyx_f_5numpy__util_dtypestring(__pyx_v_descr, (__pyx_v_info->format + 1), (__pyx_v_info->format + 0xFF), (&__pyx_v_offset)); if (unlikely(__pyx_t_7 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_f = __pyx_t_7; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":288 * info.format + _buffer_format_string_len, * &offset) * f[0] = c'\0' # Terminate format string # <<<<<<<<<<<<<< * * def __releasebuffer__(ndarray self, Py_buffer* info): */ (__pyx_v_f[0]) = '\x00'; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":197 * # experimental exception made for __getbuffer__ and __releasebuffer__ * # -- the details of this may change. * def __getbuffer__(ndarray self, Py_buffer* info, int flags): # <<<<<<<<<<<<<< * # This implementation of getbuffer is geared towards Cython * # requirements, and does not yet fullfill the PEP. */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_6); __Pyx_AddTraceback("numpy.ndarray.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; if (__pyx_v_info != NULL && __pyx_v_info->obj != NULL) { __Pyx_GOTREF(__pyx_v_info->obj); __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = NULL; } goto __pyx_L2; __pyx_L0:; if (__pyx_v_info != NULL && __pyx_v_info->obj == Py_None) { __Pyx_GOTREF(Py_None); __Pyx_DECREF(Py_None); __pyx_v_info->obj = NULL; } __pyx_L2:; __Pyx_XDECREF((PyObject *)__pyx_v_descr); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":290 * f[0] = c'\0' # Terminate format string * * def __releasebuffer__(ndarray self, Py_buffer* info): # <<<<<<<<<<<<<< * if PyArray_HASFIELDS(self): * stdlib.free(info.format) */ /* Python wrapper */ static CYTHON_UNUSED void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info); /*proto*/ static CYTHON_UNUSED void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__releasebuffer__ (wrapper)", 0); __pyx_pf_5numpy_7ndarray_2__releasebuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info)); /* function exit code */ __Pyx_RefNannyFinishContext(); } static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info) { __Pyx_RefNannyDeclarations int __pyx_t_1; __Pyx_RefNannySetupContext("__releasebuffer__", 0); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":291 * * def __releasebuffer__(ndarray self, Py_buffer* info): * if PyArray_HASFIELDS(self): # <<<<<<<<<<<<<< * stdlib.free(info.format) * if sizeof(npy_intp) != sizeof(Py_ssize_t): */ __pyx_t_1 = (PyArray_HASFIELDS(__pyx_v_self) != 0); if (__pyx_t_1) { /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":292 * def __releasebuffer__(ndarray self, Py_buffer* info): * if PyArray_HASFIELDS(self): * stdlib.free(info.format) # <<<<<<<<<<<<<< * if sizeof(npy_intp) != sizeof(Py_ssize_t): * stdlib.free(info.strides) */ free(__pyx_v_info->format); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":291 * * def __releasebuffer__(ndarray self, Py_buffer* info): * if PyArray_HASFIELDS(self): # <<<<<<<<<<<<<< * stdlib.free(info.format) * if sizeof(npy_intp) != sizeof(Py_ssize_t): */ } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":293 * if PyArray_HASFIELDS(self): * stdlib.free(info.format) * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< * stdlib.free(info.strides) * # info.shape was stored after info.strides in the same block */ __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0); if (__pyx_t_1) { /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":294 * stdlib.free(info.format) * if sizeof(npy_intp) != sizeof(Py_ssize_t): * stdlib.free(info.strides) # <<<<<<<<<<<<<< * # info.shape was stored after info.strides in the same block * */ free(__pyx_v_info->strides); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":293 * if PyArray_HASFIELDS(self): * stdlib.free(info.format) * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< * stdlib.free(info.strides) * # info.shape was stored after info.strides in the same block */ } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":290 * f[0] = c'\0' # Terminate format string * * def __releasebuffer__(ndarray self, Py_buffer* info): # <<<<<<<<<<<<<< * if PyArray_HASFIELDS(self): * stdlib.free(info.format) */ /* function exit code */ __Pyx_RefNannyFinishContext(); } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":770 * ctypedef npy_cdouble complex_t * * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< * return PyArray_MultiIterNew(1, a) * */ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__pyx_v_a) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("PyArray_MultiIterNew1", 0); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":771 * * cdef inline object PyArray_MultiIterNew1(a): * return PyArray_MultiIterNew(1, a) # <<<<<<<<<<<<<< * * cdef inline object PyArray_MultiIterNew2(a, b): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyArray_MultiIterNew(1, ((void *)__pyx_v_a)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 771; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":770 * ctypedef npy_cdouble complex_t * * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< * return PyArray_MultiIterNew(1, a) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("numpy.PyArray_MultiIterNew1", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":773 * return PyArray_MultiIterNew(1, a) * * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< * return PyArray_MultiIterNew(2, a, b) * */ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__pyx_v_a, PyObject *__pyx_v_b) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("PyArray_MultiIterNew2", 0); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":774 * * cdef inline object PyArray_MultiIterNew2(a, b): * return PyArray_MultiIterNew(2, a, b) # <<<<<<<<<<<<<< * * cdef inline object PyArray_MultiIterNew3(a, b, c): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyArray_MultiIterNew(2, ((void *)__pyx_v_a), ((void *)__pyx_v_b)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 774; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":773 * return PyArray_MultiIterNew(1, a) * * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< * return PyArray_MultiIterNew(2, a, b) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("numpy.PyArray_MultiIterNew2", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":776 * return PyArray_MultiIterNew(2, a, b) * * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< * return PyArray_MultiIterNew(3, a, b, c) * */ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("PyArray_MultiIterNew3", 0); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":777 * * cdef inline object PyArray_MultiIterNew3(a, b, c): * return PyArray_MultiIterNew(3, a, b, c) # <<<<<<<<<<<<<< * * cdef inline object PyArray_MultiIterNew4(a, b, c, d): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyArray_MultiIterNew(3, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 777; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":776 * return PyArray_MultiIterNew(2, a, b) * * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< * return PyArray_MultiIterNew(3, a, b, c) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("numpy.PyArray_MultiIterNew3", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":779 * return PyArray_MultiIterNew(3, a, b, c) * * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< * return PyArray_MultiIterNew(4, a, b, c, d) * */ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("PyArray_MultiIterNew4", 0); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":780 * * cdef inline object PyArray_MultiIterNew4(a, b, c, d): * return PyArray_MultiIterNew(4, a, b, c, d) # <<<<<<<<<<<<<< * * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyArray_MultiIterNew(4, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 780; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":779 * return PyArray_MultiIterNew(3, a, b, c) * * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< * return PyArray_MultiIterNew(4, a, b, c, d) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("numpy.PyArray_MultiIterNew4", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":782 * return PyArray_MultiIterNew(4, a, b, c, d) * * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< * return PyArray_MultiIterNew(5, a, b, c, d, e) * */ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d, PyObject *__pyx_v_e) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("PyArray_MultiIterNew5", 0); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":783 * * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): * return PyArray_MultiIterNew(5, a, b, c, d, e) # <<<<<<<<<<<<<< * * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyArray_MultiIterNew(5, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d), ((void *)__pyx_v_e)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 783; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":782 * return PyArray_MultiIterNew(4, a, b, c, d) * * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< * return PyArray_MultiIterNew(5, a, b, c, d, e) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("numpy.PyArray_MultiIterNew5", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":785 * return PyArray_MultiIterNew(5, a, b, c, d, e) * * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: # <<<<<<<<<<<<<< * # Recursive utility function used in __getbuffer__ to get format * # string. The new location in the format string is returned. */ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_descr, char *__pyx_v_f, char *__pyx_v_end, int *__pyx_v_offset) { PyArray_Descr *__pyx_v_child = 0; int __pyx_v_endian_detector; int __pyx_v_little_endian; PyObject *__pyx_v_fields = 0; PyObject *__pyx_v_childname = NULL; PyObject *__pyx_v_new_offset = NULL; PyObject *__pyx_v_t = NULL; char *__pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; Py_ssize_t __pyx_t_2; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; int __pyx_t_5; int __pyx_t_6; int __pyx_t_7; long __pyx_t_8; char *__pyx_t_9; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("_util_dtypestring", 0); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":790 * * cdef dtype child * cdef int endian_detector = 1 # <<<<<<<<<<<<<< * cdef bint little_endian = ((&endian_detector)[0] != 0) * cdef tuple fields */ __pyx_v_endian_detector = 1; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":791 * cdef dtype child * cdef int endian_detector = 1 * cdef bint little_endian = ((&endian_detector)[0] != 0) # <<<<<<<<<<<<<< * cdef tuple fields * */ __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":794 * cdef tuple fields * * for childname in descr.names: # <<<<<<<<<<<<<< * fields = descr.fields[childname] * child, new_offset = fields */ if (unlikely(__pyx_v_descr->names == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_t_1 = __pyx_v_descr->names; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; for (;;) { if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); #endif __Pyx_XDECREF_SET(__pyx_v_childname, __pyx_t_3); __pyx_t_3 = 0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":795 * * for childname in descr.names: * fields = descr.fields[childname] # <<<<<<<<<<<<<< * child, new_offset = fields * */ if (unlikely(__pyx_v_descr->fields == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_t_3 = __Pyx_PyDict_GetItem(__pyx_v_descr->fields, __pyx_v_childname); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; __Pyx_GOTREF(__pyx_t_3); if (!(likely(PyTuple_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_XDECREF_SET(__pyx_v_fields, ((PyObject*)__pyx_t_3)); __pyx_t_3 = 0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":796 * for childname in descr.names: * fields = descr.fields[childname] * child, new_offset = fields # <<<<<<<<<<<<<< * * if (end - f) - (new_offset - offset[0]) < 15: */ if (likely(__pyx_v_fields != Py_None)) { PyObject* sequence = __pyx_v_fields; #if CYTHON_COMPILING_IN_CPYTHON Py_ssize_t size = Py_SIZE(sequence); #else Py_ssize_t size = PySequence_Size(sequence); #endif if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); #else __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); #endif } else { __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_dtype))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_XDECREF_SET(__pyx_v_child, ((PyArray_Descr *)__pyx_t_3)); __pyx_t_3 = 0; __Pyx_XDECREF_SET(__pyx_v_new_offset, __pyx_t_4); __pyx_t_4 = 0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":798 * child, new_offset = fields * * if (end - f) - (new_offset - offset[0]) < 15: # <<<<<<<<<<<<<< * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") * */ __pyx_t_4 = __Pyx_PyInt_From_int((__pyx_v_offset[0])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyNumber_Subtract(__pyx_v_new_offset, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = ((((__pyx_v_end - __pyx_v_f) - ((int)__pyx_t_5)) < 15) != 0); if (__pyx_t_6) { /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":799 * * if (end - f) - (new_offset - offset[0]) < 15: * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<< * * if ((child.byteorder == c'>' and little_endian) or */ __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":798 * child, new_offset = fields * * if (end - f) - (new_offset - offset[0]) < 15: # <<<<<<<<<<<<<< * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") * */ } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":801 * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") * * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< * (child.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") */ __pyx_t_7 = ((__pyx_v_child->byteorder == '>') != 0); if (!__pyx_t_7) { goto __pyx_L8_next_or; } else { } __pyx_t_7 = (__pyx_v_little_endian != 0); if (!__pyx_t_7) { } else { __pyx_t_6 = __pyx_t_7; goto __pyx_L7_bool_binop_done; } __pyx_L8_next_or:; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":802 * * if ((child.byteorder == c'>' and little_endian) or * (child.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<< * raise ValueError(u"Non-native byte order not supported") * # One could encode it in the format string and have Cython */ __pyx_t_7 = ((__pyx_v_child->byteorder == '<') != 0); if (__pyx_t_7) { } else { __pyx_t_6 = __pyx_t_7; goto __pyx_L7_bool_binop_done; } __pyx_t_7 = ((!(__pyx_v_little_endian != 0)) != 0); __pyx_t_6 = __pyx_t_7; __pyx_L7_bool_binop_done:; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":801 * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") * * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< * (child.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") */ if (__pyx_t_6) { /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":803 * if ((child.byteorder == c'>' and little_endian) or * (child.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< * # One could encode it in the format string and have Cython * # complain instead, BUT: < and > in format strings also imply */ __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; {__pyx_filename = __pyx_f[1]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":801 * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") * * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< * (child.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") */ } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":813 * * # Output padding bytes * while offset[0] < new_offset: # <<<<<<<<<<<<<< * f[0] = 120 # "x"; pad byte * f += 1 */ while (1) { __pyx_t_3 = __Pyx_PyInt_From_int((__pyx_v_offset[0])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyObject_RichCompare(__pyx_t_3, __pyx_v_new_offset, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (!__pyx_t_6) break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":814 * # Output padding bytes * while offset[0] < new_offset: * f[0] = 120 # "x"; pad byte # <<<<<<<<<<<<<< * f += 1 * offset[0] += 1 */ (__pyx_v_f[0]) = 0x78; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":815 * while offset[0] < new_offset: * f[0] = 120 # "x"; pad byte * f += 1 # <<<<<<<<<<<<<< * offset[0] += 1 * */ __pyx_v_f = (__pyx_v_f + 1); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":816 * f[0] = 120 # "x"; pad byte * f += 1 * offset[0] += 1 # <<<<<<<<<<<<<< * * offset[0] += child.itemsize */ __pyx_t_8 = 0; (__pyx_v_offset[__pyx_t_8]) = ((__pyx_v_offset[__pyx_t_8]) + 1); } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":818 * offset[0] += 1 * * offset[0] += child.itemsize # <<<<<<<<<<<<<< * * if not PyDataType_HASFIELDS(child): */ __pyx_t_8 = 0; (__pyx_v_offset[__pyx_t_8]) = ((__pyx_v_offset[__pyx_t_8]) + __pyx_v_child->elsize); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":820 * offset[0] += child.itemsize * * if not PyDataType_HASFIELDS(child): # <<<<<<<<<<<<<< * t = child.type_num * if end - f < 5: */ __pyx_t_6 = ((!(PyDataType_HASFIELDS(__pyx_v_child) != 0)) != 0); if (__pyx_t_6) { /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":821 * * if not PyDataType_HASFIELDS(child): * t = child.type_num # <<<<<<<<<<<<<< * if end - f < 5: * raise RuntimeError(u"Format string allocated too short.") */ __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_child->type_num); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_4); __pyx_t_4 = 0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":822 * if not PyDataType_HASFIELDS(child): * t = child.type_num * if end - f < 5: # <<<<<<<<<<<<<< * raise RuntimeError(u"Format string allocated too short.") * */ __pyx_t_6 = (((__pyx_v_end - __pyx_v_f) < 5) != 0); if (__pyx_t_6) { /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":823 * t = child.type_num * if end - f < 5: * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<< * * # Until ticket #99 is fixed, use integers to avoid warnings */ __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; {__pyx_filename = __pyx_f[1]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":822 * if not PyDataType_HASFIELDS(child): * t = child.type_num * if end - f < 5: # <<<<<<<<<<<<<< * raise RuntimeError(u"Format string allocated too short.") * */ } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":826 * * # Until ticket #99 is fixed, use integers to avoid warnings * if t == NPY_BYTE: f[0] = 98 #"b" # <<<<<<<<<<<<<< * elif t == NPY_UBYTE: f[0] = 66 #"B" * elif t == NPY_SHORT: f[0] = 104 #"h" */ __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_BYTE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 98; goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":827 * # Until ticket #99 is fixed, use integers to avoid warnings * if t == NPY_BYTE: f[0] = 98 #"b" * elif t == NPY_UBYTE: f[0] = 66 #"B" # <<<<<<<<<<<<<< * elif t == NPY_SHORT: f[0] = 104 #"h" * elif t == NPY_USHORT: f[0] = 72 #"H" */ __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_UBYTE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 66; goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":828 * if t == NPY_BYTE: f[0] = 98 #"b" * elif t == NPY_UBYTE: f[0] = 66 #"B" * elif t == NPY_SHORT: f[0] = 104 #"h" # <<<<<<<<<<<<<< * elif t == NPY_USHORT: f[0] = 72 #"H" * elif t == NPY_INT: f[0] = 105 #"i" */ __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_SHORT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 0x68; goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":829 * elif t == NPY_UBYTE: f[0] = 66 #"B" * elif t == NPY_SHORT: f[0] = 104 #"h" * elif t == NPY_USHORT: f[0] = 72 #"H" # <<<<<<<<<<<<<< * elif t == NPY_INT: f[0] = 105 #"i" * elif t == NPY_UINT: f[0] = 73 #"I" */ __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_USHORT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 72; goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":830 * elif t == NPY_SHORT: f[0] = 104 #"h" * elif t == NPY_USHORT: f[0] = 72 #"H" * elif t == NPY_INT: f[0] = 105 #"i" # <<<<<<<<<<<<<< * elif t == NPY_UINT: f[0] = 73 #"I" * elif t == NPY_LONG: f[0] = 108 #"l" */ __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_INT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 0x69; goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":831 * elif t == NPY_USHORT: f[0] = 72 #"H" * elif t == NPY_INT: f[0] = 105 #"i" * elif t == NPY_UINT: f[0] = 73 #"I" # <<<<<<<<<<<<<< * elif t == NPY_LONG: f[0] = 108 #"l" * elif t == NPY_ULONG: f[0] = 76 #"L" */ __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_UINT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 73; goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":832 * elif t == NPY_INT: f[0] = 105 #"i" * elif t == NPY_UINT: f[0] = 73 #"I" * elif t == NPY_LONG: f[0] = 108 #"l" # <<<<<<<<<<<<<< * elif t == NPY_ULONG: f[0] = 76 #"L" * elif t == NPY_LONGLONG: f[0] = 113 #"q" */ __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONG); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 0x6C; goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":833 * elif t == NPY_UINT: f[0] = 73 #"I" * elif t == NPY_LONG: f[0] = 108 #"l" * elif t == NPY_ULONG: f[0] = 76 #"L" # <<<<<<<<<<<<<< * elif t == NPY_LONGLONG: f[0] = 113 #"q" * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" */ __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_ULONG); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 76; goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":834 * elif t == NPY_LONG: f[0] = 108 #"l" * elif t == NPY_ULONG: f[0] = 76 #"L" * elif t == NPY_LONGLONG: f[0] = 113 #"q" # <<<<<<<<<<<<<< * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" * elif t == NPY_FLOAT: f[0] = 102 #"f" */ __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONGLONG); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 0x71; goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":835 * elif t == NPY_ULONG: f[0] = 76 #"L" * elif t == NPY_LONGLONG: f[0] = 113 #"q" * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" # <<<<<<<<<<<<<< * elif t == NPY_FLOAT: f[0] = 102 #"f" * elif t == NPY_DOUBLE: f[0] = 100 #"d" */ __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_ULONGLONG); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 81; goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":836 * elif t == NPY_LONGLONG: f[0] = 113 #"q" * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" * elif t == NPY_FLOAT: f[0] = 102 #"f" # <<<<<<<<<<<<<< * elif t == NPY_DOUBLE: f[0] = 100 #"d" * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" */ __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_FLOAT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 0x66; goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":837 * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" * elif t == NPY_FLOAT: f[0] = 102 #"f" * elif t == NPY_DOUBLE: f[0] = 100 #"d" # <<<<<<<<<<<<<< * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf */ __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_DOUBLE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 0x64; goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":838 * elif t == NPY_FLOAT: f[0] = 102 #"f" * elif t == NPY_DOUBLE: f[0] = 100 #"d" * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" # <<<<<<<<<<<<<< * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd */ __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONGDOUBLE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 0x67; goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":839 * elif t == NPY_DOUBLE: f[0] = 100 #"d" * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf # <<<<<<<<<<<<<< * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg */ __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CFLOAT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 90; (__pyx_v_f[1]) = 0x66; __pyx_v_f = (__pyx_v_f + 1); goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":840 * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd # <<<<<<<<<<<<<< * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg * elif t == NPY_OBJECT: f[0] = 79 #"O" */ __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CDOUBLE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 90; (__pyx_v_f[1]) = 0x64; __pyx_v_f = (__pyx_v_f + 1); goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":841 * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg # <<<<<<<<<<<<<< * elif t == NPY_OBJECT: f[0] = 79 #"O" * else: */ __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CLONGDOUBLE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 90; (__pyx_v_f[1]) = 0x67; __pyx_v_f = (__pyx_v_f + 1); goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":842 * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg * elif t == NPY_OBJECT: f[0] = 79 #"O" # <<<<<<<<<<<<<< * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) */ __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_OBJECT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 79; goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":844 * elif t == NPY_OBJECT: f[0] = 79 #"O" * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< * f += 1 * else: */ /*else*/ { __pyx_t_3 = PyUnicode_Format(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_v_t); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; {__pyx_filename = __pyx_f[1]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_L15:; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":845 * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) * f += 1 # <<<<<<<<<<<<<< * else: * # Cython ignores struct boundary information ("T{...}"), */ __pyx_v_f = (__pyx_v_f + 1); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":820 * offset[0] += child.itemsize * * if not PyDataType_HASFIELDS(child): # <<<<<<<<<<<<<< * t = child.type_num * if end - f < 5: */ goto __pyx_L13; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":849 * # Cython ignores struct boundary information ("T{...}"), * # so don't output it * f = _util_dtypestring(child, f, end, offset) # <<<<<<<<<<<<<< * return f * */ /*else*/ { __pyx_t_9 = __pyx_f_5numpy__util_dtypestring(__pyx_v_child, __pyx_v_f, __pyx_v_end, __pyx_v_offset); if (unlikely(__pyx_t_9 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 849; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_f = __pyx_t_9; } __pyx_L13:; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":794 * cdef tuple fields * * for childname in descr.names: # <<<<<<<<<<<<<< * fields = descr.fields[childname] * child, new_offset = fields */ } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":850 * # so don't output it * f = _util_dtypestring(child, f, end, offset) * return f # <<<<<<<<<<<<<< * * */ __pyx_r = __pyx_v_f; goto __pyx_L0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":785 * return PyArray_MultiIterNew(5, a, b, c, d, e) * * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: # <<<<<<<<<<<<<< * # Recursive utility function used in __getbuffer__ to get format * # string. The new location in the format string is returned. */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("numpy._util_dtypestring", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF((PyObject *)__pyx_v_child); __Pyx_XDECREF(__pyx_v_fields); __Pyx_XDECREF(__pyx_v_childname); __Pyx_XDECREF(__pyx_v_new_offset); __Pyx_XDECREF(__pyx_v_t); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":966 * * * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< * cdef PyObject* baseptr * if base is None: */ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_arr, PyObject *__pyx_v_base) { PyObject *__pyx_v_baseptr; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; __Pyx_RefNannySetupContext("set_array_base", 0); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":968 * cdef inline void set_array_base(ndarray arr, object base): * cdef PyObject* baseptr * if base is None: # <<<<<<<<<<<<<< * baseptr = NULL * else: */ __pyx_t_1 = (__pyx_v_base == Py_None); __pyx_t_2 = (__pyx_t_1 != 0); if (__pyx_t_2) { /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":969 * cdef PyObject* baseptr * if base is None: * baseptr = NULL # <<<<<<<<<<<<<< * else: * Py_INCREF(base) # important to do this before decref below! */ __pyx_v_baseptr = NULL; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":968 * cdef inline void set_array_base(ndarray arr, object base): * cdef PyObject* baseptr * if base is None: # <<<<<<<<<<<<<< * baseptr = NULL * else: */ goto __pyx_L3; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":971 * baseptr = NULL * else: * Py_INCREF(base) # important to do this before decref below! # <<<<<<<<<<<<<< * baseptr = base * Py_XDECREF(arr.base) */ /*else*/ { Py_INCREF(__pyx_v_base); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":972 * else: * Py_INCREF(base) # important to do this before decref below! * baseptr = base # <<<<<<<<<<<<<< * Py_XDECREF(arr.base) * arr.base = baseptr */ __pyx_v_baseptr = ((PyObject *)__pyx_v_base); } __pyx_L3:; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":973 * Py_INCREF(base) # important to do this before decref below! * baseptr = base * Py_XDECREF(arr.base) # <<<<<<<<<<<<<< * arr.base = baseptr * */ Py_XDECREF(__pyx_v_arr->base); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":974 * baseptr = base * Py_XDECREF(arr.base) * arr.base = baseptr # <<<<<<<<<<<<<< * * cdef inline object get_array_base(ndarray arr): */ __pyx_v_arr->base = __pyx_v_baseptr; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":966 * * * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< * cdef PyObject* baseptr * if base is None: */ /* function exit code */ __Pyx_RefNannyFinishContext(); } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":976 * arr.base = baseptr * * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< * if arr.base is NULL: * return None */ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__pyx_v_arr) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; __Pyx_RefNannySetupContext("get_array_base", 0); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":977 * * cdef inline object get_array_base(ndarray arr): * if arr.base is NULL: # <<<<<<<<<<<<<< * return None * else: */ __pyx_t_1 = ((__pyx_v_arr->base == NULL) != 0); if (__pyx_t_1) { /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":978 * cdef inline object get_array_base(ndarray arr): * if arr.base is NULL: * return None # <<<<<<<<<<<<<< * else: * return arr.base */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(Py_None); __pyx_r = Py_None; goto __pyx_L0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":977 * * cdef inline object get_array_base(ndarray arr): * if arr.base is NULL: # <<<<<<<<<<<<<< * return None * else: */ } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":980 * return None * else: * return arr.base # <<<<<<<<<<<<<< */ /*else*/ { __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(((PyObject *)__pyx_v_arr->base)); __pyx_r = ((PyObject *)__pyx_v_arr->base); goto __pyx_L0; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":976 * arr.base = baseptr * * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< * if arr.base is NULL: * return None */ /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyMethodDef __pyx_methods[] = { {0, 0, 0, 0} }; #if PY_MAJOR_VERSION >= 3 static struct PyModuleDef __pyx_moduledef = { #if PY_VERSION_HEX < 0x03020000 { PyObject_HEAD_INIT(NULL) NULL, 0, NULL }, #else PyModuleDef_HEAD_INIT, #endif "core", 0, /* m_doc */ -1, /* m_size */ __pyx_methods /* m_methods */, NULL, /* m_reload */ NULL, /* m_traverse */ NULL, /* m_clear */ NULL /* m_free */ }; #endif static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_DTYPE, __pyx_k_DTYPE, sizeof(__pyx_k_DTYPE), 0, 0, 1, 1}, {&__pyx_kp_u_ERROR_vertices_did_not_sort_corr, __pyx_k_ERROR_vertices_did_not_sort_corr, sizeof(__pyx_k_ERROR_vertices_did_not_sort_corr), 0, 1, 0, 0}, {&__pyx_n_s_Exception, __pyx_k_Exception, sizeof(__pyx_k_Exception), 0, 0, 1, 1}, {&__pyx_kp_u_Format_string_allocated_too_shor, __pyx_k_Format_string_allocated_too_shor, sizeof(__pyx_k_Format_string_allocated_too_shor), 0, 1, 0, 0}, {&__pyx_kp_u_Format_string_allocated_too_shor_2, __pyx_k_Format_string_allocated_too_shor_2, sizeof(__pyx_k_Format_string_allocated_too_shor_2), 0, 1, 0, 0}, {&__pyx_kp_u_Non_native_byte_order_not_suppor, __pyx_k_Non_native_byte_order_not_suppor, sizeof(__pyx_k_Non_native_byte_order_not_suppor), 0, 1, 0, 0}, {&__pyx_n_s_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 0, 0, 1, 1}, {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1}, {&__pyx_n_s_all, __pyx_k_all, sizeof(__pyx_k_all), 0, 0, 1, 1}, {&__pyx_n_u_elliptical_overlap_grid, __pyx_k_elliptical_overlap_grid, sizeof(__pyx_k_elliptical_overlap_grid), 0, 1, 0, 1}, {&__pyx_n_s_float64, __pyx_k_float64, sizeof(__pyx_k_float64), 0, 0, 1, 1}, {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1}, {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, {&__pyx_kp_u_ndarray_is_not_C_contiguous, __pyx_k_ndarray_is_not_C_contiguous, sizeof(__pyx_k_ndarray_is_not_C_contiguous), 0, 1, 0, 0}, {&__pyx_kp_u_ndarray_is_not_Fortran_contiguou, __pyx_k_ndarray_is_not_Fortran_contiguou, sizeof(__pyx_k_ndarray_is_not_Fortran_contiguou), 0, 1, 0, 0}, {&__pyx_n_s_np, __pyx_k_np, sizeof(__pyx_k_np), 0, 0, 1, 1}, {&__pyx_n_s_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 0, 0, 1, 1}, {&__pyx_n_s_pi, __pyx_k_pi, sizeof(__pyx_k_pi), 0, 0, 1, 1}, {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1}, {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, {&__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_k_unknown_dtype_code_in_numpy_pxd, sizeof(__pyx_k_unknown_dtype_code_in_numpy_pxd), 0, 1, 0, 0}, {0, 0, 0, 0, 0, 0, 0} }; static int __Pyx_InitCachedBuiltins(void) { __pyx_builtin_Exception = __Pyx_GetBuiltinName(__pyx_n_s_Exception); if (!__pyx_builtin_Exception) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 280; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} return 0; __pyx_L1_error:; return -1; } static int __Pyx_InitCachedConstants(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); /* "photutils/geometry/core.pyx":280 * * if d1 > d2 or d2 > d3 or d1 > d3: * raise Exception("ERROR: vertices did not sort correctly") # <<<<<<<<<<<<<< * * # Determine number of vertices inside circle */ __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_u_ERROR_vertices_did_not_sort_corr); if (unlikely(!__pyx_tuple_)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 280; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple_); __Pyx_GIVEREF(__pyx_tuple_); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":218 * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<< * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) */ __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_C_contiguous); if (unlikely(!__pyx_tuple__2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__2); __Pyx_GIVEREF(__pyx_tuple__2); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":222 * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<< * * info.buf = PyArray_DATA(self) */ __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_Fortran_contiguou); if (unlikely(!__pyx_tuple__3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__3); __Pyx_GIVEREF(__pyx_tuple__3); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":259 * if ((descr.byteorder == c'>' and little_endian) or * (descr.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< * if t == NPY_BYTE: f = "b" * elif t == NPY_UBYTE: f = "B" */ __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__4); __Pyx_GIVEREF(__pyx_tuple__4); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":799 * * if (end - f) - (new_offset - offset[0]) < 15: * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<< * * if ((child.byteorder == c'>' and little_endian) or */ __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor); if (unlikely(!__pyx_tuple__5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__5); __Pyx_GIVEREF(__pyx_tuple__5); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":803 * if ((child.byteorder == c'>' and little_endian) or * (child.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< * # One could encode it in the format string and have Cython * # complain instead, BUT: < and > in format strings also imply */ __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__6); __Pyx_GIVEREF(__pyx_tuple__6); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":823 * t = child.type_num * if end - f < 5: * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<< * * # Until ticket #99 is fixed, use integers to avoid warnings */ __pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor_2); if (unlikely(!__pyx_tuple__7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__7); __Pyx_GIVEREF(__pyx_tuple__7); __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; __Pyx_RefNannyFinishContext(); return -1; } static int __Pyx_InitGlobals(void) { if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; return 0; __pyx_L1_error:; return -1; } #if PY_MAJOR_VERSION < 3 PyMODINIT_FUNC initcore(void); /*proto*/ PyMODINIT_FUNC initcore(void) #else PyMODINIT_FUNC PyInit_core(void); /*proto*/ PyMODINIT_FUNC PyInit_core(void) #endif { PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannyDeclarations #if CYTHON_REFNANNY __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); if (!__Pyx_RefNanny) { PyErr_Clear(); __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny"); if (!__Pyx_RefNanny) Py_FatalError("failed to import 'refnanny' module"); } #endif __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit_core(void)", 0); if (__Pyx_check_binary_version() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #ifdef __Pyx_CyFunction_USED if (__pyx_CyFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif #ifdef __Pyx_FusedFunction_USED if (__pyx_FusedFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif #ifdef __Pyx_Coroutine_USED if (__pyx_Coroutine_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif #ifdef __Pyx_Generator_USED if (__pyx_Generator_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif #ifdef __Pyx_StopAsyncIteration_USED if (__pyx_StopAsyncIteration_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /*--- Library function declarations ---*/ /*--- Threads initialization code ---*/ #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS #ifdef WITH_THREAD /* Python build with threading support? */ PyEval_InitThreads(); #endif #endif /*--- Module creation code ---*/ #if PY_MAJOR_VERSION < 3 __pyx_m = Py_InitModule4("core", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); #else __pyx_m = PyModule_Create(&__pyx_moduledef); #endif if (unlikely(!__pyx_m)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_INCREF(__pyx_d); __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #if CYTHON_COMPILING_IN_PYPY Py_INCREF(__pyx_b); #endif if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; /*--- Initialize various global constants etc. ---*/ if (__Pyx_InitGlobals() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) if (__Pyx_init_sys_getdefaultencoding_params() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif if (__pyx_module_is_main_photutils__geometry__core) { if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } #if PY_MAJOR_VERSION >= 3 { PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (!PyDict_GetItemString(modules, "photutils.geometry.core")) { if (unlikely(PyDict_SetItemString(modules, "photutils.geometry.core", __pyx_m) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } } #endif /*--- Builtin init code ---*/ if (__Pyx_InitCachedBuiltins() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /*--- Constants init code ---*/ if (__Pyx_InitCachedConstants() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /*--- Global init code ---*/ /*--- Variable export code ---*/ /*--- Function export code ---*/ if (__Pyx_ExportFunction("distance", (void (*)(void))__pyx_f_9photutils_8geometry_4core_distance, "double (double, double, double, double)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__Pyx_ExportFunction("area_arc", (void (*)(void))__pyx_f_9photutils_8geometry_4core_area_arc, "double (double, double, double, double, double)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__Pyx_ExportFunction("area_triangle", (void (*)(void))__pyx_f_9photutils_8geometry_4core_area_triangle, "double (double, double, double, double, double, double)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__Pyx_ExportFunction("area_arc_unit", (void (*)(void))__pyx_f_9photutils_8geometry_4core_area_arc_unit, "double (double, double, double, double)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__Pyx_ExportFunction("in_triangle", (void (*)(void))__pyx_f_9photutils_8geometry_4core_in_triangle, "int (double, double, double, double, double, double, double, double)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__Pyx_ExportFunction("overlap_area_triangle_unit_circle", (void (*)(void))__pyx_f_9photutils_8geometry_4core_overlap_area_triangle_unit_circle, "double (double, double, double, double, double, double)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /*--- Type init code ---*/ /*--- Type import code ---*/ __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "type", #if CYTHON_COMPILING_IN_PYPY sizeof(PyTypeObject), #else sizeof(PyHeapTypeObject), #endif 0); if (unlikely(!__pyx_ptype_7cpython_4type_type)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_7cpython_4bool_bool = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "bool", sizeof(PyBoolObject), 0); if (unlikely(!__pyx_ptype_7cpython_4bool_bool)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_7cpython_7complex_complex = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "complex", sizeof(PyComplexObject), 0); if (unlikely(!__pyx_ptype_7cpython_7complex_complex)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5numpy_dtype = __Pyx_ImportType("numpy", "dtype", sizeof(PyArray_Descr), 0); if (unlikely(!__pyx_ptype_5numpy_dtype)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5numpy_flatiter = __Pyx_ImportType("numpy", "flatiter", sizeof(PyArrayIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_flatiter)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5numpy_broadcast = __Pyx_ImportType("numpy", "broadcast", sizeof(PyArrayMultiIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_broadcast)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5numpy_ndarray = __Pyx_ImportType("numpy", "ndarray", sizeof(PyArrayObject), 0); if (unlikely(!__pyx_ptype_5numpy_ndarray)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5numpy_ufunc = __Pyx_ImportType("numpy", "ufunc", sizeof(PyUFuncObject), 0); if (unlikely(!__pyx_ptype_5numpy_ufunc)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 861; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /*--- Variable import code ---*/ /*--- Function import code ---*/ /*--- Execution code ---*/ #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) if (__Pyx_patch_abc() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* "photutils/geometry/core.pyx":6 * from __future__ import (absolute_import, division, print_function, * unicode_literals) * import numpy as np # <<<<<<<<<<<<<< * cimport numpy as np * */ __pyx_t_1 = __Pyx_Import(__pyx_n_s_numpy, 0, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "photutils/geometry/core.pyx":9 * cimport numpy as np * * __all__ = ['elliptical_overlap_grid'] # <<<<<<<<<<<<<< * * cdef extern from "math.h": */ __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_u_elliptical_overlap_grid); __Pyx_GIVEREF(__pyx_n_u_elliptical_overlap_grid); PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_u_elliptical_overlap_grid); if (PyDict_SetItem(__pyx_d, __pyx_n_s_all, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "photutils/geometry/core.pyx":21 * from cpython cimport bool * * DTYPE = np.float64 # <<<<<<<<<<<<<< * ctypedef np.float64_t DTYPE_t * */ __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_float64); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_DTYPE, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "photutils/geometry/core.pyx":1 * # Licensed under a 3-clause BSD style license - see LICENSE.rst # <<<<<<<<<<<<<< * * # The functions here are the core geometry functions */ __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":976 * arr.base = baseptr * * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< * if arr.base is NULL: * return None */ /*--- Wrapped vars code ---*/ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); if (__pyx_m) { if (__pyx_d) { __Pyx_AddTraceback("init photutils.geometry.core", __pyx_clineno, __pyx_lineno, __pyx_filename); } Py_DECREF(__pyx_m); __pyx_m = 0; } else if (!PyErr_Occurred()) { PyErr_SetString(PyExc_ImportError, "init photutils.geometry.core"); } __pyx_L0:; __Pyx_RefNannyFinishContext(); #if PY_MAJOR_VERSION < 3 return; #else return __pyx_m; #endif } /* --- Runtime support code --- */ #if CYTHON_REFNANNY static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { PyObject *m = NULL, *p = NULL; void *r = NULL; m = PyImport_ImportModule((char *)modname); if (!m) goto end; p = PyObject_GetAttrString(m, (char *)"RefNannyAPI"); if (!p) goto end; r = PyLong_AsVoidPtr(p); end: Py_XDECREF(p); Py_XDECREF(m); return (__Pyx_RefNannyAPIStruct *)r; } #endif static PyObject *__Pyx_GetBuiltinName(PyObject *name) { PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name); if (unlikely(!result)) { PyErr_Format(PyExc_NameError, #if PY_MAJOR_VERSION >= 3 "name '%U' is not defined", name); #else "name '%.200s' is not defined", PyString_AS_STRING(name)); #endif } return result; } static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) { #if CYTHON_COMPILING_IN_CPYTHON PyObject *tmp_type, *tmp_value, *tmp_tb; PyThreadState *tstate = PyThreadState_GET(); tmp_type = tstate->curexc_type; tmp_value = tstate->curexc_value; tmp_tb = tstate->curexc_traceback; tstate->curexc_type = type; tstate->curexc_value = value; tstate->curexc_traceback = tb; Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); #else PyErr_Restore(type, value, tb); #endif } static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) { #if CYTHON_COMPILING_IN_CPYTHON PyThreadState *tstate = PyThreadState_GET(); *type = tstate->curexc_type; *value = tstate->curexc_value; *tb = tstate->curexc_traceback; tstate->curexc_type = 0; tstate->curexc_value = 0; tstate->curexc_traceback = 0; #else PyErr_Fetch(type, value, tb); #endif } static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno, CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename, int full_traceback, CYTHON_UNUSED int nogil) { PyObject *old_exc, *old_val, *old_tb; PyObject *ctx; #ifdef WITH_THREAD PyGILState_STATE state; if (nogil) state = PyGILState_Ensure(); #endif __Pyx_ErrFetch(&old_exc, &old_val, &old_tb); if (full_traceback) { Py_XINCREF(old_exc); Py_XINCREF(old_val); Py_XINCREF(old_tb); __Pyx_ErrRestore(old_exc, old_val, old_tb); PyErr_PrintEx(1); } #if PY_MAJOR_VERSION < 3 ctx = PyString_FromString(name); #else ctx = PyUnicode_FromString(name); #endif __Pyx_ErrRestore(old_exc, old_val, old_tb); if (!ctx) { PyErr_WriteUnraisable(Py_None); } else { PyErr_WriteUnraisable(ctx); Py_DECREF(ctx); } #ifdef WITH_THREAD if (nogil) PyGILState_Release(state); #endif } static CYTHON_INLINE long __Pyx_mod_long(long a, long b) { long r = a % b; r += ((r != 0) & ((r ^ b) < 0)) * b; return r; } static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) { PyObject *result; #if CYTHON_COMPILING_IN_CPYTHON result = PyDict_GetItem(__pyx_d, name); if (likely(result)) { Py_INCREF(result); } else { #else result = PyObject_GetItem(__pyx_d, name); if (!result) { PyErr_Clear(); #endif result = __Pyx_GetBuiltinName(name); } return result; } #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) { PyObject *result; ternaryfunc call = func->ob_type->tp_call; if (unlikely(!call)) return PyObject_Call(func, arg, kw); if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) return NULL; result = (*call)(func, arg, kw); Py_LeaveRecursiveCall(); if (unlikely(!result) && unlikely(!PyErr_Occurred())) { PyErr_SetString( PyExc_SystemError, "NULL result without error in PyObject_Call"); } return result; } #endif #if PY_MAJOR_VERSION < 3 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, CYTHON_UNUSED PyObject *cause) { Py_XINCREF(type); if (!value || value == Py_None) value = NULL; else Py_INCREF(value); if (!tb || tb == Py_None) tb = NULL; else { Py_INCREF(tb); if (!PyTraceBack_Check(tb)) { PyErr_SetString(PyExc_TypeError, "raise: arg 3 must be a traceback or None"); goto raise_error; } } if (PyType_Check(type)) { #if CYTHON_COMPILING_IN_PYPY if (!value) { Py_INCREF(Py_None); value = Py_None; } #endif PyErr_NormalizeException(&type, &value, &tb); } else { if (value) { PyErr_SetString(PyExc_TypeError, "instance exception may not have a separate value"); goto raise_error; } value = type; type = (PyObject*) Py_TYPE(type); Py_INCREF(type); if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) { PyErr_SetString(PyExc_TypeError, "raise: exception class must be a subclass of BaseException"); goto raise_error; } } __Pyx_ErrRestore(type, value, tb); return; raise_error: Py_XDECREF(value); Py_XDECREF(type); Py_XDECREF(tb); return; } #else static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) { PyObject* owned_instance = NULL; if (tb == Py_None) { tb = 0; } else if (tb && !PyTraceBack_Check(tb)) { PyErr_SetString(PyExc_TypeError, "raise: arg 3 must be a traceback or None"); goto bad; } if (value == Py_None) value = 0; if (PyExceptionInstance_Check(type)) { if (value) { PyErr_SetString(PyExc_TypeError, "instance exception may not have a separate value"); goto bad; } value = type; type = (PyObject*) Py_TYPE(value); } else if (PyExceptionClass_Check(type)) { PyObject *instance_class = NULL; if (value && PyExceptionInstance_Check(value)) { instance_class = (PyObject*) Py_TYPE(value); if (instance_class != type) { int is_subclass = PyObject_IsSubclass(instance_class, type); if (!is_subclass) { instance_class = NULL; } else if (unlikely(is_subclass == -1)) { goto bad; } else { type = instance_class; } } } if (!instance_class) { PyObject *args; if (!value) args = PyTuple_New(0); else if (PyTuple_Check(value)) { Py_INCREF(value); args = value; } else args = PyTuple_Pack(1, value); if (!args) goto bad; owned_instance = PyObject_Call(type, args, NULL); Py_DECREF(args); if (!owned_instance) goto bad; value = owned_instance; if (!PyExceptionInstance_Check(value)) { PyErr_Format(PyExc_TypeError, "calling %R should have returned an instance of " "BaseException, not %R", type, Py_TYPE(value)); goto bad; } } } else { PyErr_SetString(PyExc_TypeError, "raise: exception class must be a subclass of BaseException"); goto bad; } #if PY_VERSION_HEX >= 0x03030000 if (cause) { #else if (cause && cause != Py_None) { #endif PyObject *fixed_cause; if (cause == Py_None) { fixed_cause = NULL; } else if (PyExceptionClass_Check(cause)) { fixed_cause = PyObject_CallObject(cause, NULL); if (fixed_cause == NULL) goto bad; } else if (PyExceptionInstance_Check(cause)) { fixed_cause = cause; Py_INCREF(fixed_cause); } else { PyErr_SetString(PyExc_TypeError, "exception causes must derive from " "BaseException"); goto bad; } PyException_SetCause(value, fixed_cause); } PyErr_SetObject(type, value); if (tb) { #if CYTHON_COMPILING_IN_PYPY PyObject *tmp_type, *tmp_value, *tmp_tb; PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb); Py_INCREF(tb); PyErr_Restore(tmp_type, tmp_value, tb); Py_XDECREF(tmp_tb); #else PyThreadState *tstate = PyThreadState_GET(); PyObject* tmp_tb = tstate->curexc_traceback; if (tb != tmp_tb) { Py_INCREF(tb); tstate->curexc_traceback = tb; Py_XDECREF(tmp_tb); } #endif } bad: Py_XDECREF(owned_instance); return; } #endif static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { if (unlikely(!type)) { PyErr_SetString(PyExc_SystemError, "Missing type object"); return 0; } if (likely(PyObject_TypeCheck(obj, type))) return 1; PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s", Py_TYPE(obj)->tp_name, type->tp_name); return 0; } static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) { PyErr_Format(PyExc_ValueError, "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected); } static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) { PyErr_Format(PyExc_ValueError, "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack", index, (index == 1) ? "" : "s"); } static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); } static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) { PyObject *empty_list = 0; PyObject *module = 0; PyObject *global_dict = 0; PyObject *empty_dict = 0; PyObject *list; #if PY_VERSION_HEX < 0x03030000 PyObject *py_import; py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import); if (!py_import) goto bad; #endif if (from_list) list = from_list; else { empty_list = PyList_New(0); if (!empty_list) goto bad; list = empty_list; } global_dict = PyModule_GetDict(__pyx_m); if (!global_dict) goto bad; empty_dict = PyDict_New(); if (!empty_dict) goto bad; { #if PY_MAJOR_VERSION >= 3 if (level == -1) { if (strchr(__Pyx_MODULE_NAME, '.')) { #if PY_VERSION_HEX < 0x03030000 PyObject *py_level = PyInt_FromLong(1); if (!py_level) goto bad; module = PyObject_CallFunctionObjArgs(py_import, name, global_dict, empty_dict, list, py_level, NULL); Py_DECREF(py_level); #else module = PyImport_ImportModuleLevelObject( name, global_dict, empty_dict, list, 1); #endif if (!module) { if (!PyErr_ExceptionMatches(PyExc_ImportError)) goto bad; PyErr_Clear(); } } level = 0; } #endif if (!module) { #if PY_VERSION_HEX < 0x03030000 PyObject *py_level = PyInt_FromLong(level); if (!py_level) goto bad; module = PyObject_CallFunctionObjArgs(py_import, name, global_dict, empty_dict, list, py_level, NULL); Py_DECREF(py_level); #else module = PyImport_ImportModuleLevelObject( name, global_dict, empty_dict, list, level); #endif } } bad: #if PY_VERSION_HEX < 0x03030000 Py_XDECREF(py_import); #endif Py_XDECREF(empty_list); Py_XDECREF(empty_dict); return module; } static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { int start = 0, mid = 0, end = count - 1; if (end >= 0 && code_line > entries[end].code_line) { return count; } while (start < end) { mid = start + (end - start) / 2; if (code_line < entries[mid].code_line) { end = mid; } else if (code_line > entries[mid].code_line) { start = mid + 1; } else { return mid; } } if (code_line <= entries[mid].code_line) { return mid; } else { return mid + 1; } } static PyCodeObject *__pyx_find_code_object(int code_line) { PyCodeObject* code_object; int pos; if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) { return NULL; } pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) { return NULL; } code_object = __pyx_code_cache.entries[pos].code_object; Py_INCREF(code_object); return code_object; } static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { int pos, i; __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries; if (unlikely(!code_line)) { return; } if (unlikely(!entries)) { entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry)); if (likely(entries)) { __pyx_code_cache.entries = entries; __pyx_code_cache.max_count = 64; __pyx_code_cache.count = 1; entries[0].code_line = code_line; entries[0].code_object = code_object; Py_INCREF(code_object); } return; } pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) { PyCodeObject* tmp = entries[pos].code_object; entries[pos].code_object = code_object; Py_DECREF(tmp); return; } if (__pyx_code_cache.count == __pyx_code_cache.max_count) { int new_max = __pyx_code_cache.max_count + 64; entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc( __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry)); if (unlikely(!entries)) { return; } __pyx_code_cache.entries = entries; __pyx_code_cache.max_count = new_max; } for (i=__pyx_code_cache.count; i>pos; i--) { entries[i] = entries[i-1]; } entries[pos].code_line = code_line; entries[pos].code_object = code_object; __pyx_code_cache.count++; Py_INCREF(code_object); } #include "compile.h" #include "frameobject.h" #include "traceback.h" static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( const char *funcname, int c_line, int py_line, const char *filename) { PyCodeObject *py_code = 0; PyObject *py_srcfile = 0; PyObject *py_funcname = 0; #if PY_MAJOR_VERSION < 3 py_srcfile = PyString_FromString(filename); #else py_srcfile = PyUnicode_FromString(filename); #endif if (!py_srcfile) goto bad; if (c_line) { #if PY_MAJOR_VERSION < 3 py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); #else py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); #endif } else { #if PY_MAJOR_VERSION < 3 py_funcname = PyString_FromString(funcname); #else py_funcname = PyUnicode_FromString(funcname); #endif } if (!py_funcname) goto bad; py_code = __Pyx_PyCode_New( 0, 0, 0, 0, 0, __pyx_empty_bytes, /*PyObject *code,*/ __pyx_empty_tuple, /*PyObject *consts,*/ __pyx_empty_tuple, /*PyObject *names,*/ __pyx_empty_tuple, /*PyObject *varnames,*/ __pyx_empty_tuple, /*PyObject *freevars,*/ __pyx_empty_tuple, /*PyObject *cellvars,*/ py_srcfile, /*PyObject *filename,*/ py_funcname, /*PyObject *name,*/ py_line, __pyx_empty_bytes /*PyObject *lnotab*/ ); Py_DECREF(py_srcfile); Py_DECREF(py_funcname); return py_code; bad: Py_XDECREF(py_srcfile); Py_XDECREF(py_funcname); return NULL; } static void __Pyx_AddTraceback(const char *funcname, int c_line, int py_line, const char *filename) { PyCodeObject *py_code = 0; PyFrameObject *py_frame = 0; py_code = __pyx_find_code_object(c_line ? c_line : py_line); if (!py_code) { py_code = __Pyx_CreateCodeObjectForTraceback( funcname, c_line, py_line, filename); if (!py_code) goto bad; __pyx_insert_code_object(c_line ? c_line : py_line, py_code); } py_frame = PyFrame_New( PyThreadState_GET(), /*PyThreadState *tstate,*/ py_code, /*PyCodeObject *code,*/ __pyx_d, /*PyObject *globals,*/ 0 /*PyObject *locals*/ ); if (!py_frame) goto bad; py_frame->f_lineno = py_line; PyTraceBack_Here(py_frame); bad: Py_XDECREF(py_code); Py_XDECREF(py_frame); } #if CYTHON_CCOMPLEX #ifdef __cplusplus static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { return ::std::complex< float >(x, y); } #else static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { return x + y*(__pyx_t_float_complex)_Complex_I; } #endif #else static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { __pyx_t_float_complex z; z.real = x; z.imag = y; return z; } #endif #if CYTHON_CCOMPLEX #else static CYTHON_INLINE int __Pyx_c_eqf(__pyx_t_float_complex a, __pyx_t_float_complex b) { return (a.real == b.real) && (a.imag == b.imag); } static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sumf(__pyx_t_float_complex a, __pyx_t_float_complex b) { __pyx_t_float_complex z; z.real = a.real + b.real; z.imag = a.imag + b.imag; return z; } static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_difff(__pyx_t_float_complex a, __pyx_t_float_complex b) { __pyx_t_float_complex z; z.real = a.real - b.real; z.imag = a.imag - b.imag; return z; } static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prodf(__pyx_t_float_complex a, __pyx_t_float_complex b) { __pyx_t_float_complex z; z.real = a.real * b.real - a.imag * b.imag; z.imag = a.real * b.imag + a.imag * b.real; return z; } static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quotf(__pyx_t_float_complex a, __pyx_t_float_complex b) { __pyx_t_float_complex z; float denom = b.real * b.real + b.imag * b.imag; z.real = (a.real * b.real + a.imag * b.imag) / denom; z.imag = (a.imag * b.real - a.real * b.imag) / denom; return z; } static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_negf(__pyx_t_float_complex a) { __pyx_t_float_complex z; z.real = -a.real; z.imag = -a.imag; return z; } static CYTHON_INLINE int __Pyx_c_is_zerof(__pyx_t_float_complex a) { return (a.real == 0) && (a.imag == 0); } static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conjf(__pyx_t_float_complex a) { __pyx_t_float_complex z; z.real = a.real; z.imag = -a.imag; return z; } #if 1 static CYTHON_INLINE float __Pyx_c_absf(__pyx_t_float_complex z) { #if !defined(HAVE_HYPOT) || defined(_MSC_VER) return sqrtf(z.real*z.real + z.imag*z.imag); #else return hypotf(z.real, z.imag); #endif } static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_powf(__pyx_t_float_complex a, __pyx_t_float_complex b) { __pyx_t_float_complex z; float r, lnr, theta, z_r, z_theta; if (b.imag == 0 && b.real == (int)b.real) { if (b.real < 0) { float denom = a.real * a.real + a.imag * a.imag; a.real = a.real / denom; a.imag = -a.imag / denom; b.real = -b.real; } switch ((int)b.real) { case 0: z.real = 1; z.imag = 0; return z; case 1: return a; case 2: z = __Pyx_c_prodf(a, a); return __Pyx_c_prodf(a, a); case 3: z = __Pyx_c_prodf(a, a); return __Pyx_c_prodf(z, a); case 4: z = __Pyx_c_prodf(a, a); return __Pyx_c_prodf(z, z); } } if (a.imag == 0) { if (a.real == 0) { return a; } r = a.real; theta = 0; } else { r = __Pyx_c_absf(a); theta = atan2f(a.imag, a.real); } lnr = logf(r); z_r = expf(lnr * b.real - theta * b.imag); z_theta = theta * b.real + lnr * b.imag; z.real = z_r * cosf(z_theta); z.imag = z_r * sinf(z_theta); return z; } #endif #endif #if CYTHON_CCOMPLEX #ifdef __cplusplus static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { return ::std::complex< double >(x, y); } #else static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { return x + y*(__pyx_t_double_complex)_Complex_I; } #endif #else static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { __pyx_t_double_complex z; z.real = x; z.imag = y; return z; } #endif #if CYTHON_CCOMPLEX #else static CYTHON_INLINE int __Pyx_c_eq(__pyx_t_double_complex a, __pyx_t_double_complex b) { return (a.real == b.real) && (a.imag == b.imag); } static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum(__pyx_t_double_complex a, __pyx_t_double_complex b) { __pyx_t_double_complex z; z.real = a.real + b.real; z.imag = a.imag + b.imag; return z; } static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff(__pyx_t_double_complex a, __pyx_t_double_complex b) { __pyx_t_double_complex z; z.real = a.real - b.real; z.imag = a.imag - b.imag; return z; } static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod(__pyx_t_double_complex a, __pyx_t_double_complex b) { __pyx_t_double_complex z; z.real = a.real * b.real - a.imag * b.imag; z.imag = a.real * b.imag + a.imag * b.real; return z; } static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot(__pyx_t_double_complex a, __pyx_t_double_complex b) { __pyx_t_double_complex z; double denom = b.real * b.real + b.imag * b.imag; z.real = (a.real * b.real + a.imag * b.imag) / denom; z.imag = (a.imag * b.real - a.real * b.imag) / denom; return z; } static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg(__pyx_t_double_complex a) { __pyx_t_double_complex z; z.real = -a.real; z.imag = -a.imag; return z; } static CYTHON_INLINE int __Pyx_c_is_zero(__pyx_t_double_complex a) { return (a.real == 0) && (a.imag == 0); } static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj(__pyx_t_double_complex a) { __pyx_t_double_complex z; z.real = a.real; z.imag = -a.imag; return z; } #if 1 static CYTHON_INLINE double __Pyx_c_abs(__pyx_t_double_complex z) { #if !defined(HAVE_HYPOT) || defined(_MSC_VER) return sqrt(z.real*z.real + z.imag*z.imag); #else return hypot(z.real, z.imag); #endif } static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow(__pyx_t_double_complex a, __pyx_t_double_complex b) { __pyx_t_double_complex z; double r, lnr, theta, z_r, z_theta; if (b.imag == 0 && b.real == (int)b.real) { if (b.real < 0) { double denom = a.real * a.real + a.imag * a.imag; a.real = a.real / denom; a.imag = -a.imag / denom; b.real = -b.real; } switch ((int)b.real) { case 0: z.real = 1; z.imag = 0; return z; case 1: return a; case 2: z = __Pyx_c_prod(a, a); return __Pyx_c_prod(a, a); case 3: z = __Pyx_c_prod(a, a); return __Pyx_c_prod(z, a); case 4: z = __Pyx_c_prod(a, a); return __Pyx_c_prod(z, z); } } if (a.imag == 0) { if (a.real == 0) { return a; } r = a.real; theta = 0; } else { r = __Pyx_c_abs(a); theta = atan2(a.imag, a.real); } lnr = log(r); z_r = exp(lnr * b.real - theta * b.imag); z_theta = theta * b.real + lnr * b.imag; z.real = z_r * cos(z_theta); z.imag = z_r * sin(z_theta); return z; } #endif #endif static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { const int neg_one = (int) -1, const_zero = (int) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { if (sizeof(int) < sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(int) <= sizeof(unsigned long)) { return PyLong_FromUnsignedLong((unsigned long) value); } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); } } else { if (sizeof(int) <= sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { return PyLong_FromLongLong((PY_LONG_LONG) value); } } { int one = 1; int little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&value; return _PyLong_FromByteArray(bytes, sizeof(int), little, !is_unsigned); } } #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\ __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0) #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\ __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1) #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\ {\ func_type value = func_value;\ if (sizeof(target_type) < sizeof(func_type)) {\ if (unlikely(value != (func_type) (target_type) value)) {\ func_type zero = 0;\ if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\ return (target_type) -1;\ if (is_unsigned && unlikely(value < zero))\ goto raise_neg_overflow;\ else\ goto raise_overflow;\ }\ }\ return (target_type) value;\ } #if CYTHON_USE_PYLONG_INTERNALS #include "longintrepr.h" #endif static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { const int neg_one = (int) -1, const_zero = (int) 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { if (sizeof(int) < sizeof(long)) { __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x)) } else { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { goto raise_neg_overflow; } return (int) val; } } else #endif if (likely(PyLong_Check(x))) { if (is_unsigned) { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (int) 0; case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0]) case 2: if (8 * sizeof(int) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) { return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; case 3: if (8 * sizeof(int) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) { return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; case 4: if (8 * sizeof(int) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) { return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; } #endif #if CYTHON_COMPILING_IN_CPYTHON if (unlikely(Py_SIZE(x) < 0)) { goto raise_neg_overflow; } #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (int) -1; if (unlikely(result == 1)) goto raise_neg_overflow; } #endif if (sizeof(int) <= sizeof(unsigned long)) { __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x)) } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) } } else { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (int) 0; case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, -(sdigit) digits[0]) case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0]) case -2: if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 2: if (8 * sizeof(int) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case -3: if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 3: if (8 * sizeof(int) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case -4: if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 4: if (8 * sizeof(int) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; } #endif if (sizeof(int) <= sizeof(long)) { __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x)) } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x)) } } { #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) PyErr_SetString(PyExc_RuntimeError, "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); #else int val; PyObject *v = __Pyx_PyNumber_Int(x); #if PY_MAJOR_VERSION < 3 if (likely(v) && !PyLong_Check(v)) { PyObject *tmp = v; v = PyNumber_Long(tmp); Py_DECREF(tmp); } #endif if (likely(v)) { int one = 1; int is_little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&val; int ret = _PyLong_AsByteArray((PyLongObject *)v, bytes, sizeof(val), is_little, !is_unsigned); Py_DECREF(v); if (likely(!ret)) return val; } #endif return (int) -1; } } else { int val; PyObject *tmp = __Pyx_PyNumber_Int(x); if (!tmp) return (int) -1; val = __Pyx_PyInt_As_int(tmp); Py_DECREF(tmp); return val; } raise_overflow: PyErr_SetString(PyExc_OverflowError, "value too large to convert to int"); return (int) -1; raise_neg_overflow: PyErr_SetString(PyExc_OverflowError, "can't convert negative value to int"); return (int) -1; } static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum__NPY_TYPES(enum NPY_TYPES value) { const enum NPY_TYPES neg_one = (enum NPY_TYPES) -1, const_zero = (enum NPY_TYPES) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { if (sizeof(enum NPY_TYPES) < sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(enum NPY_TYPES) <= sizeof(unsigned long)) { return PyLong_FromUnsignedLong((unsigned long) value); } else if (sizeof(enum NPY_TYPES) <= sizeof(unsigned PY_LONG_LONG)) { return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); } } else { if (sizeof(enum NPY_TYPES) <= sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(enum NPY_TYPES) <= sizeof(PY_LONG_LONG)) { return PyLong_FromLongLong((PY_LONG_LONG) value); } } { int one = 1; int little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&value; return _PyLong_FromByteArray(bytes, sizeof(enum NPY_TYPES), little, !is_unsigned); } } static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { const long neg_one = (long) -1, const_zero = (long) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { if (sizeof(long) < sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(long) <= sizeof(unsigned long)) { return PyLong_FromUnsignedLong((unsigned long) value); } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); } } else { if (sizeof(long) <= sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { return PyLong_FromLongLong((PY_LONG_LONG) value); } } { int one = 1; int little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&value; return _PyLong_FromByteArray(bytes, sizeof(long), little, !is_unsigned); } } static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { const long neg_one = (long) -1, const_zero = (long) 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { if (sizeof(long) < sizeof(long)) { __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x)) } else { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { goto raise_neg_overflow; } return (long) val; } } else #endif if (likely(PyLong_Check(x))) { if (is_unsigned) { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (long) 0; case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0]) case 2: if (8 * sizeof(long) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) { return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; case 3: if (8 * sizeof(long) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) { return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; case 4: if (8 * sizeof(long) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) { return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; } #endif #if CYTHON_COMPILING_IN_CPYTHON if (unlikely(Py_SIZE(x) < 0)) { goto raise_neg_overflow; } #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (long) -1; if (unlikely(result == 1)) goto raise_neg_overflow; } #endif if (sizeof(long) <= sizeof(unsigned long)) { __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x)) } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) } } else { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (long) 0; case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, -(sdigit) digits[0]) case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0]) case -2: if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case 2: if (8 * sizeof(long) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case -3: if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case 3: if (8 * sizeof(long) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case -4: if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case 4: if (8 * sizeof(long) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; } #endif if (sizeof(long) <= sizeof(long)) { __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x)) } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x)) } } { #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) PyErr_SetString(PyExc_RuntimeError, "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); #else long val; PyObject *v = __Pyx_PyNumber_Int(x); #if PY_MAJOR_VERSION < 3 if (likely(v) && !PyLong_Check(v)) { PyObject *tmp = v; v = PyNumber_Long(tmp); Py_DECREF(tmp); } #endif if (likely(v)) { int one = 1; int is_little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&val; int ret = _PyLong_AsByteArray((PyLongObject *)v, bytes, sizeof(val), is_little, !is_unsigned); Py_DECREF(v); if (likely(!ret)) return val; } #endif return (long) -1; } } else { long val; PyObject *tmp = __Pyx_PyNumber_Int(x); if (!tmp) return (long) -1; val = __Pyx_PyInt_As_long(tmp); Py_DECREF(tmp); return val; } raise_overflow: PyErr_SetString(PyExc_OverflowError, "value too large to convert to long"); return (long) -1; raise_neg_overflow: PyErr_SetString(PyExc_OverflowError, "can't convert negative value to long"); return (long) -1; } static int __Pyx_check_binary_version(void) { char ctversion[4], rtversion[4]; PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION); PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion()); if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) { char message[200]; PyOS_snprintf(message, sizeof(message), "compiletime version %s of module '%.100s' " "does not match runtime version %s", ctversion, __Pyx_MODULE_NAME, rtversion); return PyErr_WarnEx(NULL, message, 1); } return 0; } static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig) { PyObject *d = 0; PyObject *cobj = 0; union { void (*fp)(void); void *p; } tmp; d = PyObject_GetAttrString(__pyx_m, (char *)"__pyx_capi__"); if (!d) { PyErr_Clear(); d = PyDict_New(); if (!d) goto bad; Py_INCREF(d); if (PyModule_AddObject(__pyx_m, (char *)"__pyx_capi__", d) < 0) goto bad; } tmp.fp = f; #if PY_VERSION_HEX >= 0x02070000 cobj = PyCapsule_New(tmp.p, sig, 0); #else cobj = PyCObject_FromVoidPtrAndDesc(tmp.p, (void *)sig, 0); #endif if (!cobj) goto bad; if (PyDict_SetItemString(d, name, cobj) < 0) goto bad; Py_DECREF(cobj); Py_DECREF(d); return 0; bad: Py_XDECREF(cobj); Py_XDECREF(d); return -1; } #ifndef __PYX_HAVE_RT_ImportModule #define __PYX_HAVE_RT_ImportModule static PyObject *__Pyx_ImportModule(const char *name) { PyObject *py_name = 0; PyObject *py_module = 0; py_name = __Pyx_PyIdentifier_FromString(name); if (!py_name) goto bad; py_module = PyImport_Import(py_name); Py_DECREF(py_name); return py_module; bad: Py_XDECREF(py_name); return 0; } #endif #ifndef __PYX_HAVE_RT_ImportType #define __PYX_HAVE_RT_ImportType static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict) { PyObject *py_module = 0; PyObject *result = 0; PyObject *py_name = 0; char warning[200]; Py_ssize_t basicsize; #ifdef Py_LIMITED_API PyObject *py_basicsize; #endif py_module = __Pyx_ImportModule(module_name); if (!py_module) goto bad; py_name = __Pyx_PyIdentifier_FromString(class_name); if (!py_name) goto bad; result = PyObject_GetAttr(py_module, py_name); Py_DECREF(py_name); py_name = 0; Py_DECREF(py_module); py_module = 0; if (!result) goto bad; if (!PyType_Check(result)) { PyErr_Format(PyExc_TypeError, "%.200s.%.200s is not a type object", module_name, class_name); goto bad; } #ifndef Py_LIMITED_API basicsize = ((PyTypeObject *)result)->tp_basicsize; #else py_basicsize = PyObject_GetAttrString(result, "__basicsize__"); if (!py_basicsize) goto bad; basicsize = PyLong_AsSsize_t(py_basicsize); Py_DECREF(py_basicsize); py_basicsize = 0; if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred()) goto bad; #endif if (!strict && (size_t)basicsize > size) { PyOS_snprintf(warning, sizeof(warning), "%s.%s size changed, may indicate binary incompatibility", module_name, class_name); if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad; } else if ((size_t)basicsize != size) { PyErr_Format(PyExc_ValueError, "%.200s.%.200s has the wrong size, try recompiling", module_name, class_name); goto bad; } return (PyTypeObject *)result; bad: Py_XDECREF(py_module); Py_XDECREF(result); return NULL; } #endif static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { while (t->p) { #if PY_MAJOR_VERSION < 3 if (t->is_unicode) { *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL); } else if (t->intern) { *t->p = PyString_InternFromString(t->s); } else { *t->p = PyString_FromStringAndSize(t->s, t->n - 1); } #else if (t->is_unicode | t->is_str) { if (t->intern) { *t->p = PyUnicode_InternFromString(t->s); } else if (t->encoding) { *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL); } else { *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1); } } else { *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1); } #endif if (!*t->p) return -1; ++t; } return 0; } static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) { return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str)); } static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) { Py_ssize_t ignore; return __Pyx_PyObject_AsStringAndSize(o, &ignore); } static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { #if CYTHON_COMPILING_IN_CPYTHON && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) if ( #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII __Pyx_sys_getdefaultencoding_not_ascii && #endif PyUnicode_Check(o)) { #if PY_VERSION_HEX < 0x03030000 char* defenc_c; PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); if (!defenc) return NULL; defenc_c = PyBytes_AS_STRING(defenc); #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII { char* end = defenc_c + PyBytes_GET_SIZE(defenc); char* c; for (c = defenc_c; c < end; c++) { if ((unsigned char) (*c) >= 128) { PyUnicode_AsASCIIString(o); return NULL; } } } #endif *length = PyBytes_GET_SIZE(defenc); return defenc_c; #else if (__Pyx_PyUnicode_READY(o) == -1) return NULL; #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII if (PyUnicode_IS_ASCII(o)) { *length = PyUnicode_GET_LENGTH(o); return PyUnicode_AsUTF8(o); } else { PyUnicode_AsASCIIString(o); return NULL; } #else return PyUnicode_AsUTF8AndSize(o, length); #endif #endif } else #endif #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE)) if (PyByteArray_Check(o)) { *length = PyByteArray_GET_SIZE(o); return PyByteArray_AS_STRING(o); } else #endif { char* result; int r = PyBytes_AsStringAndSize(o, &result, length); if (unlikely(r < 0)) { return NULL; } else { return result; } } } static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { int is_true = x == Py_True; if (is_true | (x == Py_False) | (x == Py_None)) return is_true; else return PyObject_IsTrue(x); } static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) { PyNumberMethods *m; const char *name = NULL; PyObject *res = NULL; #if PY_MAJOR_VERSION < 3 if (PyInt_Check(x) || PyLong_Check(x)) #else if (PyLong_Check(x)) #endif return __Pyx_NewRef(x); m = Py_TYPE(x)->tp_as_number; #if PY_MAJOR_VERSION < 3 if (m && m->nb_int) { name = "int"; res = PyNumber_Int(x); } else if (m && m->nb_long) { name = "long"; res = PyNumber_Long(x); } #else if (m && m->nb_int) { name = "int"; res = PyNumber_Long(x); } #endif if (res) { #if PY_MAJOR_VERSION < 3 if (!PyInt_Check(res) && !PyLong_Check(res)) { #else if (!PyLong_Check(res)) { #endif PyErr_Format(PyExc_TypeError, "__%.4s__ returned non-%.4s (type %.200s)", name, name, Py_TYPE(res)->tp_name); Py_DECREF(res); return NULL; } } else if (!PyErr_Occurred()) { PyErr_SetString(PyExc_TypeError, "an integer is required"); } return res; } static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { Py_ssize_t ival; PyObject *x; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_CheckExact(b))) { if (sizeof(Py_ssize_t) >= sizeof(long)) return PyInt_AS_LONG(b); else return PyInt_AsSsize_t(x); } #endif if (likely(PyLong_CheckExact(b))) { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)b)->ob_digit; const Py_ssize_t size = Py_SIZE(b); if (likely(__Pyx_sst_abs(size) <= 1)) { ival = likely(size) ? digits[0] : 0; if (size == -1) ival = -ival; return ival; } else { switch (size) { case 2: if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case -2: if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case 3: if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case -3: if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case 4: if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case -4: if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; } } #endif return PyLong_AsSsize_t(b); } x = PyNumber_Index(b); if (!x) return -1; ival = PyInt_AsSsize_t(x); Py_DECREF(x); return ival; } static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { return PyInt_FromSize_t(ival); } #endif /* Py_PYTHON_H */ photutils-0.2.1/photutils/geometry/core.pxd0000600000214200020070000000101112444404542023247 0ustar lbradleySTSCI\science00000000000000cdef double distance(double x1, double y1, double x2, double y2) cdef double area_arc(double x1, double y1, double x2, double y2, double R) cdef double area_triangle(double x1, double y1, double x2, double y2, double x3, double y3) cdef double area_arc_unit(double x1, double y1, double x2, double y2) cdef int in_triangle(double x, double y, double x1, double y1, double x2, double y2, double x3, double y3) cdef double overlap_area_triangle_unit_circle(double x1, double y1, double x2, double y2, double x3, double y3) photutils-0.2.1/photutils/geometry/core.pyx0000600000214200020070000002662212627615324023320 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst # The functions here are the core geometry functions from __future__ import (absolute_import, division, print_function, unicode_literals) import numpy as np cimport numpy as np __all__ = ['elliptical_overlap_grid'] cdef extern from "math.h": double asin(double x) double sin(double x) double cos(double x) double sqrt(double x) double fabs(double x) from cpython cimport bool DTYPE = np.float64 ctypedef np.float64_t DTYPE_t cimport cython ctypedef struct point: double x double y ctypedef struct intersections: point p1 point p2 # NOTE: The following two functions use cdef because they are not intended to be # called from the Python code. Using def makes them callable from outside, but # also slower. Some functions currently return multiple values, and for those we # still use 'def' for now. cdef double distance(double x1, double y1, double x2, double y2): """ Distance between two points in two dimensions. Parameters ---------- x1, y1 : float The coordinates of the first point x2, y2 : float The coordinates of the second point Returns ------- d : float The Euclidean distance between the two points """ return sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2) cdef double area_arc(double x1, double y1, double x2, double y2, double r): """ Area of a circle arc with radius r between points (x1, y1) and (x2, y2). References ---------- http://mathworld.wolfram.com/CircularSegment.html """ cdef double a, theta a = distance(x1, y1, x2, y2) theta = 2. * asin(0.5 * a / r) return 0.5 * r * r * (theta - sin(theta)) cdef double area_triangle(double x1, double y1, double x2, double y2, double x3, double y3): """ Area of a triangle defined by three vertices. """ return 0.5 * abs(x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2)) cdef double area_arc_unit(double x1, double y1, double x2, double y2): """ Area of a circle arc with radius R between points (x1, y1) and (x2, y2) References ---------- http://mathworld.wolfram.com/CircularSegment.html """ cdef double a, theta a = distance(x1, y1, x2, y2) theta = 2. * asin(0.5 * a) return 0.5 * (theta - sin(theta)) cdef int in_triangle(double x, double y, double x1, double y1, double x2, double y2, double x3, double y3): """ Check if a point (x,y) is inside a triangle """ cdef int c = 0 c += ((y1 > y) != (y2 > y) and x < (x2 - x1) * (y - y1) / (y2 - y1) + x1) c += ((y2 > y) != (y3 > y) and x < (x3 - x2) * (y - y2) / (y3 - y2) + x2) c += ((y3 > y) != (y1 > y) and x < (x1 - x3) * (y - y3) / (y1 - y3) + x3) return c % 2 == 1 cdef intersections circle_line(double x1, double y1, double x2, double y2): """Intersection of a line defined by two points with a unit circle""" cdef double a, b, delta, dx, dy cdef double tolerance = 1.e-10 cdef intersections inter dx = x2 - x1 dy = y2 - y1 if fabs(dx) < tolerance and fabs(dy) < tolerance: inter.p1.x = 2. inter.p1.y = 2. inter.p2.x = 2. inter.p2.y = 2. elif fabs(dx) > fabs(dy): # Find the slope and intercept of the line a = dy / dx b = y1 - a * x1 # Find the determinant of the quadratic equation delta = 1. + a * a - b * b if delta > 0.: # solutions exist delta = sqrt(delta) inter.p1.x = (- a * b - delta) / (1. + a * a) inter.p1.y = a * inter.p1.x + b inter.p2.x = (- a * b + delta) / (1. + a * a) inter.p2.y = a * inter.p2.x + b else: # no solution, return values > 1 inter.p1.x = 2. inter.p1.y = 2. inter.p2.x = 2. inter.p2.y = 2. else: # Find the slope and intercept of the line a = dx / dy b = x1 - a * y1 # Find the determinant of the quadratic equation delta = 1. + a * a - b * b if delta > 0.: # solutions exist delta = sqrt(delta) inter.p1.y = (- a * b - delta) / (1. + a * a) inter.p1.x = a * inter.p1.y + b inter.p2.y = (- a * b + delta) / (1. + a * a) inter.p2.x = a * inter.p2.y + b else: # no solution, return values > 1 inter.p1.x = 2. inter.p1.y = 2. inter.p2.x = 2. inter.p2.y = 2. return inter cdef point circle_segment_single2(double x1, double y1, double x2, double y2): """ The intersection of a line with the unit circle. The intersection the closest to (x2, y2) is chosen. """ cdef double dx1, dy1, dx2, dy2 cdef intersections inter cdef point pt1, pt2, pt inter = circle_line(x1, y1, x2, y2) pt1 = inter.p1 pt2 = inter.p2 # Can be optimized, but just checking for correctness right now dx1 = fabs(pt1.x - x2) dy1 = fabs(pt1.y - y2) dx2 = fabs(pt2.x - x2) dy2 = fabs(pt2.y - y2) if dx1 > dy1: # compare based on x-axis if dx1 > dx2: pt = pt2 else: pt = pt1 else: if dy1 > dy2: pt = pt2 else: pt = pt1 return pt cdef intersections circle_segment(double x1, double y1, double x2, double y2): """ Intersection(s) of a segment with the unit circle. Discard any solution not on the segment. """ cdef intersections inter, inter_new cdef point pt1, pt2 inter = circle_line(x1, y1, x2, y2) pt1 = inter.p1 pt2 = inter.p2 if (pt1.x > x1 and pt1.x > x2) or (pt1.x < x1 and pt1.x < x2) or (pt1.y > y1 and pt1.y > y2) or (pt1.y < y1 and pt1.y < y2): pt1.x, pt1.y = 2., 2. if (pt2.x > x1 and pt2.x > x2) or (pt2.x < x1 and pt2.x < x2) or (pt2.y > y1 and pt2.y > y2) or (pt2.y < y1 and pt2.y < y2): pt2.x, pt2.y = 2., 2. if pt1.x > 1. and pt2.x < 2.: inter_new.p1 = pt1 inter_new.p2 = pt2 else: inter_new.p1 = pt2 inter_new.p2 = pt1 return inter_new cdef double overlap_area_triangle_unit_circle(double x1, double y1, double x2, double y2, double x3, double y3): """ Given a triangle defined by three points (x1, y1), (x2, y2), and (x3, y3), find the area of overlap with the unit circle. """ cdef double d1, d2, d3 cdef bool in1, in2, in3 cdef bool on1, on2, on3 cdef double area cdef double PI = np.pi cdef intersections inter cdef point pt1, pt2, pt3, pt4, pt5, pt6, pt_tmp # Find distance of all vertices to circle center d1 = x1 * x1 + y1 * y1 d2 = x2 * x2 + y2 * y2 d3 = x3 * x3 + y3 * y3 # Order vertices by distance from origin if d1 < d2: if d2 < d3: pass elif d1 < d3: x2, y2, d2, x3, y3, d3 = x3, y3, d3, x2, y2, d2 else: x1, y1, d1, x2, y2, d2, x3, y3, d3 = x3, y3, d3, x1, y1, d1, x2, y2, d2 else: if d1 < d3: x1, y1, d1, x2, y2, d2 = x2, y2, d2, x1, y1, d1 elif d2 < d3: x1, y1, d1, x2, y2, d2, x3, y3, d3 = x2, y2, d2, x3, y3, d3, x1, y1, d1 else: x1, y1, d1, x2, y2, d2, x3, y3, d3 = x3, y3, d3, x2, y2, d2, x1, y1, d1 if d1 > d2 or d2 > d3 or d1 > d3: raise Exception("ERROR: vertices did not sort correctly") # Determine number of vertices inside circle in1 = d1 < 1 in2 = d2 < 1 in3 = d3 < 1 # Determine which vertices are on the circle on1 = fabs(d1 - 1) < 1.e-10 on2 = fabs(d2 - 1) < 1.e-10 on3 = fabs(d3 - 1) < 1.e-10 if on3 or in3: # triangle is completely in circle area = area_triangle(x1, y1, x2, y2, x3, y3) elif in2 or on2: # If vertex 1 or 2 are on the edge of the circle, then we use the dot # product to vertex 3 to determine whether an intersection takes place. intersect13 = not on1 or x1 * (x3 - x1) + y1 * (y3 - y1) < 0. intersect23 = not on2 or x2 * (x3 - x2) + y2 * (y3 - y2) < 0. if intersect13 and intersect23 and not on2: pt1 = circle_segment_single2(x1, y1, x3, y3) pt2 = circle_segment_single2(x2, y2, x3, y3) area = area_triangle(x1, y1, x2, y2, pt1.x, pt1.y) \ + area_triangle(x2, y2, pt1.x, pt1.y, pt2.x, pt2.y) \ + area_arc_unit(pt1.x, pt1.y, pt2.x, pt2.y) elif intersect13: pt1 = circle_segment_single2(x1, y1, x3, y3) area = area_triangle(x1, y1, x2, y2, pt1.x, pt1.y) \ + area_arc_unit(x2, y2, pt1.x, pt1.y) elif intersect23: pt2 = circle_segment_single2(x2, y2, x3, y3) area = area_triangle(x1, y1, x2, y2, pt2.x, pt2.y) \ + area_arc_unit(x1, y1, pt2.x, pt2.y) else: area = area_arc_unit(x1, y1, x2, y2) elif on1: # The triangle is outside the circle area = 0.0 elif in1: # Check for intersections of far side with circle inter = circle_segment(x2, y2, x3, y3) pt1 = inter.p1 pt2 = inter.p2 pt3 = circle_segment_single2(x1, y1, x2, y2) pt4 = circle_segment_single2(x1, y1, x3, y3) if pt1.x > 1.: # indicates no intersection # Code taken from `sep.h`. # TODO: use `sep` and get rid of this Cython code. if (((0.-pt3.y) * (pt4.x-pt3.x) > (pt4.y-pt3.y) * (0.-pt3.x)) != ((y1-pt3.y) * (pt4.x-pt3.x) > (pt4.y-pt3.y) * (x1-pt3.x))): area = area_triangle(x1, y1, pt3.x, pt3.y, pt4.x, pt4.y) \ + (PI - area_arc_unit(pt3.x, pt3.y, pt4.x, pt4.y)) else: area = area_triangle(x1, y1, pt3.x, pt3.y, pt4.x, pt4.y) \ + area_arc_unit(pt3.x, pt3.y, pt4.x, pt4.y) else: if (pt2.x - x2)**2 + (pt2.y - y2)**2 < (pt1.x - x2)**2 + (pt1.y - y2)**2: pt1, pt2 = pt2, pt1 area = area_triangle(x1, y1, pt3.x, pt3.y, pt1.x, pt1.y) \ + area_triangle(x1, y1, pt1.x, pt1.y, pt2.x, pt2.y) \ + area_triangle(x1, y1, pt2.x, pt2.y, pt4.x, pt4.y) \ + area_arc_unit(pt1.x, pt1.y, pt3.x, pt3.y) \ + area_arc_unit(pt2.x, pt2.y, pt4.x, pt4.y) else: inter = circle_segment(x1, y1, x2, y2) pt1 = inter.p1 pt2 = inter.p2 inter = circle_segment(x2, y2, x3, y3) pt3 = inter.p1 pt4 = inter.p2 inter = circle_segment(x3, y3, x1, y1) pt5 = inter.p1 pt6 = inter.p2 if pt1.x <= 1.: xp, yp = 0.5 * (pt1.x + pt2.x), 0.5 * (pt1.y + pt2.y) area = overlap_area_triangle_unit_circle(x1, y1, x3, y3, xp, yp) \ + overlap_area_triangle_unit_circle(x2, y2, x3, y3, xp, yp) elif pt3.x <= 1.: xp, yp = 0.5 * (pt3.x + pt4.x), 0.5 * (pt3.y + pt4.y) area = overlap_area_triangle_unit_circle(x3, y3, x1, y1, xp, yp) \ + overlap_area_triangle_unit_circle(x2, y2, x1, y1, xp, yp) elif pt5.x <= 1.: xp, yp = 0.5 * (pt5.x + pt6.x), 0.5 * (pt5.y + pt6.y) area = overlap_area_triangle_unit_circle(x1, y1, x2, y2, xp, yp) \ + overlap_area_triangle_unit_circle(x3, y3, x2, y2, xp, yp) else: # no intersections if in_triangle(0., 0., x1, y1, x2, y2, x3, y3): return PI else: return 0. return area photutils-0.2.1/photutils/geometry/elliptical_overlap.c0000600000214200020070000116025212646264031025637 0ustar lbradleySTSCI\science00000000000000/* Generated by Cython 0.23.4 */ #define PY_SSIZE_T_CLEAN #include "Python.h" #ifndef Py_PYTHON_H #error Python headers needed to compile C extensions, please install development version of Python. #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000) #error Cython requires Python 2.6+ or Python 3.2+. #else #define CYTHON_ABI "0_23_4" #include #ifndef offsetof #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) #endif #if !defined(WIN32) && !defined(MS_WINDOWS) #ifndef __stdcall #define __stdcall #endif #ifndef __cdecl #define __cdecl #endif #ifndef __fastcall #define __fastcall #endif #endif #ifndef DL_IMPORT #define DL_IMPORT(t) t #endif #ifndef DL_EXPORT #define DL_EXPORT(t) t #endif #ifndef PY_LONG_LONG #define PY_LONG_LONG LONG_LONG #endif #ifndef Py_HUGE_VAL #define Py_HUGE_VAL HUGE_VAL #endif #ifdef PYPY_VERSION #define CYTHON_COMPILING_IN_PYPY 1 #define CYTHON_COMPILING_IN_CPYTHON 0 #else #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_CPYTHON 1 #endif #if !defined(CYTHON_USE_PYLONG_INTERNALS) && CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x02070000 #define CYTHON_USE_PYLONG_INTERNALS 1 #endif #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag) #define Py_OptimizeFlag 0 #endif #define __PYX_BUILD_PY_SSIZE_T "n" #define CYTHON_FORMAT_SSIZE_T "z" #if PY_MAJOR_VERSION < 3 #define __Pyx_BUILTIN_MODULE_NAME "__builtin__" #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) #define __Pyx_DefaultClassType PyClass_Type #else #define __Pyx_BUILTIN_MODULE_NAME "builtins" #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) #define __Pyx_DefaultClassType PyType_Type #endif #ifndef Py_TPFLAGS_CHECKTYPES #define Py_TPFLAGS_CHECKTYPES 0 #endif #ifndef Py_TPFLAGS_HAVE_INDEX #define Py_TPFLAGS_HAVE_INDEX 0 #endif #ifndef Py_TPFLAGS_HAVE_NEWBUFFER #define Py_TPFLAGS_HAVE_NEWBUFFER 0 #endif #ifndef Py_TPFLAGS_HAVE_FINALIZE #define Py_TPFLAGS_HAVE_FINALIZE 0 #endif #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) #define CYTHON_PEP393_ENABLED 1 #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\ 0 : _PyUnicode_Ready((PyObject *)(op))) #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u) #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i) #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u) #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u) #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i) #else #define CYTHON_PEP393_ENABLED 0 #define __Pyx_PyUnicode_READY(op) (0) #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u) #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i])) #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE)) #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u)) #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i])) #endif #if CYTHON_COMPILING_IN_PYPY #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b) #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b) #else #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b) #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\ PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b)) #endif #if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains) #define PyUnicode_Contains(u, s) PySequence_Contains(u, s) #endif #define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b)) #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b)) #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b) #else #define __Pyx_PyString_Format(a, b) PyString_Format(a, b) #endif #if PY_MAJOR_VERSION >= 3 #define PyBaseString_Type PyUnicode_Type #define PyStringObject PyUnicodeObject #define PyString_Type PyUnicode_Type #define PyString_Check PyUnicode_Check #define PyString_CheckExact PyUnicode_CheckExact #endif #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj) #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj) #else #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj)) #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj)) #endif #ifndef PySet_CheckExact #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) #endif #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) #if PY_MAJOR_VERSION >= 3 #define PyIntObject PyLongObject #define PyInt_Type PyLong_Type #define PyInt_Check(op) PyLong_Check(op) #define PyInt_CheckExact(op) PyLong_CheckExact(op) #define PyInt_FromString PyLong_FromString #define PyInt_FromUnicode PyLong_FromUnicode #define PyInt_FromLong PyLong_FromLong #define PyInt_FromSize_t PyLong_FromSize_t #define PyInt_FromSsize_t PyLong_FromSsize_t #define PyInt_AsLong PyLong_AsLong #define PyInt_AS_LONG PyLong_AS_LONG #define PyInt_AsSsize_t PyLong_AsSsize_t #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask #define PyNumber_Int PyNumber_Long #endif #if PY_MAJOR_VERSION >= 3 #define PyBoolObject PyLongObject #endif #if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY #ifndef PyUnicode_InternFromString #define PyUnicode_InternFromString(s) PyUnicode_FromString(s) #endif #endif #if PY_VERSION_HEX < 0x030200A4 typedef long Py_hash_t; #define __Pyx_PyInt_FromHash_t PyInt_FromLong #define __Pyx_PyInt_AsHash_t PyInt_AsLong #else #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t #endif #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func)) #else #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass) #endif #if PY_VERSION_HEX >= 0x030500B1 #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async) #elif CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 typedef struct { unaryfunc am_await; unaryfunc am_aiter; unaryfunc am_anext; } __Pyx_PyAsyncMethodsStruct; #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved)) #else #define __Pyx_PyType_AsAsync(obj) NULL #endif #ifndef CYTHON_RESTRICT #if defined(__GNUC__) #define CYTHON_RESTRICT __restrict__ #elif defined(_MSC_VER) && _MSC_VER >= 1400 #define CYTHON_RESTRICT __restrict #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define CYTHON_RESTRICT restrict #else #define CYTHON_RESTRICT #endif #endif #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None) #ifndef CYTHON_INLINE #if defined(__GNUC__) #define CYTHON_INLINE __inline__ #elif defined(_MSC_VER) #define CYTHON_INLINE __inline #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define CYTHON_INLINE inline #else #define CYTHON_INLINE #endif #endif #if defined(WIN32) || defined(MS_WINDOWS) #define _USE_MATH_DEFINES #endif #include #ifdef NAN #define __PYX_NAN() ((float) NAN) #else static CYTHON_INLINE float __PYX_NAN() { float value; memset(&value, 0xFF, sizeof(value)); return value; } #endif #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) #else #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) #endif #ifndef __PYX_EXTERN_C #ifdef __cplusplus #define __PYX_EXTERN_C extern "C" #else #define __PYX_EXTERN_C extern #endif #endif #define __PYX_HAVE__photutils__geometry__elliptical_overlap #define __PYX_HAVE_API__photutils__geometry__elliptical_overlap #include "string.h" #include "stdio.h" #include "stdlib.h" #include "numpy/arrayobject.h" #include "numpy/ufuncobject.h" #include "math.h" #include "pythread.h" #ifdef _OPENMP #include #endif /* _OPENMP */ #ifdef PYREX_WITHOUT_ASSERTIONS #define CYTHON_WITHOUT_ASSERTIONS #endif #ifndef CYTHON_UNUSED # if defined(__GNUC__) # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) # define CYTHON_UNUSED __attribute__ ((__unused__)) # else # define CYTHON_UNUSED # endif # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER)) # define CYTHON_UNUSED __attribute__ ((__unused__)) # else # define CYTHON_UNUSED # endif #endif #ifndef CYTHON_NCP_UNUSED # if CYTHON_COMPILING_IN_CPYTHON # define CYTHON_NCP_UNUSED # else # define CYTHON_NCP_UNUSED CYTHON_UNUSED # endif #endif typedef struct {PyObject **p; char *s; const Py_ssize_t n; const char* encoding; const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0 #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0 #define __PYX_DEFAULT_STRING_ENCODING "" #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize #define __Pyx_uchar_cast(c) ((unsigned char)c) #define __Pyx_long_cast(x) ((long)x) #define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\ (sizeof(type) < sizeof(Py_ssize_t)) ||\ (sizeof(type) > sizeof(Py_ssize_t) &&\ likely(v < (type)PY_SSIZE_T_MAX ||\ v == (type)PY_SSIZE_T_MAX) &&\ (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\ v == (type)PY_SSIZE_T_MIN))) ||\ (sizeof(type) == sizeof(Py_ssize_t) &&\ (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\ v == (type)PY_SSIZE_T_MAX))) ) #if defined (__cplusplus) && __cplusplus >= 201103L #include #define __Pyx_sst_abs(value) std::abs(value) #elif SIZEOF_INT >= SIZEOF_SIZE_T #define __Pyx_sst_abs(value) abs(value) #elif SIZEOF_LONG >= SIZEOF_SIZE_T #define __Pyx_sst_abs(value) labs(value) #elif defined (_MSC_VER) && defined (_M_X64) #define __Pyx_sst_abs(value) _abs64(value) #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define __Pyx_sst_abs(value) llabs(value) #elif defined (__GNUC__) #define __Pyx_sst_abs(value) __builtin_llabs(value) #else #define __Pyx_sst_abs(value) ((value<0) ? -value : value) #endif static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*); static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s)) #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l) #define __Pyx_PyBytes_FromString PyBytes_FromString #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); #if PY_MAJOR_VERSION < 3 #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize #else #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize #endif #define __Pyx_PyObject_AsSString(s) ((signed char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s) #define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s) #define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s) #define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s) #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s) #if PY_MAJOR_VERSION < 3 static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) { const Py_UNICODE *u_end = u; while (*u_end++) ; return (size_t)(u_end - u - 1); } #else #define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen #endif #define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u)) #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj) #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None) #define __Pyx_PyBool_FromLong(b) ((b) ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False)) static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x); static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); #if CYTHON_COMPILING_IN_CPYTHON #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x)) #else #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x) #endif #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x)) #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII static int __Pyx_sys_getdefaultencoding_not_ascii; static int __Pyx_init_sys_getdefaultencoding_params(void) { PyObject* sys; PyObject* default_encoding = NULL; PyObject* ascii_chars_u = NULL; PyObject* ascii_chars_b = NULL; const char* default_encoding_c; sys = PyImport_ImportModule("sys"); if (!sys) goto bad; default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL); Py_DECREF(sys); if (!default_encoding) goto bad; default_encoding_c = PyBytes_AsString(default_encoding); if (!default_encoding_c) goto bad; if (strcmp(default_encoding_c, "ascii") == 0) { __Pyx_sys_getdefaultencoding_not_ascii = 0; } else { char ascii_chars[128]; int c; for (c = 0; c < 128; c++) { ascii_chars[c] = c; } __Pyx_sys_getdefaultencoding_not_ascii = 1; ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL); if (!ascii_chars_u) goto bad; ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL); if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) { PyErr_Format( PyExc_ValueError, "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.", default_encoding_c); goto bad; } Py_DECREF(ascii_chars_u); Py_DECREF(ascii_chars_b); } Py_DECREF(default_encoding); return 0; bad: Py_XDECREF(default_encoding); Py_XDECREF(ascii_chars_u); Py_XDECREF(ascii_chars_b); return -1; } #endif #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL) #else #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL) #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT static char* __PYX_DEFAULT_STRING_ENCODING; static int __Pyx_init_sys_getdefaultencoding_params(void) { PyObject* sys; PyObject* default_encoding = NULL; char* default_encoding_c; sys = PyImport_ImportModule("sys"); if (!sys) goto bad; default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL); Py_DECREF(sys); if (!default_encoding) goto bad; default_encoding_c = PyBytes_AsString(default_encoding); if (!default_encoding_c) goto bad; __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c)); if (!__PYX_DEFAULT_STRING_ENCODING) goto bad; strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c); Py_DECREF(default_encoding); return 0; bad: Py_XDECREF(default_encoding); return -1; } #endif #endif /* Test for GCC > 2.95 */ #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))) #define likely(x) __builtin_expect(!!(x), 1) #define unlikely(x) __builtin_expect(!!(x), 0) #else /* !__GNUC__ or GCC < 2.95 */ #define likely(x) (x) #define unlikely(x) (x) #endif /* __GNUC__ */ static PyObject *__pyx_m; static PyObject *__pyx_d; static PyObject *__pyx_b; static PyObject *__pyx_empty_tuple; static PyObject *__pyx_empty_bytes; static int __pyx_lineno; static int __pyx_clineno = 0; static const char * __pyx_cfilenm= __FILE__; static const char *__pyx_filename; #if !defined(CYTHON_CCOMPLEX) #if defined(__cplusplus) #define CYTHON_CCOMPLEX 1 #elif defined(_Complex_I) #define CYTHON_CCOMPLEX 1 #else #define CYTHON_CCOMPLEX 0 #endif #endif #if CYTHON_CCOMPLEX #ifdef __cplusplus #include #else #include #endif #endif #if CYTHON_CCOMPLEX && !defined(__cplusplus) && defined(__sun__) && defined(__GNUC__) #undef _Complex_I #define _Complex_I 1.0fj #endif static const char *__pyx_f[] = { "photutils/geometry/elliptical_overlap.pyx", "__init__.pxd", "type.pxd", "bool.pxd", "complex.pxd", }; #define IS_UNSIGNED(type) (((type) -1) > 0) struct __Pyx_StructField_; #define __PYX_BUF_FLAGS_PACKED_STRUCT (1 << 0) typedef struct { const char* name; struct __Pyx_StructField_* fields; size_t size; size_t arraysize[8]; int ndim; char typegroup; char is_unsigned; int flags; } __Pyx_TypeInfo; typedef struct __Pyx_StructField_ { __Pyx_TypeInfo* type; const char* name; size_t offset; } __Pyx_StructField; typedef struct { __Pyx_StructField* field; size_t parent_offset; } __Pyx_BufFmt_StackElem; typedef struct { __Pyx_StructField root; __Pyx_BufFmt_StackElem* head; size_t fmt_offset; size_t new_count, enc_count; size_t struct_alignment; int is_complex; char enc_type; char new_packmode; char enc_packmode; char is_valid_array; } __Pyx_BufFmt_Context; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":725 * # in Cython to enable them only on the right systems. * * ctypedef npy_int8 int8_t # <<<<<<<<<<<<<< * ctypedef npy_int16 int16_t * ctypedef npy_int32 int32_t */ typedef npy_int8 __pyx_t_5numpy_int8_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":726 * * ctypedef npy_int8 int8_t * ctypedef npy_int16 int16_t # <<<<<<<<<<<<<< * ctypedef npy_int32 int32_t * ctypedef npy_int64 int64_t */ typedef npy_int16 __pyx_t_5numpy_int16_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":727 * ctypedef npy_int8 int8_t * ctypedef npy_int16 int16_t * ctypedef npy_int32 int32_t # <<<<<<<<<<<<<< * ctypedef npy_int64 int64_t * #ctypedef npy_int96 int96_t */ typedef npy_int32 __pyx_t_5numpy_int32_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":728 * ctypedef npy_int16 int16_t * ctypedef npy_int32 int32_t * ctypedef npy_int64 int64_t # <<<<<<<<<<<<<< * #ctypedef npy_int96 int96_t * #ctypedef npy_int128 int128_t */ typedef npy_int64 __pyx_t_5numpy_int64_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":732 * #ctypedef npy_int128 int128_t * * ctypedef npy_uint8 uint8_t # <<<<<<<<<<<<<< * ctypedef npy_uint16 uint16_t * ctypedef npy_uint32 uint32_t */ typedef npy_uint8 __pyx_t_5numpy_uint8_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":733 * * ctypedef npy_uint8 uint8_t * ctypedef npy_uint16 uint16_t # <<<<<<<<<<<<<< * ctypedef npy_uint32 uint32_t * ctypedef npy_uint64 uint64_t */ typedef npy_uint16 __pyx_t_5numpy_uint16_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":734 * ctypedef npy_uint8 uint8_t * ctypedef npy_uint16 uint16_t * ctypedef npy_uint32 uint32_t # <<<<<<<<<<<<<< * ctypedef npy_uint64 uint64_t * #ctypedef npy_uint96 uint96_t */ typedef npy_uint32 __pyx_t_5numpy_uint32_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":735 * ctypedef npy_uint16 uint16_t * ctypedef npy_uint32 uint32_t * ctypedef npy_uint64 uint64_t # <<<<<<<<<<<<<< * #ctypedef npy_uint96 uint96_t * #ctypedef npy_uint128 uint128_t */ typedef npy_uint64 __pyx_t_5numpy_uint64_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":739 * #ctypedef npy_uint128 uint128_t * * ctypedef npy_float32 float32_t # <<<<<<<<<<<<<< * ctypedef npy_float64 float64_t * #ctypedef npy_float80 float80_t */ typedef npy_float32 __pyx_t_5numpy_float32_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":740 * * ctypedef npy_float32 float32_t * ctypedef npy_float64 float64_t # <<<<<<<<<<<<<< * #ctypedef npy_float80 float80_t * #ctypedef npy_float128 float128_t */ typedef npy_float64 __pyx_t_5numpy_float64_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":749 * # The int types are mapped a bit surprising -- * # numpy.int corresponds to 'l' and numpy.long to 'q' * ctypedef npy_long int_t # <<<<<<<<<<<<<< * ctypedef npy_longlong long_t * ctypedef npy_longlong longlong_t */ typedef npy_long __pyx_t_5numpy_int_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":750 * # numpy.int corresponds to 'l' and numpy.long to 'q' * ctypedef npy_long int_t * ctypedef npy_longlong long_t # <<<<<<<<<<<<<< * ctypedef npy_longlong longlong_t * */ typedef npy_longlong __pyx_t_5numpy_long_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":751 * ctypedef npy_long int_t * ctypedef npy_longlong long_t * ctypedef npy_longlong longlong_t # <<<<<<<<<<<<<< * * ctypedef npy_ulong uint_t */ typedef npy_longlong __pyx_t_5numpy_longlong_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":753 * ctypedef npy_longlong longlong_t * * ctypedef npy_ulong uint_t # <<<<<<<<<<<<<< * ctypedef npy_ulonglong ulong_t * ctypedef npy_ulonglong ulonglong_t */ typedef npy_ulong __pyx_t_5numpy_uint_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":754 * * ctypedef npy_ulong uint_t * ctypedef npy_ulonglong ulong_t # <<<<<<<<<<<<<< * ctypedef npy_ulonglong ulonglong_t * */ typedef npy_ulonglong __pyx_t_5numpy_ulong_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":755 * ctypedef npy_ulong uint_t * ctypedef npy_ulonglong ulong_t * ctypedef npy_ulonglong ulonglong_t # <<<<<<<<<<<<<< * * ctypedef npy_intp intp_t */ typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":757 * ctypedef npy_ulonglong ulonglong_t * * ctypedef npy_intp intp_t # <<<<<<<<<<<<<< * ctypedef npy_uintp uintp_t * */ typedef npy_intp __pyx_t_5numpy_intp_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":758 * * ctypedef npy_intp intp_t * ctypedef npy_uintp uintp_t # <<<<<<<<<<<<<< * * ctypedef npy_double float_t */ typedef npy_uintp __pyx_t_5numpy_uintp_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":760 * ctypedef npy_uintp uintp_t * * ctypedef npy_double float_t # <<<<<<<<<<<<<< * ctypedef npy_double double_t * ctypedef npy_longdouble longdouble_t */ typedef npy_double __pyx_t_5numpy_float_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":761 * * ctypedef npy_double float_t * ctypedef npy_double double_t # <<<<<<<<<<<<<< * ctypedef npy_longdouble longdouble_t * */ typedef npy_double __pyx_t_5numpy_double_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":762 * ctypedef npy_double float_t * ctypedef npy_double double_t * ctypedef npy_longdouble longdouble_t # <<<<<<<<<<<<<< * * ctypedef npy_cfloat cfloat_t */ typedef npy_longdouble __pyx_t_5numpy_longdouble_t; /* "photutils/geometry/elliptical_overlap.pyx":26 * * DTYPE = np.float64 * ctypedef np.float64_t DTYPE_t # <<<<<<<<<<<<<< * * cimport cython */ typedef __pyx_t_5numpy_float64_t __pyx_t_9photutils_8geometry_18elliptical_overlap_DTYPE_t; #if CYTHON_CCOMPLEX #ifdef __cplusplus typedef ::std::complex< float > __pyx_t_float_complex; #else typedef float _Complex __pyx_t_float_complex; #endif #else typedef struct { float real, imag; } __pyx_t_float_complex; #endif #if CYTHON_CCOMPLEX #ifdef __cplusplus typedef ::std::complex< double > __pyx_t_double_complex; #else typedef double _Complex __pyx_t_double_complex; #endif #else typedef struct { double real, imag; } __pyx_t_double_complex; #endif /*--- Type declarations ---*/ /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":764 * ctypedef npy_longdouble longdouble_t * * ctypedef npy_cfloat cfloat_t # <<<<<<<<<<<<<< * ctypedef npy_cdouble cdouble_t * ctypedef npy_clongdouble clongdouble_t */ typedef npy_cfloat __pyx_t_5numpy_cfloat_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":765 * * ctypedef npy_cfloat cfloat_t * ctypedef npy_cdouble cdouble_t # <<<<<<<<<<<<<< * ctypedef npy_clongdouble clongdouble_t * */ typedef npy_cdouble __pyx_t_5numpy_cdouble_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":766 * ctypedef npy_cfloat cfloat_t * ctypedef npy_cdouble cdouble_t * ctypedef npy_clongdouble clongdouble_t # <<<<<<<<<<<<<< * * ctypedef npy_cdouble complex_t */ typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":768 * ctypedef npy_clongdouble clongdouble_t * * ctypedef npy_cdouble complex_t # <<<<<<<<<<<<<< * * cdef inline object PyArray_MultiIterNew1(a): */ typedef npy_cdouble __pyx_t_5numpy_complex_t; /* --- Runtime support code (head) --- */ #ifndef CYTHON_REFNANNY #define CYTHON_REFNANNY 0 #endif #if CYTHON_REFNANNY typedef struct { void (*INCREF)(void*, PyObject*, int); void (*DECREF)(void*, PyObject*, int); void (*GOTREF)(void*, PyObject*, int); void (*GIVEREF)(void*, PyObject*, int); void* (*SetupContext)(const char*, int, const char*); void (*FinishContext)(void**); } __Pyx_RefNannyAPIStruct; static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL; static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL; #ifdef WITH_THREAD #define __Pyx_RefNannySetupContext(name, acquire_gil)\ if (acquire_gil) {\ PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\ __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\ PyGILState_Release(__pyx_gilstate_save);\ } else {\ __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\ } #else #define __Pyx_RefNannySetupContext(name, acquire_gil)\ __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__) #endif #define __Pyx_RefNannyFinishContext()\ __Pyx_RefNanny->FinishContext(&__pyx_refnanny) #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__) #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__) #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__) #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__) #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0) #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0) #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0) #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0) #else #define __Pyx_RefNannyDeclarations #define __Pyx_RefNannySetupContext(name, acquire_gil) #define __Pyx_RefNannyFinishContext() #define __Pyx_INCREF(r) Py_INCREF(r) #define __Pyx_DECREF(r) Py_DECREF(r) #define __Pyx_GOTREF(r) #define __Pyx_GIVEREF(r) #define __Pyx_XINCREF(r) Py_XINCREF(r) #define __Pyx_XDECREF(r) Py_XDECREF(r) #define __Pyx_XGOTREF(r) #define __Pyx_XGIVEREF(r) #endif #define __Pyx_XDECREF_SET(r, v) do {\ PyObject *tmp = (PyObject *) r;\ r = v; __Pyx_XDECREF(tmp);\ } while (0) #define __Pyx_DECREF_SET(r, v) do {\ PyObject *tmp = (PyObject *) r;\ r = v; __Pyx_DECREF(tmp);\ } while (0) #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0) #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0) #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) { PyTypeObject* tp = Py_TYPE(obj); if (likely(tp->tp_getattro)) return tp->tp_getattro(obj, attr_name); #if PY_MAJOR_VERSION < 3 if (likely(tp->tp_getattr)) return tp->tp_getattr(obj, PyString_AS_STRING(attr_name)); #endif return PyObject_GetAttr(obj, attr_name); } #else #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n) #endif static PyObject *__Pyx_GetBuiltinName(PyObject *name); static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\ PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\ const char* function_name); static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name); #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw); #else #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw) #endif static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); static CYTHON_INLINE int __Pyx_GetBufferAndValidate(Py_buffer* buf, PyObject* obj, __Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack); static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info); static void __Pyx_RaiseBufferIndexError(int axis); #define __Pyx_BufPtrStrided2d(type, buf, i0, s0, i1, s1) (type)((char*)buf + i0 * s0 + i1 * s1) static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); static void __Pyx_WriteUnraisable(const char *name, int clineno, int lineno, const char *filename, int full_traceback, int nogil); static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) { PyObject *value; value = PyDict_GetItemWithError(d, key); if (unlikely(!value)) { if (!PyErr_Occurred()) { PyObject* args = PyTuple_Pack(1, key); if (likely(args)) PyErr_SetObject(PyExc_KeyError, args); Py_XDECREF(args); } return NULL; } Py_INCREF(value); return value; } #else #define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key) #endif static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected); static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index); static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void); static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); typedef struct { int code_line; PyCodeObject* code_object; } __Pyx_CodeObjectCacheEntry; struct __Pyx_CodeObjectCache { int count; int max_count; __Pyx_CodeObjectCacheEntry* entries; }; static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL}; static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line); static PyCodeObject *__pyx_find_code_object(int code_line); static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object); static void __Pyx_AddTraceback(const char *funcname, int c_line, int py_line, const char *filename); typedef struct { Py_ssize_t shape, strides, suboffsets; } __Pyx_Buf_DimInfo; typedef struct { size_t refcount; Py_buffer pybuffer; } __Pyx_Buffer; typedef struct { __Pyx_Buffer *rcbuffer; char *data; __Pyx_Buf_DimInfo diminfo[8]; } __Pyx_LocalBuf_ND; #if PY_MAJOR_VERSION < 3 static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags); static void __Pyx_ReleaseBuffer(Py_buffer *view); #else #define __Pyx_GetBuffer PyObject_GetBuffer #define __Pyx_ReleaseBuffer PyBuffer_Release #endif static Py_ssize_t __Pyx_zeros[] = {0, 0, 0, 0, 0, 0, 0, 0}; static Py_ssize_t __Pyx_minusones[] = {-1, -1, -1, -1, -1, -1, -1, -1}; static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value); static CYTHON_INLINE unsigned int __Pyx_PyInt_As_unsigned_int(PyObject *); #if CYTHON_CCOMPLEX #ifdef __cplusplus #define __Pyx_CREAL(z) ((z).real()) #define __Pyx_CIMAG(z) ((z).imag()) #else #define __Pyx_CREAL(z) (__real__(z)) #define __Pyx_CIMAG(z) (__imag__(z)) #endif #else #define __Pyx_CREAL(z) ((z).real) #define __Pyx_CIMAG(z) ((z).imag) #endif #if (defined(_WIN32) || defined(__clang__)) && defined(__cplusplus) && CYTHON_CCOMPLEX #define __Pyx_SET_CREAL(z,x) ((z).real(x)) #define __Pyx_SET_CIMAG(z,y) ((z).imag(y)) #else #define __Pyx_SET_CREAL(z,x) __Pyx_CREAL(z) = (x) #define __Pyx_SET_CIMAG(z,y) __Pyx_CIMAG(z) = (y) #endif static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float, float); #if CYTHON_CCOMPLEX #define __Pyx_c_eqf(a, b) ((a)==(b)) #define __Pyx_c_sumf(a, b) ((a)+(b)) #define __Pyx_c_difff(a, b) ((a)-(b)) #define __Pyx_c_prodf(a, b) ((a)*(b)) #define __Pyx_c_quotf(a, b) ((a)/(b)) #define __Pyx_c_negf(a) (-(a)) #ifdef __cplusplus #define __Pyx_c_is_zerof(z) ((z)==(float)0) #define __Pyx_c_conjf(z) (::std::conj(z)) #if 1 #define __Pyx_c_absf(z) (::std::abs(z)) #define __Pyx_c_powf(a, b) (::std::pow(a, b)) #endif #else #define __Pyx_c_is_zerof(z) ((z)==0) #define __Pyx_c_conjf(z) (conjf(z)) #if 1 #define __Pyx_c_absf(z) (cabsf(z)) #define __Pyx_c_powf(a, b) (cpowf(a, b)) #endif #endif #else static CYTHON_INLINE int __Pyx_c_eqf(__pyx_t_float_complex, __pyx_t_float_complex); static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sumf(__pyx_t_float_complex, __pyx_t_float_complex); static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_difff(__pyx_t_float_complex, __pyx_t_float_complex); static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prodf(__pyx_t_float_complex, __pyx_t_float_complex); static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quotf(__pyx_t_float_complex, __pyx_t_float_complex); static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_negf(__pyx_t_float_complex); static CYTHON_INLINE int __Pyx_c_is_zerof(__pyx_t_float_complex); static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conjf(__pyx_t_float_complex); #if 1 static CYTHON_INLINE float __Pyx_c_absf(__pyx_t_float_complex); static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_powf(__pyx_t_float_complex, __pyx_t_float_complex); #endif #endif static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double, double); #if CYTHON_CCOMPLEX #define __Pyx_c_eq(a, b) ((a)==(b)) #define __Pyx_c_sum(a, b) ((a)+(b)) #define __Pyx_c_diff(a, b) ((a)-(b)) #define __Pyx_c_prod(a, b) ((a)*(b)) #define __Pyx_c_quot(a, b) ((a)/(b)) #define __Pyx_c_neg(a) (-(a)) #ifdef __cplusplus #define __Pyx_c_is_zero(z) ((z)==(double)0) #define __Pyx_c_conj(z) (::std::conj(z)) #if 1 #define __Pyx_c_abs(z) (::std::abs(z)) #define __Pyx_c_pow(a, b) (::std::pow(a, b)) #endif #else #define __Pyx_c_is_zero(z) ((z)==0) #define __Pyx_c_conj(z) (conj(z)) #if 1 #define __Pyx_c_abs(z) (cabs(z)) #define __Pyx_c_pow(a, b) (cpow(a, b)) #endif #endif #else static CYTHON_INLINE int __Pyx_c_eq(__pyx_t_double_complex, __pyx_t_double_complex); static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum(__pyx_t_double_complex, __pyx_t_double_complex); static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff(__pyx_t_double_complex, __pyx_t_double_complex); static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod(__pyx_t_double_complex, __pyx_t_double_complex); static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot(__pyx_t_double_complex, __pyx_t_double_complex); static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg(__pyx_t_double_complex); static CYTHON_INLINE int __Pyx_c_is_zero(__pyx_t_double_complex); static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj(__pyx_t_double_complex); #if 1 static CYTHON_INLINE double __Pyx_c_abs(__pyx_t_double_complex); static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow(__pyx_t_double_complex, __pyx_t_double_complex); #endif #endif static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum__NPY_TYPES(enum NPY_TYPES value); static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); static int __Pyx_check_binary_version(void); #if !defined(__Pyx_PyIdentifier_FromString) #if PY_MAJOR_VERSION < 3 #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s) #else #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s) #endif #endif static PyObject *__Pyx_ImportModule(const char *name); static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict); static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig); static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /* Module declarations from 'cpython.buffer' */ /* Module declarations from 'libc.string' */ /* Module declarations from 'libc.stdio' */ /* Module declarations from '__builtin__' */ /* Module declarations from 'cpython.type' */ static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0; /* Module declarations from 'cpython.version' */ /* Module declarations from 'cpython.exc' */ /* Module declarations from 'cpython.module' */ /* Module declarations from 'cpython.mem' */ /* Module declarations from 'cpython.tuple' */ /* Module declarations from 'cpython.list' */ /* Module declarations from 'cpython.sequence' */ /* Module declarations from 'cpython.mapping' */ /* Module declarations from 'cpython.iterator' */ /* Module declarations from 'cpython.number' */ /* Module declarations from 'cpython.int' */ /* Module declarations from '__builtin__' */ /* Module declarations from 'cpython.bool' */ static PyTypeObject *__pyx_ptype_7cpython_4bool_bool = 0; /* Module declarations from 'cpython.long' */ /* Module declarations from 'cpython.float' */ /* Module declarations from '__builtin__' */ /* Module declarations from 'cpython.complex' */ static PyTypeObject *__pyx_ptype_7cpython_7complex_complex = 0; /* Module declarations from 'cpython.string' */ /* Module declarations from 'cpython.unicode' */ /* Module declarations from 'cpython.dict' */ /* Module declarations from 'cpython.instance' */ /* Module declarations from 'cpython.function' */ /* Module declarations from 'cpython.method' */ /* Module declarations from 'cpython.weakref' */ /* Module declarations from 'cpython.getargs' */ /* Module declarations from 'cpython.pythread' */ /* Module declarations from 'cpython.pystate' */ /* Module declarations from 'cpython.cobject' */ /* Module declarations from 'cpython.oldbuffer' */ /* Module declarations from 'cpython.set' */ /* Module declarations from 'cpython.bytes' */ /* Module declarations from 'cpython.pycapsule' */ /* Module declarations from 'cpython' */ /* Module declarations from 'cpython.object' */ /* Module declarations from 'cpython.ref' */ /* Module declarations from 'libc.stdlib' */ /* Module declarations from 'numpy' */ /* Module declarations from 'numpy' */ static PyTypeObject *__pyx_ptype_5numpy_dtype = 0; static PyTypeObject *__pyx_ptype_5numpy_flatiter = 0; static PyTypeObject *__pyx_ptype_5numpy_broadcast = 0; static PyTypeObject *__pyx_ptype_5numpy_ndarray = 0; static PyTypeObject *__pyx_ptype_5numpy_ufunc = 0; static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *, char *, char *, int *); /*proto*/ /* Module declarations from 'cython' */ /* Module declarations from 'photutils.geometry.core' */ static double (*__pyx_f_9photutils_8geometry_4core_distance)(double, double, double, double); /*proto*/ static double (*__pyx_f_9photutils_8geometry_4core_area_triangle)(double, double, double, double, double, double); /*proto*/ static double (*__pyx_f_9photutils_8geometry_4core_overlap_area_triangle_unit_circle)(double, double, double, double, double, double); /*proto*/ /* Module declarations from 'photutils.geometry.elliptical_overlap' */ static double __pyx_f_9photutils_8geometry_18elliptical_overlap_elliptical_overlap_single_subpixel(double, double, double, double, double, double, double, int); /*proto*/ static double __pyx_f_9photutils_8geometry_18elliptical_overlap_elliptical_overlap_single_exact(double, double, double, double, double, double, double); /*proto*/ static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_9photutils_8geometry_18elliptical_overlap_DTYPE_t = { "DTYPE_t", NULL, sizeof(__pyx_t_9photutils_8geometry_18elliptical_overlap_DTYPE_t), { 0 }, 0, 'R', 0, 0 }; #define __Pyx_MODULE_NAME "photutils.geometry.elliptical_overlap" int __pyx_module_is_main_photutils__geometry__elliptical_overlap = 0; /* Implementation of 'photutils.geometry.elliptical_overlap' */ static PyObject *__pyx_builtin_range; static PyObject *__pyx_builtin_ValueError; static PyObject *__pyx_builtin_RuntimeError; static char __pyx_k_B[] = "B"; static char __pyx_k_H[] = "H"; static char __pyx_k_I[] = "I"; static char __pyx_k_L[] = "L"; static char __pyx_k_O[] = "O"; static char __pyx_k_Q[] = "Q"; static char __pyx_k_b[] = "b"; static char __pyx_k_d[] = "d"; static char __pyx_k_f[] = "f"; static char __pyx_k_g[] = "g"; static char __pyx_k_h[] = "h"; static char __pyx_k_i[] = "i"; static char __pyx_k_j[] = "j"; static char __pyx_k_l[] = "l"; static char __pyx_k_q[] = "q"; static char __pyx_k_r[] = "r"; static char __pyx_k_x[] = "x"; static char __pyx_k_y[] = "y"; static char __pyx_k_Zd[] = "Zd"; static char __pyx_k_Zf[] = "Zf"; static char __pyx_k_Zg[] = "Zg"; static char __pyx_k_dx[] = "dx"; static char __pyx_k_dy[] = "dy"; static char __pyx_k_np[] = "np"; static char __pyx_k_nx[] = "nx"; static char __pyx_k_ny[] = "ny"; static char __pyx_k_rx[] = "rx"; static char __pyx_k_ry[] = "ry"; static char __pyx_k_all[] = "__all__"; static char __pyx_k_frac[] = "frac"; static char __pyx_k_main[] = "__main__"; static char __pyx_k_norm[] = "norm"; static char __pyx_k_test[] = "__test__"; static char __pyx_k_xmax[] = "xmax"; static char __pyx_k_xmin[] = "xmin"; static char __pyx_k_ymax[] = "ymax"; static char __pyx_k_ymin[] = "ymin"; static char __pyx_k_DTYPE[] = "DTYPE"; static char __pyx_k_bxmax[] = "bxmax"; static char __pyx_k_bxmin[] = "bxmin"; static char __pyx_k_bymax[] = "bymax"; static char __pyx_k_bymin[] = "bymin"; static char __pyx_k_dtype[] = "dtype"; static char __pyx_k_numpy[] = "numpy"; static char __pyx_k_pxmax[] = "pxmax"; static char __pyx_k_pxmin[] = "pxmin"; static char __pyx_k_pymax[] = "pymax"; static char __pyx_k_pymin[] = "pymin"; static char __pyx_k_range[] = "range"; static char __pyx_k_theta[] = "theta"; static char __pyx_k_zeros[] = "zeros"; static char __pyx_k_import[] = "__import__"; static char __pyx_k_float64[] = "float64"; static char __pyx_k_subpixels[] = "subpixels"; static char __pyx_k_use_exact[] = "use_exact"; static char __pyx_k_ValueError[] = "ValueError"; static char __pyx_k_RuntimeError[] = "RuntimeError"; static char __pyx_k_elliptical_overlap_grid[] = "elliptical_overlap_grid"; static char __pyx_k_ndarray_is_not_C_contiguous[] = "ndarray is not C contiguous"; static char __pyx_k_Users_lbradley_Dropbox_softw_de[] = "/Users/lbradley/Dropbox/softw/development/photutils/photutils/geometry/elliptical_overlap.pyx"; static char __pyx_k_unknown_dtype_code_in_numpy_pxd[] = "unknown dtype code in numpy.pxd (%d)"; static char __pyx_k_Format_string_allocated_too_shor[] = "Format string allocated too short, see comment in numpy.pxd"; static char __pyx_k_Non_native_byte_order_not_suppor[] = "Non-native byte order not supported"; static char __pyx_k_ndarray_is_not_Fortran_contiguou[] = "ndarray is not Fortran contiguous"; static char __pyx_k_photutils_geometry_elliptical_ov[] = "photutils.geometry.elliptical_overlap"; static char __pyx_k_Format_string_allocated_too_shor_2[] = "Format string allocated too short."; static PyObject *__pyx_n_s_DTYPE; static PyObject *__pyx_kp_u_Format_string_allocated_too_shor; static PyObject *__pyx_kp_u_Format_string_allocated_too_shor_2; static PyObject *__pyx_kp_u_Non_native_byte_order_not_suppor; static PyObject *__pyx_n_s_RuntimeError; static PyObject *__pyx_kp_s_Users_lbradley_Dropbox_softw_de; static PyObject *__pyx_n_s_ValueError; static PyObject *__pyx_n_s_all; static PyObject *__pyx_n_s_bxmax; static PyObject *__pyx_n_s_bxmin; static PyObject *__pyx_n_s_bymax; static PyObject *__pyx_n_s_bymin; static PyObject *__pyx_n_s_dtype; static PyObject *__pyx_n_s_dx; static PyObject *__pyx_n_s_dy; static PyObject *__pyx_n_s_elliptical_overlap_grid; static PyObject *__pyx_n_u_elliptical_overlap_grid; static PyObject *__pyx_n_s_float64; static PyObject *__pyx_n_s_frac; static PyObject *__pyx_n_s_i; static PyObject *__pyx_n_s_import; static PyObject *__pyx_n_s_j; static PyObject *__pyx_n_s_main; static PyObject *__pyx_kp_u_ndarray_is_not_C_contiguous; static PyObject *__pyx_kp_u_ndarray_is_not_Fortran_contiguou; static PyObject *__pyx_n_s_norm; static PyObject *__pyx_n_s_np; static PyObject *__pyx_n_s_numpy; static PyObject *__pyx_n_s_nx; static PyObject *__pyx_n_s_ny; static PyObject *__pyx_n_s_photutils_geometry_elliptical_ov; static PyObject *__pyx_n_s_pxmax; static PyObject *__pyx_n_s_pxmin; static PyObject *__pyx_n_s_pymax; static PyObject *__pyx_n_s_pymin; static PyObject *__pyx_n_s_r; static PyObject *__pyx_n_s_range; static PyObject *__pyx_n_s_rx; static PyObject *__pyx_n_s_ry; static PyObject *__pyx_n_s_subpixels; static PyObject *__pyx_n_s_test; static PyObject *__pyx_n_s_theta; static PyObject *__pyx_kp_u_unknown_dtype_code_in_numpy_pxd; static PyObject *__pyx_n_s_use_exact; static PyObject *__pyx_n_s_x; static PyObject *__pyx_n_s_xmax; static PyObject *__pyx_n_s_xmin; static PyObject *__pyx_n_s_y; static PyObject *__pyx_n_s_ymax; static PyObject *__pyx_n_s_ymin; static PyObject *__pyx_n_s_zeros; static PyObject *__pyx_pf_9photutils_8geometry_18elliptical_overlap_elliptical_overlap_grid(CYTHON_UNUSED PyObject *__pyx_self, double __pyx_v_xmin, double __pyx_v_xmax, double __pyx_v_ymin, double __pyx_v_ymax, int __pyx_v_nx, int __pyx_v_ny, double __pyx_v_rx, double __pyx_v_ry, double __pyx_v_theta, int __pyx_v_use_exact, int __pyx_v_subpixels); /* proto */ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /* proto */ static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info); /* proto */ static PyObject *__pyx_tuple_; static PyObject *__pyx_tuple__2; static PyObject *__pyx_tuple__3; static PyObject *__pyx_tuple__4; static PyObject *__pyx_tuple__5; static PyObject *__pyx_tuple__6; static PyObject *__pyx_tuple__7; static PyObject *__pyx_codeobj__8; /* "photutils/geometry/elliptical_overlap.pyx":36 * * * def elliptical_overlap_grid(double xmin, double xmax, double ymin, double ymax, # <<<<<<<<<<<<<< * int nx, int ny, double rx, double ry, double theta, * int use_exact, int subpixels): */ /* Python wrapper */ static PyObject *__pyx_pw_9photutils_8geometry_18elliptical_overlap_1elliptical_overlap_grid(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_9photutils_8geometry_18elliptical_overlap_elliptical_overlap_grid[] = "\n elliptical_overlap_grid(xmin, xmax, ymin, ymax, nx, ny, rx, ry,\n use_exact, subpixels)\n\n Area of overlap between an ellipse and a pixel grid. The ellipse is\n centered on the origin.\n\n Parameters\n ----------\n xmin, xmax, ymin, ymax : float\n Extent of the grid in the x and y direction.\n nx, ny : int\n Grid dimensions.\n rx : float\n The semimajor axis of the ellipse.\n ry : float\n The semiminor axis of the ellipse.\n theta : float\n The position angle of the semimajor axis in radians (counterclockwise).\n use_exact : 0 or 1\n If set to 1, calculates the exact overlap, while if set to 0, uses a\n subpixel sampling method with ``subpixel`` subpixels in each direction.\n subpixels : int\n If ``use_exact`` is 0, each pixel is resampled by this factor in each\n dimension. Thus, each pixel is divided into ``subpixels ** 2``\n subpixels.\n\n Returns\n -------\n frac : `~numpy.ndarray`\n 2-d array giving the fraction of the overlap.\n "; static PyMethodDef __pyx_mdef_9photutils_8geometry_18elliptical_overlap_1elliptical_overlap_grid = {"elliptical_overlap_grid", (PyCFunction)__pyx_pw_9photutils_8geometry_18elliptical_overlap_1elliptical_overlap_grid, METH_VARARGS|METH_KEYWORDS, __pyx_doc_9photutils_8geometry_18elliptical_overlap_elliptical_overlap_grid}; static PyObject *__pyx_pw_9photutils_8geometry_18elliptical_overlap_1elliptical_overlap_grid(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { double __pyx_v_xmin; double __pyx_v_xmax; double __pyx_v_ymin; double __pyx_v_ymax; int __pyx_v_nx; int __pyx_v_ny; double __pyx_v_rx; double __pyx_v_ry; double __pyx_v_theta; int __pyx_v_use_exact; int __pyx_v_subpixels; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("elliptical_overlap_grid (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_xmin,&__pyx_n_s_xmax,&__pyx_n_s_ymin,&__pyx_n_s_ymax,&__pyx_n_s_nx,&__pyx_n_s_ny,&__pyx_n_s_rx,&__pyx_n_s_ry,&__pyx_n_s_theta,&__pyx_n_s_use_exact,&__pyx_n_s_subpixels,0}; PyObject* values[11] = {0,0,0,0,0,0,0,0,0,0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10); case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9); case 9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8); case 8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7); case 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6); case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_xmin)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_xmax)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("elliptical_overlap_grid", 1, 11, 11, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ymin)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("elliptical_overlap_grid", 1, 11, 11, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 3: if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ymax)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("elliptical_overlap_grid", 1, 11, 11, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 4: if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_nx)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("elliptical_overlap_grid", 1, 11, 11, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 5: if (likely((values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ny)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("elliptical_overlap_grid", 1, 11, 11, 5); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 6: if (likely((values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_rx)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("elliptical_overlap_grid", 1, 11, 11, 6); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 7: if (likely((values[7] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ry)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("elliptical_overlap_grid", 1, 11, 11, 7); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 8: if (likely((values[8] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_theta)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("elliptical_overlap_grid", 1, 11, 11, 8); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 9: if (likely((values[9] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_use_exact)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("elliptical_overlap_grid", 1, 11, 11, 9); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 10: if (likely((values[10] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_subpixels)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("elliptical_overlap_grid", 1, 11, 11, 10); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "elliptical_overlap_grid") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 11) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[2] = PyTuple_GET_ITEM(__pyx_args, 2); values[3] = PyTuple_GET_ITEM(__pyx_args, 3); values[4] = PyTuple_GET_ITEM(__pyx_args, 4); values[5] = PyTuple_GET_ITEM(__pyx_args, 5); values[6] = PyTuple_GET_ITEM(__pyx_args, 6); values[7] = PyTuple_GET_ITEM(__pyx_args, 7); values[8] = PyTuple_GET_ITEM(__pyx_args, 8); values[9] = PyTuple_GET_ITEM(__pyx_args, 9); values[10] = PyTuple_GET_ITEM(__pyx_args, 10); } __pyx_v_xmin = __pyx_PyFloat_AsDouble(values[0]); if (unlikely((__pyx_v_xmin == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_xmax = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_xmax == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_ymin = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_ymin == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_ymax = __pyx_PyFloat_AsDouble(values[3]); if (unlikely((__pyx_v_ymax == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_nx = __Pyx_PyInt_As_int(values[4]); if (unlikely((__pyx_v_nx == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_ny = __Pyx_PyInt_As_int(values[5]); if (unlikely((__pyx_v_ny == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_rx = __pyx_PyFloat_AsDouble(values[6]); if (unlikely((__pyx_v_rx == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_ry = __pyx_PyFloat_AsDouble(values[7]); if (unlikely((__pyx_v_ry == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_theta = __pyx_PyFloat_AsDouble(values[8]); if (unlikely((__pyx_v_theta == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_use_exact = __Pyx_PyInt_As_int(values[9]); if (unlikely((__pyx_v_use_exact == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_subpixels = __Pyx_PyInt_As_int(values[10]); if (unlikely((__pyx_v_subpixels == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("elliptical_overlap_grid", 1, 11, 11, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("photutils.geometry.elliptical_overlap.elliptical_overlap_grid", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_9photutils_8geometry_18elliptical_overlap_elliptical_overlap_grid(__pyx_self, __pyx_v_xmin, __pyx_v_xmax, __pyx_v_ymin, __pyx_v_ymax, __pyx_v_nx, __pyx_v_ny, __pyx_v_rx, __pyx_v_ry, __pyx_v_theta, __pyx_v_use_exact, __pyx_v_subpixels); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_9photutils_8geometry_18elliptical_overlap_elliptical_overlap_grid(CYTHON_UNUSED PyObject *__pyx_self, double __pyx_v_xmin, double __pyx_v_xmax, double __pyx_v_ymin, double __pyx_v_ymax, int __pyx_v_nx, int __pyx_v_ny, double __pyx_v_rx, double __pyx_v_ry, double __pyx_v_theta, int __pyx_v_use_exact, int __pyx_v_subpixels) { unsigned int __pyx_v_i; unsigned int __pyx_v_j; double __pyx_v_dx; double __pyx_v_dy; double __pyx_v_bxmin; double __pyx_v_bxmax; double __pyx_v_bymin; double __pyx_v_bymax; double __pyx_v_pxmin; double __pyx_v_pxmax; double __pyx_v_pymin; double __pyx_v_pymax; double __pyx_v_norm; PyArrayObject *__pyx_v_frac = 0; double __pyx_v_r; __Pyx_LocalBuf_ND __pyx_pybuffernd_frac; __Pyx_Buffer __pyx_pybuffer_frac; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyArrayObject *__pyx_t_5 = NULL; double __pyx_t_6; double __pyx_t_7; double __pyx_t_8; int __pyx_t_9; unsigned int __pyx_t_10; int __pyx_t_11; int __pyx_t_12; int __pyx_t_13; unsigned int __pyx_t_14; size_t __pyx_t_15; size_t __pyx_t_16; int __pyx_t_17; size_t __pyx_t_18; size_t __pyx_t_19; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("elliptical_overlap_grid", 0); __pyx_pybuffer_frac.pybuffer.buf = NULL; __pyx_pybuffer_frac.refcount = 0; __pyx_pybuffernd_frac.data = NULL; __pyx_pybuffernd_frac.rcbuffer = &__pyx_pybuffer_frac; /* "photutils/geometry/elliptical_overlap.pyx":79 * * # Define output array * cdef np.ndarray[DTYPE_t, ndim=2] frac = np.zeros([ny, nx], dtype=DTYPE) # <<<<<<<<<<<<<< * * # Find the width of each element in x and y */ __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_ny); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_nx); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyList_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_1); PyList_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_3); PyList_SET_ITEM(__pyx_t_4, 1, __pyx_t_3); __pyx_t_1 = 0; __pyx_t_3 = 0; __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_DTYPE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_5 = ((PyArrayObject *)__pyx_t_1); { __Pyx_BufFmt_StackElem __pyx_stack[1]; if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_frac.rcbuffer->pybuffer, (PyObject*)__pyx_t_5, &__Pyx_TypeInfo_nn___pyx_t_9photutils_8geometry_18elliptical_overlap_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) { __pyx_v_frac = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_frac.rcbuffer->pybuffer.buf = NULL; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } else {__pyx_pybuffernd_frac.diminfo[0].strides = __pyx_pybuffernd_frac.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_frac.diminfo[0].shape = __pyx_pybuffernd_frac.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_frac.diminfo[1].strides = __pyx_pybuffernd_frac.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_frac.diminfo[1].shape = __pyx_pybuffernd_frac.rcbuffer->pybuffer.shape[1]; } } __pyx_t_5 = 0; __pyx_v_frac = ((PyArrayObject *)__pyx_t_1); __pyx_t_1 = 0; /* "photutils/geometry/elliptical_overlap.pyx":82 * * # Find the width of each element in x and y * dx = (xmax - xmin) / nx # <<<<<<<<<<<<<< * dy = (ymax - ymin) / ny * */ __pyx_t_6 = (__pyx_v_xmax - __pyx_v_xmin); if (unlikely(__pyx_v_nx == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "float division"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_v_dx = (__pyx_t_6 / ((double)__pyx_v_nx)); /* "photutils/geometry/elliptical_overlap.pyx":83 * # Find the width of each element in x and y * dx = (xmax - xmin) / nx * dy = (ymax - ymin) / ny # <<<<<<<<<<<<<< * * norm = 1. / (dx * dy) */ __pyx_t_6 = (__pyx_v_ymax - __pyx_v_ymin); if (unlikely(__pyx_v_ny == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "float division"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_v_dy = (__pyx_t_6 / ((double)__pyx_v_ny)); /* "photutils/geometry/elliptical_overlap.pyx":85 * dy = (ymax - ymin) / ny * * norm = 1. / (dx * dy) # <<<<<<<<<<<<<< * * # For now we use a bounding circle and then use that to find a bounding box */ __pyx_t_6 = (__pyx_v_dx * __pyx_v_dy); if (unlikely(__pyx_t_6 == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "float division"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_v_norm = (1. / __pyx_t_6); /* "photutils/geometry/elliptical_overlap.pyx":91 * * # Find bounding circle radius * r = max(rx, ry) # <<<<<<<<<<<<<< * * # Define bounding box */ __pyx_t_6 = __pyx_v_ry; __pyx_t_7 = __pyx_v_rx; if (((__pyx_t_6 > __pyx_t_7) != 0)) { __pyx_t_8 = __pyx_t_6; } else { __pyx_t_8 = __pyx_t_7; } __pyx_v_r = __pyx_t_8; /* "photutils/geometry/elliptical_overlap.pyx":94 * * # Define bounding box * bxmin = -r - 0.5 * dx # <<<<<<<<<<<<<< * bxmax = +r + 0.5 * dx * bymin = -r - 0.5 * dy */ __pyx_v_bxmin = ((-__pyx_v_r) - (0.5 * __pyx_v_dx)); /* "photutils/geometry/elliptical_overlap.pyx":95 * # Define bounding box * bxmin = -r - 0.5 * dx * bxmax = +r + 0.5 * dx # <<<<<<<<<<<<<< * bymin = -r - 0.5 * dy * bymax = +r + 0.5 * dy */ __pyx_v_bxmax = (__pyx_v_r + (0.5 * __pyx_v_dx)); /* "photutils/geometry/elliptical_overlap.pyx":96 * bxmin = -r - 0.5 * dx * bxmax = +r + 0.5 * dx * bymin = -r - 0.5 * dy # <<<<<<<<<<<<<< * bymax = +r + 0.5 * dy * */ __pyx_v_bymin = ((-__pyx_v_r) - (0.5 * __pyx_v_dy)); /* "photutils/geometry/elliptical_overlap.pyx":97 * bxmax = +r + 0.5 * dx * bymin = -r - 0.5 * dy * bymax = +r + 0.5 * dy # <<<<<<<<<<<<<< * * for i in range(nx): */ __pyx_v_bymax = (__pyx_v_r + (0.5 * __pyx_v_dy)); /* "photutils/geometry/elliptical_overlap.pyx":99 * bymax = +r + 0.5 * dy * * for i in range(nx): # <<<<<<<<<<<<<< * pxmin = xmin + i * dx # lower end of pixel * pxmax = pxmin + dx # upper end of pixel */ __pyx_t_9 = __pyx_v_nx; for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) { __pyx_v_i = __pyx_t_10; /* "photutils/geometry/elliptical_overlap.pyx":100 * * for i in range(nx): * pxmin = xmin + i * dx # lower end of pixel # <<<<<<<<<<<<<< * pxmax = pxmin + dx # upper end of pixel * if pxmax > bxmin and pxmin < bxmax: */ __pyx_v_pxmin = (__pyx_v_xmin + (__pyx_v_i * __pyx_v_dx)); /* "photutils/geometry/elliptical_overlap.pyx":101 * for i in range(nx): * pxmin = xmin + i * dx # lower end of pixel * pxmax = pxmin + dx # upper end of pixel # <<<<<<<<<<<<<< * if pxmax > bxmin and pxmin < bxmax: * for j in range(ny): */ __pyx_v_pxmax = (__pyx_v_pxmin + __pyx_v_dx); /* "photutils/geometry/elliptical_overlap.pyx":102 * pxmin = xmin + i * dx # lower end of pixel * pxmax = pxmin + dx # upper end of pixel * if pxmax > bxmin and pxmin < bxmax: # <<<<<<<<<<<<<< * for j in range(ny): * pymin = ymin + j * dy */ __pyx_t_12 = ((__pyx_v_pxmax > __pyx_v_bxmin) != 0); if (__pyx_t_12) { } else { __pyx_t_11 = __pyx_t_12; goto __pyx_L6_bool_binop_done; } __pyx_t_12 = ((__pyx_v_pxmin < __pyx_v_bxmax) != 0); __pyx_t_11 = __pyx_t_12; __pyx_L6_bool_binop_done:; if (__pyx_t_11) { /* "photutils/geometry/elliptical_overlap.pyx":103 * pxmax = pxmin + dx # upper end of pixel * if pxmax > bxmin and pxmin < bxmax: * for j in range(ny): # <<<<<<<<<<<<<< * pymin = ymin + j * dy * pymax = pymin + dy */ __pyx_t_13 = __pyx_v_ny; for (__pyx_t_14 = 0; __pyx_t_14 < __pyx_t_13; __pyx_t_14+=1) { __pyx_v_j = __pyx_t_14; /* "photutils/geometry/elliptical_overlap.pyx":104 * if pxmax > bxmin and pxmin < bxmax: * for j in range(ny): * pymin = ymin + j * dy # <<<<<<<<<<<<<< * pymax = pymin + dy * if pymax > bymin and pymin < bymax: */ __pyx_v_pymin = (__pyx_v_ymin + (__pyx_v_j * __pyx_v_dy)); /* "photutils/geometry/elliptical_overlap.pyx":105 * for j in range(ny): * pymin = ymin + j * dy * pymax = pymin + dy # <<<<<<<<<<<<<< * if pymax > bymin and pymin < bymax: * if use_exact: */ __pyx_v_pymax = (__pyx_v_pymin + __pyx_v_dy); /* "photutils/geometry/elliptical_overlap.pyx":106 * pymin = ymin + j * dy * pymax = pymin + dy * if pymax > bymin and pymin < bymax: # <<<<<<<<<<<<<< * if use_exact: * frac[j, i] = elliptical_overlap_single_exact( */ __pyx_t_12 = ((__pyx_v_pymax > __pyx_v_bymin) != 0); if (__pyx_t_12) { } else { __pyx_t_11 = __pyx_t_12; goto __pyx_L11_bool_binop_done; } __pyx_t_12 = ((__pyx_v_pymin < __pyx_v_bymax) != 0); __pyx_t_11 = __pyx_t_12; __pyx_L11_bool_binop_done:; if (__pyx_t_11) { /* "photutils/geometry/elliptical_overlap.pyx":107 * pymax = pymin + dy * if pymax > bymin and pymin < bymax: * if use_exact: # <<<<<<<<<<<<<< * frac[j, i] = elliptical_overlap_single_exact( * pxmin, pymin, pxmax, pymax, rx, ry, theta) * norm */ __pyx_t_11 = (__pyx_v_use_exact != 0); if (__pyx_t_11) { /* "photutils/geometry/elliptical_overlap.pyx":108 * if pymax > bymin and pymin < bymax: * if use_exact: * frac[j, i] = elliptical_overlap_single_exact( # <<<<<<<<<<<<<< * pxmin, pymin, pxmax, pymax, rx, ry, theta) * norm * else: */ __pyx_t_15 = __pyx_v_j; __pyx_t_16 = __pyx_v_i; __pyx_t_17 = -1; if (unlikely(__pyx_t_15 >= (size_t)__pyx_pybuffernd_frac.diminfo[0].shape)) __pyx_t_17 = 0; if (unlikely(__pyx_t_16 >= (size_t)__pyx_pybuffernd_frac.diminfo[1].shape)) __pyx_t_17 = 1; if (unlikely(__pyx_t_17 != -1)) { __Pyx_RaiseBufferIndexError(__pyx_t_17); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } *__Pyx_BufPtrStrided2d(__pyx_t_9photutils_8geometry_18elliptical_overlap_DTYPE_t *, __pyx_pybuffernd_frac.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_frac.diminfo[0].strides, __pyx_t_16, __pyx_pybuffernd_frac.diminfo[1].strides) = (__pyx_f_9photutils_8geometry_18elliptical_overlap_elliptical_overlap_single_exact(__pyx_v_pxmin, __pyx_v_pymin, __pyx_v_pxmax, __pyx_v_pymax, __pyx_v_rx, __pyx_v_ry, __pyx_v_theta) * __pyx_v_norm); /* "photutils/geometry/elliptical_overlap.pyx":107 * pymax = pymin + dy * if pymax > bymin and pymin < bymax: * if use_exact: # <<<<<<<<<<<<<< * frac[j, i] = elliptical_overlap_single_exact( * pxmin, pymin, pxmax, pymax, rx, ry, theta) * norm */ goto __pyx_L13; } /* "photutils/geometry/elliptical_overlap.pyx":111 * pxmin, pymin, pxmax, pymax, rx, ry, theta) * norm * else: * frac[j, i] = elliptical_overlap_single_subpixel( # <<<<<<<<<<<<<< * pxmin, pymin, pxmax, pymax, rx, ry, theta, * subpixels) */ /*else*/ { /* "photutils/geometry/elliptical_overlap.pyx":113 * frac[j, i] = elliptical_overlap_single_subpixel( * pxmin, pymin, pxmax, pymax, rx, ry, theta, * subpixels) # <<<<<<<<<<<<<< * return frac * */ __pyx_t_18 = __pyx_v_j; __pyx_t_19 = __pyx_v_i; __pyx_t_17 = -1; if (unlikely(__pyx_t_18 >= (size_t)__pyx_pybuffernd_frac.diminfo[0].shape)) __pyx_t_17 = 0; if (unlikely(__pyx_t_19 >= (size_t)__pyx_pybuffernd_frac.diminfo[1].shape)) __pyx_t_17 = 1; if (unlikely(__pyx_t_17 != -1)) { __Pyx_RaiseBufferIndexError(__pyx_t_17); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } *__Pyx_BufPtrStrided2d(__pyx_t_9photutils_8geometry_18elliptical_overlap_DTYPE_t *, __pyx_pybuffernd_frac.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_frac.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_frac.diminfo[1].strides) = __pyx_f_9photutils_8geometry_18elliptical_overlap_elliptical_overlap_single_subpixel(__pyx_v_pxmin, __pyx_v_pymin, __pyx_v_pxmax, __pyx_v_pymax, __pyx_v_rx, __pyx_v_ry, __pyx_v_theta, __pyx_v_subpixels); } __pyx_L13:; /* "photutils/geometry/elliptical_overlap.pyx":106 * pymin = ymin + j * dy * pymax = pymin + dy * if pymax > bymin and pymin < bymax: # <<<<<<<<<<<<<< * if use_exact: * frac[j, i] = elliptical_overlap_single_exact( */ } } /* "photutils/geometry/elliptical_overlap.pyx":102 * pxmin = xmin + i * dx # lower end of pixel * pxmax = pxmin + dx # upper end of pixel * if pxmax > bxmin and pxmin < bxmax: # <<<<<<<<<<<<<< * for j in range(ny): * pymin = ymin + j * dy */ } } /* "photutils/geometry/elliptical_overlap.pyx":114 * pxmin, pymin, pxmax, pymax, rx, ry, theta, * subpixels) * return frac # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(((PyObject *)__pyx_v_frac)); __pyx_r = ((PyObject *)__pyx_v_frac); goto __pyx_L0; /* "photutils/geometry/elliptical_overlap.pyx":36 * * * def elliptical_overlap_grid(double xmin, double xmax, double ymin, double ymax, # <<<<<<<<<<<<<< * int nx, int ny, double rx, double ry, double theta, * int use_exact, int subpixels): */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_frac.rcbuffer->pybuffer); __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} __Pyx_AddTraceback("photutils.geometry.elliptical_overlap.elliptical_overlap_grid", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; goto __pyx_L2; __pyx_L0:; __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_frac.rcbuffer->pybuffer); __pyx_L2:; __Pyx_XDECREF((PyObject *)__pyx_v_frac); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "photutils/geometry/elliptical_overlap.pyx":123 * * * cdef double elliptical_overlap_single_subpixel(double x0, double y0, # <<<<<<<<<<<<<< * double x1, double y1, * double rx, double ry, */ static double __pyx_f_9photutils_8geometry_18elliptical_overlap_elliptical_overlap_single_subpixel(double __pyx_v_x0, double __pyx_v_y0, double __pyx_v_x1, double __pyx_v_y1, double __pyx_v_rx, double __pyx_v_ry, double __pyx_v_theta, int __pyx_v_subpixels) { CYTHON_UNUSED unsigned int __pyx_v_i; CYTHON_UNUSED unsigned int __pyx_v_j; double __pyx_v_x; double __pyx_v_y; double __pyx_v_frac; double __pyx_v_inv_rx_sq; double __pyx_v_inv_ry_sq; double __pyx_v_cos_theta; double __pyx_v_sin_theta; double __pyx_v_dx; double __pyx_v_dy; double __pyx_v_x_tr; double __pyx_v_y_tr; double __pyx_r; __Pyx_RefNannyDeclarations double __pyx_t_1; int __pyx_t_2; unsigned int __pyx_t_3; int __pyx_t_4; unsigned int __pyx_t_5; int __pyx_t_6; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("elliptical_overlap_single_subpixel", 0); /* "photutils/geometry/elliptical_overlap.pyx":134 * cdef unsigned int i, j * cdef double x, y * cdef double frac = 0. # Accumulator. # <<<<<<<<<<<<<< * cdef double inv_rx_sq, inv_ry_sq * cdef double cos_theta = cos(theta) */ __pyx_v_frac = 0.; /* "photutils/geometry/elliptical_overlap.pyx":136 * cdef double frac = 0. # Accumulator. * cdef double inv_rx_sq, inv_ry_sq * cdef double cos_theta = cos(theta) # <<<<<<<<<<<<<< * cdef double sin_theta = sin(theta) * cdef double dx, dy */ __pyx_v_cos_theta = cos(__pyx_v_theta); /* "photutils/geometry/elliptical_overlap.pyx":137 * cdef double inv_rx_sq, inv_ry_sq * cdef double cos_theta = cos(theta) * cdef double sin_theta = sin(theta) # <<<<<<<<<<<<<< * cdef double dx, dy * cdef double x_tr, y_tr */ __pyx_v_sin_theta = sin(__pyx_v_theta); /* "photutils/geometry/elliptical_overlap.pyx":141 * cdef double x_tr, y_tr * * dx = (x1 - x0) / subpixels # <<<<<<<<<<<<<< * dy = (y1 - y0) / subpixels * */ __pyx_t_1 = (__pyx_v_x1 - __pyx_v_x0); if (unlikely(__pyx_v_subpixels == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "float division"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_v_dx = (__pyx_t_1 / ((double)__pyx_v_subpixels)); /* "photutils/geometry/elliptical_overlap.pyx":142 * * dx = (x1 - x0) / subpixels * dy = (y1 - y0) / subpixels # <<<<<<<<<<<<<< * * inv_rx_sq = 1. / (rx * rx) */ __pyx_t_1 = (__pyx_v_y1 - __pyx_v_y0); if (unlikely(__pyx_v_subpixels == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "float division"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_v_dy = (__pyx_t_1 / ((double)__pyx_v_subpixels)); /* "photutils/geometry/elliptical_overlap.pyx":144 * dy = (y1 - y0) / subpixels * * inv_rx_sq = 1. / (rx * rx) # <<<<<<<<<<<<<< * inv_ry_sq = 1. / (ry * ry) * */ __pyx_t_1 = (__pyx_v_rx * __pyx_v_rx); if (unlikely(__pyx_t_1 == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "float division"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_v_inv_rx_sq = (1. / __pyx_t_1); /* "photutils/geometry/elliptical_overlap.pyx":145 * * inv_rx_sq = 1. / (rx * rx) * inv_ry_sq = 1. / (ry * ry) # <<<<<<<<<<<<<< * * x = x0 - 0.5 * dx */ __pyx_t_1 = (__pyx_v_ry * __pyx_v_ry); if (unlikely(__pyx_t_1 == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "float division"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_v_inv_ry_sq = (1. / __pyx_t_1); /* "photutils/geometry/elliptical_overlap.pyx":147 * inv_ry_sq = 1. / (ry * ry) * * x = x0 - 0.5 * dx # <<<<<<<<<<<<<< * for i in range(subpixels): * x += dx */ __pyx_v_x = (__pyx_v_x0 - (0.5 * __pyx_v_dx)); /* "photutils/geometry/elliptical_overlap.pyx":148 * * x = x0 - 0.5 * dx * for i in range(subpixels): # <<<<<<<<<<<<<< * x += dx * y = y0 - 0.5 * dy */ __pyx_t_2 = __pyx_v_subpixels; for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) { __pyx_v_i = __pyx_t_3; /* "photutils/geometry/elliptical_overlap.pyx":149 * x = x0 - 0.5 * dx * for i in range(subpixels): * x += dx # <<<<<<<<<<<<<< * y = y0 - 0.5 * dy * for j in range(subpixels): */ __pyx_v_x = (__pyx_v_x + __pyx_v_dx); /* "photutils/geometry/elliptical_overlap.pyx":150 * for i in range(subpixels): * x += dx * y = y0 - 0.5 * dy # <<<<<<<<<<<<<< * for j in range(subpixels): * y += dy */ __pyx_v_y = (__pyx_v_y0 - (0.5 * __pyx_v_dy)); /* "photutils/geometry/elliptical_overlap.pyx":151 * x += dx * y = y0 - 0.5 * dy * for j in range(subpixels): # <<<<<<<<<<<<<< * y += dy * */ __pyx_t_4 = __pyx_v_subpixels; for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) { __pyx_v_j = __pyx_t_5; /* "photutils/geometry/elliptical_overlap.pyx":152 * y = y0 - 0.5 * dy * for j in range(subpixels): * y += dy # <<<<<<<<<<<<<< * * # Transform into frame of rotated ellipse */ __pyx_v_y = (__pyx_v_y + __pyx_v_dy); /* "photutils/geometry/elliptical_overlap.pyx":155 * * # Transform into frame of rotated ellipse * x_tr = y * sin_theta + x * cos_theta # <<<<<<<<<<<<<< * y_tr = y * cos_theta - x * sin_theta * */ __pyx_v_x_tr = ((__pyx_v_y * __pyx_v_sin_theta) + (__pyx_v_x * __pyx_v_cos_theta)); /* "photutils/geometry/elliptical_overlap.pyx":156 * # Transform into frame of rotated ellipse * x_tr = y * sin_theta + x * cos_theta * y_tr = y * cos_theta - x * sin_theta # <<<<<<<<<<<<<< * * if x_tr * x_tr * inv_rx_sq + y_tr * y_tr * inv_ry_sq < 1.: */ __pyx_v_y_tr = ((__pyx_v_y * __pyx_v_cos_theta) - (__pyx_v_x * __pyx_v_sin_theta)); /* "photutils/geometry/elliptical_overlap.pyx":158 * y_tr = y * cos_theta - x * sin_theta * * if x_tr * x_tr * inv_rx_sq + y_tr * y_tr * inv_ry_sq < 1.: # <<<<<<<<<<<<<< * frac += 1. * */ __pyx_t_6 = (((((__pyx_v_x_tr * __pyx_v_x_tr) * __pyx_v_inv_rx_sq) + ((__pyx_v_y_tr * __pyx_v_y_tr) * __pyx_v_inv_ry_sq)) < 1.) != 0); if (__pyx_t_6) { /* "photutils/geometry/elliptical_overlap.pyx":159 * * if x_tr * x_tr * inv_rx_sq + y_tr * y_tr * inv_ry_sq < 1.: * frac += 1. # <<<<<<<<<<<<<< * * return frac / (subpixels * subpixels) */ __pyx_v_frac = (__pyx_v_frac + 1.); /* "photutils/geometry/elliptical_overlap.pyx":158 * y_tr = y * cos_theta - x * sin_theta * * if x_tr * x_tr * inv_rx_sq + y_tr * y_tr * inv_ry_sq < 1.: # <<<<<<<<<<<<<< * frac += 1. * */ } } } /* "photutils/geometry/elliptical_overlap.pyx":161 * frac += 1. * * return frac / (subpixels * subpixels) # <<<<<<<<<<<<<< * * */ __pyx_t_2 = (__pyx_v_subpixels * __pyx_v_subpixels); if (unlikely(__pyx_t_2 == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "float division"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_r = (__pyx_v_frac / ((double)__pyx_t_2)); goto __pyx_L0; /* "photutils/geometry/elliptical_overlap.pyx":123 * * * cdef double elliptical_overlap_single_subpixel(double x0, double y0, # <<<<<<<<<<<<<< * double x1, double y1, * double rx, double ry, */ /* function exit code */ __pyx_L1_error:; __Pyx_WriteUnraisable("photutils.geometry.elliptical_overlap.elliptical_overlap_single_subpixel", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0); __pyx_r = 0; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "photutils/geometry/elliptical_overlap.pyx":164 * * * cdef double elliptical_overlap_single_exact(double xmin, double ymin, # <<<<<<<<<<<<<< * double xmax, double ymax, * double rx, double ry, */ static double __pyx_f_9photutils_8geometry_18elliptical_overlap_elliptical_overlap_single_exact(double __pyx_v_xmin, double __pyx_v_ymin, double __pyx_v_xmax, double __pyx_v_ymax, double __pyx_v_rx, double __pyx_v_ry, double __pyx_v_theta) { double __pyx_v_cos_m_theta; double __pyx_v_sin_m_theta; double __pyx_v_scale; double __pyx_v_x1; double __pyx_v_y1; double __pyx_v_x2; double __pyx_v_y2; double __pyx_v_x3; double __pyx_v_y3; double __pyx_v_x4; double __pyx_v_y4; double __pyx_r; __Pyx_RefNannyDeclarations double __pyx_t_1; double __pyx_t_2; double __pyx_t_3; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("elliptical_overlap_single_exact", 0); /* "photutils/geometry/elliptical_overlap.pyx":174 * """ * * cdef double cos_m_theta = cos(-theta) # <<<<<<<<<<<<<< * cdef double sin_m_theta = sin(-theta) * cdef double scale */ __pyx_v_cos_m_theta = cos((-__pyx_v_theta)); /* "photutils/geometry/elliptical_overlap.pyx":175 * * cdef double cos_m_theta = cos(-theta) * cdef double sin_m_theta = sin(-theta) # <<<<<<<<<<<<<< * cdef double scale * */ __pyx_v_sin_m_theta = sin((-__pyx_v_theta)); /* "photutils/geometry/elliptical_overlap.pyx":179 * * # Find scale by which the areas will be shrunk * scale = rx * ry # <<<<<<<<<<<<<< * * # Reproject rectangle to frame of reference in which ellipse is a */ __pyx_v_scale = (__pyx_v_rx * __pyx_v_ry); /* "photutils/geometry/elliptical_overlap.pyx":183 * # Reproject rectangle to frame of reference in which ellipse is a * # unit circle * x1, y1 = ((xmin * cos_m_theta - ymin * sin_m_theta) / rx, # <<<<<<<<<<<<<< * (xmin * sin_m_theta + ymin * cos_m_theta) / ry) * x2, y2 = ((xmax * cos_m_theta - ymin * sin_m_theta) / rx, */ __pyx_t_1 = ((__pyx_v_xmin * __pyx_v_cos_m_theta) - (__pyx_v_ymin * __pyx_v_sin_m_theta)); if (unlikely(__pyx_v_rx == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "float division"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_t_2 = (__pyx_t_1 / __pyx_v_rx); /* "photutils/geometry/elliptical_overlap.pyx":184 * # unit circle * x1, y1 = ((xmin * cos_m_theta - ymin * sin_m_theta) / rx, * (xmin * sin_m_theta + ymin * cos_m_theta) / ry) # <<<<<<<<<<<<<< * x2, y2 = ((xmax * cos_m_theta - ymin * sin_m_theta) / rx, * (xmax * sin_m_theta + ymin * cos_m_theta) / ry) */ __pyx_t_1 = ((__pyx_v_xmin * __pyx_v_sin_m_theta) + (__pyx_v_ymin * __pyx_v_cos_m_theta)); if (unlikely(__pyx_v_ry == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "float division"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_t_3 = (__pyx_t_1 / __pyx_v_ry); __pyx_v_x1 = __pyx_t_2; __pyx_v_y1 = __pyx_t_3; /* "photutils/geometry/elliptical_overlap.pyx":185 * x1, y1 = ((xmin * cos_m_theta - ymin * sin_m_theta) / rx, * (xmin * sin_m_theta + ymin * cos_m_theta) / ry) * x2, y2 = ((xmax * cos_m_theta - ymin * sin_m_theta) / rx, # <<<<<<<<<<<<<< * (xmax * sin_m_theta + ymin * cos_m_theta) / ry) * x3, y3 = ((xmax * cos_m_theta - ymax * sin_m_theta) / rx, */ __pyx_t_3 = ((__pyx_v_xmax * __pyx_v_cos_m_theta) - (__pyx_v_ymin * __pyx_v_sin_m_theta)); if (unlikely(__pyx_v_rx == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "float division"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_t_2 = (__pyx_t_3 / __pyx_v_rx); /* "photutils/geometry/elliptical_overlap.pyx":186 * (xmin * sin_m_theta + ymin * cos_m_theta) / ry) * x2, y2 = ((xmax * cos_m_theta - ymin * sin_m_theta) / rx, * (xmax * sin_m_theta + ymin * cos_m_theta) / ry) # <<<<<<<<<<<<<< * x3, y3 = ((xmax * cos_m_theta - ymax * sin_m_theta) / rx, * (xmax * sin_m_theta + ymax * cos_m_theta) / ry) */ __pyx_t_3 = ((__pyx_v_xmax * __pyx_v_sin_m_theta) + (__pyx_v_ymin * __pyx_v_cos_m_theta)); if (unlikely(__pyx_v_ry == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "float division"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_t_1 = (__pyx_t_3 / __pyx_v_ry); __pyx_v_x2 = __pyx_t_2; __pyx_v_y2 = __pyx_t_1; /* "photutils/geometry/elliptical_overlap.pyx":187 * x2, y2 = ((xmax * cos_m_theta - ymin * sin_m_theta) / rx, * (xmax * sin_m_theta + ymin * cos_m_theta) / ry) * x3, y3 = ((xmax * cos_m_theta - ymax * sin_m_theta) / rx, # <<<<<<<<<<<<<< * (xmax * sin_m_theta + ymax * cos_m_theta) / ry) * x4, y4 = ((xmin * cos_m_theta - ymax * sin_m_theta) / rx, */ __pyx_t_1 = ((__pyx_v_xmax * __pyx_v_cos_m_theta) - (__pyx_v_ymax * __pyx_v_sin_m_theta)); if (unlikely(__pyx_v_rx == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "float division"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_t_2 = (__pyx_t_1 / __pyx_v_rx); /* "photutils/geometry/elliptical_overlap.pyx":188 * (xmax * sin_m_theta + ymin * cos_m_theta) / ry) * x3, y3 = ((xmax * cos_m_theta - ymax * sin_m_theta) / rx, * (xmax * sin_m_theta + ymax * cos_m_theta) / ry) # <<<<<<<<<<<<<< * x4, y4 = ((xmin * cos_m_theta - ymax * sin_m_theta) / rx, * (xmin * sin_m_theta + ymax * cos_m_theta) / ry) */ __pyx_t_1 = ((__pyx_v_xmax * __pyx_v_sin_m_theta) + (__pyx_v_ymax * __pyx_v_cos_m_theta)); if (unlikely(__pyx_v_ry == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "float division"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_t_3 = (__pyx_t_1 / __pyx_v_ry); __pyx_v_x3 = __pyx_t_2; __pyx_v_y3 = __pyx_t_3; /* "photutils/geometry/elliptical_overlap.pyx":189 * x3, y3 = ((xmax * cos_m_theta - ymax * sin_m_theta) / rx, * (xmax * sin_m_theta + ymax * cos_m_theta) / ry) * x4, y4 = ((xmin * cos_m_theta - ymax * sin_m_theta) / rx, # <<<<<<<<<<<<<< * (xmin * sin_m_theta + ymax * cos_m_theta) / ry) * */ __pyx_t_3 = ((__pyx_v_xmin * __pyx_v_cos_m_theta) - (__pyx_v_ymax * __pyx_v_sin_m_theta)); if (unlikely(__pyx_v_rx == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "float division"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_t_2 = (__pyx_t_3 / __pyx_v_rx); /* "photutils/geometry/elliptical_overlap.pyx":190 * (xmax * sin_m_theta + ymax * cos_m_theta) / ry) * x4, y4 = ((xmin * cos_m_theta - ymax * sin_m_theta) / rx, * (xmin * sin_m_theta + ymax * cos_m_theta) / ry) # <<<<<<<<<<<<<< * * # Divide resulting quadrilateral into two triangles and find */ __pyx_t_3 = ((__pyx_v_xmin * __pyx_v_sin_m_theta) + (__pyx_v_ymax * __pyx_v_cos_m_theta)); if (unlikely(__pyx_v_ry == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "float division"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_t_1 = (__pyx_t_3 / __pyx_v_ry); __pyx_v_x4 = __pyx_t_2; __pyx_v_y4 = __pyx_t_1; /* "photutils/geometry/elliptical_overlap.pyx":195 * # intersection with unit circle * return (overlap_area_triangle_unit_circle(x1, y1, x2, y2, x3, y3) + * overlap_area_triangle_unit_circle(x1, y1, x4, y4, x3, y3)) * scale # <<<<<<<<<<<<<< */ __pyx_r = ((__pyx_f_9photutils_8geometry_4core_overlap_area_triangle_unit_circle(__pyx_v_x1, __pyx_v_y1, __pyx_v_x2, __pyx_v_y2, __pyx_v_x3, __pyx_v_y3) + __pyx_f_9photutils_8geometry_4core_overlap_area_triangle_unit_circle(__pyx_v_x1, __pyx_v_y1, __pyx_v_x4, __pyx_v_y4, __pyx_v_x3, __pyx_v_y3)) * __pyx_v_scale); goto __pyx_L0; /* "photutils/geometry/elliptical_overlap.pyx":164 * * * cdef double elliptical_overlap_single_exact(double xmin, double ymin, # <<<<<<<<<<<<<< * double xmax, double ymax, * double rx, double ry, */ /* function exit code */ __pyx_L1_error:; __Pyx_WriteUnraisable("photutils.geometry.elliptical_overlap.elliptical_overlap_single_exact", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0); __pyx_r = 0; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":197 * # experimental exception made for __getbuffer__ and __releasebuffer__ * # -- the details of this may change. * def __getbuffer__(ndarray self, Py_buffer* info, int flags): # <<<<<<<<<<<<<< * # This implementation of getbuffer is geared towards Cython * # requirements, and does not yet fullfill the PEP. */ /* Python wrapper */ static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/ static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0); __pyx_r = __pyx_pf_5numpy_7ndarray___getbuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { int __pyx_v_copy_shape; int __pyx_v_i; int __pyx_v_ndim; int __pyx_v_endian_detector; int __pyx_v_little_endian; int __pyx_v_t; char *__pyx_v_f; PyArray_Descr *__pyx_v_descr = 0; int __pyx_v_offset; int __pyx_v_hasfields; int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; PyObject *__pyx_t_3 = NULL; int __pyx_t_4; int __pyx_t_5; PyObject *__pyx_t_6 = NULL; char *__pyx_t_7; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__getbuffer__", 0); if (__pyx_v_info != NULL) { __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None); __Pyx_GIVEREF(__pyx_v_info->obj); } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":203 * # of flags * * if info == NULL: return # <<<<<<<<<<<<<< * * cdef int copy_shape, i, ndim */ __pyx_t_1 = ((__pyx_v_info == NULL) != 0); if (__pyx_t_1) { __pyx_r = 0; goto __pyx_L0; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":206 * * cdef int copy_shape, i, ndim * cdef int endian_detector = 1 # <<<<<<<<<<<<<< * cdef bint little_endian = ((&endian_detector)[0] != 0) * */ __pyx_v_endian_detector = 1; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":207 * cdef int copy_shape, i, ndim * cdef int endian_detector = 1 * cdef bint little_endian = ((&endian_detector)[0] != 0) # <<<<<<<<<<<<<< * * ndim = PyArray_NDIM(self) */ __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":209 * cdef bint little_endian = ((&endian_detector)[0] != 0) * * ndim = PyArray_NDIM(self) # <<<<<<<<<<<<<< * * if sizeof(npy_intp) != sizeof(Py_ssize_t): */ __pyx_v_ndim = PyArray_NDIM(__pyx_v_self); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":211 * ndim = PyArray_NDIM(self) * * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< * copy_shape = 1 * else: */ __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0); if (__pyx_t_1) { /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":212 * * if sizeof(npy_intp) != sizeof(Py_ssize_t): * copy_shape = 1 # <<<<<<<<<<<<<< * else: * copy_shape = 0 */ __pyx_v_copy_shape = 1; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":211 * ndim = PyArray_NDIM(self) * * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< * copy_shape = 1 * else: */ goto __pyx_L4; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":214 * copy_shape = 1 * else: * copy_shape = 0 # <<<<<<<<<<<<<< * * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) */ /*else*/ { __pyx_v_copy_shape = 0; } __pyx_L4:; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":216 * copy_shape = 0 * * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): * raise ValueError(u"ndarray is not C contiguous") */ __pyx_t_2 = (((__pyx_v_flags & PyBUF_C_CONTIGUOUS) == PyBUF_C_CONTIGUOUS) != 0); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L6_bool_binop_done; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":217 * * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): # <<<<<<<<<<<<<< * raise ValueError(u"ndarray is not C contiguous") * */ __pyx_t_2 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_C_CONTIGUOUS) != 0)) != 0); __pyx_t_1 = __pyx_t_2; __pyx_L6_bool_binop_done:; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":216 * copy_shape = 0 * * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): * raise ValueError(u"ndarray is not C contiguous") */ if (__pyx_t_1) { /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":218 * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<< * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) */ __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; {__pyx_filename = __pyx_f[1]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":216 * copy_shape = 0 * * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): * raise ValueError(u"ndarray is not C contiguous") */ } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":220 * raise ValueError(u"ndarray is not C contiguous") * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): * raise ValueError(u"ndarray is not Fortran contiguous") */ __pyx_t_2 = (((__pyx_v_flags & PyBUF_F_CONTIGUOUS) == PyBUF_F_CONTIGUOUS) != 0); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L9_bool_binop_done; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":221 * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): # <<<<<<<<<<<<<< * raise ValueError(u"ndarray is not Fortran contiguous") * */ __pyx_t_2 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_F_CONTIGUOUS) != 0)) != 0); __pyx_t_1 = __pyx_t_2; __pyx_L9_bool_binop_done:; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":220 * raise ValueError(u"ndarray is not C contiguous") * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): * raise ValueError(u"ndarray is not Fortran contiguous") */ if (__pyx_t_1) { /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":222 * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<< * * info.buf = PyArray_DATA(self) */ __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; {__pyx_filename = __pyx_f[1]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":220 * raise ValueError(u"ndarray is not C contiguous") * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): * raise ValueError(u"ndarray is not Fortran contiguous") */ } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":224 * raise ValueError(u"ndarray is not Fortran contiguous") * * info.buf = PyArray_DATA(self) # <<<<<<<<<<<<<< * info.ndim = ndim * if copy_shape: */ __pyx_v_info->buf = PyArray_DATA(__pyx_v_self); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":225 * * info.buf = PyArray_DATA(self) * info.ndim = ndim # <<<<<<<<<<<<<< * if copy_shape: * # Allocate new buffer for strides and shape info. */ __pyx_v_info->ndim = __pyx_v_ndim; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":226 * info.buf = PyArray_DATA(self) * info.ndim = ndim * if copy_shape: # <<<<<<<<<<<<<< * # Allocate new buffer for strides and shape info. * # This is allocated as one block, strides first. */ __pyx_t_1 = (__pyx_v_copy_shape != 0); if (__pyx_t_1) { /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":229 * # Allocate new buffer for strides and shape info. * # This is allocated as one block, strides first. * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) # <<<<<<<<<<<<<< * info.shape = info.strides + ndim * for i in range(ndim): */ __pyx_v_info->strides = ((Py_ssize_t *)malloc((((sizeof(Py_ssize_t)) * ((size_t)__pyx_v_ndim)) * 2))); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":230 * # This is allocated as one block, strides first. * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) * info.shape = info.strides + ndim # <<<<<<<<<<<<<< * for i in range(ndim): * info.strides[i] = PyArray_STRIDES(self)[i] */ __pyx_v_info->shape = (__pyx_v_info->strides + __pyx_v_ndim); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":231 * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) * info.shape = info.strides + ndim * for i in range(ndim): # <<<<<<<<<<<<<< * info.strides[i] = PyArray_STRIDES(self)[i] * info.shape[i] = PyArray_DIMS(self)[i] */ __pyx_t_4 = __pyx_v_ndim; for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) { __pyx_v_i = __pyx_t_5; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":232 * info.shape = info.strides + ndim * for i in range(ndim): * info.strides[i] = PyArray_STRIDES(self)[i] # <<<<<<<<<<<<<< * info.shape[i] = PyArray_DIMS(self)[i] * else: */ (__pyx_v_info->strides[__pyx_v_i]) = (PyArray_STRIDES(__pyx_v_self)[__pyx_v_i]); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":233 * for i in range(ndim): * info.strides[i] = PyArray_STRIDES(self)[i] * info.shape[i] = PyArray_DIMS(self)[i] # <<<<<<<<<<<<<< * else: * info.strides = PyArray_STRIDES(self) */ (__pyx_v_info->shape[__pyx_v_i]) = (PyArray_DIMS(__pyx_v_self)[__pyx_v_i]); } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":226 * info.buf = PyArray_DATA(self) * info.ndim = ndim * if copy_shape: # <<<<<<<<<<<<<< * # Allocate new buffer for strides and shape info. * # This is allocated as one block, strides first. */ goto __pyx_L11; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":235 * info.shape[i] = PyArray_DIMS(self)[i] * else: * info.strides = PyArray_STRIDES(self) # <<<<<<<<<<<<<< * info.shape = PyArray_DIMS(self) * info.suboffsets = NULL */ /*else*/ { __pyx_v_info->strides = ((Py_ssize_t *)PyArray_STRIDES(__pyx_v_self)); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":236 * else: * info.strides = PyArray_STRIDES(self) * info.shape = PyArray_DIMS(self) # <<<<<<<<<<<<<< * info.suboffsets = NULL * info.itemsize = PyArray_ITEMSIZE(self) */ __pyx_v_info->shape = ((Py_ssize_t *)PyArray_DIMS(__pyx_v_self)); } __pyx_L11:; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":237 * info.strides = PyArray_STRIDES(self) * info.shape = PyArray_DIMS(self) * info.suboffsets = NULL # <<<<<<<<<<<<<< * info.itemsize = PyArray_ITEMSIZE(self) * info.readonly = not PyArray_ISWRITEABLE(self) */ __pyx_v_info->suboffsets = NULL; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":238 * info.shape = PyArray_DIMS(self) * info.suboffsets = NULL * info.itemsize = PyArray_ITEMSIZE(self) # <<<<<<<<<<<<<< * info.readonly = not PyArray_ISWRITEABLE(self) * */ __pyx_v_info->itemsize = PyArray_ITEMSIZE(__pyx_v_self); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":239 * info.suboffsets = NULL * info.itemsize = PyArray_ITEMSIZE(self) * info.readonly = not PyArray_ISWRITEABLE(self) # <<<<<<<<<<<<<< * * cdef int t */ __pyx_v_info->readonly = (!(PyArray_ISWRITEABLE(__pyx_v_self) != 0)); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":242 * * cdef int t * cdef char* f = NULL # <<<<<<<<<<<<<< * cdef dtype descr = self.descr * cdef int offset */ __pyx_v_f = NULL; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":243 * cdef int t * cdef char* f = NULL * cdef dtype descr = self.descr # <<<<<<<<<<<<<< * cdef int offset * */ __pyx_t_3 = ((PyObject *)__pyx_v_self->descr); __Pyx_INCREF(__pyx_t_3); __pyx_v_descr = ((PyArray_Descr *)__pyx_t_3); __pyx_t_3 = 0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":246 * cdef int offset * * cdef bint hasfields = PyDataType_HASFIELDS(descr) # <<<<<<<<<<<<<< * * if not hasfields and not copy_shape: */ __pyx_v_hasfields = PyDataType_HASFIELDS(__pyx_v_descr); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":248 * cdef bint hasfields = PyDataType_HASFIELDS(descr) * * if not hasfields and not copy_shape: # <<<<<<<<<<<<<< * # do not call releasebuffer * info.obj = None */ __pyx_t_2 = ((!(__pyx_v_hasfields != 0)) != 0); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L15_bool_binop_done; } __pyx_t_2 = ((!(__pyx_v_copy_shape != 0)) != 0); __pyx_t_1 = __pyx_t_2; __pyx_L15_bool_binop_done:; if (__pyx_t_1) { /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":250 * if not hasfields and not copy_shape: * # do not call releasebuffer * info.obj = None # <<<<<<<<<<<<<< * else: * # need to call releasebuffer */ __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_info->obj); __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = Py_None; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":248 * cdef bint hasfields = PyDataType_HASFIELDS(descr) * * if not hasfields and not copy_shape: # <<<<<<<<<<<<<< * # do not call releasebuffer * info.obj = None */ goto __pyx_L14; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":253 * else: * # need to call releasebuffer * info.obj = self # <<<<<<<<<<<<<< * * if not hasfields: */ /*else*/ { __Pyx_INCREF(((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); __Pyx_GOTREF(__pyx_v_info->obj); __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = ((PyObject *)__pyx_v_self); } __pyx_L14:; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":255 * info.obj = self * * if not hasfields: # <<<<<<<<<<<<<< * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or */ __pyx_t_1 = ((!(__pyx_v_hasfields != 0)) != 0); if (__pyx_t_1) { /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":256 * * if not hasfields: * t = descr.type_num # <<<<<<<<<<<<<< * if ((descr.byteorder == c'>' and little_endian) or * (descr.byteorder == c'<' and not little_endian)): */ __pyx_t_4 = __pyx_v_descr->type_num; __pyx_v_t = __pyx_t_4; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":257 * if not hasfields: * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< * (descr.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") */ __pyx_t_2 = ((__pyx_v_descr->byteorder == '>') != 0); if (!__pyx_t_2) { goto __pyx_L20_next_or; } else { } __pyx_t_2 = (__pyx_v_little_endian != 0); if (!__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L19_bool_binop_done; } __pyx_L20_next_or:; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":258 * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or * (descr.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<< * raise ValueError(u"Non-native byte order not supported") * if t == NPY_BYTE: f = "b" */ __pyx_t_2 = ((__pyx_v_descr->byteorder == '<') != 0); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L19_bool_binop_done; } __pyx_t_2 = ((!(__pyx_v_little_endian != 0)) != 0); __pyx_t_1 = __pyx_t_2; __pyx_L19_bool_binop_done:; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":257 * if not hasfields: * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< * (descr.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") */ if (__pyx_t_1) { /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":259 * if ((descr.byteorder == c'>' and little_endian) or * (descr.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< * if t == NPY_BYTE: f = "b" * elif t == NPY_UBYTE: f = "B" */ __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; {__pyx_filename = __pyx_f[1]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":257 * if not hasfields: * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< * (descr.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") */ } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":260 * (descr.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") * if t == NPY_BYTE: f = "b" # <<<<<<<<<<<<<< * elif t == NPY_UBYTE: f = "B" * elif t == NPY_SHORT: f = "h" */ switch (__pyx_v_t) { case NPY_BYTE: __pyx_v_f = __pyx_k_b; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":261 * raise ValueError(u"Non-native byte order not supported") * if t == NPY_BYTE: f = "b" * elif t == NPY_UBYTE: f = "B" # <<<<<<<<<<<<<< * elif t == NPY_SHORT: f = "h" * elif t == NPY_USHORT: f = "H" */ case NPY_UBYTE: __pyx_v_f = __pyx_k_B; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":262 * if t == NPY_BYTE: f = "b" * elif t == NPY_UBYTE: f = "B" * elif t == NPY_SHORT: f = "h" # <<<<<<<<<<<<<< * elif t == NPY_USHORT: f = "H" * elif t == NPY_INT: f = "i" */ case NPY_SHORT: __pyx_v_f = __pyx_k_h; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":263 * elif t == NPY_UBYTE: f = "B" * elif t == NPY_SHORT: f = "h" * elif t == NPY_USHORT: f = "H" # <<<<<<<<<<<<<< * elif t == NPY_INT: f = "i" * elif t == NPY_UINT: f = "I" */ case NPY_USHORT: __pyx_v_f = __pyx_k_H; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":264 * elif t == NPY_SHORT: f = "h" * elif t == NPY_USHORT: f = "H" * elif t == NPY_INT: f = "i" # <<<<<<<<<<<<<< * elif t == NPY_UINT: f = "I" * elif t == NPY_LONG: f = "l" */ case NPY_INT: __pyx_v_f = __pyx_k_i; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":265 * elif t == NPY_USHORT: f = "H" * elif t == NPY_INT: f = "i" * elif t == NPY_UINT: f = "I" # <<<<<<<<<<<<<< * elif t == NPY_LONG: f = "l" * elif t == NPY_ULONG: f = "L" */ case NPY_UINT: __pyx_v_f = __pyx_k_I; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":266 * elif t == NPY_INT: f = "i" * elif t == NPY_UINT: f = "I" * elif t == NPY_LONG: f = "l" # <<<<<<<<<<<<<< * elif t == NPY_ULONG: f = "L" * elif t == NPY_LONGLONG: f = "q" */ case NPY_LONG: __pyx_v_f = __pyx_k_l; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":267 * elif t == NPY_UINT: f = "I" * elif t == NPY_LONG: f = "l" * elif t == NPY_ULONG: f = "L" # <<<<<<<<<<<<<< * elif t == NPY_LONGLONG: f = "q" * elif t == NPY_ULONGLONG: f = "Q" */ case NPY_ULONG: __pyx_v_f = __pyx_k_L; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":268 * elif t == NPY_LONG: f = "l" * elif t == NPY_ULONG: f = "L" * elif t == NPY_LONGLONG: f = "q" # <<<<<<<<<<<<<< * elif t == NPY_ULONGLONG: f = "Q" * elif t == NPY_FLOAT: f = "f" */ case NPY_LONGLONG: __pyx_v_f = __pyx_k_q; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":269 * elif t == NPY_ULONG: f = "L" * elif t == NPY_LONGLONG: f = "q" * elif t == NPY_ULONGLONG: f = "Q" # <<<<<<<<<<<<<< * elif t == NPY_FLOAT: f = "f" * elif t == NPY_DOUBLE: f = "d" */ case NPY_ULONGLONG: __pyx_v_f = __pyx_k_Q; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":270 * elif t == NPY_LONGLONG: f = "q" * elif t == NPY_ULONGLONG: f = "Q" * elif t == NPY_FLOAT: f = "f" # <<<<<<<<<<<<<< * elif t == NPY_DOUBLE: f = "d" * elif t == NPY_LONGDOUBLE: f = "g" */ case NPY_FLOAT: __pyx_v_f = __pyx_k_f; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":271 * elif t == NPY_ULONGLONG: f = "Q" * elif t == NPY_FLOAT: f = "f" * elif t == NPY_DOUBLE: f = "d" # <<<<<<<<<<<<<< * elif t == NPY_LONGDOUBLE: f = "g" * elif t == NPY_CFLOAT: f = "Zf" */ case NPY_DOUBLE: __pyx_v_f = __pyx_k_d; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":272 * elif t == NPY_FLOAT: f = "f" * elif t == NPY_DOUBLE: f = "d" * elif t == NPY_LONGDOUBLE: f = "g" # <<<<<<<<<<<<<< * elif t == NPY_CFLOAT: f = "Zf" * elif t == NPY_CDOUBLE: f = "Zd" */ case NPY_LONGDOUBLE: __pyx_v_f = __pyx_k_g; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":273 * elif t == NPY_DOUBLE: f = "d" * elif t == NPY_LONGDOUBLE: f = "g" * elif t == NPY_CFLOAT: f = "Zf" # <<<<<<<<<<<<<< * elif t == NPY_CDOUBLE: f = "Zd" * elif t == NPY_CLONGDOUBLE: f = "Zg" */ case NPY_CFLOAT: __pyx_v_f = __pyx_k_Zf; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":274 * elif t == NPY_LONGDOUBLE: f = "g" * elif t == NPY_CFLOAT: f = "Zf" * elif t == NPY_CDOUBLE: f = "Zd" # <<<<<<<<<<<<<< * elif t == NPY_CLONGDOUBLE: f = "Zg" * elif t == NPY_OBJECT: f = "O" */ case NPY_CDOUBLE: __pyx_v_f = __pyx_k_Zd; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":275 * elif t == NPY_CFLOAT: f = "Zf" * elif t == NPY_CDOUBLE: f = "Zd" * elif t == NPY_CLONGDOUBLE: f = "Zg" # <<<<<<<<<<<<<< * elif t == NPY_OBJECT: f = "O" * else: */ case NPY_CLONGDOUBLE: __pyx_v_f = __pyx_k_Zg; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":276 * elif t == NPY_CDOUBLE: f = "Zd" * elif t == NPY_CLONGDOUBLE: f = "Zg" * elif t == NPY_OBJECT: f = "O" # <<<<<<<<<<<<<< * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) */ case NPY_OBJECT: __pyx_v_f = __pyx_k_O; break; default: /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":278 * elif t == NPY_OBJECT: f = "O" * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< * info.format = f * return */ __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_t); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = PyUnicode_Format(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_t_3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_6, 0, 0, 0); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; {__pyx_filename = __pyx_f[1]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L1_error;} break; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":279 * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) * info.format = f # <<<<<<<<<<<<<< * return * else: */ __pyx_v_info->format = __pyx_v_f; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":280 * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) * info.format = f * return # <<<<<<<<<<<<<< * else: * info.format = stdlib.malloc(_buffer_format_string_len) */ __pyx_r = 0; goto __pyx_L0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":255 * info.obj = self * * if not hasfields: # <<<<<<<<<<<<<< * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or */ } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":282 * return * else: * info.format = stdlib.malloc(_buffer_format_string_len) # <<<<<<<<<<<<<< * info.format[0] = c'^' # Native data types, manual alignment * offset = 0 */ /*else*/ { __pyx_v_info->format = ((char *)malloc(0xFF)); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":283 * else: * info.format = stdlib.malloc(_buffer_format_string_len) * info.format[0] = c'^' # Native data types, manual alignment # <<<<<<<<<<<<<< * offset = 0 * f = _util_dtypestring(descr, info.format + 1, */ (__pyx_v_info->format[0]) = '^'; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":284 * info.format = stdlib.malloc(_buffer_format_string_len) * info.format[0] = c'^' # Native data types, manual alignment * offset = 0 # <<<<<<<<<<<<<< * f = _util_dtypestring(descr, info.format + 1, * info.format + _buffer_format_string_len, */ __pyx_v_offset = 0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":285 * info.format[0] = c'^' # Native data types, manual alignment * offset = 0 * f = _util_dtypestring(descr, info.format + 1, # <<<<<<<<<<<<<< * info.format + _buffer_format_string_len, * &offset) */ __pyx_t_7 = __pyx_f_5numpy__util_dtypestring(__pyx_v_descr, (__pyx_v_info->format + 1), (__pyx_v_info->format + 0xFF), (&__pyx_v_offset)); if (unlikely(__pyx_t_7 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_f = __pyx_t_7; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":288 * info.format + _buffer_format_string_len, * &offset) * f[0] = c'\0' # Terminate format string # <<<<<<<<<<<<<< * * def __releasebuffer__(ndarray self, Py_buffer* info): */ (__pyx_v_f[0]) = '\x00'; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":197 * # experimental exception made for __getbuffer__ and __releasebuffer__ * # -- the details of this may change. * def __getbuffer__(ndarray self, Py_buffer* info, int flags): # <<<<<<<<<<<<<< * # This implementation of getbuffer is geared towards Cython * # requirements, and does not yet fullfill the PEP. */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_6); __Pyx_AddTraceback("numpy.ndarray.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; if (__pyx_v_info != NULL && __pyx_v_info->obj != NULL) { __Pyx_GOTREF(__pyx_v_info->obj); __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = NULL; } goto __pyx_L2; __pyx_L0:; if (__pyx_v_info != NULL && __pyx_v_info->obj == Py_None) { __Pyx_GOTREF(Py_None); __Pyx_DECREF(Py_None); __pyx_v_info->obj = NULL; } __pyx_L2:; __Pyx_XDECREF((PyObject *)__pyx_v_descr); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":290 * f[0] = c'\0' # Terminate format string * * def __releasebuffer__(ndarray self, Py_buffer* info): # <<<<<<<<<<<<<< * if PyArray_HASFIELDS(self): * stdlib.free(info.format) */ /* Python wrapper */ static CYTHON_UNUSED void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info); /*proto*/ static CYTHON_UNUSED void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__releasebuffer__ (wrapper)", 0); __pyx_pf_5numpy_7ndarray_2__releasebuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info)); /* function exit code */ __Pyx_RefNannyFinishContext(); } static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info) { __Pyx_RefNannyDeclarations int __pyx_t_1; __Pyx_RefNannySetupContext("__releasebuffer__", 0); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":291 * * def __releasebuffer__(ndarray self, Py_buffer* info): * if PyArray_HASFIELDS(self): # <<<<<<<<<<<<<< * stdlib.free(info.format) * if sizeof(npy_intp) != sizeof(Py_ssize_t): */ __pyx_t_1 = (PyArray_HASFIELDS(__pyx_v_self) != 0); if (__pyx_t_1) { /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":292 * def __releasebuffer__(ndarray self, Py_buffer* info): * if PyArray_HASFIELDS(self): * stdlib.free(info.format) # <<<<<<<<<<<<<< * if sizeof(npy_intp) != sizeof(Py_ssize_t): * stdlib.free(info.strides) */ free(__pyx_v_info->format); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":291 * * def __releasebuffer__(ndarray self, Py_buffer* info): * if PyArray_HASFIELDS(self): # <<<<<<<<<<<<<< * stdlib.free(info.format) * if sizeof(npy_intp) != sizeof(Py_ssize_t): */ } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":293 * if PyArray_HASFIELDS(self): * stdlib.free(info.format) * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< * stdlib.free(info.strides) * # info.shape was stored after info.strides in the same block */ __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0); if (__pyx_t_1) { /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":294 * stdlib.free(info.format) * if sizeof(npy_intp) != sizeof(Py_ssize_t): * stdlib.free(info.strides) # <<<<<<<<<<<<<< * # info.shape was stored after info.strides in the same block * */ free(__pyx_v_info->strides); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":293 * if PyArray_HASFIELDS(self): * stdlib.free(info.format) * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< * stdlib.free(info.strides) * # info.shape was stored after info.strides in the same block */ } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":290 * f[0] = c'\0' # Terminate format string * * def __releasebuffer__(ndarray self, Py_buffer* info): # <<<<<<<<<<<<<< * if PyArray_HASFIELDS(self): * stdlib.free(info.format) */ /* function exit code */ __Pyx_RefNannyFinishContext(); } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":770 * ctypedef npy_cdouble complex_t * * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< * return PyArray_MultiIterNew(1, a) * */ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__pyx_v_a) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("PyArray_MultiIterNew1", 0); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":771 * * cdef inline object PyArray_MultiIterNew1(a): * return PyArray_MultiIterNew(1, a) # <<<<<<<<<<<<<< * * cdef inline object PyArray_MultiIterNew2(a, b): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyArray_MultiIterNew(1, ((void *)__pyx_v_a)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 771; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":770 * ctypedef npy_cdouble complex_t * * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< * return PyArray_MultiIterNew(1, a) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("numpy.PyArray_MultiIterNew1", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":773 * return PyArray_MultiIterNew(1, a) * * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< * return PyArray_MultiIterNew(2, a, b) * */ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__pyx_v_a, PyObject *__pyx_v_b) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("PyArray_MultiIterNew2", 0); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":774 * * cdef inline object PyArray_MultiIterNew2(a, b): * return PyArray_MultiIterNew(2, a, b) # <<<<<<<<<<<<<< * * cdef inline object PyArray_MultiIterNew3(a, b, c): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyArray_MultiIterNew(2, ((void *)__pyx_v_a), ((void *)__pyx_v_b)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 774; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":773 * return PyArray_MultiIterNew(1, a) * * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< * return PyArray_MultiIterNew(2, a, b) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("numpy.PyArray_MultiIterNew2", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":776 * return PyArray_MultiIterNew(2, a, b) * * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< * return PyArray_MultiIterNew(3, a, b, c) * */ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("PyArray_MultiIterNew3", 0); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":777 * * cdef inline object PyArray_MultiIterNew3(a, b, c): * return PyArray_MultiIterNew(3, a, b, c) # <<<<<<<<<<<<<< * * cdef inline object PyArray_MultiIterNew4(a, b, c, d): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyArray_MultiIterNew(3, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 777; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":776 * return PyArray_MultiIterNew(2, a, b) * * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< * return PyArray_MultiIterNew(3, a, b, c) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("numpy.PyArray_MultiIterNew3", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":779 * return PyArray_MultiIterNew(3, a, b, c) * * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< * return PyArray_MultiIterNew(4, a, b, c, d) * */ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("PyArray_MultiIterNew4", 0); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":780 * * cdef inline object PyArray_MultiIterNew4(a, b, c, d): * return PyArray_MultiIterNew(4, a, b, c, d) # <<<<<<<<<<<<<< * * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyArray_MultiIterNew(4, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 780; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":779 * return PyArray_MultiIterNew(3, a, b, c) * * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< * return PyArray_MultiIterNew(4, a, b, c, d) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("numpy.PyArray_MultiIterNew4", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":782 * return PyArray_MultiIterNew(4, a, b, c, d) * * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< * return PyArray_MultiIterNew(5, a, b, c, d, e) * */ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d, PyObject *__pyx_v_e) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("PyArray_MultiIterNew5", 0); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":783 * * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): * return PyArray_MultiIterNew(5, a, b, c, d, e) # <<<<<<<<<<<<<< * * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyArray_MultiIterNew(5, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d), ((void *)__pyx_v_e)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 783; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":782 * return PyArray_MultiIterNew(4, a, b, c, d) * * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< * return PyArray_MultiIterNew(5, a, b, c, d, e) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("numpy.PyArray_MultiIterNew5", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":785 * return PyArray_MultiIterNew(5, a, b, c, d, e) * * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: # <<<<<<<<<<<<<< * # Recursive utility function used in __getbuffer__ to get format * # string. The new location in the format string is returned. */ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_descr, char *__pyx_v_f, char *__pyx_v_end, int *__pyx_v_offset) { PyArray_Descr *__pyx_v_child = 0; int __pyx_v_endian_detector; int __pyx_v_little_endian; PyObject *__pyx_v_fields = 0; PyObject *__pyx_v_childname = NULL; PyObject *__pyx_v_new_offset = NULL; PyObject *__pyx_v_t = NULL; char *__pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; Py_ssize_t __pyx_t_2; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; int __pyx_t_5; int __pyx_t_6; int __pyx_t_7; long __pyx_t_8; char *__pyx_t_9; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("_util_dtypestring", 0); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":790 * * cdef dtype child * cdef int endian_detector = 1 # <<<<<<<<<<<<<< * cdef bint little_endian = ((&endian_detector)[0] != 0) * cdef tuple fields */ __pyx_v_endian_detector = 1; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":791 * cdef dtype child * cdef int endian_detector = 1 * cdef bint little_endian = ((&endian_detector)[0] != 0) # <<<<<<<<<<<<<< * cdef tuple fields * */ __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":794 * cdef tuple fields * * for childname in descr.names: # <<<<<<<<<<<<<< * fields = descr.fields[childname] * child, new_offset = fields */ if (unlikely(__pyx_v_descr->names == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_t_1 = __pyx_v_descr->names; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; for (;;) { if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); #endif __Pyx_XDECREF_SET(__pyx_v_childname, __pyx_t_3); __pyx_t_3 = 0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":795 * * for childname in descr.names: * fields = descr.fields[childname] # <<<<<<<<<<<<<< * child, new_offset = fields * */ if (unlikely(__pyx_v_descr->fields == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_t_3 = __Pyx_PyDict_GetItem(__pyx_v_descr->fields, __pyx_v_childname); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; __Pyx_GOTREF(__pyx_t_3); if (!(likely(PyTuple_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_XDECREF_SET(__pyx_v_fields, ((PyObject*)__pyx_t_3)); __pyx_t_3 = 0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":796 * for childname in descr.names: * fields = descr.fields[childname] * child, new_offset = fields # <<<<<<<<<<<<<< * * if (end - f) - (new_offset - offset[0]) < 15: */ if (likely(__pyx_v_fields != Py_None)) { PyObject* sequence = __pyx_v_fields; #if CYTHON_COMPILING_IN_CPYTHON Py_ssize_t size = Py_SIZE(sequence); #else Py_ssize_t size = PySequence_Size(sequence); #endif if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); #else __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); #endif } else { __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_dtype))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_XDECREF_SET(__pyx_v_child, ((PyArray_Descr *)__pyx_t_3)); __pyx_t_3 = 0; __Pyx_XDECREF_SET(__pyx_v_new_offset, __pyx_t_4); __pyx_t_4 = 0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":798 * child, new_offset = fields * * if (end - f) - (new_offset - offset[0]) < 15: # <<<<<<<<<<<<<< * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") * */ __pyx_t_4 = __Pyx_PyInt_From_int((__pyx_v_offset[0])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyNumber_Subtract(__pyx_v_new_offset, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = ((((__pyx_v_end - __pyx_v_f) - ((int)__pyx_t_5)) < 15) != 0); if (__pyx_t_6) { /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":799 * * if (end - f) - (new_offset - offset[0]) < 15: * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<< * * if ((child.byteorder == c'>' and little_endian) or */ __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":798 * child, new_offset = fields * * if (end - f) - (new_offset - offset[0]) < 15: # <<<<<<<<<<<<<< * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") * */ } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":801 * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") * * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< * (child.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") */ __pyx_t_7 = ((__pyx_v_child->byteorder == '>') != 0); if (!__pyx_t_7) { goto __pyx_L8_next_or; } else { } __pyx_t_7 = (__pyx_v_little_endian != 0); if (!__pyx_t_7) { } else { __pyx_t_6 = __pyx_t_7; goto __pyx_L7_bool_binop_done; } __pyx_L8_next_or:; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":802 * * if ((child.byteorder == c'>' and little_endian) or * (child.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<< * raise ValueError(u"Non-native byte order not supported") * # One could encode it in the format string and have Cython */ __pyx_t_7 = ((__pyx_v_child->byteorder == '<') != 0); if (__pyx_t_7) { } else { __pyx_t_6 = __pyx_t_7; goto __pyx_L7_bool_binop_done; } __pyx_t_7 = ((!(__pyx_v_little_endian != 0)) != 0); __pyx_t_6 = __pyx_t_7; __pyx_L7_bool_binop_done:; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":801 * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") * * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< * (child.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") */ if (__pyx_t_6) { /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":803 * if ((child.byteorder == c'>' and little_endian) or * (child.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< * # One could encode it in the format string and have Cython * # complain instead, BUT: < and > in format strings also imply */ __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; {__pyx_filename = __pyx_f[1]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":801 * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") * * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< * (child.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") */ } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":813 * * # Output padding bytes * while offset[0] < new_offset: # <<<<<<<<<<<<<< * f[0] = 120 # "x"; pad byte * f += 1 */ while (1) { __pyx_t_3 = __Pyx_PyInt_From_int((__pyx_v_offset[0])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyObject_RichCompare(__pyx_t_3, __pyx_v_new_offset, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (!__pyx_t_6) break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":814 * # Output padding bytes * while offset[0] < new_offset: * f[0] = 120 # "x"; pad byte # <<<<<<<<<<<<<< * f += 1 * offset[0] += 1 */ (__pyx_v_f[0]) = 0x78; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":815 * while offset[0] < new_offset: * f[0] = 120 # "x"; pad byte * f += 1 # <<<<<<<<<<<<<< * offset[0] += 1 * */ __pyx_v_f = (__pyx_v_f + 1); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":816 * f[0] = 120 # "x"; pad byte * f += 1 * offset[0] += 1 # <<<<<<<<<<<<<< * * offset[0] += child.itemsize */ __pyx_t_8 = 0; (__pyx_v_offset[__pyx_t_8]) = ((__pyx_v_offset[__pyx_t_8]) + 1); } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":818 * offset[0] += 1 * * offset[0] += child.itemsize # <<<<<<<<<<<<<< * * if not PyDataType_HASFIELDS(child): */ __pyx_t_8 = 0; (__pyx_v_offset[__pyx_t_8]) = ((__pyx_v_offset[__pyx_t_8]) + __pyx_v_child->elsize); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":820 * offset[0] += child.itemsize * * if not PyDataType_HASFIELDS(child): # <<<<<<<<<<<<<< * t = child.type_num * if end - f < 5: */ __pyx_t_6 = ((!(PyDataType_HASFIELDS(__pyx_v_child) != 0)) != 0); if (__pyx_t_6) { /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":821 * * if not PyDataType_HASFIELDS(child): * t = child.type_num # <<<<<<<<<<<<<< * if end - f < 5: * raise RuntimeError(u"Format string allocated too short.") */ __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_child->type_num); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_4); __pyx_t_4 = 0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":822 * if not PyDataType_HASFIELDS(child): * t = child.type_num * if end - f < 5: # <<<<<<<<<<<<<< * raise RuntimeError(u"Format string allocated too short.") * */ __pyx_t_6 = (((__pyx_v_end - __pyx_v_f) < 5) != 0); if (__pyx_t_6) { /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":823 * t = child.type_num * if end - f < 5: * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<< * * # Until ticket #99 is fixed, use integers to avoid warnings */ __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; {__pyx_filename = __pyx_f[1]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":822 * if not PyDataType_HASFIELDS(child): * t = child.type_num * if end - f < 5: # <<<<<<<<<<<<<< * raise RuntimeError(u"Format string allocated too short.") * */ } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":826 * * # Until ticket #99 is fixed, use integers to avoid warnings * if t == NPY_BYTE: f[0] = 98 #"b" # <<<<<<<<<<<<<< * elif t == NPY_UBYTE: f[0] = 66 #"B" * elif t == NPY_SHORT: f[0] = 104 #"h" */ __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_BYTE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 98; goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":827 * # Until ticket #99 is fixed, use integers to avoid warnings * if t == NPY_BYTE: f[0] = 98 #"b" * elif t == NPY_UBYTE: f[0] = 66 #"B" # <<<<<<<<<<<<<< * elif t == NPY_SHORT: f[0] = 104 #"h" * elif t == NPY_USHORT: f[0] = 72 #"H" */ __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_UBYTE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 66; goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":828 * if t == NPY_BYTE: f[0] = 98 #"b" * elif t == NPY_UBYTE: f[0] = 66 #"B" * elif t == NPY_SHORT: f[0] = 104 #"h" # <<<<<<<<<<<<<< * elif t == NPY_USHORT: f[0] = 72 #"H" * elif t == NPY_INT: f[0] = 105 #"i" */ __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_SHORT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 0x68; goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":829 * elif t == NPY_UBYTE: f[0] = 66 #"B" * elif t == NPY_SHORT: f[0] = 104 #"h" * elif t == NPY_USHORT: f[0] = 72 #"H" # <<<<<<<<<<<<<< * elif t == NPY_INT: f[0] = 105 #"i" * elif t == NPY_UINT: f[0] = 73 #"I" */ __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_USHORT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 72; goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":830 * elif t == NPY_SHORT: f[0] = 104 #"h" * elif t == NPY_USHORT: f[0] = 72 #"H" * elif t == NPY_INT: f[0] = 105 #"i" # <<<<<<<<<<<<<< * elif t == NPY_UINT: f[0] = 73 #"I" * elif t == NPY_LONG: f[0] = 108 #"l" */ __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_INT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 0x69; goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":831 * elif t == NPY_USHORT: f[0] = 72 #"H" * elif t == NPY_INT: f[0] = 105 #"i" * elif t == NPY_UINT: f[0] = 73 #"I" # <<<<<<<<<<<<<< * elif t == NPY_LONG: f[0] = 108 #"l" * elif t == NPY_ULONG: f[0] = 76 #"L" */ __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_UINT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 73; goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":832 * elif t == NPY_INT: f[0] = 105 #"i" * elif t == NPY_UINT: f[0] = 73 #"I" * elif t == NPY_LONG: f[0] = 108 #"l" # <<<<<<<<<<<<<< * elif t == NPY_ULONG: f[0] = 76 #"L" * elif t == NPY_LONGLONG: f[0] = 113 #"q" */ __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONG); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 0x6C; goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":833 * elif t == NPY_UINT: f[0] = 73 #"I" * elif t == NPY_LONG: f[0] = 108 #"l" * elif t == NPY_ULONG: f[0] = 76 #"L" # <<<<<<<<<<<<<< * elif t == NPY_LONGLONG: f[0] = 113 #"q" * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" */ __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_ULONG); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 76; goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":834 * elif t == NPY_LONG: f[0] = 108 #"l" * elif t == NPY_ULONG: f[0] = 76 #"L" * elif t == NPY_LONGLONG: f[0] = 113 #"q" # <<<<<<<<<<<<<< * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" * elif t == NPY_FLOAT: f[0] = 102 #"f" */ __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONGLONG); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 0x71; goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":835 * elif t == NPY_ULONG: f[0] = 76 #"L" * elif t == NPY_LONGLONG: f[0] = 113 #"q" * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" # <<<<<<<<<<<<<< * elif t == NPY_FLOAT: f[0] = 102 #"f" * elif t == NPY_DOUBLE: f[0] = 100 #"d" */ __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_ULONGLONG); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 81; goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":836 * elif t == NPY_LONGLONG: f[0] = 113 #"q" * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" * elif t == NPY_FLOAT: f[0] = 102 #"f" # <<<<<<<<<<<<<< * elif t == NPY_DOUBLE: f[0] = 100 #"d" * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" */ __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_FLOAT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 0x66; goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":837 * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" * elif t == NPY_FLOAT: f[0] = 102 #"f" * elif t == NPY_DOUBLE: f[0] = 100 #"d" # <<<<<<<<<<<<<< * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf */ __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_DOUBLE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 0x64; goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":838 * elif t == NPY_FLOAT: f[0] = 102 #"f" * elif t == NPY_DOUBLE: f[0] = 100 #"d" * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" # <<<<<<<<<<<<<< * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd */ __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONGDOUBLE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 0x67; goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":839 * elif t == NPY_DOUBLE: f[0] = 100 #"d" * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf # <<<<<<<<<<<<<< * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg */ __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CFLOAT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 90; (__pyx_v_f[1]) = 0x66; __pyx_v_f = (__pyx_v_f + 1); goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":840 * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd # <<<<<<<<<<<<<< * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg * elif t == NPY_OBJECT: f[0] = 79 #"O" */ __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CDOUBLE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 90; (__pyx_v_f[1]) = 0x64; __pyx_v_f = (__pyx_v_f + 1); goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":841 * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg # <<<<<<<<<<<<<< * elif t == NPY_OBJECT: f[0] = 79 #"O" * else: */ __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CLONGDOUBLE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 90; (__pyx_v_f[1]) = 0x67; __pyx_v_f = (__pyx_v_f + 1); goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":842 * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg * elif t == NPY_OBJECT: f[0] = 79 #"O" # <<<<<<<<<<<<<< * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) */ __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_OBJECT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 79; goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":844 * elif t == NPY_OBJECT: f[0] = 79 #"O" * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< * f += 1 * else: */ /*else*/ { __pyx_t_3 = PyUnicode_Format(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_v_t); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; {__pyx_filename = __pyx_f[1]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_L15:; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":845 * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) * f += 1 # <<<<<<<<<<<<<< * else: * # Cython ignores struct boundary information ("T{...}"), */ __pyx_v_f = (__pyx_v_f + 1); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":820 * offset[0] += child.itemsize * * if not PyDataType_HASFIELDS(child): # <<<<<<<<<<<<<< * t = child.type_num * if end - f < 5: */ goto __pyx_L13; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":849 * # Cython ignores struct boundary information ("T{...}"), * # so don't output it * f = _util_dtypestring(child, f, end, offset) # <<<<<<<<<<<<<< * return f * */ /*else*/ { __pyx_t_9 = __pyx_f_5numpy__util_dtypestring(__pyx_v_child, __pyx_v_f, __pyx_v_end, __pyx_v_offset); if (unlikely(__pyx_t_9 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 849; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_f = __pyx_t_9; } __pyx_L13:; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":794 * cdef tuple fields * * for childname in descr.names: # <<<<<<<<<<<<<< * fields = descr.fields[childname] * child, new_offset = fields */ } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":850 * # so don't output it * f = _util_dtypestring(child, f, end, offset) * return f # <<<<<<<<<<<<<< * * */ __pyx_r = __pyx_v_f; goto __pyx_L0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":785 * return PyArray_MultiIterNew(5, a, b, c, d, e) * * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: # <<<<<<<<<<<<<< * # Recursive utility function used in __getbuffer__ to get format * # string. The new location in the format string is returned. */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("numpy._util_dtypestring", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF((PyObject *)__pyx_v_child); __Pyx_XDECREF(__pyx_v_fields); __Pyx_XDECREF(__pyx_v_childname); __Pyx_XDECREF(__pyx_v_new_offset); __Pyx_XDECREF(__pyx_v_t); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":966 * * * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< * cdef PyObject* baseptr * if base is None: */ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_arr, PyObject *__pyx_v_base) { PyObject *__pyx_v_baseptr; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; __Pyx_RefNannySetupContext("set_array_base", 0); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":968 * cdef inline void set_array_base(ndarray arr, object base): * cdef PyObject* baseptr * if base is None: # <<<<<<<<<<<<<< * baseptr = NULL * else: */ __pyx_t_1 = (__pyx_v_base == Py_None); __pyx_t_2 = (__pyx_t_1 != 0); if (__pyx_t_2) { /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":969 * cdef PyObject* baseptr * if base is None: * baseptr = NULL # <<<<<<<<<<<<<< * else: * Py_INCREF(base) # important to do this before decref below! */ __pyx_v_baseptr = NULL; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":968 * cdef inline void set_array_base(ndarray arr, object base): * cdef PyObject* baseptr * if base is None: # <<<<<<<<<<<<<< * baseptr = NULL * else: */ goto __pyx_L3; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":971 * baseptr = NULL * else: * Py_INCREF(base) # important to do this before decref below! # <<<<<<<<<<<<<< * baseptr = base * Py_XDECREF(arr.base) */ /*else*/ { Py_INCREF(__pyx_v_base); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":972 * else: * Py_INCREF(base) # important to do this before decref below! * baseptr = base # <<<<<<<<<<<<<< * Py_XDECREF(arr.base) * arr.base = baseptr */ __pyx_v_baseptr = ((PyObject *)__pyx_v_base); } __pyx_L3:; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":973 * Py_INCREF(base) # important to do this before decref below! * baseptr = base * Py_XDECREF(arr.base) # <<<<<<<<<<<<<< * arr.base = baseptr * */ Py_XDECREF(__pyx_v_arr->base); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":974 * baseptr = base * Py_XDECREF(arr.base) * arr.base = baseptr # <<<<<<<<<<<<<< * * cdef inline object get_array_base(ndarray arr): */ __pyx_v_arr->base = __pyx_v_baseptr; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":966 * * * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< * cdef PyObject* baseptr * if base is None: */ /* function exit code */ __Pyx_RefNannyFinishContext(); } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":976 * arr.base = baseptr * * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< * if arr.base is NULL: * return None */ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__pyx_v_arr) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; __Pyx_RefNannySetupContext("get_array_base", 0); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":977 * * cdef inline object get_array_base(ndarray arr): * if arr.base is NULL: # <<<<<<<<<<<<<< * return None * else: */ __pyx_t_1 = ((__pyx_v_arr->base == NULL) != 0); if (__pyx_t_1) { /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":978 * cdef inline object get_array_base(ndarray arr): * if arr.base is NULL: * return None # <<<<<<<<<<<<<< * else: * return arr.base */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(Py_None); __pyx_r = Py_None; goto __pyx_L0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":977 * * cdef inline object get_array_base(ndarray arr): * if arr.base is NULL: # <<<<<<<<<<<<<< * return None * else: */ } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":980 * return None * else: * return arr.base # <<<<<<<<<<<<<< */ /*else*/ { __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(((PyObject *)__pyx_v_arr->base)); __pyx_r = ((PyObject *)__pyx_v_arr->base); goto __pyx_L0; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":976 * arr.base = baseptr * * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< * if arr.base is NULL: * return None */ /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyMethodDef __pyx_methods[] = { {0, 0, 0, 0} }; #if PY_MAJOR_VERSION >= 3 static struct PyModuleDef __pyx_moduledef = { #if PY_VERSION_HEX < 0x03020000 { PyObject_HEAD_INIT(NULL) NULL, 0, NULL }, #else PyModuleDef_HEAD_INIT, #endif "elliptical_overlap", 0, /* m_doc */ -1, /* m_size */ __pyx_methods /* m_methods */, NULL, /* m_reload */ NULL, /* m_traverse */ NULL, /* m_clear */ NULL /* m_free */ }; #endif static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_DTYPE, __pyx_k_DTYPE, sizeof(__pyx_k_DTYPE), 0, 0, 1, 1}, {&__pyx_kp_u_Format_string_allocated_too_shor, __pyx_k_Format_string_allocated_too_shor, sizeof(__pyx_k_Format_string_allocated_too_shor), 0, 1, 0, 0}, {&__pyx_kp_u_Format_string_allocated_too_shor_2, __pyx_k_Format_string_allocated_too_shor_2, sizeof(__pyx_k_Format_string_allocated_too_shor_2), 0, 1, 0, 0}, {&__pyx_kp_u_Non_native_byte_order_not_suppor, __pyx_k_Non_native_byte_order_not_suppor, sizeof(__pyx_k_Non_native_byte_order_not_suppor), 0, 1, 0, 0}, {&__pyx_n_s_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 0, 0, 1, 1}, {&__pyx_kp_s_Users_lbradley_Dropbox_softw_de, __pyx_k_Users_lbradley_Dropbox_softw_de, sizeof(__pyx_k_Users_lbradley_Dropbox_softw_de), 0, 0, 1, 0}, {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1}, {&__pyx_n_s_all, __pyx_k_all, sizeof(__pyx_k_all), 0, 0, 1, 1}, {&__pyx_n_s_bxmax, __pyx_k_bxmax, sizeof(__pyx_k_bxmax), 0, 0, 1, 1}, {&__pyx_n_s_bxmin, __pyx_k_bxmin, sizeof(__pyx_k_bxmin), 0, 0, 1, 1}, {&__pyx_n_s_bymax, __pyx_k_bymax, sizeof(__pyx_k_bymax), 0, 0, 1, 1}, {&__pyx_n_s_bymin, __pyx_k_bymin, sizeof(__pyx_k_bymin), 0, 0, 1, 1}, {&__pyx_n_s_dtype, __pyx_k_dtype, sizeof(__pyx_k_dtype), 0, 0, 1, 1}, {&__pyx_n_s_dx, __pyx_k_dx, sizeof(__pyx_k_dx), 0, 0, 1, 1}, {&__pyx_n_s_dy, __pyx_k_dy, sizeof(__pyx_k_dy), 0, 0, 1, 1}, {&__pyx_n_s_elliptical_overlap_grid, __pyx_k_elliptical_overlap_grid, sizeof(__pyx_k_elliptical_overlap_grid), 0, 0, 1, 1}, {&__pyx_n_u_elliptical_overlap_grid, __pyx_k_elliptical_overlap_grid, sizeof(__pyx_k_elliptical_overlap_grid), 0, 1, 0, 1}, {&__pyx_n_s_float64, __pyx_k_float64, sizeof(__pyx_k_float64), 0, 0, 1, 1}, {&__pyx_n_s_frac, __pyx_k_frac, sizeof(__pyx_k_frac), 0, 0, 1, 1}, {&__pyx_n_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 1}, {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1}, {&__pyx_n_s_j, __pyx_k_j, sizeof(__pyx_k_j), 0, 0, 1, 1}, {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, {&__pyx_kp_u_ndarray_is_not_C_contiguous, __pyx_k_ndarray_is_not_C_contiguous, sizeof(__pyx_k_ndarray_is_not_C_contiguous), 0, 1, 0, 0}, {&__pyx_kp_u_ndarray_is_not_Fortran_contiguou, __pyx_k_ndarray_is_not_Fortran_contiguou, sizeof(__pyx_k_ndarray_is_not_Fortran_contiguou), 0, 1, 0, 0}, {&__pyx_n_s_norm, __pyx_k_norm, sizeof(__pyx_k_norm), 0, 0, 1, 1}, {&__pyx_n_s_np, __pyx_k_np, sizeof(__pyx_k_np), 0, 0, 1, 1}, {&__pyx_n_s_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 0, 0, 1, 1}, {&__pyx_n_s_nx, __pyx_k_nx, sizeof(__pyx_k_nx), 0, 0, 1, 1}, {&__pyx_n_s_ny, __pyx_k_ny, sizeof(__pyx_k_ny), 0, 0, 1, 1}, {&__pyx_n_s_photutils_geometry_elliptical_ov, __pyx_k_photutils_geometry_elliptical_ov, sizeof(__pyx_k_photutils_geometry_elliptical_ov), 0, 0, 1, 1}, {&__pyx_n_s_pxmax, __pyx_k_pxmax, sizeof(__pyx_k_pxmax), 0, 0, 1, 1}, {&__pyx_n_s_pxmin, __pyx_k_pxmin, sizeof(__pyx_k_pxmin), 0, 0, 1, 1}, {&__pyx_n_s_pymax, __pyx_k_pymax, sizeof(__pyx_k_pymax), 0, 0, 1, 1}, {&__pyx_n_s_pymin, __pyx_k_pymin, sizeof(__pyx_k_pymin), 0, 0, 1, 1}, {&__pyx_n_s_r, __pyx_k_r, sizeof(__pyx_k_r), 0, 0, 1, 1}, {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1}, {&__pyx_n_s_rx, __pyx_k_rx, sizeof(__pyx_k_rx), 0, 0, 1, 1}, {&__pyx_n_s_ry, __pyx_k_ry, sizeof(__pyx_k_ry), 0, 0, 1, 1}, {&__pyx_n_s_subpixels, __pyx_k_subpixels, sizeof(__pyx_k_subpixels), 0, 0, 1, 1}, {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, {&__pyx_n_s_theta, __pyx_k_theta, sizeof(__pyx_k_theta), 0, 0, 1, 1}, {&__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_k_unknown_dtype_code_in_numpy_pxd, sizeof(__pyx_k_unknown_dtype_code_in_numpy_pxd), 0, 1, 0, 0}, {&__pyx_n_s_use_exact, __pyx_k_use_exact, sizeof(__pyx_k_use_exact), 0, 0, 1, 1}, {&__pyx_n_s_x, __pyx_k_x, sizeof(__pyx_k_x), 0, 0, 1, 1}, {&__pyx_n_s_xmax, __pyx_k_xmax, sizeof(__pyx_k_xmax), 0, 0, 1, 1}, {&__pyx_n_s_xmin, __pyx_k_xmin, sizeof(__pyx_k_xmin), 0, 0, 1, 1}, {&__pyx_n_s_y, __pyx_k_y, sizeof(__pyx_k_y), 0, 0, 1, 1}, {&__pyx_n_s_ymax, __pyx_k_ymax, sizeof(__pyx_k_ymax), 0, 0, 1, 1}, {&__pyx_n_s_ymin, __pyx_k_ymin, sizeof(__pyx_k_ymin), 0, 0, 1, 1}, {&__pyx_n_s_zeros, __pyx_k_zeros, sizeof(__pyx_k_zeros), 0, 0, 1, 1}, {0, 0, 0, 0, 0, 0, 0} }; static int __Pyx_InitCachedBuiltins(void) { __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} return 0; __pyx_L1_error:; return -1; } static int __Pyx_InitCachedConstants(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":218 * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<< * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) */ __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_C_contiguous); if (unlikely(!__pyx_tuple_)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple_); __Pyx_GIVEREF(__pyx_tuple_); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":222 * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<< * * info.buf = PyArray_DATA(self) */ __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_Fortran_contiguou); if (unlikely(!__pyx_tuple__2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__2); __Pyx_GIVEREF(__pyx_tuple__2); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":259 * if ((descr.byteorder == c'>' and little_endian) or * (descr.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< * if t == NPY_BYTE: f = "b" * elif t == NPY_UBYTE: f = "B" */ __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__3); __Pyx_GIVEREF(__pyx_tuple__3); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":799 * * if (end - f) - (new_offset - offset[0]) < 15: * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<< * * if ((child.byteorder == c'>' and little_endian) or */ __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor); if (unlikely(!__pyx_tuple__4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__4); __Pyx_GIVEREF(__pyx_tuple__4); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":803 * if ((child.byteorder == c'>' and little_endian) or * (child.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< * # One could encode it in the format string and have Cython * # complain instead, BUT: < and > in format strings also imply */ __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__5); __Pyx_GIVEREF(__pyx_tuple__5); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":823 * t = child.type_num * if end - f < 5: * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<< * * # Until ticket #99 is fixed, use integers to avoid warnings */ __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor_2); if (unlikely(!__pyx_tuple__6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__6); __Pyx_GIVEREF(__pyx_tuple__6); /* "photutils/geometry/elliptical_overlap.pyx":36 * * * def elliptical_overlap_grid(double xmin, double xmax, double ymin, double ymax, # <<<<<<<<<<<<<< * int nx, int ny, double rx, double ry, double theta, * int use_exact, int subpixels): */ __pyx_tuple__7 = PyTuple_Pack(28, __pyx_n_s_xmin, __pyx_n_s_xmax, __pyx_n_s_ymin, __pyx_n_s_ymax, __pyx_n_s_nx, __pyx_n_s_ny, __pyx_n_s_rx, __pyx_n_s_ry, __pyx_n_s_theta, __pyx_n_s_use_exact, __pyx_n_s_subpixels, __pyx_n_s_i, __pyx_n_s_j, __pyx_n_s_x, __pyx_n_s_y, __pyx_n_s_dx, __pyx_n_s_dy, __pyx_n_s_bxmin, __pyx_n_s_bxmax, __pyx_n_s_bymin, __pyx_n_s_bymax, __pyx_n_s_pxmin, __pyx_n_s_pxmax, __pyx_n_s_pymin, __pyx_n_s_pymax, __pyx_n_s_norm, __pyx_n_s_frac, __pyx_n_s_r); if (unlikely(!__pyx_tuple__7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__7); __Pyx_GIVEREF(__pyx_tuple__7); __pyx_codeobj__8 = (PyObject*)__Pyx_PyCode_New(11, 0, 28, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__7, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_lbradley_Dropbox_softw_de, __pyx_n_s_elliptical_overlap_grid, 36, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; __Pyx_RefNannyFinishContext(); return -1; } static int __Pyx_InitGlobals(void) { if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; return 0; __pyx_L1_error:; return -1; } #if PY_MAJOR_VERSION < 3 PyMODINIT_FUNC initelliptical_overlap(void); /*proto*/ PyMODINIT_FUNC initelliptical_overlap(void) #else PyMODINIT_FUNC PyInit_elliptical_overlap(void); /*proto*/ PyMODINIT_FUNC PyInit_elliptical_overlap(void) #endif { PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannyDeclarations #if CYTHON_REFNANNY __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); if (!__Pyx_RefNanny) { PyErr_Clear(); __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny"); if (!__Pyx_RefNanny) Py_FatalError("failed to import 'refnanny' module"); } #endif __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit_elliptical_overlap(void)", 0); if (__Pyx_check_binary_version() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #ifdef __Pyx_CyFunction_USED if (__pyx_CyFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif #ifdef __Pyx_FusedFunction_USED if (__pyx_FusedFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif #ifdef __Pyx_Coroutine_USED if (__pyx_Coroutine_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif #ifdef __Pyx_Generator_USED if (__pyx_Generator_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif #ifdef __Pyx_StopAsyncIteration_USED if (__pyx_StopAsyncIteration_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /*--- Library function declarations ---*/ /*--- Threads initialization code ---*/ #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS #ifdef WITH_THREAD /* Python build with threading support? */ PyEval_InitThreads(); #endif #endif /*--- Module creation code ---*/ #if PY_MAJOR_VERSION < 3 __pyx_m = Py_InitModule4("elliptical_overlap", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); #else __pyx_m = PyModule_Create(&__pyx_moduledef); #endif if (unlikely(!__pyx_m)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_INCREF(__pyx_d); __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #if CYTHON_COMPILING_IN_PYPY Py_INCREF(__pyx_b); #endif if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; /*--- Initialize various global constants etc. ---*/ if (__Pyx_InitGlobals() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) if (__Pyx_init_sys_getdefaultencoding_params() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif if (__pyx_module_is_main_photutils__geometry__elliptical_overlap) { if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } #if PY_MAJOR_VERSION >= 3 { PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (!PyDict_GetItemString(modules, "photutils.geometry.elliptical_overlap")) { if (unlikely(PyDict_SetItemString(modules, "photutils.geometry.elliptical_overlap", __pyx_m) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } } #endif /*--- Builtin init code ---*/ if (__Pyx_InitCachedBuiltins() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /*--- Constants init code ---*/ if (__Pyx_InitCachedConstants() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /*--- Global init code ---*/ /*--- Variable export code ---*/ /*--- Function export code ---*/ /*--- Type init code ---*/ /*--- Type import code ---*/ __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "type", #if CYTHON_COMPILING_IN_PYPY sizeof(PyTypeObject), #else sizeof(PyHeapTypeObject), #endif 0); if (unlikely(!__pyx_ptype_7cpython_4type_type)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_7cpython_4bool_bool = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "bool", sizeof(PyBoolObject), 0); if (unlikely(!__pyx_ptype_7cpython_4bool_bool)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_7cpython_7complex_complex = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "complex", sizeof(PyComplexObject), 0); if (unlikely(!__pyx_ptype_7cpython_7complex_complex)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5numpy_dtype = __Pyx_ImportType("numpy", "dtype", sizeof(PyArray_Descr), 0); if (unlikely(!__pyx_ptype_5numpy_dtype)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5numpy_flatiter = __Pyx_ImportType("numpy", "flatiter", sizeof(PyArrayIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_flatiter)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5numpy_broadcast = __Pyx_ImportType("numpy", "broadcast", sizeof(PyArrayMultiIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_broadcast)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5numpy_ndarray = __Pyx_ImportType("numpy", "ndarray", sizeof(PyArrayObject), 0); if (unlikely(!__pyx_ptype_5numpy_ndarray)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5numpy_ufunc = __Pyx_ImportType("numpy", "ufunc", sizeof(PyUFuncObject), 0); if (unlikely(!__pyx_ptype_5numpy_ufunc)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 861; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /*--- Variable import code ---*/ /*--- Function import code ---*/ __pyx_t_1 = __Pyx_ImportModule("photutils.geometry.core"); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__Pyx_ImportFunction(__pyx_t_1, "distance", (void (**)(void))&__pyx_f_9photutils_8geometry_4core_distance, "double (double, double, double, double)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__Pyx_ImportFunction(__pyx_t_1, "area_triangle", (void (**)(void))&__pyx_f_9photutils_8geometry_4core_area_triangle, "double (double, double, double, double, double, double)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__Pyx_ImportFunction(__pyx_t_1, "overlap_area_triangle_unit_circle", (void (**)(void))&__pyx_f_9photutils_8geometry_4core_overlap_area_triangle_unit_circle, "double (double, double, double, double, double, double)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_t_1); __pyx_t_1 = 0; /*--- Execution code ---*/ #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) if (__Pyx_patch_abc() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* "photutils/geometry/elliptical_overlap.pyx":11 * from __future__ import (absolute_import, division, print_function, * unicode_literals) * import numpy as np # <<<<<<<<<<<<<< * cimport numpy as np * */ __pyx_t_2 = __Pyx_Import(__pyx_n_s_numpy, 0, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "photutils/geometry/elliptical_overlap.pyx":14 * cimport numpy as np * * __all__ = ['elliptical_overlap_grid'] # <<<<<<<<<<<<<< * * cdef extern from "math.h": */ __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_u_elliptical_overlap_grid); __Pyx_GIVEREF(__pyx_n_u_elliptical_overlap_grid); PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_u_elliptical_overlap_grid); if (PyDict_SetItem(__pyx_d, __pyx_n_s_all, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "photutils/geometry/elliptical_overlap.pyx":25 * from cpython cimport bool * * DTYPE = np.float64 # <<<<<<<<<<<<<< * ctypedef np.float64_t DTYPE_t * */ __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_float64); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_DTYPE, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "photutils/geometry/elliptical_overlap.pyx":36 * * * def elliptical_overlap_grid(double xmin, double xmax, double ymin, double ymax, # <<<<<<<<<<<<<< * int nx, int ny, double rx, double ry, double theta, * int use_exact, int subpixels): */ __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_9photutils_8geometry_18elliptical_overlap_1elliptical_overlap_grid, NULL, __pyx_n_s_photutils_geometry_elliptical_ov); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_elliptical_overlap_grid, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "photutils/geometry/elliptical_overlap.pyx":1 * # Licensed under a 3-clause BSD style license - see LICENSE.rst # <<<<<<<<<<<<<< * * # The functions defined here allow one to determine the exact area of */ __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":976 * arr.base = baseptr * * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< * if arr.base is NULL: * return None */ /*--- Wrapped vars code ---*/ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); if (__pyx_m) { if (__pyx_d) { __Pyx_AddTraceback("init photutils.geometry.elliptical_overlap", __pyx_clineno, __pyx_lineno, __pyx_filename); } Py_DECREF(__pyx_m); __pyx_m = 0; } else if (!PyErr_Occurred()) { PyErr_SetString(PyExc_ImportError, "init photutils.geometry.elliptical_overlap"); } __pyx_L0:; __Pyx_RefNannyFinishContext(); #if PY_MAJOR_VERSION < 3 return; #else return __pyx_m; #endif } /* --- Runtime support code --- */ #if CYTHON_REFNANNY static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { PyObject *m = NULL, *p = NULL; void *r = NULL; m = PyImport_ImportModule((char *)modname); if (!m) goto end; p = PyObject_GetAttrString(m, (char *)"RefNannyAPI"); if (!p) goto end; r = PyLong_AsVoidPtr(p); end: Py_XDECREF(p); Py_XDECREF(m); return (__Pyx_RefNannyAPIStruct *)r; } #endif static PyObject *__Pyx_GetBuiltinName(PyObject *name) { PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name); if (unlikely(!result)) { PyErr_Format(PyExc_NameError, #if PY_MAJOR_VERSION >= 3 "name '%U' is not defined", name); #else "name '%.200s' is not defined", PyString_AS_STRING(name)); #endif } return result; } static void __Pyx_RaiseArgtupleInvalid( const char* func_name, int exact, Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found) { Py_ssize_t num_expected; const char *more_or_less; if (num_found < num_min) { num_expected = num_min; more_or_less = "at least"; } else { num_expected = num_max; more_or_less = "at most"; } if (exact) { more_or_less = "exactly"; } PyErr_Format(PyExc_TypeError, "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)", func_name, more_or_less, num_expected, (num_expected == 1) ? "" : "s", num_found); } static void __Pyx_RaiseDoubleKeywordsError( const char* func_name, PyObject* kw_name) { PyErr_Format(PyExc_TypeError, #if PY_MAJOR_VERSION >= 3 "%s() got multiple values for keyword argument '%U'", func_name, kw_name); #else "%s() got multiple values for keyword argument '%s'", func_name, PyString_AsString(kw_name)); #endif } static int __Pyx_ParseOptionalKeywords( PyObject *kwds, PyObject **argnames[], PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, const char* function_name) { PyObject *key = 0, *value = 0; Py_ssize_t pos = 0; PyObject*** name; PyObject*** first_kw_arg = argnames + num_pos_args; while (PyDict_Next(kwds, &pos, &key, &value)) { name = first_kw_arg; while (*name && (**name != key)) name++; if (*name) { values[name-argnames] = value; continue; } name = first_kw_arg; #if PY_MAJOR_VERSION < 3 if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) { while (*name) { if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key)) && _PyString_Eq(**name, key)) { values[name-argnames] = value; break; } name++; } if (*name) continue; else { PyObject*** argname = argnames; while (argname != first_kw_arg) { if ((**argname == key) || ( (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key)) && _PyString_Eq(**argname, key))) { goto arg_passed_twice; } argname++; } } } else #endif if (likely(PyUnicode_Check(key))) { while (*name) { int cmp = (**name == key) ? 0 : #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 : #endif PyUnicode_Compare(**name, key); if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; if (cmp == 0) { values[name-argnames] = value; break; } name++; } if (*name) continue; else { PyObject*** argname = argnames; while (argname != first_kw_arg) { int cmp = (**argname == key) ? 0 : #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 : #endif PyUnicode_Compare(**argname, key); if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; if (cmp == 0) goto arg_passed_twice; argname++; } } } else goto invalid_keyword_type; if (kwds2) { if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad; } else { goto invalid_keyword; } } return 0; arg_passed_twice: __Pyx_RaiseDoubleKeywordsError(function_name, key); goto bad; invalid_keyword_type: PyErr_Format(PyExc_TypeError, "%.200s() keywords must be strings", function_name); goto bad; invalid_keyword: PyErr_Format(PyExc_TypeError, #if PY_MAJOR_VERSION < 3 "%.200s() got an unexpected keyword argument '%.200s'", function_name, PyString_AsString(key)); #else "%s() got an unexpected keyword argument '%U'", function_name, key); #endif bad: return -1; } static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) { PyObject *result; #if CYTHON_COMPILING_IN_CPYTHON result = PyDict_GetItem(__pyx_d, name); if (likely(result)) { Py_INCREF(result); } else { #else result = PyObject_GetItem(__pyx_d, name); if (!result) { PyErr_Clear(); #endif result = __Pyx_GetBuiltinName(name); } return result; } #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) { PyObject *result; ternaryfunc call = func->ob_type->tp_call; if (unlikely(!call)) return PyObject_Call(func, arg, kw); if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) return NULL; result = (*call)(func, arg, kw); Py_LeaveRecursiveCall(); if (unlikely(!result) && unlikely(!PyErr_Occurred())) { PyErr_SetString( PyExc_SystemError, "NULL result without error in PyObject_Call"); } return result; } #endif static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { if (unlikely(!type)) { PyErr_SetString(PyExc_SystemError, "Missing type object"); return 0; } if (likely(PyObject_TypeCheck(obj, type))) return 1; PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s", Py_TYPE(obj)->tp_name, type->tp_name); return 0; } static CYTHON_INLINE int __Pyx_IsLittleEndian(void) { unsigned int n = 1; return *(unsigned char*)(&n) != 0; } static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx, __Pyx_BufFmt_StackElem* stack, __Pyx_TypeInfo* type) { stack[0].field = &ctx->root; stack[0].parent_offset = 0; ctx->root.type = type; ctx->root.name = "buffer dtype"; ctx->root.offset = 0; ctx->head = stack; ctx->head->field = &ctx->root; ctx->fmt_offset = 0; ctx->head->parent_offset = 0; ctx->new_packmode = '@'; ctx->enc_packmode = '@'; ctx->new_count = 1; ctx->enc_count = 0; ctx->enc_type = 0; ctx->is_complex = 0; ctx->is_valid_array = 0; ctx->struct_alignment = 0; while (type->typegroup == 'S') { ++ctx->head; ctx->head->field = type->fields; ctx->head->parent_offset = 0; type = type->fields->type; } } static int __Pyx_BufFmt_ParseNumber(const char** ts) { int count; const char* t = *ts; if (*t < '0' || *t > '9') { return -1; } else { count = *t++ - '0'; while (*t >= '0' && *t < '9') { count *= 10; count += *t++ - '0'; } } *ts = t; return count; } static int __Pyx_BufFmt_ExpectNumber(const char **ts) { int number = __Pyx_BufFmt_ParseNumber(ts); if (number == -1) PyErr_Format(PyExc_ValueError,\ "Does not understand character buffer dtype format string ('%c')", **ts); return number; } static void __Pyx_BufFmt_RaiseUnexpectedChar(char ch) { PyErr_Format(PyExc_ValueError, "Unexpected format string character: '%c'", ch); } static const char* __Pyx_BufFmt_DescribeTypeChar(char ch, int is_complex) { switch (ch) { case 'c': return "'char'"; case 'b': return "'signed char'"; case 'B': return "'unsigned char'"; case 'h': return "'short'"; case 'H': return "'unsigned short'"; case 'i': return "'int'"; case 'I': return "'unsigned int'"; case 'l': return "'long'"; case 'L': return "'unsigned long'"; case 'q': return "'long long'"; case 'Q': return "'unsigned long long'"; case 'f': return (is_complex ? "'complex float'" : "'float'"); case 'd': return (is_complex ? "'complex double'" : "'double'"); case 'g': return (is_complex ? "'complex long double'" : "'long double'"); case 'T': return "a struct"; case 'O': return "Python object"; case 'P': return "a pointer"; case 's': case 'p': return "a string"; case 0: return "end"; default: return "unparseable format string"; } } static size_t __Pyx_BufFmt_TypeCharToStandardSize(char ch, int is_complex) { switch (ch) { case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; case 'h': case 'H': return 2; case 'i': case 'I': case 'l': case 'L': return 4; case 'q': case 'Q': return 8; case 'f': return (is_complex ? 8 : 4); case 'd': return (is_complex ? 16 : 8); case 'g': { PyErr_SetString(PyExc_ValueError, "Python does not define a standard format string size for long double ('g').."); return 0; } case 'O': case 'P': return sizeof(void*); default: __Pyx_BufFmt_RaiseUnexpectedChar(ch); return 0; } } static size_t __Pyx_BufFmt_TypeCharToNativeSize(char ch, int is_complex) { switch (ch) { case 'c': case 'b': case 'B': case 's': case 'p': return 1; case 'h': case 'H': return sizeof(short); case 'i': case 'I': return sizeof(int); case 'l': case 'L': return sizeof(long); #ifdef HAVE_LONG_LONG case 'q': case 'Q': return sizeof(PY_LONG_LONG); #endif case 'f': return sizeof(float) * (is_complex ? 2 : 1); case 'd': return sizeof(double) * (is_complex ? 2 : 1); case 'g': return sizeof(long double) * (is_complex ? 2 : 1); case 'O': case 'P': return sizeof(void*); default: { __Pyx_BufFmt_RaiseUnexpectedChar(ch); return 0; } } } typedef struct { char c; short x; } __Pyx_st_short; typedef struct { char c; int x; } __Pyx_st_int; typedef struct { char c; long x; } __Pyx_st_long; typedef struct { char c; float x; } __Pyx_st_float; typedef struct { char c; double x; } __Pyx_st_double; typedef struct { char c; long double x; } __Pyx_st_longdouble; typedef struct { char c; void *x; } __Pyx_st_void_p; #ifdef HAVE_LONG_LONG typedef struct { char c; PY_LONG_LONG x; } __Pyx_st_longlong; #endif static size_t __Pyx_BufFmt_TypeCharToAlignment(char ch, CYTHON_UNUSED int is_complex) { switch (ch) { case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; case 'h': case 'H': return sizeof(__Pyx_st_short) - sizeof(short); case 'i': case 'I': return sizeof(__Pyx_st_int) - sizeof(int); case 'l': case 'L': return sizeof(__Pyx_st_long) - sizeof(long); #ifdef HAVE_LONG_LONG case 'q': case 'Q': return sizeof(__Pyx_st_longlong) - sizeof(PY_LONG_LONG); #endif case 'f': return sizeof(__Pyx_st_float) - sizeof(float); case 'd': return sizeof(__Pyx_st_double) - sizeof(double); case 'g': return sizeof(__Pyx_st_longdouble) - sizeof(long double); case 'P': case 'O': return sizeof(__Pyx_st_void_p) - sizeof(void*); default: __Pyx_BufFmt_RaiseUnexpectedChar(ch); return 0; } } /* These are for computing the padding at the end of the struct to align on the first member of the struct. This will probably the same as above, but we don't have any guarantees. */ typedef struct { short x; char c; } __Pyx_pad_short; typedef struct { int x; char c; } __Pyx_pad_int; typedef struct { long x; char c; } __Pyx_pad_long; typedef struct { float x; char c; } __Pyx_pad_float; typedef struct { double x; char c; } __Pyx_pad_double; typedef struct { long double x; char c; } __Pyx_pad_longdouble; typedef struct { void *x; char c; } __Pyx_pad_void_p; #ifdef HAVE_LONG_LONG typedef struct { PY_LONG_LONG x; char c; } __Pyx_pad_longlong; #endif static size_t __Pyx_BufFmt_TypeCharToPadding(char ch, CYTHON_UNUSED int is_complex) { switch (ch) { case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; case 'h': case 'H': return sizeof(__Pyx_pad_short) - sizeof(short); case 'i': case 'I': return sizeof(__Pyx_pad_int) - sizeof(int); case 'l': case 'L': return sizeof(__Pyx_pad_long) - sizeof(long); #ifdef HAVE_LONG_LONG case 'q': case 'Q': return sizeof(__Pyx_pad_longlong) - sizeof(PY_LONG_LONG); #endif case 'f': return sizeof(__Pyx_pad_float) - sizeof(float); case 'd': return sizeof(__Pyx_pad_double) - sizeof(double); case 'g': return sizeof(__Pyx_pad_longdouble) - sizeof(long double); case 'P': case 'O': return sizeof(__Pyx_pad_void_p) - sizeof(void*); default: __Pyx_BufFmt_RaiseUnexpectedChar(ch); return 0; } } static char __Pyx_BufFmt_TypeCharToGroup(char ch, int is_complex) { switch (ch) { case 'c': return 'H'; case 'b': case 'h': case 'i': case 'l': case 'q': case 's': case 'p': return 'I'; case 'B': case 'H': case 'I': case 'L': case 'Q': return 'U'; case 'f': case 'd': case 'g': return (is_complex ? 'C' : 'R'); case 'O': return 'O'; case 'P': return 'P'; default: { __Pyx_BufFmt_RaiseUnexpectedChar(ch); return 0; } } } static void __Pyx_BufFmt_RaiseExpected(__Pyx_BufFmt_Context* ctx) { if (ctx->head == NULL || ctx->head->field == &ctx->root) { const char* expected; const char* quote; if (ctx->head == NULL) { expected = "end"; quote = ""; } else { expected = ctx->head->field->type->name; quote = "'"; } PyErr_Format(PyExc_ValueError, "Buffer dtype mismatch, expected %s%s%s but got %s", quote, expected, quote, __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex)); } else { __Pyx_StructField* field = ctx->head->field; __Pyx_StructField* parent = (ctx->head - 1)->field; PyErr_Format(PyExc_ValueError, "Buffer dtype mismatch, expected '%s' but got %s in '%s.%s'", field->type->name, __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex), parent->type->name, field->name); } } static int __Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context* ctx) { char group; size_t size, offset, arraysize = 1; if (ctx->enc_type == 0) return 0; if (ctx->head->field->type->arraysize[0]) { int i, ndim = 0; if (ctx->enc_type == 's' || ctx->enc_type == 'p') { ctx->is_valid_array = ctx->head->field->type->ndim == 1; ndim = 1; if (ctx->enc_count != ctx->head->field->type->arraysize[0]) { PyErr_Format(PyExc_ValueError, "Expected a dimension of size %zu, got %zu", ctx->head->field->type->arraysize[0], ctx->enc_count); return -1; } } if (!ctx->is_valid_array) { PyErr_Format(PyExc_ValueError, "Expected %d dimensions, got %d", ctx->head->field->type->ndim, ndim); return -1; } for (i = 0; i < ctx->head->field->type->ndim; i++) { arraysize *= ctx->head->field->type->arraysize[i]; } ctx->is_valid_array = 0; ctx->enc_count = 1; } group = __Pyx_BufFmt_TypeCharToGroup(ctx->enc_type, ctx->is_complex); do { __Pyx_StructField* field = ctx->head->field; __Pyx_TypeInfo* type = field->type; if (ctx->enc_packmode == '@' || ctx->enc_packmode == '^') { size = __Pyx_BufFmt_TypeCharToNativeSize(ctx->enc_type, ctx->is_complex); } else { size = __Pyx_BufFmt_TypeCharToStandardSize(ctx->enc_type, ctx->is_complex); } if (ctx->enc_packmode == '@') { size_t align_at = __Pyx_BufFmt_TypeCharToAlignment(ctx->enc_type, ctx->is_complex); size_t align_mod_offset; if (align_at == 0) return -1; align_mod_offset = ctx->fmt_offset % align_at; if (align_mod_offset > 0) ctx->fmt_offset += align_at - align_mod_offset; if (ctx->struct_alignment == 0) ctx->struct_alignment = __Pyx_BufFmt_TypeCharToPadding(ctx->enc_type, ctx->is_complex); } if (type->size != size || type->typegroup != group) { if (type->typegroup == 'C' && type->fields != NULL) { size_t parent_offset = ctx->head->parent_offset + field->offset; ++ctx->head; ctx->head->field = type->fields; ctx->head->parent_offset = parent_offset; continue; } if ((type->typegroup == 'H' || group == 'H') && type->size == size) { } else { __Pyx_BufFmt_RaiseExpected(ctx); return -1; } } offset = ctx->head->parent_offset + field->offset; if (ctx->fmt_offset != offset) { PyErr_Format(PyExc_ValueError, "Buffer dtype mismatch; next field is at offset %" CYTHON_FORMAT_SSIZE_T "d but %" CYTHON_FORMAT_SSIZE_T "d expected", (Py_ssize_t)ctx->fmt_offset, (Py_ssize_t)offset); return -1; } ctx->fmt_offset += size; if (arraysize) ctx->fmt_offset += (arraysize - 1) * size; --ctx->enc_count; while (1) { if (field == &ctx->root) { ctx->head = NULL; if (ctx->enc_count != 0) { __Pyx_BufFmt_RaiseExpected(ctx); return -1; } break; } ctx->head->field = ++field; if (field->type == NULL) { --ctx->head; field = ctx->head->field; continue; } else if (field->type->typegroup == 'S') { size_t parent_offset = ctx->head->parent_offset + field->offset; if (field->type->fields->type == NULL) continue; field = field->type->fields; ++ctx->head; ctx->head->field = field; ctx->head->parent_offset = parent_offset; break; } else { break; } } } while (ctx->enc_count); ctx->enc_type = 0; ctx->is_complex = 0; return 0; } static CYTHON_INLINE PyObject * __pyx_buffmt_parse_array(__Pyx_BufFmt_Context* ctx, const char** tsp) { const char *ts = *tsp; int i = 0, number; int ndim = ctx->head->field->type->ndim; ; ++ts; if (ctx->new_count != 1) { PyErr_SetString(PyExc_ValueError, "Cannot handle repeated arrays in format string"); return NULL; } if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; while (*ts && *ts != ')') { switch (*ts) { case ' ': case '\f': case '\r': case '\n': case '\t': case '\v': continue; default: break; } number = __Pyx_BufFmt_ExpectNumber(&ts); if (number == -1) return NULL; if (i < ndim && (size_t) number != ctx->head->field->type->arraysize[i]) return PyErr_Format(PyExc_ValueError, "Expected a dimension of size %zu, got %d", ctx->head->field->type->arraysize[i], number); if (*ts != ',' && *ts != ')') return PyErr_Format(PyExc_ValueError, "Expected a comma in format string, got '%c'", *ts); if (*ts == ',') ts++; i++; } if (i != ndim) return PyErr_Format(PyExc_ValueError, "Expected %d dimension(s), got %d", ctx->head->field->type->ndim, i); if (!*ts) { PyErr_SetString(PyExc_ValueError, "Unexpected end of format string, expected ')'"); return NULL; } ctx->is_valid_array = 1; ctx->new_count = 1; *tsp = ++ts; return Py_None; } static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts) { int got_Z = 0; while (1) { switch(*ts) { case 0: if (ctx->enc_type != 0 && ctx->head == NULL) { __Pyx_BufFmt_RaiseExpected(ctx); return NULL; } if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; if (ctx->head != NULL) { __Pyx_BufFmt_RaiseExpected(ctx); return NULL; } return ts; case ' ': case '\r': case '\n': ++ts; break; case '<': if (!__Pyx_IsLittleEndian()) { PyErr_SetString(PyExc_ValueError, "Little-endian buffer not supported on big-endian compiler"); return NULL; } ctx->new_packmode = '='; ++ts; break; case '>': case '!': if (__Pyx_IsLittleEndian()) { PyErr_SetString(PyExc_ValueError, "Big-endian buffer not supported on little-endian compiler"); return NULL; } ctx->new_packmode = '='; ++ts; break; case '=': case '@': case '^': ctx->new_packmode = *ts++; break; case 'T': { const char* ts_after_sub; size_t i, struct_count = ctx->new_count; size_t struct_alignment = ctx->struct_alignment; ctx->new_count = 1; ++ts; if (*ts != '{') { PyErr_SetString(PyExc_ValueError, "Buffer acquisition: Expected '{' after 'T'"); return NULL; } if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; ctx->enc_type = 0; ctx->enc_count = 0; ctx->struct_alignment = 0; ++ts; ts_after_sub = ts; for (i = 0; i != struct_count; ++i) { ts_after_sub = __Pyx_BufFmt_CheckString(ctx, ts); if (!ts_after_sub) return NULL; } ts = ts_after_sub; if (struct_alignment) ctx->struct_alignment = struct_alignment; } break; case '}': { size_t alignment = ctx->struct_alignment; ++ts; if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; ctx->enc_type = 0; if (alignment && ctx->fmt_offset % alignment) { ctx->fmt_offset += alignment - (ctx->fmt_offset % alignment); } } return ts; case 'x': if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; ctx->fmt_offset += ctx->new_count; ctx->new_count = 1; ctx->enc_count = 0; ctx->enc_type = 0; ctx->enc_packmode = ctx->new_packmode; ++ts; break; case 'Z': got_Z = 1; ++ts; if (*ts != 'f' && *ts != 'd' && *ts != 'g') { __Pyx_BufFmt_RaiseUnexpectedChar('Z'); return NULL; } case 'c': case 'b': case 'B': case 'h': case 'H': case 'i': case 'I': case 'l': case 'L': case 'q': case 'Q': case 'f': case 'd': case 'g': case 'O': case 'p': if (ctx->enc_type == *ts && got_Z == ctx->is_complex && ctx->enc_packmode == ctx->new_packmode) { ctx->enc_count += ctx->new_count; ctx->new_count = 1; got_Z = 0; ++ts; break; } case 's': if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; ctx->enc_count = ctx->new_count; ctx->enc_packmode = ctx->new_packmode; ctx->enc_type = *ts; ctx->is_complex = got_Z; ++ts; ctx->new_count = 1; got_Z = 0; break; case ':': ++ts; while(*ts != ':') ++ts; ++ts; break; case '(': if (!__pyx_buffmt_parse_array(ctx, &ts)) return NULL; break; default: { int number = __Pyx_BufFmt_ExpectNumber(&ts); if (number == -1) return NULL; ctx->new_count = (size_t)number; } } } } static CYTHON_INLINE void __Pyx_ZeroBuffer(Py_buffer* buf) { buf->buf = NULL; buf->obj = NULL; buf->strides = __Pyx_zeros; buf->shape = __Pyx_zeros; buf->suboffsets = __Pyx_minusones; } static CYTHON_INLINE int __Pyx_GetBufferAndValidate( Py_buffer* buf, PyObject* obj, __Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack) { if (obj == Py_None || obj == NULL) { __Pyx_ZeroBuffer(buf); return 0; } buf->buf = NULL; if (__Pyx_GetBuffer(obj, buf, flags) == -1) goto fail; if (buf->ndim != nd) { PyErr_Format(PyExc_ValueError, "Buffer has wrong number of dimensions (expected %d, got %d)", nd, buf->ndim); goto fail; } if (!cast) { __Pyx_BufFmt_Context ctx; __Pyx_BufFmt_Init(&ctx, stack, dtype); if (!__Pyx_BufFmt_CheckString(&ctx, buf->format)) goto fail; } if ((unsigned)buf->itemsize != dtype->size) { PyErr_Format(PyExc_ValueError, "Item size of buffer (%" CYTHON_FORMAT_SSIZE_T "d byte%s) does not match size of '%s' (%" CYTHON_FORMAT_SSIZE_T "d byte%s)", buf->itemsize, (buf->itemsize > 1) ? "s" : "", dtype->name, (Py_ssize_t)dtype->size, (dtype->size > 1) ? "s" : ""); goto fail; } if (buf->suboffsets == NULL) buf->suboffsets = __Pyx_minusones; return 0; fail:; __Pyx_ZeroBuffer(buf); return -1; } static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info) { if (info->buf == NULL) return; if (info->suboffsets == __Pyx_minusones) info->suboffsets = NULL; __Pyx_ReleaseBuffer(info); } static void __Pyx_RaiseBufferIndexError(int axis) { PyErr_Format(PyExc_IndexError, "Out of bounds on buffer access (axis %d)", axis); } static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) { #if CYTHON_COMPILING_IN_CPYTHON PyObject *tmp_type, *tmp_value, *tmp_tb; PyThreadState *tstate = PyThreadState_GET(); tmp_type = tstate->curexc_type; tmp_value = tstate->curexc_value; tmp_tb = tstate->curexc_traceback; tstate->curexc_type = type; tstate->curexc_value = value; tstate->curexc_traceback = tb; Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); #else PyErr_Restore(type, value, tb); #endif } static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) { #if CYTHON_COMPILING_IN_CPYTHON PyThreadState *tstate = PyThreadState_GET(); *type = tstate->curexc_type; *value = tstate->curexc_value; *tb = tstate->curexc_traceback; tstate->curexc_type = 0; tstate->curexc_value = 0; tstate->curexc_traceback = 0; #else PyErr_Fetch(type, value, tb); #endif } static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno, CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename, int full_traceback, CYTHON_UNUSED int nogil) { PyObject *old_exc, *old_val, *old_tb; PyObject *ctx; #ifdef WITH_THREAD PyGILState_STATE state; if (nogil) state = PyGILState_Ensure(); #endif __Pyx_ErrFetch(&old_exc, &old_val, &old_tb); if (full_traceback) { Py_XINCREF(old_exc); Py_XINCREF(old_val); Py_XINCREF(old_tb); __Pyx_ErrRestore(old_exc, old_val, old_tb); PyErr_PrintEx(1); } #if PY_MAJOR_VERSION < 3 ctx = PyString_FromString(name); #else ctx = PyUnicode_FromString(name); #endif __Pyx_ErrRestore(old_exc, old_val, old_tb); if (!ctx) { PyErr_WriteUnraisable(Py_None); } else { PyErr_WriteUnraisable(ctx); Py_DECREF(ctx); } #ifdef WITH_THREAD if (nogil) PyGILState_Release(state); #endif } #if PY_MAJOR_VERSION < 3 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, CYTHON_UNUSED PyObject *cause) { Py_XINCREF(type); if (!value || value == Py_None) value = NULL; else Py_INCREF(value); if (!tb || tb == Py_None) tb = NULL; else { Py_INCREF(tb); if (!PyTraceBack_Check(tb)) { PyErr_SetString(PyExc_TypeError, "raise: arg 3 must be a traceback or None"); goto raise_error; } } if (PyType_Check(type)) { #if CYTHON_COMPILING_IN_PYPY if (!value) { Py_INCREF(Py_None); value = Py_None; } #endif PyErr_NormalizeException(&type, &value, &tb); } else { if (value) { PyErr_SetString(PyExc_TypeError, "instance exception may not have a separate value"); goto raise_error; } value = type; type = (PyObject*) Py_TYPE(type); Py_INCREF(type); if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) { PyErr_SetString(PyExc_TypeError, "raise: exception class must be a subclass of BaseException"); goto raise_error; } } __Pyx_ErrRestore(type, value, tb); return; raise_error: Py_XDECREF(value); Py_XDECREF(type); Py_XDECREF(tb); return; } #else static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) { PyObject* owned_instance = NULL; if (tb == Py_None) { tb = 0; } else if (tb && !PyTraceBack_Check(tb)) { PyErr_SetString(PyExc_TypeError, "raise: arg 3 must be a traceback or None"); goto bad; } if (value == Py_None) value = 0; if (PyExceptionInstance_Check(type)) { if (value) { PyErr_SetString(PyExc_TypeError, "instance exception may not have a separate value"); goto bad; } value = type; type = (PyObject*) Py_TYPE(value); } else if (PyExceptionClass_Check(type)) { PyObject *instance_class = NULL; if (value && PyExceptionInstance_Check(value)) { instance_class = (PyObject*) Py_TYPE(value); if (instance_class != type) { int is_subclass = PyObject_IsSubclass(instance_class, type); if (!is_subclass) { instance_class = NULL; } else if (unlikely(is_subclass == -1)) { goto bad; } else { type = instance_class; } } } if (!instance_class) { PyObject *args; if (!value) args = PyTuple_New(0); else if (PyTuple_Check(value)) { Py_INCREF(value); args = value; } else args = PyTuple_Pack(1, value); if (!args) goto bad; owned_instance = PyObject_Call(type, args, NULL); Py_DECREF(args); if (!owned_instance) goto bad; value = owned_instance; if (!PyExceptionInstance_Check(value)) { PyErr_Format(PyExc_TypeError, "calling %R should have returned an instance of " "BaseException, not %R", type, Py_TYPE(value)); goto bad; } } } else { PyErr_SetString(PyExc_TypeError, "raise: exception class must be a subclass of BaseException"); goto bad; } #if PY_VERSION_HEX >= 0x03030000 if (cause) { #else if (cause && cause != Py_None) { #endif PyObject *fixed_cause; if (cause == Py_None) { fixed_cause = NULL; } else if (PyExceptionClass_Check(cause)) { fixed_cause = PyObject_CallObject(cause, NULL); if (fixed_cause == NULL) goto bad; } else if (PyExceptionInstance_Check(cause)) { fixed_cause = cause; Py_INCREF(fixed_cause); } else { PyErr_SetString(PyExc_TypeError, "exception causes must derive from " "BaseException"); goto bad; } PyException_SetCause(value, fixed_cause); } PyErr_SetObject(type, value); if (tb) { #if CYTHON_COMPILING_IN_PYPY PyObject *tmp_type, *tmp_value, *tmp_tb; PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb); Py_INCREF(tb); PyErr_Restore(tmp_type, tmp_value, tb); Py_XDECREF(tmp_tb); #else PyThreadState *tstate = PyThreadState_GET(); PyObject* tmp_tb = tstate->curexc_traceback; if (tb != tmp_tb) { Py_INCREF(tb); tstate->curexc_traceback = tb; Py_XDECREF(tmp_tb); } #endif } bad: Py_XDECREF(owned_instance); return; } #endif static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) { PyErr_Format(PyExc_ValueError, "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected); } static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) { PyErr_Format(PyExc_ValueError, "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack", index, (index == 1) ? "" : "s"); } static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); } static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) { PyObject *empty_list = 0; PyObject *module = 0; PyObject *global_dict = 0; PyObject *empty_dict = 0; PyObject *list; #if PY_VERSION_HEX < 0x03030000 PyObject *py_import; py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import); if (!py_import) goto bad; #endif if (from_list) list = from_list; else { empty_list = PyList_New(0); if (!empty_list) goto bad; list = empty_list; } global_dict = PyModule_GetDict(__pyx_m); if (!global_dict) goto bad; empty_dict = PyDict_New(); if (!empty_dict) goto bad; { #if PY_MAJOR_VERSION >= 3 if (level == -1) { if (strchr(__Pyx_MODULE_NAME, '.')) { #if PY_VERSION_HEX < 0x03030000 PyObject *py_level = PyInt_FromLong(1); if (!py_level) goto bad; module = PyObject_CallFunctionObjArgs(py_import, name, global_dict, empty_dict, list, py_level, NULL); Py_DECREF(py_level); #else module = PyImport_ImportModuleLevelObject( name, global_dict, empty_dict, list, 1); #endif if (!module) { if (!PyErr_ExceptionMatches(PyExc_ImportError)) goto bad; PyErr_Clear(); } } level = 0; } #endif if (!module) { #if PY_VERSION_HEX < 0x03030000 PyObject *py_level = PyInt_FromLong(level); if (!py_level) goto bad; module = PyObject_CallFunctionObjArgs(py_import, name, global_dict, empty_dict, list, py_level, NULL); Py_DECREF(py_level); #else module = PyImport_ImportModuleLevelObject( name, global_dict, empty_dict, list, level); #endif } } bad: #if PY_VERSION_HEX < 0x03030000 Py_XDECREF(py_import); #endif Py_XDECREF(empty_list); Py_XDECREF(empty_dict); return module; } static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { int start = 0, mid = 0, end = count - 1; if (end >= 0 && code_line > entries[end].code_line) { return count; } while (start < end) { mid = start + (end - start) / 2; if (code_line < entries[mid].code_line) { end = mid; } else if (code_line > entries[mid].code_line) { start = mid + 1; } else { return mid; } } if (code_line <= entries[mid].code_line) { return mid; } else { return mid + 1; } } static PyCodeObject *__pyx_find_code_object(int code_line) { PyCodeObject* code_object; int pos; if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) { return NULL; } pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) { return NULL; } code_object = __pyx_code_cache.entries[pos].code_object; Py_INCREF(code_object); return code_object; } static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { int pos, i; __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries; if (unlikely(!code_line)) { return; } if (unlikely(!entries)) { entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry)); if (likely(entries)) { __pyx_code_cache.entries = entries; __pyx_code_cache.max_count = 64; __pyx_code_cache.count = 1; entries[0].code_line = code_line; entries[0].code_object = code_object; Py_INCREF(code_object); } return; } pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) { PyCodeObject* tmp = entries[pos].code_object; entries[pos].code_object = code_object; Py_DECREF(tmp); return; } if (__pyx_code_cache.count == __pyx_code_cache.max_count) { int new_max = __pyx_code_cache.max_count + 64; entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc( __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry)); if (unlikely(!entries)) { return; } __pyx_code_cache.entries = entries; __pyx_code_cache.max_count = new_max; } for (i=__pyx_code_cache.count; i>pos; i--) { entries[i] = entries[i-1]; } entries[pos].code_line = code_line; entries[pos].code_object = code_object; __pyx_code_cache.count++; Py_INCREF(code_object); } #include "compile.h" #include "frameobject.h" #include "traceback.h" static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( const char *funcname, int c_line, int py_line, const char *filename) { PyCodeObject *py_code = 0; PyObject *py_srcfile = 0; PyObject *py_funcname = 0; #if PY_MAJOR_VERSION < 3 py_srcfile = PyString_FromString(filename); #else py_srcfile = PyUnicode_FromString(filename); #endif if (!py_srcfile) goto bad; if (c_line) { #if PY_MAJOR_VERSION < 3 py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); #else py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); #endif } else { #if PY_MAJOR_VERSION < 3 py_funcname = PyString_FromString(funcname); #else py_funcname = PyUnicode_FromString(funcname); #endif } if (!py_funcname) goto bad; py_code = __Pyx_PyCode_New( 0, 0, 0, 0, 0, __pyx_empty_bytes, /*PyObject *code,*/ __pyx_empty_tuple, /*PyObject *consts,*/ __pyx_empty_tuple, /*PyObject *names,*/ __pyx_empty_tuple, /*PyObject *varnames,*/ __pyx_empty_tuple, /*PyObject *freevars,*/ __pyx_empty_tuple, /*PyObject *cellvars,*/ py_srcfile, /*PyObject *filename,*/ py_funcname, /*PyObject *name,*/ py_line, __pyx_empty_bytes /*PyObject *lnotab*/ ); Py_DECREF(py_srcfile); Py_DECREF(py_funcname); return py_code; bad: Py_XDECREF(py_srcfile); Py_XDECREF(py_funcname); return NULL; } static void __Pyx_AddTraceback(const char *funcname, int c_line, int py_line, const char *filename) { PyCodeObject *py_code = 0; PyFrameObject *py_frame = 0; py_code = __pyx_find_code_object(c_line ? c_line : py_line); if (!py_code) { py_code = __Pyx_CreateCodeObjectForTraceback( funcname, c_line, py_line, filename); if (!py_code) goto bad; __pyx_insert_code_object(c_line ? c_line : py_line, py_code); } py_frame = PyFrame_New( PyThreadState_GET(), /*PyThreadState *tstate,*/ py_code, /*PyCodeObject *code,*/ __pyx_d, /*PyObject *globals,*/ 0 /*PyObject *locals*/ ); if (!py_frame) goto bad; py_frame->f_lineno = py_line; PyTraceBack_Here(py_frame); bad: Py_XDECREF(py_code); Py_XDECREF(py_frame); } #if PY_MAJOR_VERSION < 3 static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) { if (PyObject_CheckBuffer(obj)) return PyObject_GetBuffer(obj, view, flags); if (PyObject_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) return __pyx_pw_5numpy_7ndarray_1__getbuffer__(obj, view, flags); PyErr_Format(PyExc_TypeError, "'%.200s' does not have the buffer interface", Py_TYPE(obj)->tp_name); return -1; } static void __Pyx_ReleaseBuffer(Py_buffer *view) { PyObject *obj = view->obj; if (!obj) return; if (PyObject_CheckBuffer(obj)) { PyBuffer_Release(view); return; } if (PyObject_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) { __pyx_pw_5numpy_7ndarray_3__releasebuffer__(obj, view); return; } Py_DECREF(obj); view->obj = NULL; } #endif #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\ __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0) #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\ __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1) #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\ {\ func_type value = func_value;\ if (sizeof(target_type) < sizeof(func_type)) {\ if (unlikely(value != (func_type) (target_type) value)) {\ func_type zero = 0;\ if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\ return (target_type) -1;\ if (is_unsigned && unlikely(value < zero))\ goto raise_neg_overflow;\ else\ goto raise_overflow;\ }\ }\ return (target_type) value;\ } #if CYTHON_USE_PYLONG_INTERNALS #include "longintrepr.h" #endif static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { const int neg_one = (int) -1, const_zero = (int) 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { if (sizeof(int) < sizeof(long)) { __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x)) } else { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { goto raise_neg_overflow; } return (int) val; } } else #endif if (likely(PyLong_Check(x))) { if (is_unsigned) { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (int) 0; case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0]) case 2: if (8 * sizeof(int) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) { return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; case 3: if (8 * sizeof(int) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) { return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; case 4: if (8 * sizeof(int) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) { return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; } #endif #if CYTHON_COMPILING_IN_CPYTHON if (unlikely(Py_SIZE(x) < 0)) { goto raise_neg_overflow; } #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (int) -1; if (unlikely(result == 1)) goto raise_neg_overflow; } #endif if (sizeof(int) <= sizeof(unsigned long)) { __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x)) } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) } } else { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (int) 0; case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, -(sdigit) digits[0]) case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0]) case -2: if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 2: if (8 * sizeof(int) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case -3: if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 3: if (8 * sizeof(int) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case -4: if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 4: if (8 * sizeof(int) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; } #endif if (sizeof(int) <= sizeof(long)) { __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x)) } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x)) } } { #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) PyErr_SetString(PyExc_RuntimeError, "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); #else int val; PyObject *v = __Pyx_PyNumber_Int(x); #if PY_MAJOR_VERSION < 3 if (likely(v) && !PyLong_Check(v)) { PyObject *tmp = v; v = PyNumber_Long(tmp); Py_DECREF(tmp); } #endif if (likely(v)) { int one = 1; int is_little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&val; int ret = _PyLong_AsByteArray((PyLongObject *)v, bytes, sizeof(val), is_little, !is_unsigned); Py_DECREF(v); if (likely(!ret)) return val; } #endif return (int) -1; } } else { int val; PyObject *tmp = __Pyx_PyNumber_Int(x); if (!tmp) return (int) -1; val = __Pyx_PyInt_As_int(tmp); Py_DECREF(tmp); return val; } raise_overflow: PyErr_SetString(PyExc_OverflowError, "value too large to convert to int"); return (int) -1; raise_neg_overflow: PyErr_SetString(PyExc_OverflowError, "can't convert negative value to int"); return (int) -1; } static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { const int neg_one = (int) -1, const_zero = (int) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { if (sizeof(int) < sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(int) <= sizeof(unsigned long)) { return PyLong_FromUnsignedLong((unsigned long) value); } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); } } else { if (sizeof(int) <= sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { return PyLong_FromLongLong((PY_LONG_LONG) value); } } { int one = 1; int little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&value; return _PyLong_FromByteArray(bytes, sizeof(int), little, !is_unsigned); } } static CYTHON_INLINE unsigned int __Pyx_PyInt_As_unsigned_int(PyObject *x) { const unsigned int neg_one = (unsigned int) -1, const_zero = (unsigned int) 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { if (sizeof(unsigned int) < sizeof(long)) { __PYX_VERIFY_RETURN_INT(unsigned int, long, PyInt_AS_LONG(x)) } else { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { goto raise_neg_overflow; } return (unsigned int) val; } } else #endif if (likely(PyLong_Check(x))) { if (is_unsigned) { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (unsigned int) 0; case 1: __PYX_VERIFY_RETURN_INT(unsigned int, digit, digits[0]) case 2: if (8 * sizeof(unsigned int) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(unsigned int) >= 2 * PyLong_SHIFT) { return (unsigned int) (((((unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])); } } break; case 3: if (8 * sizeof(unsigned int) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(unsigned int) >= 3 * PyLong_SHIFT) { return (unsigned int) (((((((unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])); } } break; case 4: if (8 * sizeof(unsigned int) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(unsigned int) >= 4 * PyLong_SHIFT) { return (unsigned int) (((((((((unsigned int)digits[3]) << PyLong_SHIFT) | (unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])); } } break; } #endif #if CYTHON_COMPILING_IN_CPYTHON if (unlikely(Py_SIZE(x) < 0)) { goto raise_neg_overflow; } #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (unsigned int) -1; if (unlikely(result == 1)) goto raise_neg_overflow; } #endif if (sizeof(unsigned int) <= sizeof(unsigned long)) { __PYX_VERIFY_RETURN_INT_EXC(unsigned int, unsigned long, PyLong_AsUnsignedLong(x)) } else if (sizeof(unsigned int) <= sizeof(unsigned PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(unsigned int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) } } else { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (unsigned int) 0; case -1: __PYX_VERIFY_RETURN_INT(unsigned int, sdigit, -(sdigit) digits[0]) case 1: __PYX_VERIFY_RETURN_INT(unsigned int, digit, +digits[0]) case -2: if (8 * sizeof(unsigned int) - 1 > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(unsigned int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(unsigned int) - 1 > 2 * PyLong_SHIFT) { return (unsigned int) (((unsigned int)-1)*(((((unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]))); } } break; case 2: if (8 * sizeof(unsigned int) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(unsigned int) - 1 > 2 * PyLong_SHIFT) { return (unsigned int) ((((((unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]))); } } break; case -3: if (8 * sizeof(unsigned int) - 1 > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(unsigned int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(unsigned int) - 1 > 3 * PyLong_SHIFT) { return (unsigned int) (((unsigned int)-1)*(((((((unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]))); } } break; case 3: if (8 * sizeof(unsigned int) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(unsigned int) - 1 > 3 * PyLong_SHIFT) { return (unsigned int) ((((((((unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]))); } } break; case -4: if (8 * sizeof(unsigned int) - 1 > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(unsigned int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(unsigned int) - 1 > 4 * PyLong_SHIFT) { return (unsigned int) (((unsigned int)-1)*(((((((((unsigned int)digits[3]) << PyLong_SHIFT) | (unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]))); } } break; case 4: if (8 * sizeof(unsigned int) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(unsigned int) - 1 > 4 * PyLong_SHIFT) { return (unsigned int) ((((((((((unsigned int)digits[3]) << PyLong_SHIFT) | (unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]))); } } break; } #endif if (sizeof(unsigned int) <= sizeof(long)) { __PYX_VERIFY_RETURN_INT_EXC(unsigned int, long, PyLong_AsLong(x)) } else if (sizeof(unsigned int) <= sizeof(PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(unsigned int, PY_LONG_LONG, PyLong_AsLongLong(x)) } } { #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) PyErr_SetString(PyExc_RuntimeError, "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); #else unsigned int val; PyObject *v = __Pyx_PyNumber_Int(x); #if PY_MAJOR_VERSION < 3 if (likely(v) && !PyLong_Check(v)) { PyObject *tmp = v; v = PyNumber_Long(tmp); Py_DECREF(tmp); } #endif if (likely(v)) { int one = 1; int is_little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&val; int ret = _PyLong_AsByteArray((PyLongObject *)v, bytes, sizeof(val), is_little, !is_unsigned); Py_DECREF(v); if (likely(!ret)) return val; } #endif return (unsigned int) -1; } } else { unsigned int val; PyObject *tmp = __Pyx_PyNumber_Int(x); if (!tmp) return (unsigned int) -1; val = __Pyx_PyInt_As_unsigned_int(tmp); Py_DECREF(tmp); return val; } raise_overflow: PyErr_SetString(PyExc_OverflowError, "value too large to convert to unsigned int"); return (unsigned int) -1; raise_neg_overflow: PyErr_SetString(PyExc_OverflowError, "can't convert negative value to unsigned int"); return (unsigned int) -1; } #if CYTHON_CCOMPLEX #ifdef __cplusplus static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { return ::std::complex< float >(x, y); } #else static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { return x + y*(__pyx_t_float_complex)_Complex_I; } #endif #else static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { __pyx_t_float_complex z; z.real = x; z.imag = y; return z; } #endif #if CYTHON_CCOMPLEX #else static CYTHON_INLINE int __Pyx_c_eqf(__pyx_t_float_complex a, __pyx_t_float_complex b) { return (a.real == b.real) && (a.imag == b.imag); } static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sumf(__pyx_t_float_complex a, __pyx_t_float_complex b) { __pyx_t_float_complex z; z.real = a.real + b.real; z.imag = a.imag + b.imag; return z; } static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_difff(__pyx_t_float_complex a, __pyx_t_float_complex b) { __pyx_t_float_complex z; z.real = a.real - b.real; z.imag = a.imag - b.imag; return z; } static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prodf(__pyx_t_float_complex a, __pyx_t_float_complex b) { __pyx_t_float_complex z; z.real = a.real * b.real - a.imag * b.imag; z.imag = a.real * b.imag + a.imag * b.real; return z; } static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quotf(__pyx_t_float_complex a, __pyx_t_float_complex b) { __pyx_t_float_complex z; float denom = b.real * b.real + b.imag * b.imag; z.real = (a.real * b.real + a.imag * b.imag) / denom; z.imag = (a.imag * b.real - a.real * b.imag) / denom; return z; } static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_negf(__pyx_t_float_complex a) { __pyx_t_float_complex z; z.real = -a.real; z.imag = -a.imag; return z; } static CYTHON_INLINE int __Pyx_c_is_zerof(__pyx_t_float_complex a) { return (a.real == 0) && (a.imag == 0); } static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conjf(__pyx_t_float_complex a) { __pyx_t_float_complex z; z.real = a.real; z.imag = -a.imag; return z; } #if 1 static CYTHON_INLINE float __Pyx_c_absf(__pyx_t_float_complex z) { #if !defined(HAVE_HYPOT) || defined(_MSC_VER) return sqrtf(z.real*z.real + z.imag*z.imag); #else return hypotf(z.real, z.imag); #endif } static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_powf(__pyx_t_float_complex a, __pyx_t_float_complex b) { __pyx_t_float_complex z; float r, lnr, theta, z_r, z_theta; if (b.imag == 0 && b.real == (int)b.real) { if (b.real < 0) { float denom = a.real * a.real + a.imag * a.imag; a.real = a.real / denom; a.imag = -a.imag / denom; b.real = -b.real; } switch ((int)b.real) { case 0: z.real = 1; z.imag = 0; return z; case 1: return a; case 2: z = __Pyx_c_prodf(a, a); return __Pyx_c_prodf(a, a); case 3: z = __Pyx_c_prodf(a, a); return __Pyx_c_prodf(z, a); case 4: z = __Pyx_c_prodf(a, a); return __Pyx_c_prodf(z, z); } } if (a.imag == 0) { if (a.real == 0) { return a; } r = a.real; theta = 0; } else { r = __Pyx_c_absf(a); theta = atan2f(a.imag, a.real); } lnr = logf(r); z_r = expf(lnr * b.real - theta * b.imag); z_theta = theta * b.real + lnr * b.imag; z.real = z_r * cosf(z_theta); z.imag = z_r * sinf(z_theta); return z; } #endif #endif #if CYTHON_CCOMPLEX #ifdef __cplusplus static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { return ::std::complex< double >(x, y); } #else static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { return x + y*(__pyx_t_double_complex)_Complex_I; } #endif #else static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { __pyx_t_double_complex z; z.real = x; z.imag = y; return z; } #endif #if CYTHON_CCOMPLEX #else static CYTHON_INLINE int __Pyx_c_eq(__pyx_t_double_complex a, __pyx_t_double_complex b) { return (a.real == b.real) && (a.imag == b.imag); } static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum(__pyx_t_double_complex a, __pyx_t_double_complex b) { __pyx_t_double_complex z; z.real = a.real + b.real; z.imag = a.imag + b.imag; return z; } static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff(__pyx_t_double_complex a, __pyx_t_double_complex b) { __pyx_t_double_complex z; z.real = a.real - b.real; z.imag = a.imag - b.imag; return z; } static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod(__pyx_t_double_complex a, __pyx_t_double_complex b) { __pyx_t_double_complex z; z.real = a.real * b.real - a.imag * b.imag; z.imag = a.real * b.imag + a.imag * b.real; return z; } static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot(__pyx_t_double_complex a, __pyx_t_double_complex b) { __pyx_t_double_complex z; double denom = b.real * b.real + b.imag * b.imag; z.real = (a.real * b.real + a.imag * b.imag) / denom; z.imag = (a.imag * b.real - a.real * b.imag) / denom; return z; } static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg(__pyx_t_double_complex a) { __pyx_t_double_complex z; z.real = -a.real; z.imag = -a.imag; return z; } static CYTHON_INLINE int __Pyx_c_is_zero(__pyx_t_double_complex a) { return (a.real == 0) && (a.imag == 0); } static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj(__pyx_t_double_complex a) { __pyx_t_double_complex z; z.real = a.real; z.imag = -a.imag; return z; } #if 1 static CYTHON_INLINE double __Pyx_c_abs(__pyx_t_double_complex z) { #if !defined(HAVE_HYPOT) || defined(_MSC_VER) return sqrt(z.real*z.real + z.imag*z.imag); #else return hypot(z.real, z.imag); #endif } static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow(__pyx_t_double_complex a, __pyx_t_double_complex b) { __pyx_t_double_complex z; double r, lnr, theta, z_r, z_theta; if (b.imag == 0 && b.real == (int)b.real) { if (b.real < 0) { double denom = a.real * a.real + a.imag * a.imag; a.real = a.real / denom; a.imag = -a.imag / denom; b.real = -b.real; } switch ((int)b.real) { case 0: z.real = 1; z.imag = 0; return z; case 1: return a; case 2: z = __Pyx_c_prod(a, a); return __Pyx_c_prod(a, a); case 3: z = __Pyx_c_prod(a, a); return __Pyx_c_prod(z, a); case 4: z = __Pyx_c_prod(a, a); return __Pyx_c_prod(z, z); } } if (a.imag == 0) { if (a.real == 0) { return a; } r = a.real; theta = 0; } else { r = __Pyx_c_abs(a); theta = atan2(a.imag, a.real); } lnr = log(r); z_r = exp(lnr * b.real - theta * b.imag); z_theta = theta * b.real + lnr * b.imag; z.real = z_r * cos(z_theta); z.imag = z_r * sin(z_theta); return z; } #endif #endif static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum__NPY_TYPES(enum NPY_TYPES value) { const enum NPY_TYPES neg_one = (enum NPY_TYPES) -1, const_zero = (enum NPY_TYPES) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { if (sizeof(enum NPY_TYPES) < sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(enum NPY_TYPES) <= sizeof(unsigned long)) { return PyLong_FromUnsignedLong((unsigned long) value); } else if (sizeof(enum NPY_TYPES) <= sizeof(unsigned PY_LONG_LONG)) { return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); } } else { if (sizeof(enum NPY_TYPES) <= sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(enum NPY_TYPES) <= sizeof(PY_LONG_LONG)) { return PyLong_FromLongLong((PY_LONG_LONG) value); } } { int one = 1; int little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&value; return _PyLong_FromByteArray(bytes, sizeof(enum NPY_TYPES), little, !is_unsigned); } } static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { const long neg_one = (long) -1, const_zero = (long) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { if (sizeof(long) < sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(long) <= sizeof(unsigned long)) { return PyLong_FromUnsignedLong((unsigned long) value); } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); } } else { if (sizeof(long) <= sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { return PyLong_FromLongLong((PY_LONG_LONG) value); } } { int one = 1; int little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&value; return _PyLong_FromByteArray(bytes, sizeof(long), little, !is_unsigned); } } static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { const long neg_one = (long) -1, const_zero = (long) 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { if (sizeof(long) < sizeof(long)) { __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x)) } else { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { goto raise_neg_overflow; } return (long) val; } } else #endif if (likely(PyLong_Check(x))) { if (is_unsigned) { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (long) 0; case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0]) case 2: if (8 * sizeof(long) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) { return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; case 3: if (8 * sizeof(long) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) { return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; case 4: if (8 * sizeof(long) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) { return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; } #endif #if CYTHON_COMPILING_IN_CPYTHON if (unlikely(Py_SIZE(x) < 0)) { goto raise_neg_overflow; } #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (long) -1; if (unlikely(result == 1)) goto raise_neg_overflow; } #endif if (sizeof(long) <= sizeof(unsigned long)) { __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x)) } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) } } else { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (long) 0; case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, -(sdigit) digits[0]) case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0]) case -2: if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case 2: if (8 * sizeof(long) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case -3: if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case 3: if (8 * sizeof(long) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case -4: if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case 4: if (8 * sizeof(long) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; } #endif if (sizeof(long) <= sizeof(long)) { __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x)) } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x)) } } { #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) PyErr_SetString(PyExc_RuntimeError, "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); #else long val; PyObject *v = __Pyx_PyNumber_Int(x); #if PY_MAJOR_VERSION < 3 if (likely(v) && !PyLong_Check(v)) { PyObject *tmp = v; v = PyNumber_Long(tmp); Py_DECREF(tmp); } #endif if (likely(v)) { int one = 1; int is_little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&val; int ret = _PyLong_AsByteArray((PyLongObject *)v, bytes, sizeof(val), is_little, !is_unsigned); Py_DECREF(v); if (likely(!ret)) return val; } #endif return (long) -1; } } else { long val; PyObject *tmp = __Pyx_PyNumber_Int(x); if (!tmp) return (long) -1; val = __Pyx_PyInt_As_long(tmp); Py_DECREF(tmp); return val; } raise_overflow: PyErr_SetString(PyExc_OverflowError, "value too large to convert to long"); return (long) -1; raise_neg_overflow: PyErr_SetString(PyExc_OverflowError, "can't convert negative value to long"); return (long) -1; } static int __Pyx_check_binary_version(void) { char ctversion[4], rtversion[4]; PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION); PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion()); if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) { char message[200]; PyOS_snprintf(message, sizeof(message), "compiletime version %s of module '%.100s' " "does not match runtime version %s", ctversion, __Pyx_MODULE_NAME, rtversion); return PyErr_WarnEx(NULL, message, 1); } return 0; } #ifndef __PYX_HAVE_RT_ImportModule #define __PYX_HAVE_RT_ImportModule static PyObject *__Pyx_ImportModule(const char *name) { PyObject *py_name = 0; PyObject *py_module = 0; py_name = __Pyx_PyIdentifier_FromString(name); if (!py_name) goto bad; py_module = PyImport_Import(py_name); Py_DECREF(py_name); return py_module; bad: Py_XDECREF(py_name); return 0; } #endif #ifndef __PYX_HAVE_RT_ImportType #define __PYX_HAVE_RT_ImportType static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict) { PyObject *py_module = 0; PyObject *result = 0; PyObject *py_name = 0; char warning[200]; Py_ssize_t basicsize; #ifdef Py_LIMITED_API PyObject *py_basicsize; #endif py_module = __Pyx_ImportModule(module_name); if (!py_module) goto bad; py_name = __Pyx_PyIdentifier_FromString(class_name); if (!py_name) goto bad; result = PyObject_GetAttr(py_module, py_name); Py_DECREF(py_name); py_name = 0; Py_DECREF(py_module); py_module = 0; if (!result) goto bad; if (!PyType_Check(result)) { PyErr_Format(PyExc_TypeError, "%.200s.%.200s is not a type object", module_name, class_name); goto bad; } #ifndef Py_LIMITED_API basicsize = ((PyTypeObject *)result)->tp_basicsize; #else py_basicsize = PyObject_GetAttrString(result, "__basicsize__"); if (!py_basicsize) goto bad; basicsize = PyLong_AsSsize_t(py_basicsize); Py_DECREF(py_basicsize); py_basicsize = 0; if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred()) goto bad; #endif if (!strict && (size_t)basicsize > size) { PyOS_snprintf(warning, sizeof(warning), "%s.%s size changed, may indicate binary incompatibility", module_name, class_name); if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad; } else if ((size_t)basicsize != size) { PyErr_Format(PyExc_ValueError, "%.200s.%.200s has the wrong size, try recompiling", module_name, class_name); goto bad; } return (PyTypeObject *)result; bad: Py_XDECREF(py_module); Py_XDECREF(result); return NULL; } #endif #ifndef __PYX_HAVE_RT_ImportFunction #define __PYX_HAVE_RT_ImportFunction static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) { PyObject *d = 0; PyObject *cobj = 0; union { void (*fp)(void); void *p; } tmp; d = PyObject_GetAttrString(module, (char *)"__pyx_capi__"); if (!d) goto bad; cobj = PyDict_GetItemString(d, funcname); if (!cobj) { PyErr_Format(PyExc_ImportError, "%.200s does not export expected C function %.200s", PyModule_GetName(module), funcname); goto bad; } #if PY_VERSION_HEX >= 0x02070000 if (!PyCapsule_IsValid(cobj, sig)) { PyErr_Format(PyExc_TypeError, "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)", PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj)); goto bad; } tmp.p = PyCapsule_GetPointer(cobj, sig); #else {const char *desc, *s1, *s2; desc = (const char *)PyCObject_GetDesc(cobj); if (!desc) goto bad; s1 = desc; s2 = sig; while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; } if (*s1 != *s2) { PyErr_Format(PyExc_TypeError, "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)", PyModule_GetName(module), funcname, sig, desc); goto bad; } tmp.p = PyCObject_AsVoidPtr(cobj);} #endif *f = tmp.fp; if (!(*f)) goto bad; Py_DECREF(d); return 0; bad: Py_XDECREF(d); return -1; } #endif static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { while (t->p) { #if PY_MAJOR_VERSION < 3 if (t->is_unicode) { *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL); } else if (t->intern) { *t->p = PyString_InternFromString(t->s); } else { *t->p = PyString_FromStringAndSize(t->s, t->n - 1); } #else if (t->is_unicode | t->is_str) { if (t->intern) { *t->p = PyUnicode_InternFromString(t->s); } else if (t->encoding) { *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL); } else { *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1); } } else { *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1); } #endif if (!*t->p) return -1; ++t; } return 0; } static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) { return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str)); } static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) { Py_ssize_t ignore; return __Pyx_PyObject_AsStringAndSize(o, &ignore); } static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { #if CYTHON_COMPILING_IN_CPYTHON && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) if ( #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII __Pyx_sys_getdefaultencoding_not_ascii && #endif PyUnicode_Check(o)) { #if PY_VERSION_HEX < 0x03030000 char* defenc_c; PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); if (!defenc) return NULL; defenc_c = PyBytes_AS_STRING(defenc); #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII { char* end = defenc_c + PyBytes_GET_SIZE(defenc); char* c; for (c = defenc_c; c < end; c++) { if ((unsigned char) (*c) >= 128) { PyUnicode_AsASCIIString(o); return NULL; } } } #endif *length = PyBytes_GET_SIZE(defenc); return defenc_c; #else if (__Pyx_PyUnicode_READY(o) == -1) return NULL; #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII if (PyUnicode_IS_ASCII(o)) { *length = PyUnicode_GET_LENGTH(o); return PyUnicode_AsUTF8(o); } else { PyUnicode_AsASCIIString(o); return NULL; } #else return PyUnicode_AsUTF8AndSize(o, length); #endif #endif } else #endif #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE)) if (PyByteArray_Check(o)) { *length = PyByteArray_GET_SIZE(o); return PyByteArray_AS_STRING(o); } else #endif { char* result; int r = PyBytes_AsStringAndSize(o, &result, length); if (unlikely(r < 0)) { return NULL; } else { return result; } } } static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { int is_true = x == Py_True; if (is_true | (x == Py_False) | (x == Py_None)) return is_true; else return PyObject_IsTrue(x); } static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) { PyNumberMethods *m; const char *name = NULL; PyObject *res = NULL; #if PY_MAJOR_VERSION < 3 if (PyInt_Check(x) || PyLong_Check(x)) #else if (PyLong_Check(x)) #endif return __Pyx_NewRef(x); m = Py_TYPE(x)->tp_as_number; #if PY_MAJOR_VERSION < 3 if (m && m->nb_int) { name = "int"; res = PyNumber_Int(x); } else if (m && m->nb_long) { name = "long"; res = PyNumber_Long(x); } #else if (m && m->nb_int) { name = "int"; res = PyNumber_Long(x); } #endif if (res) { #if PY_MAJOR_VERSION < 3 if (!PyInt_Check(res) && !PyLong_Check(res)) { #else if (!PyLong_Check(res)) { #endif PyErr_Format(PyExc_TypeError, "__%.4s__ returned non-%.4s (type %.200s)", name, name, Py_TYPE(res)->tp_name); Py_DECREF(res); return NULL; } } else if (!PyErr_Occurred()) { PyErr_SetString(PyExc_TypeError, "an integer is required"); } return res; } static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { Py_ssize_t ival; PyObject *x; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_CheckExact(b))) { if (sizeof(Py_ssize_t) >= sizeof(long)) return PyInt_AS_LONG(b); else return PyInt_AsSsize_t(x); } #endif if (likely(PyLong_CheckExact(b))) { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)b)->ob_digit; const Py_ssize_t size = Py_SIZE(b); if (likely(__Pyx_sst_abs(size) <= 1)) { ival = likely(size) ? digits[0] : 0; if (size == -1) ival = -ival; return ival; } else { switch (size) { case 2: if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case -2: if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case 3: if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case -3: if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case 4: if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case -4: if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; } } #endif return PyLong_AsSsize_t(b); } x = PyNumber_Index(b); if (!x) return -1; ival = PyInt_AsSsize_t(x); Py_DECREF(x); return ival; } static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { return PyInt_FromSize_t(ival); } #endif /* Py_PYTHON_H */ photutils-0.2.1/photutils/geometry/elliptical_overlap.pyx0000600000214200020070000001537212627615324026242 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst # The functions defined here allow one to determine the exact area of # overlap of an ellipse and a triangle (written by Thomas Robitaille). # The approach is to divide the rectangle into two triangles, and # reproject these so that the ellipse is a unit circle, then compute the # intersection of a triagnel with a unit circle. from __future__ import (absolute_import, division, print_function, unicode_literals) import numpy as np cimport numpy as np __all__ = ['elliptical_overlap_grid'] cdef extern from "math.h": double asin(double x) double sin(double x) double cos(double x) double sqrt(double x) from cpython cimport bool DTYPE = np.float64 ctypedef np.float64_t DTYPE_t cimport cython # NOTE: Here we need to make sure we use cimport to import the C functions from # core (since these were defined with cdef). This also requires the core.pxd # file to exist with the function signatures. from .core cimport distance, area_triangle, overlap_area_triangle_unit_circle def elliptical_overlap_grid(double xmin, double xmax, double ymin, double ymax, int nx, int ny, double rx, double ry, double theta, int use_exact, int subpixels): """ elliptical_overlap_grid(xmin, xmax, ymin, ymax, nx, ny, rx, ry, use_exact, subpixels) Area of overlap between an ellipse and a pixel grid. The ellipse is centered on the origin. Parameters ---------- xmin, xmax, ymin, ymax : float Extent of the grid in the x and y direction. nx, ny : int Grid dimensions. rx : float The semimajor axis of the ellipse. ry : float The semiminor axis of the ellipse. theta : float The position angle of the semimajor axis in radians (counterclockwise). use_exact : 0 or 1 If set to 1, calculates the exact overlap, while if set to 0, uses a subpixel sampling method with ``subpixel`` subpixels in each direction. subpixels : int If ``use_exact`` is 0, each pixel is resampled by this factor in each dimension. Thus, each pixel is divided into ``subpixels ** 2`` subpixels. Returns ------- frac : `~numpy.ndarray` 2-d array giving the fraction of the overlap. """ cdef unsigned int i, j cdef double x, y, dx, dy cdef double bxmin, bxmax, bymin, bymax cdef double pxmin, pxmax, pymin, pymax cdef double norm # Define output array cdef np.ndarray[DTYPE_t, ndim=2] frac = np.zeros([ny, nx], dtype=DTYPE) # Find the width of each element in x and y dx = (xmax - xmin) / nx dy = (ymax - ymin) / ny norm = 1. / (dx * dy) # For now we use a bounding circle and then use that to find a bounding box # but of course this is inefficient and could be done better. # Find bounding circle radius r = max(rx, ry) # Define bounding box bxmin = -r - 0.5 * dx bxmax = +r + 0.5 * dx bymin = -r - 0.5 * dy bymax = +r + 0.5 * dy for i in range(nx): pxmin = xmin + i * dx # lower end of pixel pxmax = pxmin + dx # upper end of pixel if pxmax > bxmin and pxmin < bxmax: for j in range(ny): pymin = ymin + j * dy pymax = pymin + dy if pymax > bymin and pymin < bymax: if use_exact: frac[j, i] = elliptical_overlap_single_exact( pxmin, pymin, pxmax, pymax, rx, ry, theta) * norm else: frac[j, i] = elliptical_overlap_single_subpixel( pxmin, pymin, pxmax, pymax, rx, ry, theta, subpixels) return frac # NOTE: The following two functions use cdef because they are not # intended to be called from the Python code. Using def makes them # callable from outside, but also slower. In any case, these aren't useful # to call from outside because they only operate on a single pixel. cdef double elliptical_overlap_single_subpixel(double x0, double y0, double x1, double y1, double rx, double ry, double theta, int subpixels): """ Return the fraction of overlap between a ellipse and a single pixel with given extent, using a sub-pixel sampling method. """ cdef unsigned int i, j cdef double x, y cdef double frac = 0. # Accumulator. cdef double inv_rx_sq, inv_ry_sq cdef double cos_theta = cos(theta) cdef double sin_theta = sin(theta) cdef double dx, dy cdef double x_tr, y_tr dx = (x1 - x0) / subpixels dy = (y1 - y0) / subpixels inv_rx_sq = 1. / (rx * rx) inv_ry_sq = 1. / (ry * ry) x = x0 - 0.5 * dx for i in range(subpixels): x += dx y = y0 - 0.5 * dy for j in range(subpixels): y += dy # Transform into frame of rotated ellipse x_tr = y * sin_theta + x * cos_theta y_tr = y * cos_theta - x * sin_theta if x_tr * x_tr * inv_rx_sq + y_tr * y_tr * inv_ry_sq < 1.: frac += 1. return frac / (subpixels * subpixels) cdef double elliptical_overlap_single_exact(double xmin, double ymin, double xmax, double ymax, double rx, double ry, double theta): """ Given a rectangle defined by (xmin, ymin, xmax, ymax) and an ellipse with major and minor axes rx and ry respectively, position angle theta, and centered at the origin, find the area of overlap. """ cdef double cos_m_theta = cos(-theta) cdef double sin_m_theta = sin(-theta) cdef double scale # Find scale by which the areas will be shrunk scale = rx * ry # Reproject rectangle to frame of reference in which ellipse is a # unit circle x1, y1 = ((xmin * cos_m_theta - ymin * sin_m_theta) / rx, (xmin * sin_m_theta + ymin * cos_m_theta) / ry) x2, y2 = ((xmax * cos_m_theta - ymin * sin_m_theta) / rx, (xmax * sin_m_theta + ymin * cos_m_theta) / ry) x3, y3 = ((xmax * cos_m_theta - ymax * sin_m_theta) / rx, (xmax * sin_m_theta + ymax * cos_m_theta) / ry) x4, y4 = ((xmin * cos_m_theta - ymax * sin_m_theta) / rx, (xmin * sin_m_theta + ymax * cos_m_theta) / ry) # Divide resulting quadrilateral into two triangles and find # intersection with unit circle return (overlap_area_triangle_unit_circle(x1, y1, x2, y2, x3, y3) + overlap_area_triangle_unit_circle(x1, y1, x4, y4, x3, y3)) * scale photutils-0.2.1/photutils/geometry/rectangular_overlap.c0000600000214200020070000111571312646264032026027 0ustar lbradleySTSCI\science00000000000000/* Generated by Cython 0.23.4 */ #define PY_SSIZE_T_CLEAN #include "Python.h" #ifndef Py_PYTHON_H #error Python headers needed to compile C extensions, please install development version of Python. #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000) #error Cython requires Python 2.6+ or Python 3.2+. #else #define CYTHON_ABI "0_23_4" #include #ifndef offsetof #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) #endif #if !defined(WIN32) && !defined(MS_WINDOWS) #ifndef __stdcall #define __stdcall #endif #ifndef __cdecl #define __cdecl #endif #ifndef __fastcall #define __fastcall #endif #endif #ifndef DL_IMPORT #define DL_IMPORT(t) t #endif #ifndef DL_EXPORT #define DL_EXPORT(t) t #endif #ifndef PY_LONG_LONG #define PY_LONG_LONG LONG_LONG #endif #ifndef Py_HUGE_VAL #define Py_HUGE_VAL HUGE_VAL #endif #ifdef PYPY_VERSION #define CYTHON_COMPILING_IN_PYPY 1 #define CYTHON_COMPILING_IN_CPYTHON 0 #else #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_CPYTHON 1 #endif #if !defined(CYTHON_USE_PYLONG_INTERNALS) && CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x02070000 #define CYTHON_USE_PYLONG_INTERNALS 1 #endif #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag) #define Py_OptimizeFlag 0 #endif #define __PYX_BUILD_PY_SSIZE_T "n" #define CYTHON_FORMAT_SSIZE_T "z" #if PY_MAJOR_VERSION < 3 #define __Pyx_BUILTIN_MODULE_NAME "__builtin__" #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) #define __Pyx_DefaultClassType PyClass_Type #else #define __Pyx_BUILTIN_MODULE_NAME "builtins" #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) #define __Pyx_DefaultClassType PyType_Type #endif #ifndef Py_TPFLAGS_CHECKTYPES #define Py_TPFLAGS_CHECKTYPES 0 #endif #ifndef Py_TPFLAGS_HAVE_INDEX #define Py_TPFLAGS_HAVE_INDEX 0 #endif #ifndef Py_TPFLAGS_HAVE_NEWBUFFER #define Py_TPFLAGS_HAVE_NEWBUFFER 0 #endif #ifndef Py_TPFLAGS_HAVE_FINALIZE #define Py_TPFLAGS_HAVE_FINALIZE 0 #endif #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) #define CYTHON_PEP393_ENABLED 1 #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\ 0 : _PyUnicode_Ready((PyObject *)(op))) #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u) #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i) #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u) #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u) #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i) #else #define CYTHON_PEP393_ENABLED 0 #define __Pyx_PyUnicode_READY(op) (0) #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u) #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i])) #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE)) #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u)) #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i])) #endif #if CYTHON_COMPILING_IN_PYPY #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b) #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b) #else #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b) #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\ PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b)) #endif #if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains) #define PyUnicode_Contains(u, s) PySequence_Contains(u, s) #endif #define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b)) #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b)) #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b) #else #define __Pyx_PyString_Format(a, b) PyString_Format(a, b) #endif #if PY_MAJOR_VERSION >= 3 #define PyBaseString_Type PyUnicode_Type #define PyStringObject PyUnicodeObject #define PyString_Type PyUnicode_Type #define PyString_Check PyUnicode_Check #define PyString_CheckExact PyUnicode_CheckExact #endif #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj) #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj) #else #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj)) #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj)) #endif #ifndef PySet_CheckExact #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) #endif #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) #if PY_MAJOR_VERSION >= 3 #define PyIntObject PyLongObject #define PyInt_Type PyLong_Type #define PyInt_Check(op) PyLong_Check(op) #define PyInt_CheckExact(op) PyLong_CheckExact(op) #define PyInt_FromString PyLong_FromString #define PyInt_FromUnicode PyLong_FromUnicode #define PyInt_FromLong PyLong_FromLong #define PyInt_FromSize_t PyLong_FromSize_t #define PyInt_FromSsize_t PyLong_FromSsize_t #define PyInt_AsLong PyLong_AsLong #define PyInt_AS_LONG PyLong_AS_LONG #define PyInt_AsSsize_t PyLong_AsSsize_t #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask #define PyNumber_Int PyNumber_Long #endif #if PY_MAJOR_VERSION >= 3 #define PyBoolObject PyLongObject #endif #if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY #ifndef PyUnicode_InternFromString #define PyUnicode_InternFromString(s) PyUnicode_FromString(s) #endif #endif #if PY_VERSION_HEX < 0x030200A4 typedef long Py_hash_t; #define __Pyx_PyInt_FromHash_t PyInt_FromLong #define __Pyx_PyInt_AsHash_t PyInt_AsLong #else #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t #endif #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func)) #else #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass) #endif #if PY_VERSION_HEX >= 0x030500B1 #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async) #elif CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 typedef struct { unaryfunc am_await; unaryfunc am_aiter; unaryfunc am_anext; } __Pyx_PyAsyncMethodsStruct; #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved)) #else #define __Pyx_PyType_AsAsync(obj) NULL #endif #ifndef CYTHON_RESTRICT #if defined(__GNUC__) #define CYTHON_RESTRICT __restrict__ #elif defined(_MSC_VER) && _MSC_VER >= 1400 #define CYTHON_RESTRICT __restrict #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define CYTHON_RESTRICT restrict #else #define CYTHON_RESTRICT #endif #endif #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None) #ifndef CYTHON_INLINE #if defined(__GNUC__) #define CYTHON_INLINE __inline__ #elif defined(_MSC_VER) #define CYTHON_INLINE __inline #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define CYTHON_INLINE inline #else #define CYTHON_INLINE #endif #endif #if defined(WIN32) || defined(MS_WINDOWS) #define _USE_MATH_DEFINES #endif #include #ifdef NAN #define __PYX_NAN() ((float) NAN) #else static CYTHON_INLINE float __PYX_NAN() { float value; memset(&value, 0xFF, sizeof(value)); return value; } #endif #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) #else #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) #endif #ifndef __PYX_EXTERN_C #ifdef __cplusplus #define __PYX_EXTERN_C extern "C" #else #define __PYX_EXTERN_C extern #endif #endif #define __PYX_HAVE__photutils__geometry__rectangular_overlap #define __PYX_HAVE_API__photutils__geometry__rectangular_overlap #include "string.h" #include "stdio.h" #include "stdlib.h" #include "numpy/arrayobject.h" #include "numpy/ufuncobject.h" #include "math.h" #include "pythread.h" #ifdef _OPENMP #include #endif /* _OPENMP */ #ifdef PYREX_WITHOUT_ASSERTIONS #define CYTHON_WITHOUT_ASSERTIONS #endif #ifndef CYTHON_UNUSED # if defined(__GNUC__) # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) # define CYTHON_UNUSED __attribute__ ((__unused__)) # else # define CYTHON_UNUSED # endif # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER)) # define CYTHON_UNUSED __attribute__ ((__unused__)) # else # define CYTHON_UNUSED # endif #endif #ifndef CYTHON_NCP_UNUSED # if CYTHON_COMPILING_IN_CPYTHON # define CYTHON_NCP_UNUSED # else # define CYTHON_NCP_UNUSED CYTHON_UNUSED # endif #endif typedef struct {PyObject **p; char *s; const Py_ssize_t n; const char* encoding; const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0 #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0 #define __PYX_DEFAULT_STRING_ENCODING "" #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize #define __Pyx_uchar_cast(c) ((unsigned char)c) #define __Pyx_long_cast(x) ((long)x) #define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\ (sizeof(type) < sizeof(Py_ssize_t)) ||\ (sizeof(type) > sizeof(Py_ssize_t) &&\ likely(v < (type)PY_SSIZE_T_MAX ||\ v == (type)PY_SSIZE_T_MAX) &&\ (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\ v == (type)PY_SSIZE_T_MIN))) ||\ (sizeof(type) == sizeof(Py_ssize_t) &&\ (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\ v == (type)PY_SSIZE_T_MAX))) ) #if defined (__cplusplus) && __cplusplus >= 201103L #include #define __Pyx_sst_abs(value) std::abs(value) #elif SIZEOF_INT >= SIZEOF_SIZE_T #define __Pyx_sst_abs(value) abs(value) #elif SIZEOF_LONG >= SIZEOF_SIZE_T #define __Pyx_sst_abs(value) labs(value) #elif defined (_MSC_VER) && defined (_M_X64) #define __Pyx_sst_abs(value) _abs64(value) #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define __Pyx_sst_abs(value) llabs(value) #elif defined (__GNUC__) #define __Pyx_sst_abs(value) __builtin_llabs(value) #else #define __Pyx_sst_abs(value) ((value<0) ? -value : value) #endif static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*); static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s)) #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l) #define __Pyx_PyBytes_FromString PyBytes_FromString #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); #if PY_MAJOR_VERSION < 3 #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize #else #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize #endif #define __Pyx_PyObject_AsSString(s) ((signed char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s) #define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s) #define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s) #define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s) #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s) #if PY_MAJOR_VERSION < 3 static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) { const Py_UNICODE *u_end = u; while (*u_end++) ; return (size_t)(u_end - u - 1); } #else #define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen #endif #define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u)) #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj) #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None) #define __Pyx_PyBool_FromLong(b) ((b) ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False)) static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x); static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); #if CYTHON_COMPILING_IN_CPYTHON #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x)) #else #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x) #endif #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x)) #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII static int __Pyx_sys_getdefaultencoding_not_ascii; static int __Pyx_init_sys_getdefaultencoding_params(void) { PyObject* sys; PyObject* default_encoding = NULL; PyObject* ascii_chars_u = NULL; PyObject* ascii_chars_b = NULL; const char* default_encoding_c; sys = PyImport_ImportModule("sys"); if (!sys) goto bad; default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL); Py_DECREF(sys); if (!default_encoding) goto bad; default_encoding_c = PyBytes_AsString(default_encoding); if (!default_encoding_c) goto bad; if (strcmp(default_encoding_c, "ascii") == 0) { __Pyx_sys_getdefaultencoding_not_ascii = 0; } else { char ascii_chars[128]; int c; for (c = 0; c < 128; c++) { ascii_chars[c] = c; } __Pyx_sys_getdefaultencoding_not_ascii = 1; ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL); if (!ascii_chars_u) goto bad; ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL); if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) { PyErr_Format( PyExc_ValueError, "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.", default_encoding_c); goto bad; } Py_DECREF(ascii_chars_u); Py_DECREF(ascii_chars_b); } Py_DECREF(default_encoding); return 0; bad: Py_XDECREF(default_encoding); Py_XDECREF(ascii_chars_u); Py_XDECREF(ascii_chars_b); return -1; } #endif #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL) #else #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL) #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT static char* __PYX_DEFAULT_STRING_ENCODING; static int __Pyx_init_sys_getdefaultencoding_params(void) { PyObject* sys; PyObject* default_encoding = NULL; char* default_encoding_c; sys = PyImport_ImportModule("sys"); if (!sys) goto bad; default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL); Py_DECREF(sys); if (!default_encoding) goto bad; default_encoding_c = PyBytes_AsString(default_encoding); if (!default_encoding_c) goto bad; __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c)); if (!__PYX_DEFAULT_STRING_ENCODING) goto bad; strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c); Py_DECREF(default_encoding); return 0; bad: Py_XDECREF(default_encoding); return -1; } #endif #endif /* Test for GCC > 2.95 */ #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))) #define likely(x) __builtin_expect(!!(x), 1) #define unlikely(x) __builtin_expect(!!(x), 0) #else /* !__GNUC__ or GCC < 2.95 */ #define likely(x) (x) #define unlikely(x) (x) #endif /* __GNUC__ */ static PyObject *__pyx_m; static PyObject *__pyx_d; static PyObject *__pyx_b; static PyObject *__pyx_empty_tuple; static PyObject *__pyx_empty_bytes; static int __pyx_lineno; static int __pyx_clineno = 0; static const char * __pyx_cfilenm= __FILE__; static const char *__pyx_filename; #if !defined(CYTHON_CCOMPLEX) #if defined(__cplusplus) #define CYTHON_CCOMPLEX 1 #elif defined(_Complex_I) #define CYTHON_CCOMPLEX 1 #else #define CYTHON_CCOMPLEX 0 #endif #endif #if CYTHON_CCOMPLEX #ifdef __cplusplus #include #else #include #endif #endif #if CYTHON_CCOMPLEX && !defined(__cplusplus) && defined(__sun__) && defined(__GNUC__) #undef _Complex_I #define _Complex_I 1.0fj #endif static const char *__pyx_f[] = { "photutils/geometry/rectangular_overlap.pyx", "__init__.pxd", "type.pxd", "bool.pxd", "complex.pxd", }; #define IS_UNSIGNED(type) (((type) -1) > 0) struct __Pyx_StructField_; #define __PYX_BUF_FLAGS_PACKED_STRUCT (1 << 0) typedef struct { const char* name; struct __Pyx_StructField_* fields; size_t size; size_t arraysize[8]; int ndim; char typegroup; char is_unsigned; int flags; } __Pyx_TypeInfo; typedef struct __Pyx_StructField_ { __Pyx_TypeInfo* type; const char* name; size_t offset; } __Pyx_StructField; typedef struct { __Pyx_StructField* field; size_t parent_offset; } __Pyx_BufFmt_StackElem; typedef struct { __Pyx_StructField root; __Pyx_BufFmt_StackElem* head; size_t fmt_offset; size_t new_count, enc_count; size_t struct_alignment; int is_complex; char enc_type; char new_packmode; char enc_packmode; char is_valid_array; } __Pyx_BufFmt_Context; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":725 * # in Cython to enable them only on the right systems. * * ctypedef npy_int8 int8_t # <<<<<<<<<<<<<< * ctypedef npy_int16 int16_t * ctypedef npy_int32 int32_t */ typedef npy_int8 __pyx_t_5numpy_int8_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":726 * * ctypedef npy_int8 int8_t * ctypedef npy_int16 int16_t # <<<<<<<<<<<<<< * ctypedef npy_int32 int32_t * ctypedef npy_int64 int64_t */ typedef npy_int16 __pyx_t_5numpy_int16_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":727 * ctypedef npy_int8 int8_t * ctypedef npy_int16 int16_t * ctypedef npy_int32 int32_t # <<<<<<<<<<<<<< * ctypedef npy_int64 int64_t * #ctypedef npy_int96 int96_t */ typedef npy_int32 __pyx_t_5numpy_int32_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":728 * ctypedef npy_int16 int16_t * ctypedef npy_int32 int32_t * ctypedef npy_int64 int64_t # <<<<<<<<<<<<<< * #ctypedef npy_int96 int96_t * #ctypedef npy_int128 int128_t */ typedef npy_int64 __pyx_t_5numpy_int64_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":732 * #ctypedef npy_int128 int128_t * * ctypedef npy_uint8 uint8_t # <<<<<<<<<<<<<< * ctypedef npy_uint16 uint16_t * ctypedef npy_uint32 uint32_t */ typedef npy_uint8 __pyx_t_5numpy_uint8_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":733 * * ctypedef npy_uint8 uint8_t * ctypedef npy_uint16 uint16_t # <<<<<<<<<<<<<< * ctypedef npy_uint32 uint32_t * ctypedef npy_uint64 uint64_t */ typedef npy_uint16 __pyx_t_5numpy_uint16_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":734 * ctypedef npy_uint8 uint8_t * ctypedef npy_uint16 uint16_t * ctypedef npy_uint32 uint32_t # <<<<<<<<<<<<<< * ctypedef npy_uint64 uint64_t * #ctypedef npy_uint96 uint96_t */ typedef npy_uint32 __pyx_t_5numpy_uint32_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":735 * ctypedef npy_uint16 uint16_t * ctypedef npy_uint32 uint32_t * ctypedef npy_uint64 uint64_t # <<<<<<<<<<<<<< * #ctypedef npy_uint96 uint96_t * #ctypedef npy_uint128 uint128_t */ typedef npy_uint64 __pyx_t_5numpy_uint64_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":739 * #ctypedef npy_uint128 uint128_t * * ctypedef npy_float32 float32_t # <<<<<<<<<<<<<< * ctypedef npy_float64 float64_t * #ctypedef npy_float80 float80_t */ typedef npy_float32 __pyx_t_5numpy_float32_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":740 * * ctypedef npy_float32 float32_t * ctypedef npy_float64 float64_t # <<<<<<<<<<<<<< * #ctypedef npy_float80 float80_t * #ctypedef npy_float128 float128_t */ typedef npy_float64 __pyx_t_5numpy_float64_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":749 * # The int types are mapped a bit surprising -- * # numpy.int corresponds to 'l' and numpy.long to 'q' * ctypedef npy_long int_t # <<<<<<<<<<<<<< * ctypedef npy_longlong long_t * ctypedef npy_longlong longlong_t */ typedef npy_long __pyx_t_5numpy_int_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":750 * # numpy.int corresponds to 'l' and numpy.long to 'q' * ctypedef npy_long int_t * ctypedef npy_longlong long_t # <<<<<<<<<<<<<< * ctypedef npy_longlong longlong_t * */ typedef npy_longlong __pyx_t_5numpy_long_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":751 * ctypedef npy_long int_t * ctypedef npy_longlong long_t * ctypedef npy_longlong longlong_t # <<<<<<<<<<<<<< * * ctypedef npy_ulong uint_t */ typedef npy_longlong __pyx_t_5numpy_longlong_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":753 * ctypedef npy_longlong longlong_t * * ctypedef npy_ulong uint_t # <<<<<<<<<<<<<< * ctypedef npy_ulonglong ulong_t * ctypedef npy_ulonglong ulonglong_t */ typedef npy_ulong __pyx_t_5numpy_uint_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":754 * * ctypedef npy_ulong uint_t * ctypedef npy_ulonglong ulong_t # <<<<<<<<<<<<<< * ctypedef npy_ulonglong ulonglong_t * */ typedef npy_ulonglong __pyx_t_5numpy_ulong_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":755 * ctypedef npy_ulong uint_t * ctypedef npy_ulonglong ulong_t * ctypedef npy_ulonglong ulonglong_t # <<<<<<<<<<<<<< * * ctypedef npy_intp intp_t */ typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":757 * ctypedef npy_ulonglong ulonglong_t * * ctypedef npy_intp intp_t # <<<<<<<<<<<<<< * ctypedef npy_uintp uintp_t * */ typedef npy_intp __pyx_t_5numpy_intp_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":758 * * ctypedef npy_intp intp_t * ctypedef npy_uintp uintp_t # <<<<<<<<<<<<<< * * ctypedef npy_double float_t */ typedef npy_uintp __pyx_t_5numpy_uintp_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":760 * ctypedef npy_uintp uintp_t * * ctypedef npy_double float_t # <<<<<<<<<<<<<< * ctypedef npy_double double_t * ctypedef npy_longdouble longdouble_t */ typedef npy_double __pyx_t_5numpy_float_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":761 * * ctypedef npy_double float_t * ctypedef npy_double double_t # <<<<<<<<<<<<<< * ctypedef npy_longdouble longdouble_t * */ typedef npy_double __pyx_t_5numpy_double_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":762 * ctypedef npy_double float_t * ctypedef npy_double double_t * ctypedef npy_longdouble longdouble_t # <<<<<<<<<<<<<< * * ctypedef npy_cfloat cfloat_t */ typedef npy_longdouble __pyx_t_5numpy_longdouble_t; /* "photutils/geometry/rectangular_overlap.pyx":21 * * DTYPE = np.float64 * ctypedef np.float64_t DTYPE_t # <<<<<<<<<<<<<< * * cimport cython */ typedef __pyx_t_5numpy_float64_t __pyx_t_9photutils_8geometry_19rectangular_overlap_DTYPE_t; #if CYTHON_CCOMPLEX #ifdef __cplusplus typedef ::std::complex< float > __pyx_t_float_complex; #else typedef float _Complex __pyx_t_float_complex; #endif #else typedef struct { float real, imag; } __pyx_t_float_complex; #endif #if CYTHON_CCOMPLEX #ifdef __cplusplus typedef ::std::complex< double > __pyx_t_double_complex; #else typedef double _Complex __pyx_t_double_complex; #endif #else typedef struct { double real, imag; } __pyx_t_double_complex; #endif /*--- Type declarations ---*/ /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":764 * ctypedef npy_longdouble longdouble_t * * ctypedef npy_cfloat cfloat_t # <<<<<<<<<<<<<< * ctypedef npy_cdouble cdouble_t * ctypedef npy_clongdouble clongdouble_t */ typedef npy_cfloat __pyx_t_5numpy_cfloat_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":765 * * ctypedef npy_cfloat cfloat_t * ctypedef npy_cdouble cdouble_t # <<<<<<<<<<<<<< * ctypedef npy_clongdouble clongdouble_t * */ typedef npy_cdouble __pyx_t_5numpy_cdouble_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":766 * ctypedef npy_cfloat cfloat_t * ctypedef npy_cdouble cdouble_t * ctypedef npy_clongdouble clongdouble_t # <<<<<<<<<<<<<< * * ctypedef npy_cdouble complex_t */ typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":768 * ctypedef npy_clongdouble clongdouble_t * * ctypedef npy_cdouble complex_t # <<<<<<<<<<<<<< * * cdef inline object PyArray_MultiIterNew1(a): */ typedef npy_cdouble __pyx_t_5numpy_complex_t; /* --- Runtime support code (head) --- */ #ifndef CYTHON_REFNANNY #define CYTHON_REFNANNY 0 #endif #if CYTHON_REFNANNY typedef struct { void (*INCREF)(void*, PyObject*, int); void (*DECREF)(void*, PyObject*, int); void (*GOTREF)(void*, PyObject*, int); void (*GIVEREF)(void*, PyObject*, int); void* (*SetupContext)(const char*, int, const char*); void (*FinishContext)(void**); } __Pyx_RefNannyAPIStruct; static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL; static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL; #ifdef WITH_THREAD #define __Pyx_RefNannySetupContext(name, acquire_gil)\ if (acquire_gil) {\ PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\ __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\ PyGILState_Release(__pyx_gilstate_save);\ } else {\ __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\ } #else #define __Pyx_RefNannySetupContext(name, acquire_gil)\ __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__) #endif #define __Pyx_RefNannyFinishContext()\ __Pyx_RefNanny->FinishContext(&__pyx_refnanny) #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__) #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__) #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__) #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__) #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0) #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0) #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0) #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0) #else #define __Pyx_RefNannyDeclarations #define __Pyx_RefNannySetupContext(name, acquire_gil) #define __Pyx_RefNannyFinishContext() #define __Pyx_INCREF(r) Py_INCREF(r) #define __Pyx_DECREF(r) Py_DECREF(r) #define __Pyx_GOTREF(r) #define __Pyx_GIVEREF(r) #define __Pyx_XINCREF(r) Py_XINCREF(r) #define __Pyx_XDECREF(r) Py_XDECREF(r) #define __Pyx_XGOTREF(r) #define __Pyx_XGIVEREF(r) #endif #define __Pyx_XDECREF_SET(r, v) do {\ PyObject *tmp = (PyObject *) r;\ r = v; __Pyx_XDECREF(tmp);\ } while (0) #define __Pyx_DECREF_SET(r, v) do {\ PyObject *tmp = (PyObject *) r;\ r = v; __Pyx_DECREF(tmp);\ } while (0) #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0) #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0) #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) { PyTypeObject* tp = Py_TYPE(obj); if (likely(tp->tp_getattro)) return tp->tp_getattro(obj, attr_name); #if PY_MAJOR_VERSION < 3 if (likely(tp->tp_getattr)) return tp->tp_getattr(obj, PyString_AS_STRING(attr_name)); #endif return PyObject_GetAttr(obj, attr_name); } #else #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n) #endif static PyObject *__Pyx_GetBuiltinName(PyObject *name); static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\ PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\ const char* function_name); static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name); #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw); #else #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw) #endif static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); static CYTHON_INLINE int __Pyx_GetBufferAndValidate(Py_buffer* buf, PyObject* obj, __Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack); static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info); static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); static void __Pyx_RaiseBufferIndexError(int axis); #define __Pyx_BufPtrStrided2d(type, buf, i0, s0, i1, s1) (type)((char*)buf + i0 * s0 + i1 * s1) static void __Pyx_WriteUnraisable(const char *name, int clineno, int lineno, const char *filename, int full_traceback, int nogil); #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) { PyObject *value; value = PyDict_GetItemWithError(d, key); if (unlikely(!value)) { if (!PyErr_Occurred()) { PyObject* args = PyTuple_Pack(1, key); if (likely(args)) PyErr_SetObject(PyExc_KeyError, args); Py_XDECREF(args); } return NULL; } Py_INCREF(value); return value; } #else #define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key) #endif static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected); static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index); static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void); static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); typedef struct { int code_line; PyCodeObject* code_object; } __Pyx_CodeObjectCacheEntry; struct __Pyx_CodeObjectCache { int count; int max_count; __Pyx_CodeObjectCacheEntry* entries; }; static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL}; static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line); static PyCodeObject *__pyx_find_code_object(int code_line); static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object); static void __Pyx_AddTraceback(const char *funcname, int c_line, int py_line, const char *filename); typedef struct { Py_ssize_t shape, strides, suboffsets; } __Pyx_Buf_DimInfo; typedef struct { size_t refcount; Py_buffer pybuffer; } __Pyx_Buffer; typedef struct { __Pyx_Buffer *rcbuffer; char *data; __Pyx_Buf_DimInfo diminfo[8]; } __Pyx_LocalBuf_ND; #if PY_MAJOR_VERSION < 3 static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags); static void __Pyx_ReleaseBuffer(Py_buffer *view); #else #define __Pyx_GetBuffer PyObject_GetBuffer #define __Pyx_ReleaseBuffer PyBuffer_Release #endif static Py_ssize_t __Pyx_zeros[] = {0, 0, 0, 0, 0, 0, 0, 0}; static Py_ssize_t __Pyx_minusones[] = {-1, -1, -1, -1, -1, -1, -1, -1}; static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value); static CYTHON_INLINE unsigned int __Pyx_PyInt_As_unsigned_int(PyObject *); #if CYTHON_CCOMPLEX #ifdef __cplusplus #define __Pyx_CREAL(z) ((z).real()) #define __Pyx_CIMAG(z) ((z).imag()) #else #define __Pyx_CREAL(z) (__real__(z)) #define __Pyx_CIMAG(z) (__imag__(z)) #endif #else #define __Pyx_CREAL(z) ((z).real) #define __Pyx_CIMAG(z) ((z).imag) #endif #if (defined(_WIN32) || defined(__clang__)) && defined(__cplusplus) && CYTHON_CCOMPLEX #define __Pyx_SET_CREAL(z,x) ((z).real(x)) #define __Pyx_SET_CIMAG(z,y) ((z).imag(y)) #else #define __Pyx_SET_CREAL(z,x) __Pyx_CREAL(z) = (x) #define __Pyx_SET_CIMAG(z,y) __Pyx_CIMAG(z) = (y) #endif static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float, float); #if CYTHON_CCOMPLEX #define __Pyx_c_eqf(a, b) ((a)==(b)) #define __Pyx_c_sumf(a, b) ((a)+(b)) #define __Pyx_c_difff(a, b) ((a)-(b)) #define __Pyx_c_prodf(a, b) ((a)*(b)) #define __Pyx_c_quotf(a, b) ((a)/(b)) #define __Pyx_c_negf(a) (-(a)) #ifdef __cplusplus #define __Pyx_c_is_zerof(z) ((z)==(float)0) #define __Pyx_c_conjf(z) (::std::conj(z)) #if 1 #define __Pyx_c_absf(z) (::std::abs(z)) #define __Pyx_c_powf(a, b) (::std::pow(a, b)) #endif #else #define __Pyx_c_is_zerof(z) ((z)==0) #define __Pyx_c_conjf(z) (conjf(z)) #if 1 #define __Pyx_c_absf(z) (cabsf(z)) #define __Pyx_c_powf(a, b) (cpowf(a, b)) #endif #endif #else static CYTHON_INLINE int __Pyx_c_eqf(__pyx_t_float_complex, __pyx_t_float_complex); static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sumf(__pyx_t_float_complex, __pyx_t_float_complex); static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_difff(__pyx_t_float_complex, __pyx_t_float_complex); static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prodf(__pyx_t_float_complex, __pyx_t_float_complex); static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quotf(__pyx_t_float_complex, __pyx_t_float_complex); static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_negf(__pyx_t_float_complex); static CYTHON_INLINE int __Pyx_c_is_zerof(__pyx_t_float_complex); static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conjf(__pyx_t_float_complex); #if 1 static CYTHON_INLINE float __Pyx_c_absf(__pyx_t_float_complex); static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_powf(__pyx_t_float_complex, __pyx_t_float_complex); #endif #endif static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double, double); #if CYTHON_CCOMPLEX #define __Pyx_c_eq(a, b) ((a)==(b)) #define __Pyx_c_sum(a, b) ((a)+(b)) #define __Pyx_c_diff(a, b) ((a)-(b)) #define __Pyx_c_prod(a, b) ((a)*(b)) #define __Pyx_c_quot(a, b) ((a)/(b)) #define __Pyx_c_neg(a) (-(a)) #ifdef __cplusplus #define __Pyx_c_is_zero(z) ((z)==(double)0) #define __Pyx_c_conj(z) (::std::conj(z)) #if 1 #define __Pyx_c_abs(z) (::std::abs(z)) #define __Pyx_c_pow(a, b) (::std::pow(a, b)) #endif #else #define __Pyx_c_is_zero(z) ((z)==0) #define __Pyx_c_conj(z) (conj(z)) #if 1 #define __Pyx_c_abs(z) (cabs(z)) #define __Pyx_c_pow(a, b) (cpow(a, b)) #endif #endif #else static CYTHON_INLINE int __Pyx_c_eq(__pyx_t_double_complex, __pyx_t_double_complex); static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum(__pyx_t_double_complex, __pyx_t_double_complex); static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff(__pyx_t_double_complex, __pyx_t_double_complex); static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod(__pyx_t_double_complex, __pyx_t_double_complex); static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot(__pyx_t_double_complex, __pyx_t_double_complex); static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg(__pyx_t_double_complex); static CYTHON_INLINE int __Pyx_c_is_zero(__pyx_t_double_complex); static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj(__pyx_t_double_complex); #if 1 static CYTHON_INLINE double __Pyx_c_abs(__pyx_t_double_complex); static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow(__pyx_t_double_complex, __pyx_t_double_complex); #endif #endif static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum__NPY_TYPES(enum NPY_TYPES value); static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); static int __Pyx_check_binary_version(void); #if !defined(__Pyx_PyIdentifier_FromString) #if PY_MAJOR_VERSION < 3 #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s) #else #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s) #endif #endif static PyObject *__Pyx_ImportModule(const char *name); static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict); static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /* Module declarations from 'cpython.buffer' */ /* Module declarations from 'libc.string' */ /* Module declarations from 'libc.stdio' */ /* Module declarations from '__builtin__' */ /* Module declarations from 'cpython.type' */ static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0; /* Module declarations from 'cpython.version' */ /* Module declarations from 'cpython.exc' */ /* Module declarations from 'cpython.module' */ /* Module declarations from 'cpython.mem' */ /* Module declarations from 'cpython.tuple' */ /* Module declarations from 'cpython.list' */ /* Module declarations from 'cpython.sequence' */ /* Module declarations from 'cpython.mapping' */ /* Module declarations from 'cpython.iterator' */ /* Module declarations from 'cpython.number' */ /* Module declarations from 'cpython.int' */ /* Module declarations from '__builtin__' */ /* Module declarations from 'cpython.bool' */ static PyTypeObject *__pyx_ptype_7cpython_4bool_bool = 0; /* Module declarations from 'cpython.long' */ /* Module declarations from 'cpython.float' */ /* Module declarations from '__builtin__' */ /* Module declarations from 'cpython.complex' */ static PyTypeObject *__pyx_ptype_7cpython_7complex_complex = 0; /* Module declarations from 'cpython.string' */ /* Module declarations from 'cpython.unicode' */ /* Module declarations from 'cpython.dict' */ /* Module declarations from 'cpython.instance' */ /* Module declarations from 'cpython.function' */ /* Module declarations from 'cpython.method' */ /* Module declarations from 'cpython.weakref' */ /* Module declarations from 'cpython.getargs' */ /* Module declarations from 'cpython.pythread' */ /* Module declarations from 'cpython.pystate' */ /* Module declarations from 'cpython.cobject' */ /* Module declarations from 'cpython.oldbuffer' */ /* Module declarations from 'cpython.set' */ /* Module declarations from 'cpython.bytes' */ /* Module declarations from 'cpython.pycapsule' */ /* Module declarations from 'cpython' */ /* Module declarations from 'cpython.object' */ /* Module declarations from 'cpython.ref' */ /* Module declarations from 'libc.stdlib' */ /* Module declarations from 'numpy' */ /* Module declarations from 'numpy' */ static PyTypeObject *__pyx_ptype_5numpy_dtype = 0; static PyTypeObject *__pyx_ptype_5numpy_flatiter = 0; static PyTypeObject *__pyx_ptype_5numpy_broadcast = 0; static PyTypeObject *__pyx_ptype_5numpy_ndarray = 0; static PyTypeObject *__pyx_ptype_5numpy_ufunc = 0; static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *, char *, char *, int *); /*proto*/ /* Module declarations from 'cython' */ /* Module declarations from 'photutils.geometry.rectangular_overlap' */ static double __pyx_f_9photutils_8geometry_19rectangular_overlap_rectangular_overlap_single_subpixel(double, double, double, double, double, double, double, int); /*proto*/ static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_9photutils_8geometry_19rectangular_overlap_DTYPE_t = { "DTYPE_t", NULL, sizeof(__pyx_t_9photutils_8geometry_19rectangular_overlap_DTYPE_t), { 0 }, 0, 'R', 0, 0 }; #define __Pyx_MODULE_NAME "photutils.geometry.rectangular_overlap" int __pyx_module_is_main_photutils__geometry__rectangular_overlap = 0; /* Implementation of 'photutils.geometry.rectangular_overlap' */ static PyObject *__pyx_builtin_NotImplementedError; static PyObject *__pyx_builtin_range; static PyObject *__pyx_builtin_ValueError; static PyObject *__pyx_builtin_RuntimeError; static char __pyx_k_B[] = "B"; static char __pyx_k_H[] = "H"; static char __pyx_k_I[] = "I"; static char __pyx_k_L[] = "L"; static char __pyx_k_O[] = "O"; static char __pyx_k_Q[] = "Q"; static char __pyx_k_b[] = "b"; static char __pyx_k_d[] = "d"; static char __pyx_k_f[] = "f"; static char __pyx_k_g[] = "g"; static char __pyx_k_h[] = "h"; static char __pyx_k_i[] = "i"; static char __pyx_k_j[] = "j"; static char __pyx_k_l[] = "l"; static char __pyx_k_q[] = "q"; static char __pyx_k_x[] = "x"; static char __pyx_k_y[] = "y"; static char __pyx_k_Zd[] = "Zd"; static char __pyx_k_Zf[] = "Zf"; static char __pyx_k_Zg[] = "Zg"; static char __pyx_k_dx[] = "dx"; static char __pyx_k_dy[] = "dy"; static char __pyx_k_np[] = "np"; static char __pyx_k_nx[] = "nx"; static char __pyx_k_ny[] = "ny"; static char __pyx_k_all[] = "__all__"; static char __pyx_k_frac[] = "frac"; static char __pyx_k_main[] = "__main__"; static char __pyx_k_test[] = "__test__"; static char __pyx_k_xmax[] = "xmax"; static char __pyx_k_xmin[] = "xmin"; static char __pyx_k_ymax[] = "ymax"; static char __pyx_k_ymin[] = "ymin"; static char __pyx_k_DTYPE[] = "DTYPE"; static char __pyx_k_dtype[] = "dtype"; static char __pyx_k_numpy[] = "numpy"; static char __pyx_k_pxmax[] = "pxmax"; static char __pyx_k_pxmin[] = "pxmin"; static char __pyx_k_pymax[] = "pymax"; static char __pyx_k_pymin[] = "pymin"; static char __pyx_k_range[] = "range"; static char __pyx_k_theta[] = "theta"; static char __pyx_k_width[] = "width"; static char __pyx_k_zeros[] = "zeros"; static char __pyx_k_height[] = "height"; static char __pyx_k_import[] = "__import__"; static char __pyx_k_float64[] = "float64"; static char __pyx_k_subpixels[] = "subpixels"; static char __pyx_k_use_exact[] = "use_exact"; static char __pyx_k_ValueError[] = "ValueError"; static char __pyx_k_RuntimeError[] = "RuntimeError"; static char __pyx_k_NotImplementedError[] = "NotImplementedError"; static char __pyx_k_rectangular_overlap_grid[] = "rectangular_overlap_grid"; static char __pyx_k_ndarray_is_not_C_contiguous[] = "ndarray is not C contiguous"; static char __pyx_k_Users_lbradley_Dropbox_softw_de[] = "/Users/lbradley/Dropbox/softw/development/photutils/photutils/geometry/rectangular_overlap.pyx"; static char __pyx_k_unknown_dtype_code_in_numpy_pxd[] = "unknown dtype code in numpy.pxd (%d)"; static char __pyx_k_Exact_mode_has_not_been_implemen[] = "Exact mode has not been implemented for rectangular apertures"; static char __pyx_k_Format_string_allocated_too_shor[] = "Format string allocated too short, see comment in numpy.pxd"; static char __pyx_k_Non_native_byte_order_not_suppor[] = "Non-native byte order not supported"; static char __pyx_k_ndarray_is_not_Fortran_contiguou[] = "ndarray is not Fortran contiguous"; static char __pyx_k_photutils_geometry_rectangular_o[] = "photutils.geometry.rectangular_overlap"; static char __pyx_k_Format_string_allocated_too_shor_2[] = "Format string allocated too short."; static PyObject *__pyx_n_s_DTYPE; static PyObject *__pyx_kp_u_Exact_mode_has_not_been_implemen; static PyObject *__pyx_kp_u_Format_string_allocated_too_shor; static PyObject *__pyx_kp_u_Format_string_allocated_too_shor_2; static PyObject *__pyx_kp_u_Non_native_byte_order_not_suppor; static PyObject *__pyx_n_s_NotImplementedError; static PyObject *__pyx_n_s_RuntimeError; static PyObject *__pyx_kp_s_Users_lbradley_Dropbox_softw_de; static PyObject *__pyx_n_s_ValueError; static PyObject *__pyx_n_s_all; static PyObject *__pyx_n_s_dtype; static PyObject *__pyx_n_s_dx; static PyObject *__pyx_n_s_dy; static PyObject *__pyx_n_s_float64; static PyObject *__pyx_n_s_frac; static PyObject *__pyx_n_s_height; static PyObject *__pyx_n_s_i; static PyObject *__pyx_n_s_import; static PyObject *__pyx_n_s_j; static PyObject *__pyx_n_s_main; static PyObject *__pyx_kp_u_ndarray_is_not_C_contiguous; static PyObject *__pyx_kp_u_ndarray_is_not_Fortran_contiguou; static PyObject *__pyx_n_s_np; static PyObject *__pyx_n_s_numpy; static PyObject *__pyx_n_s_nx; static PyObject *__pyx_n_s_ny; static PyObject *__pyx_n_s_photutils_geometry_rectangular_o; static PyObject *__pyx_n_s_pxmax; static PyObject *__pyx_n_s_pxmin; static PyObject *__pyx_n_s_pymax; static PyObject *__pyx_n_s_pymin; static PyObject *__pyx_n_s_range; static PyObject *__pyx_n_s_rectangular_overlap_grid; static PyObject *__pyx_n_u_rectangular_overlap_grid; static PyObject *__pyx_n_s_subpixels; static PyObject *__pyx_n_s_test; static PyObject *__pyx_n_s_theta; static PyObject *__pyx_kp_u_unknown_dtype_code_in_numpy_pxd; static PyObject *__pyx_n_s_use_exact; static PyObject *__pyx_n_s_width; static PyObject *__pyx_n_s_x; static PyObject *__pyx_n_s_xmax; static PyObject *__pyx_n_s_xmin; static PyObject *__pyx_n_s_y; static PyObject *__pyx_n_s_ymax; static PyObject *__pyx_n_s_ymin; static PyObject *__pyx_n_s_zeros; static PyObject *__pyx_pf_9photutils_8geometry_19rectangular_overlap_rectangular_overlap_grid(CYTHON_UNUSED PyObject *__pyx_self, double __pyx_v_xmin, double __pyx_v_xmax, double __pyx_v_ymin, double __pyx_v_ymax, int __pyx_v_nx, int __pyx_v_ny, double __pyx_v_width, double __pyx_v_height, double __pyx_v_theta, int __pyx_v_use_exact, int __pyx_v_subpixels); /* proto */ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /* proto */ static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info); /* proto */ static PyObject *__pyx_tuple_; static PyObject *__pyx_tuple__2; static PyObject *__pyx_tuple__3; static PyObject *__pyx_tuple__4; static PyObject *__pyx_tuple__5; static PyObject *__pyx_tuple__6; static PyObject *__pyx_tuple__7; static PyObject *__pyx_tuple__8; static PyObject *__pyx_codeobj__9; /* "photutils/geometry/rectangular_overlap.pyx":26 * * * def rectangular_overlap_grid(double xmin, double xmax, double ymin, # <<<<<<<<<<<<<< * double ymax, int nx, int ny, double width, * double height, double theta, int use_exact, */ /* Python wrapper */ static PyObject *__pyx_pw_9photutils_8geometry_19rectangular_overlap_1rectangular_overlap_grid(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_9photutils_8geometry_19rectangular_overlap_rectangular_overlap_grid[] = "\n rectangular_overlap_grid(xmin, xmax, ymin, ymax, nx, ny, width, height,\n use_exact, subpixels)\n\n Area of overlap between a rectangle and a pixel grid. The rectangle is\n centered on the origin.\n\n Parameters\n ----------\n xmin, xmax, ymin, ymax : float\n Extent of the grid in the x and y direction.\n nx, ny : int\n Grid dimensions.\n width : float\n The width of the rectangle\n height : float\n The height of the rectangle\n theta : float\n The position angle of the rectangle in radians (counterclockwise).\n use_exact : 0 or 1\n If set to 1, calculates the exact overlap, while if set to 0, uses a\n subpixel sampling method with ``subpixel`` subpixels in each direction.\n subpixels : int\n If ``use_exact`` is 0, each pixel is resampled by this factor in each\n dimension. Thus, each pixel is divided into ``subpixels ** 2``\n subpixels.\n\n Returns\n -------\n frac : `~numpy.ndarray`\n 2-d array giving the fraction of the overlap.\n "; static PyMethodDef __pyx_mdef_9photutils_8geometry_19rectangular_overlap_1rectangular_overlap_grid = {"rectangular_overlap_grid", (PyCFunction)__pyx_pw_9photutils_8geometry_19rectangular_overlap_1rectangular_overlap_grid, METH_VARARGS|METH_KEYWORDS, __pyx_doc_9photutils_8geometry_19rectangular_overlap_rectangular_overlap_grid}; static PyObject *__pyx_pw_9photutils_8geometry_19rectangular_overlap_1rectangular_overlap_grid(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { double __pyx_v_xmin; double __pyx_v_xmax; double __pyx_v_ymin; double __pyx_v_ymax; int __pyx_v_nx; int __pyx_v_ny; double __pyx_v_width; double __pyx_v_height; double __pyx_v_theta; int __pyx_v_use_exact; int __pyx_v_subpixels; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("rectangular_overlap_grid (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_xmin,&__pyx_n_s_xmax,&__pyx_n_s_ymin,&__pyx_n_s_ymax,&__pyx_n_s_nx,&__pyx_n_s_ny,&__pyx_n_s_width,&__pyx_n_s_height,&__pyx_n_s_theta,&__pyx_n_s_use_exact,&__pyx_n_s_subpixels,0}; PyObject* values[11] = {0,0,0,0,0,0,0,0,0,0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10); case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9); case 9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8); case 8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7); case 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6); case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_xmin)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_xmax)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("rectangular_overlap_grid", 1, 11, 11, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ymin)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("rectangular_overlap_grid", 1, 11, 11, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 3: if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ymax)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("rectangular_overlap_grid", 1, 11, 11, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 4: if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_nx)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("rectangular_overlap_grid", 1, 11, 11, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 5: if (likely((values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ny)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("rectangular_overlap_grid", 1, 11, 11, 5); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 6: if (likely((values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_width)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("rectangular_overlap_grid", 1, 11, 11, 6); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 7: if (likely((values[7] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_height)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("rectangular_overlap_grid", 1, 11, 11, 7); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 8: if (likely((values[8] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_theta)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("rectangular_overlap_grid", 1, 11, 11, 8); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 9: if (likely((values[9] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_use_exact)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("rectangular_overlap_grid", 1, 11, 11, 9); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 10: if (likely((values[10] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_subpixels)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("rectangular_overlap_grid", 1, 11, 11, 10); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "rectangular_overlap_grid") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 11) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[2] = PyTuple_GET_ITEM(__pyx_args, 2); values[3] = PyTuple_GET_ITEM(__pyx_args, 3); values[4] = PyTuple_GET_ITEM(__pyx_args, 4); values[5] = PyTuple_GET_ITEM(__pyx_args, 5); values[6] = PyTuple_GET_ITEM(__pyx_args, 6); values[7] = PyTuple_GET_ITEM(__pyx_args, 7); values[8] = PyTuple_GET_ITEM(__pyx_args, 8); values[9] = PyTuple_GET_ITEM(__pyx_args, 9); values[10] = PyTuple_GET_ITEM(__pyx_args, 10); } __pyx_v_xmin = __pyx_PyFloat_AsDouble(values[0]); if (unlikely((__pyx_v_xmin == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_xmax = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_xmax == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_ymin = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_ymin == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_ymax = __pyx_PyFloat_AsDouble(values[3]); if (unlikely((__pyx_v_ymax == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_nx = __Pyx_PyInt_As_int(values[4]); if (unlikely((__pyx_v_nx == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_ny = __Pyx_PyInt_As_int(values[5]); if (unlikely((__pyx_v_ny == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_width = __pyx_PyFloat_AsDouble(values[6]); if (unlikely((__pyx_v_width == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_height = __pyx_PyFloat_AsDouble(values[7]); if (unlikely((__pyx_v_height == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_theta = __pyx_PyFloat_AsDouble(values[8]); if (unlikely((__pyx_v_theta == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_use_exact = __Pyx_PyInt_As_int(values[9]); if (unlikely((__pyx_v_use_exact == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_subpixels = __Pyx_PyInt_As_int(values[10]); if (unlikely((__pyx_v_subpixels == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("rectangular_overlap_grid", 1, 11, 11, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("photutils.geometry.rectangular_overlap.rectangular_overlap_grid", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_9photutils_8geometry_19rectangular_overlap_rectangular_overlap_grid(__pyx_self, __pyx_v_xmin, __pyx_v_xmax, __pyx_v_ymin, __pyx_v_ymax, __pyx_v_nx, __pyx_v_ny, __pyx_v_width, __pyx_v_height, __pyx_v_theta, __pyx_v_use_exact, __pyx_v_subpixels); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_9photutils_8geometry_19rectangular_overlap_rectangular_overlap_grid(CYTHON_UNUSED PyObject *__pyx_self, double __pyx_v_xmin, double __pyx_v_xmax, double __pyx_v_ymin, double __pyx_v_ymax, int __pyx_v_nx, int __pyx_v_ny, double __pyx_v_width, double __pyx_v_height, double __pyx_v_theta, int __pyx_v_use_exact, int __pyx_v_subpixels) { unsigned int __pyx_v_i; unsigned int __pyx_v_j; double __pyx_v_dx; double __pyx_v_dy; double __pyx_v_pxmin; double __pyx_v_pxmax; double __pyx_v_pymin; double __pyx_v_pymax; PyArrayObject *__pyx_v_frac = 0; __Pyx_LocalBuf_ND __pyx_pybuffernd_frac; __Pyx_Buffer __pyx_pybuffer_frac; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyArrayObject *__pyx_t_5 = NULL; int __pyx_t_6; double __pyx_t_7; int __pyx_t_8; unsigned int __pyx_t_9; int __pyx_t_10; unsigned int __pyx_t_11; size_t __pyx_t_12; size_t __pyx_t_13; int __pyx_t_14; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("rectangular_overlap_grid", 0); __pyx_pybuffer_frac.pybuffer.buf = NULL; __pyx_pybuffer_frac.refcount = 0; __pyx_pybuffernd_frac.data = NULL; __pyx_pybuffernd_frac.rcbuffer = &__pyx_pybuffer_frac; /* "photutils/geometry/rectangular_overlap.pyx":68 * * # Define output array * cdef np.ndarray[DTYPE_t, ndim=2] frac = np.zeros([ny, nx], dtype=DTYPE) # <<<<<<<<<<<<<< * * if use_exact == 1: */ __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_ny); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_nx); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyList_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_1); PyList_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_3); PyList_SET_ITEM(__pyx_t_4, 1, __pyx_t_3); __pyx_t_1 = 0; __pyx_t_3 = 0; __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_DTYPE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_5 = ((PyArrayObject *)__pyx_t_1); { __Pyx_BufFmt_StackElem __pyx_stack[1]; if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_frac.rcbuffer->pybuffer, (PyObject*)__pyx_t_5, &__Pyx_TypeInfo_nn___pyx_t_9photutils_8geometry_19rectangular_overlap_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) { __pyx_v_frac = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_frac.rcbuffer->pybuffer.buf = NULL; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } else {__pyx_pybuffernd_frac.diminfo[0].strides = __pyx_pybuffernd_frac.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_frac.diminfo[0].shape = __pyx_pybuffernd_frac.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_frac.diminfo[1].strides = __pyx_pybuffernd_frac.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_frac.diminfo[1].shape = __pyx_pybuffernd_frac.rcbuffer->pybuffer.shape[1]; } } __pyx_t_5 = 0; __pyx_v_frac = ((PyArrayObject *)__pyx_t_1); __pyx_t_1 = 0; /* "photutils/geometry/rectangular_overlap.pyx":70 * cdef np.ndarray[DTYPE_t, ndim=2] frac = np.zeros([ny, nx], dtype=DTYPE) * * if use_exact == 1: # <<<<<<<<<<<<<< * raise NotImplementedError("Exact mode has not been implemented for " * "rectangular apertures") */ __pyx_t_6 = ((__pyx_v_use_exact == 1) != 0); if (__pyx_t_6) { /* "photutils/geometry/rectangular_overlap.pyx":71 * * if use_exact == 1: * raise NotImplementedError("Exact mode has not been implemented for " # <<<<<<<<<<<<<< * "rectangular apertures") * */ __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_NotImplementedError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "photutils/geometry/rectangular_overlap.pyx":70 * cdef np.ndarray[DTYPE_t, ndim=2] frac = np.zeros([ny, nx], dtype=DTYPE) * * if use_exact == 1: # <<<<<<<<<<<<<< * raise NotImplementedError("Exact mode has not been implemented for " * "rectangular apertures") */ } /* "photutils/geometry/rectangular_overlap.pyx":75 * * # Find the width of each element in x and y * dx = (xmax - xmin) / nx # <<<<<<<<<<<<<< * dy = (ymax - ymin) / ny * */ __pyx_t_7 = (__pyx_v_xmax - __pyx_v_xmin); if (unlikely(__pyx_v_nx == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "float division"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_v_dx = (__pyx_t_7 / ((double)__pyx_v_nx)); /* "photutils/geometry/rectangular_overlap.pyx":76 * # Find the width of each element in x and y * dx = (xmax - xmin) / nx * dy = (ymax - ymin) / ny # <<<<<<<<<<<<<< * * # TODO: can implement a bounding box here for efficiency (as for the */ __pyx_t_7 = (__pyx_v_ymax - __pyx_v_ymin); if (unlikely(__pyx_v_ny == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "float division"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_v_dy = (__pyx_t_7 / ((double)__pyx_v_ny)); /* "photutils/geometry/rectangular_overlap.pyx":81 * # circular and elliptical aperture photometry) * * for i in range(nx): # <<<<<<<<<<<<<< * pxmin = xmin + i * dx # lower end of pixel * pxmax = pxmin + dx # upper end of pixel */ __pyx_t_8 = __pyx_v_nx; for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_8; __pyx_t_9+=1) { __pyx_v_i = __pyx_t_9; /* "photutils/geometry/rectangular_overlap.pyx":82 * * for i in range(nx): * pxmin = xmin + i * dx # lower end of pixel # <<<<<<<<<<<<<< * pxmax = pxmin + dx # upper end of pixel * for j in range(ny): */ __pyx_v_pxmin = (__pyx_v_xmin + (__pyx_v_i * __pyx_v_dx)); /* "photutils/geometry/rectangular_overlap.pyx":83 * for i in range(nx): * pxmin = xmin + i * dx # lower end of pixel * pxmax = pxmin + dx # upper end of pixel # <<<<<<<<<<<<<< * for j in range(ny): * pymin = ymin + j * dy */ __pyx_v_pxmax = (__pyx_v_pxmin + __pyx_v_dx); /* "photutils/geometry/rectangular_overlap.pyx":84 * pxmin = xmin + i * dx # lower end of pixel * pxmax = pxmin + dx # upper end of pixel * for j in range(ny): # <<<<<<<<<<<<<< * pymin = ymin + j * dy * pymax = pymin + dy */ __pyx_t_10 = __pyx_v_ny; for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) { __pyx_v_j = __pyx_t_11; /* "photutils/geometry/rectangular_overlap.pyx":85 * pxmax = pxmin + dx # upper end of pixel * for j in range(ny): * pymin = ymin + j * dy # <<<<<<<<<<<<<< * pymax = pymin + dy * frac[j, i] = rectangular_overlap_single_subpixel( */ __pyx_v_pymin = (__pyx_v_ymin + (__pyx_v_j * __pyx_v_dy)); /* "photutils/geometry/rectangular_overlap.pyx":86 * for j in range(ny): * pymin = ymin + j * dy * pymax = pymin + dy # <<<<<<<<<<<<<< * frac[j, i] = rectangular_overlap_single_subpixel( * pxmin, pymin, pxmax, pymax, width, height, theta, */ __pyx_v_pymax = (__pyx_v_pymin + __pyx_v_dy); /* "photutils/geometry/rectangular_overlap.pyx":87 * pymin = ymin + j * dy * pymax = pymin + dy * frac[j, i] = rectangular_overlap_single_subpixel( # <<<<<<<<<<<<<< * pxmin, pymin, pxmax, pymax, width, height, theta, * subpixels) */ __pyx_t_12 = __pyx_v_j; __pyx_t_13 = __pyx_v_i; __pyx_t_14 = -1; if (unlikely(__pyx_t_12 >= (size_t)__pyx_pybuffernd_frac.diminfo[0].shape)) __pyx_t_14 = 0; if (unlikely(__pyx_t_13 >= (size_t)__pyx_pybuffernd_frac.diminfo[1].shape)) __pyx_t_14 = 1; if (unlikely(__pyx_t_14 != -1)) { __Pyx_RaiseBufferIndexError(__pyx_t_14); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } *__Pyx_BufPtrStrided2d(__pyx_t_9photutils_8geometry_19rectangular_overlap_DTYPE_t *, __pyx_pybuffernd_frac.rcbuffer->pybuffer.buf, __pyx_t_12, __pyx_pybuffernd_frac.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_frac.diminfo[1].strides) = __pyx_f_9photutils_8geometry_19rectangular_overlap_rectangular_overlap_single_subpixel(__pyx_v_pxmin, __pyx_v_pymin, __pyx_v_pxmax, __pyx_v_pymax, __pyx_v_width, __pyx_v_height, __pyx_v_theta, __pyx_v_subpixels); } } /* "photutils/geometry/rectangular_overlap.pyx":91 * subpixels) * * return frac # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(((PyObject *)__pyx_v_frac)); __pyx_r = ((PyObject *)__pyx_v_frac); goto __pyx_L0; /* "photutils/geometry/rectangular_overlap.pyx":26 * * * def rectangular_overlap_grid(double xmin, double xmax, double ymin, # <<<<<<<<<<<<<< * double ymax, int nx, int ny, double width, * double height, double theta, int use_exact, */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_frac.rcbuffer->pybuffer); __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} __Pyx_AddTraceback("photutils.geometry.rectangular_overlap.rectangular_overlap_grid", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; goto __pyx_L2; __pyx_L0:; __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_frac.rcbuffer->pybuffer); __pyx_L2:; __Pyx_XDECREF((PyObject *)__pyx_v_frac); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "photutils/geometry/rectangular_overlap.pyx":94 * * * cdef double rectangular_overlap_single_subpixel(double x0, double y0, # <<<<<<<<<<<<<< * double x1, double y1, * double width, double height, */ static double __pyx_f_9photutils_8geometry_19rectangular_overlap_rectangular_overlap_single_subpixel(double __pyx_v_x0, double __pyx_v_y0, double __pyx_v_x1, double __pyx_v_y1, double __pyx_v_width, double __pyx_v_height, double __pyx_v_theta, int __pyx_v_subpixels) { CYTHON_UNUSED unsigned int __pyx_v_i; CYTHON_UNUSED unsigned int __pyx_v_j; double __pyx_v_x; double __pyx_v_y; double __pyx_v_frac; double __pyx_v_cos_theta; double __pyx_v_sin_theta; double __pyx_v_half_width; double __pyx_v_half_height; double __pyx_v_dx; double __pyx_v_dy; double __pyx_v_x_tr; double __pyx_v_y_tr; double __pyx_r; __Pyx_RefNannyDeclarations double __pyx_t_1; int __pyx_t_2; unsigned int __pyx_t_3; int __pyx_t_4; unsigned int __pyx_t_5; int __pyx_t_6; int __pyx_t_7; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("rectangular_overlap_single_subpixel", 0); /* "photutils/geometry/rectangular_overlap.pyx":105 * cdef unsigned int i, j * cdef double x, y * cdef double frac = 0. # Accumulator. # <<<<<<<<<<<<<< * cdef double cos_theta = cos(theta) * cdef double sin_theta = sin(theta) */ __pyx_v_frac = 0.; /* "photutils/geometry/rectangular_overlap.pyx":106 * cdef double x, y * cdef double frac = 0. # Accumulator. * cdef double cos_theta = cos(theta) # <<<<<<<<<<<<<< * cdef double sin_theta = sin(theta) * cdef double half_width, half_height */ __pyx_v_cos_theta = cos(__pyx_v_theta); /* "photutils/geometry/rectangular_overlap.pyx":107 * cdef double frac = 0. # Accumulator. * cdef double cos_theta = cos(theta) * cdef double sin_theta = sin(theta) # <<<<<<<<<<<<<< * cdef double half_width, half_height * */ __pyx_v_sin_theta = sin(__pyx_v_theta); /* "photutils/geometry/rectangular_overlap.pyx":110 * cdef double half_width, half_height * * half_width = width / 2. # <<<<<<<<<<<<<< * half_height = height / 2. * */ __pyx_v_half_width = (__pyx_v_width / 2.); /* "photutils/geometry/rectangular_overlap.pyx":111 * * half_width = width / 2. * half_height = height / 2. # <<<<<<<<<<<<<< * * dx = (x1 - x0) / subpixels */ __pyx_v_half_height = (__pyx_v_height / 2.); /* "photutils/geometry/rectangular_overlap.pyx":113 * half_height = height / 2. * * dx = (x1 - x0) / subpixels # <<<<<<<<<<<<<< * dy = (y1 - y0) / subpixels * */ __pyx_t_1 = (__pyx_v_x1 - __pyx_v_x0); if (unlikely(__pyx_v_subpixels == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "float division"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_v_dx = (__pyx_t_1 / ((double)__pyx_v_subpixels)); /* "photutils/geometry/rectangular_overlap.pyx":114 * * dx = (x1 - x0) / subpixels * dy = (y1 - y0) / subpixels # <<<<<<<<<<<<<< * * x = x0 - 0.5 * dx */ __pyx_t_1 = (__pyx_v_y1 - __pyx_v_y0); if (unlikely(__pyx_v_subpixels == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "float division"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_v_dy = (__pyx_t_1 / ((double)__pyx_v_subpixels)); /* "photutils/geometry/rectangular_overlap.pyx":116 * dy = (y1 - y0) / subpixels * * x = x0 - 0.5 * dx # <<<<<<<<<<<<<< * for i in range(subpixels): * x += dx */ __pyx_v_x = (__pyx_v_x0 - (0.5 * __pyx_v_dx)); /* "photutils/geometry/rectangular_overlap.pyx":117 * * x = x0 - 0.5 * dx * for i in range(subpixels): # <<<<<<<<<<<<<< * x += dx * y = y0 - 0.5 * dy */ __pyx_t_2 = __pyx_v_subpixels; for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) { __pyx_v_i = __pyx_t_3; /* "photutils/geometry/rectangular_overlap.pyx":118 * x = x0 - 0.5 * dx * for i in range(subpixels): * x += dx # <<<<<<<<<<<<<< * y = y0 - 0.5 * dy * for j in range(subpixels): */ __pyx_v_x = (__pyx_v_x + __pyx_v_dx); /* "photutils/geometry/rectangular_overlap.pyx":119 * for i in range(subpixels): * x += dx * y = y0 - 0.5 * dy # <<<<<<<<<<<<<< * for j in range(subpixels): * y += dy */ __pyx_v_y = (__pyx_v_y0 - (0.5 * __pyx_v_dy)); /* "photutils/geometry/rectangular_overlap.pyx":120 * x += dx * y = y0 - 0.5 * dy * for j in range(subpixels): # <<<<<<<<<<<<<< * y += dy * */ __pyx_t_4 = __pyx_v_subpixels; for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) { __pyx_v_j = __pyx_t_5; /* "photutils/geometry/rectangular_overlap.pyx":121 * y = y0 - 0.5 * dy * for j in range(subpixels): * y += dy # <<<<<<<<<<<<<< * * # Transform into frame of rotated rectangle */ __pyx_v_y = (__pyx_v_y + __pyx_v_dy); /* "photutils/geometry/rectangular_overlap.pyx":124 * * # Transform into frame of rotated rectangle * x_tr = y * sin_theta + x * cos_theta # <<<<<<<<<<<<<< * y_tr = y * cos_theta - x * sin_theta * */ __pyx_v_x_tr = ((__pyx_v_y * __pyx_v_sin_theta) + (__pyx_v_x * __pyx_v_cos_theta)); /* "photutils/geometry/rectangular_overlap.pyx":125 * # Transform into frame of rotated rectangle * x_tr = y * sin_theta + x * cos_theta * y_tr = y * cos_theta - x * sin_theta # <<<<<<<<<<<<<< * * if fabs(x_tr) < half_width and fabs(y_tr) < half_height: */ __pyx_v_y_tr = ((__pyx_v_y * __pyx_v_cos_theta) - (__pyx_v_x * __pyx_v_sin_theta)); /* "photutils/geometry/rectangular_overlap.pyx":127 * y_tr = y * cos_theta - x * sin_theta * * if fabs(x_tr) < half_width and fabs(y_tr) < half_height: # <<<<<<<<<<<<<< * frac += 1. * */ __pyx_t_7 = ((fabs(__pyx_v_x_tr) < __pyx_v_half_width) != 0); if (__pyx_t_7) { } else { __pyx_t_6 = __pyx_t_7; goto __pyx_L8_bool_binop_done; } __pyx_t_7 = ((fabs(__pyx_v_y_tr) < __pyx_v_half_height) != 0); __pyx_t_6 = __pyx_t_7; __pyx_L8_bool_binop_done:; if (__pyx_t_6) { /* "photutils/geometry/rectangular_overlap.pyx":128 * * if fabs(x_tr) < half_width and fabs(y_tr) < half_height: * frac += 1. # <<<<<<<<<<<<<< * * return frac / (subpixels * subpixels) */ __pyx_v_frac = (__pyx_v_frac + 1.); /* "photutils/geometry/rectangular_overlap.pyx":127 * y_tr = y * cos_theta - x * sin_theta * * if fabs(x_tr) < half_width and fabs(y_tr) < half_height: # <<<<<<<<<<<<<< * frac += 1. * */ } } } /* "photutils/geometry/rectangular_overlap.pyx":130 * frac += 1. * * return frac / (subpixels * subpixels) # <<<<<<<<<<<<<< */ __pyx_t_2 = (__pyx_v_subpixels * __pyx_v_subpixels); if (unlikely(__pyx_t_2 == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "float division"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_r = (__pyx_v_frac / ((double)__pyx_t_2)); goto __pyx_L0; /* "photutils/geometry/rectangular_overlap.pyx":94 * * * cdef double rectangular_overlap_single_subpixel(double x0, double y0, # <<<<<<<<<<<<<< * double x1, double y1, * double width, double height, */ /* function exit code */ __pyx_L1_error:; __Pyx_WriteUnraisable("photutils.geometry.rectangular_overlap.rectangular_overlap_single_subpixel", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0); __pyx_r = 0; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":197 * # experimental exception made for __getbuffer__ and __releasebuffer__ * # -- the details of this may change. * def __getbuffer__(ndarray self, Py_buffer* info, int flags): # <<<<<<<<<<<<<< * # This implementation of getbuffer is geared towards Cython * # requirements, and does not yet fullfill the PEP. */ /* Python wrapper */ static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/ static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0); __pyx_r = __pyx_pf_5numpy_7ndarray___getbuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { int __pyx_v_copy_shape; int __pyx_v_i; int __pyx_v_ndim; int __pyx_v_endian_detector; int __pyx_v_little_endian; int __pyx_v_t; char *__pyx_v_f; PyArray_Descr *__pyx_v_descr = 0; int __pyx_v_offset; int __pyx_v_hasfields; int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; PyObject *__pyx_t_3 = NULL; int __pyx_t_4; int __pyx_t_5; PyObject *__pyx_t_6 = NULL; char *__pyx_t_7; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__getbuffer__", 0); if (__pyx_v_info != NULL) { __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None); __Pyx_GIVEREF(__pyx_v_info->obj); } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":203 * # of flags * * if info == NULL: return # <<<<<<<<<<<<<< * * cdef int copy_shape, i, ndim */ __pyx_t_1 = ((__pyx_v_info == NULL) != 0); if (__pyx_t_1) { __pyx_r = 0; goto __pyx_L0; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":206 * * cdef int copy_shape, i, ndim * cdef int endian_detector = 1 # <<<<<<<<<<<<<< * cdef bint little_endian = ((&endian_detector)[0] != 0) * */ __pyx_v_endian_detector = 1; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":207 * cdef int copy_shape, i, ndim * cdef int endian_detector = 1 * cdef bint little_endian = ((&endian_detector)[0] != 0) # <<<<<<<<<<<<<< * * ndim = PyArray_NDIM(self) */ __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":209 * cdef bint little_endian = ((&endian_detector)[0] != 0) * * ndim = PyArray_NDIM(self) # <<<<<<<<<<<<<< * * if sizeof(npy_intp) != sizeof(Py_ssize_t): */ __pyx_v_ndim = PyArray_NDIM(__pyx_v_self); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":211 * ndim = PyArray_NDIM(self) * * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< * copy_shape = 1 * else: */ __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0); if (__pyx_t_1) { /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":212 * * if sizeof(npy_intp) != sizeof(Py_ssize_t): * copy_shape = 1 # <<<<<<<<<<<<<< * else: * copy_shape = 0 */ __pyx_v_copy_shape = 1; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":211 * ndim = PyArray_NDIM(self) * * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< * copy_shape = 1 * else: */ goto __pyx_L4; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":214 * copy_shape = 1 * else: * copy_shape = 0 # <<<<<<<<<<<<<< * * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) */ /*else*/ { __pyx_v_copy_shape = 0; } __pyx_L4:; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":216 * copy_shape = 0 * * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): * raise ValueError(u"ndarray is not C contiguous") */ __pyx_t_2 = (((__pyx_v_flags & PyBUF_C_CONTIGUOUS) == PyBUF_C_CONTIGUOUS) != 0); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L6_bool_binop_done; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":217 * * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): # <<<<<<<<<<<<<< * raise ValueError(u"ndarray is not C contiguous") * */ __pyx_t_2 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_C_CONTIGUOUS) != 0)) != 0); __pyx_t_1 = __pyx_t_2; __pyx_L6_bool_binop_done:; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":216 * copy_shape = 0 * * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): * raise ValueError(u"ndarray is not C contiguous") */ if (__pyx_t_1) { /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":218 * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<< * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) */ __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; {__pyx_filename = __pyx_f[1]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":216 * copy_shape = 0 * * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): * raise ValueError(u"ndarray is not C contiguous") */ } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":220 * raise ValueError(u"ndarray is not C contiguous") * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): * raise ValueError(u"ndarray is not Fortran contiguous") */ __pyx_t_2 = (((__pyx_v_flags & PyBUF_F_CONTIGUOUS) == PyBUF_F_CONTIGUOUS) != 0); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L9_bool_binop_done; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":221 * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): # <<<<<<<<<<<<<< * raise ValueError(u"ndarray is not Fortran contiguous") * */ __pyx_t_2 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_F_CONTIGUOUS) != 0)) != 0); __pyx_t_1 = __pyx_t_2; __pyx_L9_bool_binop_done:; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":220 * raise ValueError(u"ndarray is not C contiguous") * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): * raise ValueError(u"ndarray is not Fortran contiguous") */ if (__pyx_t_1) { /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":222 * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<< * * info.buf = PyArray_DATA(self) */ __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; {__pyx_filename = __pyx_f[1]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":220 * raise ValueError(u"ndarray is not C contiguous") * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): * raise ValueError(u"ndarray is not Fortran contiguous") */ } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":224 * raise ValueError(u"ndarray is not Fortran contiguous") * * info.buf = PyArray_DATA(self) # <<<<<<<<<<<<<< * info.ndim = ndim * if copy_shape: */ __pyx_v_info->buf = PyArray_DATA(__pyx_v_self); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":225 * * info.buf = PyArray_DATA(self) * info.ndim = ndim # <<<<<<<<<<<<<< * if copy_shape: * # Allocate new buffer for strides and shape info. */ __pyx_v_info->ndim = __pyx_v_ndim; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":226 * info.buf = PyArray_DATA(self) * info.ndim = ndim * if copy_shape: # <<<<<<<<<<<<<< * # Allocate new buffer for strides and shape info. * # This is allocated as one block, strides first. */ __pyx_t_1 = (__pyx_v_copy_shape != 0); if (__pyx_t_1) { /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":229 * # Allocate new buffer for strides and shape info. * # This is allocated as one block, strides first. * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) # <<<<<<<<<<<<<< * info.shape = info.strides + ndim * for i in range(ndim): */ __pyx_v_info->strides = ((Py_ssize_t *)malloc((((sizeof(Py_ssize_t)) * ((size_t)__pyx_v_ndim)) * 2))); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":230 * # This is allocated as one block, strides first. * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) * info.shape = info.strides + ndim # <<<<<<<<<<<<<< * for i in range(ndim): * info.strides[i] = PyArray_STRIDES(self)[i] */ __pyx_v_info->shape = (__pyx_v_info->strides + __pyx_v_ndim); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":231 * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) * info.shape = info.strides + ndim * for i in range(ndim): # <<<<<<<<<<<<<< * info.strides[i] = PyArray_STRIDES(self)[i] * info.shape[i] = PyArray_DIMS(self)[i] */ __pyx_t_4 = __pyx_v_ndim; for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) { __pyx_v_i = __pyx_t_5; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":232 * info.shape = info.strides + ndim * for i in range(ndim): * info.strides[i] = PyArray_STRIDES(self)[i] # <<<<<<<<<<<<<< * info.shape[i] = PyArray_DIMS(self)[i] * else: */ (__pyx_v_info->strides[__pyx_v_i]) = (PyArray_STRIDES(__pyx_v_self)[__pyx_v_i]); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":233 * for i in range(ndim): * info.strides[i] = PyArray_STRIDES(self)[i] * info.shape[i] = PyArray_DIMS(self)[i] # <<<<<<<<<<<<<< * else: * info.strides = PyArray_STRIDES(self) */ (__pyx_v_info->shape[__pyx_v_i]) = (PyArray_DIMS(__pyx_v_self)[__pyx_v_i]); } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":226 * info.buf = PyArray_DATA(self) * info.ndim = ndim * if copy_shape: # <<<<<<<<<<<<<< * # Allocate new buffer for strides and shape info. * # This is allocated as one block, strides first. */ goto __pyx_L11; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":235 * info.shape[i] = PyArray_DIMS(self)[i] * else: * info.strides = PyArray_STRIDES(self) # <<<<<<<<<<<<<< * info.shape = PyArray_DIMS(self) * info.suboffsets = NULL */ /*else*/ { __pyx_v_info->strides = ((Py_ssize_t *)PyArray_STRIDES(__pyx_v_self)); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":236 * else: * info.strides = PyArray_STRIDES(self) * info.shape = PyArray_DIMS(self) # <<<<<<<<<<<<<< * info.suboffsets = NULL * info.itemsize = PyArray_ITEMSIZE(self) */ __pyx_v_info->shape = ((Py_ssize_t *)PyArray_DIMS(__pyx_v_self)); } __pyx_L11:; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":237 * info.strides = PyArray_STRIDES(self) * info.shape = PyArray_DIMS(self) * info.suboffsets = NULL # <<<<<<<<<<<<<< * info.itemsize = PyArray_ITEMSIZE(self) * info.readonly = not PyArray_ISWRITEABLE(self) */ __pyx_v_info->suboffsets = NULL; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":238 * info.shape = PyArray_DIMS(self) * info.suboffsets = NULL * info.itemsize = PyArray_ITEMSIZE(self) # <<<<<<<<<<<<<< * info.readonly = not PyArray_ISWRITEABLE(self) * */ __pyx_v_info->itemsize = PyArray_ITEMSIZE(__pyx_v_self); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":239 * info.suboffsets = NULL * info.itemsize = PyArray_ITEMSIZE(self) * info.readonly = not PyArray_ISWRITEABLE(self) # <<<<<<<<<<<<<< * * cdef int t */ __pyx_v_info->readonly = (!(PyArray_ISWRITEABLE(__pyx_v_self) != 0)); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":242 * * cdef int t * cdef char* f = NULL # <<<<<<<<<<<<<< * cdef dtype descr = self.descr * cdef int offset */ __pyx_v_f = NULL; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":243 * cdef int t * cdef char* f = NULL * cdef dtype descr = self.descr # <<<<<<<<<<<<<< * cdef int offset * */ __pyx_t_3 = ((PyObject *)__pyx_v_self->descr); __Pyx_INCREF(__pyx_t_3); __pyx_v_descr = ((PyArray_Descr *)__pyx_t_3); __pyx_t_3 = 0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":246 * cdef int offset * * cdef bint hasfields = PyDataType_HASFIELDS(descr) # <<<<<<<<<<<<<< * * if not hasfields and not copy_shape: */ __pyx_v_hasfields = PyDataType_HASFIELDS(__pyx_v_descr); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":248 * cdef bint hasfields = PyDataType_HASFIELDS(descr) * * if not hasfields and not copy_shape: # <<<<<<<<<<<<<< * # do not call releasebuffer * info.obj = None */ __pyx_t_2 = ((!(__pyx_v_hasfields != 0)) != 0); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L15_bool_binop_done; } __pyx_t_2 = ((!(__pyx_v_copy_shape != 0)) != 0); __pyx_t_1 = __pyx_t_2; __pyx_L15_bool_binop_done:; if (__pyx_t_1) { /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":250 * if not hasfields and not copy_shape: * # do not call releasebuffer * info.obj = None # <<<<<<<<<<<<<< * else: * # need to call releasebuffer */ __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_info->obj); __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = Py_None; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":248 * cdef bint hasfields = PyDataType_HASFIELDS(descr) * * if not hasfields and not copy_shape: # <<<<<<<<<<<<<< * # do not call releasebuffer * info.obj = None */ goto __pyx_L14; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":253 * else: * # need to call releasebuffer * info.obj = self # <<<<<<<<<<<<<< * * if not hasfields: */ /*else*/ { __Pyx_INCREF(((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); __Pyx_GOTREF(__pyx_v_info->obj); __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = ((PyObject *)__pyx_v_self); } __pyx_L14:; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":255 * info.obj = self * * if not hasfields: # <<<<<<<<<<<<<< * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or */ __pyx_t_1 = ((!(__pyx_v_hasfields != 0)) != 0); if (__pyx_t_1) { /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":256 * * if not hasfields: * t = descr.type_num # <<<<<<<<<<<<<< * if ((descr.byteorder == c'>' and little_endian) or * (descr.byteorder == c'<' and not little_endian)): */ __pyx_t_4 = __pyx_v_descr->type_num; __pyx_v_t = __pyx_t_4; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":257 * if not hasfields: * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< * (descr.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") */ __pyx_t_2 = ((__pyx_v_descr->byteorder == '>') != 0); if (!__pyx_t_2) { goto __pyx_L20_next_or; } else { } __pyx_t_2 = (__pyx_v_little_endian != 0); if (!__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L19_bool_binop_done; } __pyx_L20_next_or:; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":258 * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or * (descr.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<< * raise ValueError(u"Non-native byte order not supported") * if t == NPY_BYTE: f = "b" */ __pyx_t_2 = ((__pyx_v_descr->byteorder == '<') != 0); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L19_bool_binop_done; } __pyx_t_2 = ((!(__pyx_v_little_endian != 0)) != 0); __pyx_t_1 = __pyx_t_2; __pyx_L19_bool_binop_done:; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":257 * if not hasfields: * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< * (descr.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") */ if (__pyx_t_1) { /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":259 * if ((descr.byteorder == c'>' and little_endian) or * (descr.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< * if t == NPY_BYTE: f = "b" * elif t == NPY_UBYTE: f = "B" */ __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; {__pyx_filename = __pyx_f[1]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":257 * if not hasfields: * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< * (descr.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") */ } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":260 * (descr.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") * if t == NPY_BYTE: f = "b" # <<<<<<<<<<<<<< * elif t == NPY_UBYTE: f = "B" * elif t == NPY_SHORT: f = "h" */ switch (__pyx_v_t) { case NPY_BYTE: __pyx_v_f = __pyx_k_b; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":261 * raise ValueError(u"Non-native byte order not supported") * if t == NPY_BYTE: f = "b" * elif t == NPY_UBYTE: f = "B" # <<<<<<<<<<<<<< * elif t == NPY_SHORT: f = "h" * elif t == NPY_USHORT: f = "H" */ case NPY_UBYTE: __pyx_v_f = __pyx_k_B; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":262 * if t == NPY_BYTE: f = "b" * elif t == NPY_UBYTE: f = "B" * elif t == NPY_SHORT: f = "h" # <<<<<<<<<<<<<< * elif t == NPY_USHORT: f = "H" * elif t == NPY_INT: f = "i" */ case NPY_SHORT: __pyx_v_f = __pyx_k_h; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":263 * elif t == NPY_UBYTE: f = "B" * elif t == NPY_SHORT: f = "h" * elif t == NPY_USHORT: f = "H" # <<<<<<<<<<<<<< * elif t == NPY_INT: f = "i" * elif t == NPY_UINT: f = "I" */ case NPY_USHORT: __pyx_v_f = __pyx_k_H; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":264 * elif t == NPY_SHORT: f = "h" * elif t == NPY_USHORT: f = "H" * elif t == NPY_INT: f = "i" # <<<<<<<<<<<<<< * elif t == NPY_UINT: f = "I" * elif t == NPY_LONG: f = "l" */ case NPY_INT: __pyx_v_f = __pyx_k_i; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":265 * elif t == NPY_USHORT: f = "H" * elif t == NPY_INT: f = "i" * elif t == NPY_UINT: f = "I" # <<<<<<<<<<<<<< * elif t == NPY_LONG: f = "l" * elif t == NPY_ULONG: f = "L" */ case NPY_UINT: __pyx_v_f = __pyx_k_I; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":266 * elif t == NPY_INT: f = "i" * elif t == NPY_UINT: f = "I" * elif t == NPY_LONG: f = "l" # <<<<<<<<<<<<<< * elif t == NPY_ULONG: f = "L" * elif t == NPY_LONGLONG: f = "q" */ case NPY_LONG: __pyx_v_f = __pyx_k_l; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":267 * elif t == NPY_UINT: f = "I" * elif t == NPY_LONG: f = "l" * elif t == NPY_ULONG: f = "L" # <<<<<<<<<<<<<< * elif t == NPY_LONGLONG: f = "q" * elif t == NPY_ULONGLONG: f = "Q" */ case NPY_ULONG: __pyx_v_f = __pyx_k_L; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":268 * elif t == NPY_LONG: f = "l" * elif t == NPY_ULONG: f = "L" * elif t == NPY_LONGLONG: f = "q" # <<<<<<<<<<<<<< * elif t == NPY_ULONGLONG: f = "Q" * elif t == NPY_FLOAT: f = "f" */ case NPY_LONGLONG: __pyx_v_f = __pyx_k_q; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":269 * elif t == NPY_ULONG: f = "L" * elif t == NPY_LONGLONG: f = "q" * elif t == NPY_ULONGLONG: f = "Q" # <<<<<<<<<<<<<< * elif t == NPY_FLOAT: f = "f" * elif t == NPY_DOUBLE: f = "d" */ case NPY_ULONGLONG: __pyx_v_f = __pyx_k_Q; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":270 * elif t == NPY_LONGLONG: f = "q" * elif t == NPY_ULONGLONG: f = "Q" * elif t == NPY_FLOAT: f = "f" # <<<<<<<<<<<<<< * elif t == NPY_DOUBLE: f = "d" * elif t == NPY_LONGDOUBLE: f = "g" */ case NPY_FLOAT: __pyx_v_f = __pyx_k_f; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":271 * elif t == NPY_ULONGLONG: f = "Q" * elif t == NPY_FLOAT: f = "f" * elif t == NPY_DOUBLE: f = "d" # <<<<<<<<<<<<<< * elif t == NPY_LONGDOUBLE: f = "g" * elif t == NPY_CFLOAT: f = "Zf" */ case NPY_DOUBLE: __pyx_v_f = __pyx_k_d; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":272 * elif t == NPY_FLOAT: f = "f" * elif t == NPY_DOUBLE: f = "d" * elif t == NPY_LONGDOUBLE: f = "g" # <<<<<<<<<<<<<< * elif t == NPY_CFLOAT: f = "Zf" * elif t == NPY_CDOUBLE: f = "Zd" */ case NPY_LONGDOUBLE: __pyx_v_f = __pyx_k_g; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":273 * elif t == NPY_DOUBLE: f = "d" * elif t == NPY_LONGDOUBLE: f = "g" * elif t == NPY_CFLOAT: f = "Zf" # <<<<<<<<<<<<<< * elif t == NPY_CDOUBLE: f = "Zd" * elif t == NPY_CLONGDOUBLE: f = "Zg" */ case NPY_CFLOAT: __pyx_v_f = __pyx_k_Zf; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":274 * elif t == NPY_LONGDOUBLE: f = "g" * elif t == NPY_CFLOAT: f = "Zf" * elif t == NPY_CDOUBLE: f = "Zd" # <<<<<<<<<<<<<< * elif t == NPY_CLONGDOUBLE: f = "Zg" * elif t == NPY_OBJECT: f = "O" */ case NPY_CDOUBLE: __pyx_v_f = __pyx_k_Zd; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":275 * elif t == NPY_CFLOAT: f = "Zf" * elif t == NPY_CDOUBLE: f = "Zd" * elif t == NPY_CLONGDOUBLE: f = "Zg" # <<<<<<<<<<<<<< * elif t == NPY_OBJECT: f = "O" * else: */ case NPY_CLONGDOUBLE: __pyx_v_f = __pyx_k_Zg; break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":276 * elif t == NPY_CDOUBLE: f = "Zd" * elif t == NPY_CLONGDOUBLE: f = "Zg" * elif t == NPY_OBJECT: f = "O" # <<<<<<<<<<<<<< * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) */ case NPY_OBJECT: __pyx_v_f = __pyx_k_O; break; default: /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":278 * elif t == NPY_OBJECT: f = "O" * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< * info.format = f * return */ __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_t); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = PyUnicode_Format(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_t_3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_6, 0, 0, 0); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; {__pyx_filename = __pyx_f[1]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L1_error;} break; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":279 * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) * info.format = f # <<<<<<<<<<<<<< * return * else: */ __pyx_v_info->format = __pyx_v_f; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":280 * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) * info.format = f * return # <<<<<<<<<<<<<< * else: * info.format = stdlib.malloc(_buffer_format_string_len) */ __pyx_r = 0; goto __pyx_L0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":255 * info.obj = self * * if not hasfields: # <<<<<<<<<<<<<< * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or */ } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":282 * return * else: * info.format = stdlib.malloc(_buffer_format_string_len) # <<<<<<<<<<<<<< * info.format[0] = c'^' # Native data types, manual alignment * offset = 0 */ /*else*/ { __pyx_v_info->format = ((char *)malloc(0xFF)); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":283 * else: * info.format = stdlib.malloc(_buffer_format_string_len) * info.format[0] = c'^' # Native data types, manual alignment # <<<<<<<<<<<<<< * offset = 0 * f = _util_dtypestring(descr, info.format + 1, */ (__pyx_v_info->format[0]) = '^'; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":284 * info.format = stdlib.malloc(_buffer_format_string_len) * info.format[0] = c'^' # Native data types, manual alignment * offset = 0 # <<<<<<<<<<<<<< * f = _util_dtypestring(descr, info.format + 1, * info.format + _buffer_format_string_len, */ __pyx_v_offset = 0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":285 * info.format[0] = c'^' # Native data types, manual alignment * offset = 0 * f = _util_dtypestring(descr, info.format + 1, # <<<<<<<<<<<<<< * info.format + _buffer_format_string_len, * &offset) */ __pyx_t_7 = __pyx_f_5numpy__util_dtypestring(__pyx_v_descr, (__pyx_v_info->format + 1), (__pyx_v_info->format + 0xFF), (&__pyx_v_offset)); if (unlikely(__pyx_t_7 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_f = __pyx_t_7; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":288 * info.format + _buffer_format_string_len, * &offset) * f[0] = c'\0' # Terminate format string # <<<<<<<<<<<<<< * * def __releasebuffer__(ndarray self, Py_buffer* info): */ (__pyx_v_f[0]) = '\x00'; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":197 * # experimental exception made for __getbuffer__ and __releasebuffer__ * # -- the details of this may change. * def __getbuffer__(ndarray self, Py_buffer* info, int flags): # <<<<<<<<<<<<<< * # This implementation of getbuffer is geared towards Cython * # requirements, and does not yet fullfill the PEP. */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_6); __Pyx_AddTraceback("numpy.ndarray.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; if (__pyx_v_info != NULL && __pyx_v_info->obj != NULL) { __Pyx_GOTREF(__pyx_v_info->obj); __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = NULL; } goto __pyx_L2; __pyx_L0:; if (__pyx_v_info != NULL && __pyx_v_info->obj == Py_None) { __Pyx_GOTREF(Py_None); __Pyx_DECREF(Py_None); __pyx_v_info->obj = NULL; } __pyx_L2:; __Pyx_XDECREF((PyObject *)__pyx_v_descr); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":290 * f[0] = c'\0' # Terminate format string * * def __releasebuffer__(ndarray self, Py_buffer* info): # <<<<<<<<<<<<<< * if PyArray_HASFIELDS(self): * stdlib.free(info.format) */ /* Python wrapper */ static CYTHON_UNUSED void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info); /*proto*/ static CYTHON_UNUSED void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__releasebuffer__ (wrapper)", 0); __pyx_pf_5numpy_7ndarray_2__releasebuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info)); /* function exit code */ __Pyx_RefNannyFinishContext(); } static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info) { __Pyx_RefNannyDeclarations int __pyx_t_1; __Pyx_RefNannySetupContext("__releasebuffer__", 0); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":291 * * def __releasebuffer__(ndarray self, Py_buffer* info): * if PyArray_HASFIELDS(self): # <<<<<<<<<<<<<< * stdlib.free(info.format) * if sizeof(npy_intp) != sizeof(Py_ssize_t): */ __pyx_t_1 = (PyArray_HASFIELDS(__pyx_v_self) != 0); if (__pyx_t_1) { /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":292 * def __releasebuffer__(ndarray self, Py_buffer* info): * if PyArray_HASFIELDS(self): * stdlib.free(info.format) # <<<<<<<<<<<<<< * if sizeof(npy_intp) != sizeof(Py_ssize_t): * stdlib.free(info.strides) */ free(__pyx_v_info->format); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":291 * * def __releasebuffer__(ndarray self, Py_buffer* info): * if PyArray_HASFIELDS(self): # <<<<<<<<<<<<<< * stdlib.free(info.format) * if sizeof(npy_intp) != sizeof(Py_ssize_t): */ } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":293 * if PyArray_HASFIELDS(self): * stdlib.free(info.format) * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< * stdlib.free(info.strides) * # info.shape was stored after info.strides in the same block */ __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0); if (__pyx_t_1) { /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":294 * stdlib.free(info.format) * if sizeof(npy_intp) != sizeof(Py_ssize_t): * stdlib.free(info.strides) # <<<<<<<<<<<<<< * # info.shape was stored after info.strides in the same block * */ free(__pyx_v_info->strides); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":293 * if PyArray_HASFIELDS(self): * stdlib.free(info.format) * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< * stdlib.free(info.strides) * # info.shape was stored after info.strides in the same block */ } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":290 * f[0] = c'\0' # Terminate format string * * def __releasebuffer__(ndarray self, Py_buffer* info): # <<<<<<<<<<<<<< * if PyArray_HASFIELDS(self): * stdlib.free(info.format) */ /* function exit code */ __Pyx_RefNannyFinishContext(); } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":770 * ctypedef npy_cdouble complex_t * * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< * return PyArray_MultiIterNew(1, a) * */ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__pyx_v_a) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("PyArray_MultiIterNew1", 0); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":771 * * cdef inline object PyArray_MultiIterNew1(a): * return PyArray_MultiIterNew(1, a) # <<<<<<<<<<<<<< * * cdef inline object PyArray_MultiIterNew2(a, b): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyArray_MultiIterNew(1, ((void *)__pyx_v_a)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 771; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":770 * ctypedef npy_cdouble complex_t * * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< * return PyArray_MultiIterNew(1, a) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("numpy.PyArray_MultiIterNew1", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":773 * return PyArray_MultiIterNew(1, a) * * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< * return PyArray_MultiIterNew(2, a, b) * */ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__pyx_v_a, PyObject *__pyx_v_b) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("PyArray_MultiIterNew2", 0); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":774 * * cdef inline object PyArray_MultiIterNew2(a, b): * return PyArray_MultiIterNew(2, a, b) # <<<<<<<<<<<<<< * * cdef inline object PyArray_MultiIterNew3(a, b, c): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyArray_MultiIterNew(2, ((void *)__pyx_v_a), ((void *)__pyx_v_b)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 774; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":773 * return PyArray_MultiIterNew(1, a) * * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< * return PyArray_MultiIterNew(2, a, b) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("numpy.PyArray_MultiIterNew2", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":776 * return PyArray_MultiIterNew(2, a, b) * * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< * return PyArray_MultiIterNew(3, a, b, c) * */ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("PyArray_MultiIterNew3", 0); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":777 * * cdef inline object PyArray_MultiIterNew3(a, b, c): * return PyArray_MultiIterNew(3, a, b, c) # <<<<<<<<<<<<<< * * cdef inline object PyArray_MultiIterNew4(a, b, c, d): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyArray_MultiIterNew(3, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 777; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":776 * return PyArray_MultiIterNew(2, a, b) * * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< * return PyArray_MultiIterNew(3, a, b, c) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("numpy.PyArray_MultiIterNew3", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":779 * return PyArray_MultiIterNew(3, a, b, c) * * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< * return PyArray_MultiIterNew(4, a, b, c, d) * */ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("PyArray_MultiIterNew4", 0); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":780 * * cdef inline object PyArray_MultiIterNew4(a, b, c, d): * return PyArray_MultiIterNew(4, a, b, c, d) # <<<<<<<<<<<<<< * * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyArray_MultiIterNew(4, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 780; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":779 * return PyArray_MultiIterNew(3, a, b, c) * * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< * return PyArray_MultiIterNew(4, a, b, c, d) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("numpy.PyArray_MultiIterNew4", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":782 * return PyArray_MultiIterNew(4, a, b, c, d) * * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< * return PyArray_MultiIterNew(5, a, b, c, d, e) * */ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d, PyObject *__pyx_v_e) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("PyArray_MultiIterNew5", 0); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":783 * * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): * return PyArray_MultiIterNew(5, a, b, c, d, e) # <<<<<<<<<<<<<< * * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyArray_MultiIterNew(5, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d), ((void *)__pyx_v_e)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 783; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":782 * return PyArray_MultiIterNew(4, a, b, c, d) * * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< * return PyArray_MultiIterNew(5, a, b, c, d, e) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("numpy.PyArray_MultiIterNew5", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":785 * return PyArray_MultiIterNew(5, a, b, c, d, e) * * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: # <<<<<<<<<<<<<< * # Recursive utility function used in __getbuffer__ to get format * # string. The new location in the format string is returned. */ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_descr, char *__pyx_v_f, char *__pyx_v_end, int *__pyx_v_offset) { PyArray_Descr *__pyx_v_child = 0; int __pyx_v_endian_detector; int __pyx_v_little_endian; PyObject *__pyx_v_fields = 0; PyObject *__pyx_v_childname = NULL; PyObject *__pyx_v_new_offset = NULL; PyObject *__pyx_v_t = NULL; char *__pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; Py_ssize_t __pyx_t_2; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; int __pyx_t_5; int __pyx_t_6; int __pyx_t_7; long __pyx_t_8; char *__pyx_t_9; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("_util_dtypestring", 0); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":790 * * cdef dtype child * cdef int endian_detector = 1 # <<<<<<<<<<<<<< * cdef bint little_endian = ((&endian_detector)[0] != 0) * cdef tuple fields */ __pyx_v_endian_detector = 1; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":791 * cdef dtype child * cdef int endian_detector = 1 * cdef bint little_endian = ((&endian_detector)[0] != 0) # <<<<<<<<<<<<<< * cdef tuple fields * */ __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":794 * cdef tuple fields * * for childname in descr.names: # <<<<<<<<<<<<<< * fields = descr.fields[childname] * child, new_offset = fields */ if (unlikely(__pyx_v_descr->names == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_t_1 = __pyx_v_descr->names; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; for (;;) { if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); #endif __Pyx_XDECREF_SET(__pyx_v_childname, __pyx_t_3); __pyx_t_3 = 0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":795 * * for childname in descr.names: * fields = descr.fields[childname] # <<<<<<<<<<<<<< * child, new_offset = fields * */ if (unlikely(__pyx_v_descr->fields == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_t_3 = __Pyx_PyDict_GetItem(__pyx_v_descr->fields, __pyx_v_childname); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; __Pyx_GOTREF(__pyx_t_3); if (!(likely(PyTuple_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_XDECREF_SET(__pyx_v_fields, ((PyObject*)__pyx_t_3)); __pyx_t_3 = 0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":796 * for childname in descr.names: * fields = descr.fields[childname] * child, new_offset = fields # <<<<<<<<<<<<<< * * if (end - f) - (new_offset - offset[0]) < 15: */ if (likely(__pyx_v_fields != Py_None)) { PyObject* sequence = __pyx_v_fields; #if CYTHON_COMPILING_IN_CPYTHON Py_ssize_t size = Py_SIZE(sequence); #else Py_ssize_t size = PySequence_Size(sequence); #endif if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); #else __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); #endif } else { __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_dtype))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_XDECREF_SET(__pyx_v_child, ((PyArray_Descr *)__pyx_t_3)); __pyx_t_3 = 0; __Pyx_XDECREF_SET(__pyx_v_new_offset, __pyx_t_4); __pyx_t_4 = 0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":798 * child, new_offset = fields * * if (end - f) - (new_offset - offset[0]) < 15: # <<<<<<<<<<<<<< * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") * */ __pyx_t_4 = __Pyx_PyInt_From_int((__pyx_v_offset[0])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyNumber_Subtract(__pyx_v_new_offset, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = ((((__pyx_v_end - __pyx_v_f) - ((int)__pyx_t_5)) < 15) != 0); if (__pyx_t_6) { /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":799 * * if (end - f) - (new_offset - offset[0]) < 15: * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<< * * if ((child.byteorder == c'>' and little_endian) or */ __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":798 * child, new_offset = fields * * if (end - f) - (new_offset - offset[0]) < 15: # <<<<<<<<<<<<<< * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") * */ } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":801 * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") * * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< * (child.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") */ __pyx_t_7 = ((__pyx_v_child->byteorder == '>') != 0); if (!__pyx_t_7) { goto __pyx_L8_next_or; } else { } __pyx_t_7 = (__pyx_v_little_endian != 0); if (!__pyx_t_7) { } else { __pyx_t_6 = __pyx_t_7; goto __pyx_L7_bool_binop_done; } __pyx_L8_next_or:; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":802 * * if ((child.byteorder == c'>' and little_endian) or * (child.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<< * raise ValueError(u"Non-native byte order not supported") * # One could encode it in the format string and have Cython */ __pyx_t_7 = ((__pyx_v_child->byteorder == '<') != 0); if (__pyx_t_7) { } else { __pyx_t_6 = __pyx_t_7; goto __pyx_L7_bool_binop_done; } __pyx_t_7 = ((!(__pyx_v_little_endian != 0)) != 0); __pyx_t_6 = __pyx_t_7; __pyx_L7_bool_binop_done:; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":801 * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") * * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< * (child.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") */ if (__pyx_t_6) { /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":803 * if ((child.byteorder == c'>' and little_endian) or * (child.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< * # One could encode it in the format string and have Cython * # complain instead, BUT: < and > in format strings also imply */ __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; {__pyx_filename = __pyx_f[1]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":801 * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") * * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< * (child.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") */ } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":813 * * # Output padding bytes * while offset[0] < new_offset: # <<<<<<<<<<<<<< * f[0] = 120 # "x"; pad byte * f += 1 */ while (1) { __pyx_t_3 = __Pyx_PyInt_From_int((__pyx_v_offset[0])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyObject_RichCompare(__pyx_t_3, __pyx_v_new_offset, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (!__pyx_t_6) break; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":814 * # Output padding bytes * while offset[0] < new_offset: * f[0] = 120 # "x"; pad byte # <<<<<<<<<<<<<< * f += 1 * offset[0] += 1 */ (__pyx_v_f[0]) = 0x78; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":815 * while offset[0] < new_offset: * f[0] = 120 # "x"; pad byte * f += 1 # <<<<<<<<<<<<<< * offset[0] += 1 * */ __pyx_v_f = (__pyx_v_f + 1); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":816 * f[0] = 120 # "x"; pad byte * f += 1 * offset[0] += 1 # <<<<<<<<<<<<<< * * offset[0] += child.itemsize */ __pyx_t_8 = 0; (__pyx_v_offset[__pyx_t_8]) = ((__pyx_v_offset[__pyx_t_8]) + 1); } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":818 * offset[0] += 1 * * offset[0] += child.itemsize # <<<<<<<<<<<<<< * * if not PyDataType_HASFIELDS(child): */ __pyx_t_8 = 0; (__pyx_v_offset[__pyx_t_8]) = ((__pyx_v_offset[__pyx_t_8]) + __pyx_v_child->elsize); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":820 * offset[0] += child.itemsize * * if not PyDataType_HASFIELDS(child): # <<<<<<<<<<<<<< * t = child.type_num * if end - f < 5: */ __pyx_t_6 = ((!(PyDataType_HASFIELDS(__pyx_v_child) != 0)) != 0); if (__pyx_t_6) { /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":821 * * if not PyDataType_HASFIELDS(child): * t = child.type_num # <<<<<<<<<<<<<< * if end - f < 5: * raise RuntimeError(u"Format string allocated too short.") */ __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_child->type_num); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_4); __pyx_t_4 = 0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":822 * if not PyDataType_HASFIELDS(child): * t = child.type_num * if end - f < 5: # <<<<<<<<<<<<<< * raise RuntimeError(u"Format string allocated too short.") * */ __pyx_t_6 = (((__pyx_v_end - __pyx_v_f) < 5) != 0); if (__pyx_t_6) { /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":823 * t = child.type_num * if end - f < 5: * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<< * * # Until ticket #99 is fixed, use integers to avoid warnings */ __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; {__pyx_filename = __pyx_f[1]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":822 * if not PyDataType_HASFIELDS(child): * t = child.type_num * if end - f < 5: # <<<<<<<<<<<<<< * raise RuntimeError(u"Format string allocated too short.") * */ } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":826 * * # Until ticket #99 is fixed, use integers to avoid warnings * if t == NPY_BYTE: f[0] = 98 #"b" # <<<<<<<<<<<<<< * elif t == NPY_UBYTE: f[0] = 66 #"B" * elif t == NPY_SHORT: f[0] = 104 #"h" */ __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_BYTE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 98; goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":827 * # Until ticket #99 is fixed, use integers to avoid warnings * if t == NPY_BYTE: f[0] = 98 #"b" * elif t == NPY_UBYTE: f[0] = 66 #"B" # <<<<<<<<<<<<<< * elif t == NPY_SHORT: f[0] = 104 #"h" * elif t == NPY_USHORT: f[0] = 72 #"H" */ __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_UBYTE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 66; goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":828 * if t == NPY_BYTE: f[0] = 98 #"b" * elif t == NPY_UBYTE: f[0] = 66 #"B" * elif t == NPY_SHORT: f[0] = 104 #"h" # <<<<<<<<<<<<<< * elif t == NPY_USHORT: f[0] = 72 #"H" * elif t == NPY_INT: f[0] = 105 #"i" */ __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_SHORT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 0x68; goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":829 * elif t == NPY_UBYTE: f[0] = 66 #"B" * elif t == NPY_SHORT: f[0] = 104 #"h" * elif t == NPY_USHORT: f[0] = 72 #"H" # <<<<<<<<<<<<<< * elif t == NPY_INT: f[0] = 105 #"i" * elif t == NPY_UINT: f[0] = 73 #"I" */ __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_USHORT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 72; goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":830 * elif t == NPY_SHORT: f[0] = 104 #"h" * elif t == NPY_USHORT: f[0] = 72 #"H" * elif t == NPY_INT: f[0] = 105 #"i" # <<<<<<<<<<<<<< * elif t == NPY_UINT: f[0] = 73 #"I" * elif t == NPY_LONG: f[0] = 108 #"l" */ __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_INT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 0x69; goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":831 * elif t == NPY_USHORT: f[0] = 72 #"H" * elif t == NPY_INT: f[0] = 105 #"i" * elif t == NPY_UINT: f[0] = 73 #"I" # <<<<<<<<<<<<<< * elif t == NPY_LONG: f[0] = 108 #"l" * elif t == NPY_ULONG: f[0] = 76 #"L" */ __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_UINT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 73; goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":832 * elif t == NPY_INT: f[0] = 105 #"i" * elif t == NPY_UINT: f[0] = 73 #"I" * elif t == NPY_LONG: f[0] = 108 #"l" # <<<<<<<<<<<<<< * elif t == NPY_ULONG: f[0] = 76 #"L" * elif t == NPY_LONGLONG: f[0] = 113 #"q" */ __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONG); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 0x6C; goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":833 * elif t == NPY_UINT: f[0] = 73 #"I" * elif t == NPY_LONG: f[0] = 108 #"l" * elif t == NPY_ULONG: f[0] = 76 #"L" # <<<<<<<<<<<<<< * elif t == NPY_LONGLONG: f[0] = 113 #"q" * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" */ __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_ULONG); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 76; goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":834 * elif t == NPY_LONG: f[0] = 108 #"l" * elif t == NPY_ULONG: f[0] = 76 #"L" * elif t == NPY_LONGLONG: f[0] = 113 #"q" # <<<<<<<<<<<<<< * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" * elif t == NPY_FLOAT: f[0] = 102 #"f" */ __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONGLONG); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 0x71; goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":835 * elif t == NPY_ULONG: f[0] = 76 #"L" * elif t == NPY_LONGLONG: f[0] = 113 #"q" * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" # <<<<<<<<<<<<<< * elif t == NPY_FLOAT: f[0] = 102 #"f" * elif t == NPY_DOUBLE: f[0] = 100 #"d" */ __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_ULONGLONG); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 81; goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":836 * elif t == NPY_LONGLONG: f[0] = 113 #"q" * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" * elif t == NPY_FLOAT: f[0] = 102 #"f" # <<<<<<<<<<<<<< * elif t == NPY_DOUBLE: f[0] = 100 #"d" * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" */ __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_FLOAT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 0x66; goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":837 * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" * elif t == NPY_FLOAT: f[0] = 102 #"f" * elif t == NPY_DOUBLE: f[0] = 100 #"d" # <<<<<<<<<<<<<< * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf */ __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_DOUBLE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 0x64; goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":838 * elif t == NPY_FLOAT: f[0] = 102 #"f" * elif t == NPY_DOUBLE: f[0] = 100 #"d" * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" # <<<<<<<<<<<<<< * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd */ __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONGDOUBLE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 0x67; goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":839 * elif t == NPY_DOUBLE: f[0] = 100 #"d" * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf # <<<<<<<<<<<<<< * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg */ __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CFLOAT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 90; (__pyx_v_f[1]) = 0x66; __pyx_v_f = (__pyx_v_f + 1); goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":840 * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd # <<<<<<<<<<<<<< * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg * elif t == NPY_OBJECT: f[0] = 79 #"O" */ __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CDOUBLE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 90; (__pyx_v_f[1]) = 0x64; __pyx_v_f = (__pyx_v_f + 1); goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":841 * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg # <<<<<<<<<<<<<< * elif t == NPY_OBJECT: f[0] = 79 #"O" * else: */ __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CLONGDOUBLE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 90; (__pyx_v_f[1]) = 0x67; __pyx_v_f = (__pyx_v_f + 1); goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":842 * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg * elif t == NPY_OBJECT: f[0] = 79 #"O" # <<<<<<<<<<<<<< * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) */ __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_OBJECT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 79; goto __pyx_L15; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":844 * elif t == NPY_OBJECT: f[0] = 79 #"O" * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< * f += 1 * else: */ /*else*/ { __pyx_t_3 = PyUnicode_Format(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_v_t); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; {__pyx_filename = __pyx_f[1]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_L15:; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":845 * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) * f += 1 # <<<<<<<<<<<<<< * else: * # Cython ignores struct boundary information ("T{...}"), */ __pyx_v_f = (__pyx_v_f + 1); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":820 * offset[0] += child.itemsize * * if not PyDataType_HASFIELDS(child): # <<<<<<<<<<<<<< * t = child.type_num * if end - f < 5: */ goto __pyx_L13; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":849 * # Cython ignores struct boundary information ("T{...}"), * # so don't output it * f = _util_dtypestring(child, f, end, offset) # <<<<<<<<<<<<<< * return f * */ /*else*/ { __pyx_t_9 = __pyx_f_5numpy__util_dtypestring(__pyx_v_child, __pyx_v_f, __pyx_v_end, __pyx_v_offset); if (unlikely(__pyx_t_9 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 849; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_f = __pyx_t_9; } __pyx_L13:; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":794 * cdef tuple fields * * for childname in descr.names: # <<<<<<<<<<<<<< * fields = descr.fields[childname] * child, new_offset = fields */ } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":850 * # so don't output it * f = _util_dtypestring(child, f, end, offset) * return f # <<<<<<<<<<<<<< * * */ __pyx_r = __pyx_v_f; goto __pyx_L0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":785 * return PyArray_MultiIterNew(5, a, b, c, d, e) * * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: # <<<<<<<<<<<<<< * # Recursive utility function used in __getbuffer__ to get format * # string. The new location in the format string is returned. */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("numpy._util_dtypestring", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF((PyObject *)__pyx_v_child); __Pyx_XDECREF(__pyx_v_fields); __Pyx_XDECREF(__pyx_v_childname); __Pyx_XDECREF(__pyx_v_new_offset); __Pyx_XDECREF(__pyx_v_t); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":966 * * * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< * cdef PyObject* baseptr * if base is None: */ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_arr, PyObject *__pyx_v_base) { PyObject *__pyx_v_baseptr; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; __Pyx_RefNannySetupContext("set_array_base", 0); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":968 * cdef inline void set_array_base(ndarray arr, object base): * cdef PyObject* baseptr * if base is None: # <<<<<<<<<<<<<< * baseptr = NULL * else: */ __pyx_t_1 = (__pyx_v_base == Py_None); __pyx_t_2 = (__pyx_t_1 != 0); if (__pyx_t_2) { /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":969 * cdef PyObject* baseptr * if base is None: * baseptr = NULL # <<<<<<<<<<<<<< * else: * Py_INCREF(base) # important to do this before decref below! */ __pyx_v_baseptr = NULL; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":968 * cdef inline void set_array_base(ndarray arr, object base): * cdef PyObject* baseptr * if base is None: # <<<<<<<<<<<<<< * baseptr = NULL * else: */ goto __pyx_L3; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":971 * baseptr = NULL * else: * Py_INCREF(base) # important to do this before decref below! # <<<<<<<<<<<<<< * baseptr = base * Py_XDECREF(arr.base) */ /*else*/ { Py_INCREF(__pyx_v_base); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":972 * else: * Py_INCREF(base) # important to do this before decref below! * baseptr = base # <<<<<<<<<<<<<< * Py_XDECREF(arr.base) * arr.base = baseptr */ __pyx_v_baseptr = ((PyObject *)__pyx_v_base); } __pyx_L3:; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":973 * Py_INCREF(base) # important to do this before decref below! * baseptr = base * Py_XDECREF(arr.base) # <<<<<<<<<<<<<< * arr.base = baseptr * */ Py_XDECREF(__pyx_v_arr->base); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":974 * baseptr = base * Py_XDECREF(arr.base) * arr.base = baseptr # <<<<<<<<<<<<<< * * cdef inline object get_array_base(ndarray arr): */ __pyx_v_arr->base = __pyx_v_baseptr; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":966 * * * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< * cdef PyObject* baseptr * if base is None: */ /* function exit code */ __Pyx_RefNannyFinishContext(); } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":976 * arr.base = baseptr * * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< * if arr.base is NULL: * return None */ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__pyx_v_arr) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; __Pyx_RefNannySetupContext("get_array_base", 0); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":977 * * cdef inline object get_array_base(ndarray arr): * if arr.base is NULL: # <<<<<<<<<<<<<< * return None * else: */ __pyx_t_1 = ((__pyx_v_arr->base == NULL) != 0); if (__pyx_t_1) { /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":978 * cdef inline object get_array_base(ndarray arr): * if arr.base is NULL: * return None # <<<<<<<<<<<<<< * else: * return arr.base */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(Py_None); __pyx_r = Py_None; goto __pyx_L0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":977 * * cdef inline object get_array_base(ndarray arr): * if arr.base is NULL: # <<<<<<<<<<<<<< * return None * else: */ } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":980 * return None * else: * return arr.base # <<<<<<<<<<<<<< */ /*else*/ { __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(((PyObject *)__pyx_v_arr->base)); __pyx_r = ((PyObject *)__pyx_v_arr->base); goto __pyx_L0; } /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":976 * arr.base = baseptr * * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< * if arr.base is NULL: * return None */ /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyMethodDef __pyx_methods[] = { {0, 0, 0, 0} }; #if PY_MAJOR_VERSION >= 3 static struct PyModuleDef __pyx_moduledef = { #if PY_VERSION_HEX < 0x03020000 { PyObject_HEAD_INIT(NULL) NULL, 0, NULL }, #else PyModuleDef_HEAD_INIT, #endif "rectangular_overlap", 0, /* m_doc */ -1, /* m_size */ __pyx_methods /* m_methods */, NULL, /* m_reload */ NULL, /* m_traverse */ NULL, /* m_clear */ NULL /* m_free */ }; #endif static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_DTYPE, __pyx_k_DTYPE, sizeof(__pyx_k_DTYPE), 0, 0, 1, 1}, {&__pyx_kp_u_Exact_mode_has_not_been_implemen, __pyx_k_Exact_mode_has_not_been_implemen, sizeof(__pyx_k_Exact_mode_has_not_been_implemen), 0, 1, 0, 0}, {&__pyx_kp_u_Format_string_allocated_too_shor, __pyx_k_Format_string_allocated_too_shor, sizeof(__pyx_k_Format_string_allocated_too_shor), 0, 1, 0, 0}, {&__pyx_kp_u_Format_string_allocated_too_shor_2, __pyx_k_Format_string_allocated_too_shor_2, sizeof(__pyx_k_Format_string_allocated_too_shor_2), 0, 1, 0, 0}, {&__pyx_kp_u_Non_native_byte_order_not_suppor, __pyx_k_Non_native_byte_order_not_suppor, sizeof(__pyx_k_Non_native_byte_order_not_suppor), 0, 1, 0, 0}, {&__pyx_n_s_NotImplementedError, __pyx_k_NotImplementedError, sizeof(__pyx_k_NotImplementedError), 0, 0, 1, 1}, {&__pyx_n_s_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 0, 0, 1, 1}, {&__pyx_kp_s_Users_lbradley_Dropbox_softw_de, __pyx_k_Users_lbradley_Dropbox_softw_de, sizeof(__pyx_k_Users_lbradley_Dropbox_softw_de), 0, 0, 1, 0}, {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1}, {&__pyx_n_s_all, __pyx_k_all, sizeof(__pyx_k_all), 0, 0, 1, 1}, {&__pyx_n_s_dtype, __pyx_k_dtype, sizeof(__pyx_k_dtype), 0, 0, 1, 1}, {&__pyx_n_s_dx, __pyx_k_dx, sizeof(__pyx_k_dx), 0, 0, 1, 1}, {&__pyx_n_s_dy, __pyx_k_dy, sizeof(__pyx_k_dy), 0, 0, 1, 1}, {&__pyx_n_s_float64, __pyx_k_float64, sizeof(__pyx_k_float64), 0, 0, 1, 1}, {&__pyx_n_s_frac, __pyx_k_frac, sizeof(__pyx_k_frac), 0, 0, 1, 1}, {&__pyx_n_s_height, __pyx_k_height, sizeof(__pyx_k_height), 0, 0, 1, 1}, {&__pyx_n_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 1}, {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1}, {&__pyx_n_s_j, __pyx_k_j, sizeof(__pyx_k_j), 0, 0, 1, 1}, {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, {&__pyx_kp_u_ndarray_is_not_C_contiguous, __pyx_k_ndarray_is_not_C_contiguous, sizeof(__pyx_k_ndarray_is_not_C_contiguous), 0, 1, 0, 0}, {&__pyx_kp_u_ndarray_is_not_Fortran_contiguou, __pyx_k_ndarray_is_not_Fortran_contiguou, sizeof(__pyx_k_ndarray_is_not_Fortran_contiguou), 0, 1, 0, 0}, {&__pyx_n_s_np, __pyx_k_np, sizeof(__pyx_k_np), 0, 0, 1, 1}, {&__pyx_n_s_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 0, 0, 1, 1}, {&__pyx_n_s_nx, __pyx_k_nx, sizeof(__pyx_k_nx), 0, 0, 1, 1}, {&__pyx_n_s_ny, __pyx_k_ny, sizeof(__pyx_k_ny), 0, 0, 1, 1}, {&__pyx_n_s_photutils_geometry_rectangular_o, __pyx_k_photutils_geometry_rectangular_o, sizeof(__pyx_k_photutils_geometry_rectangular_o), 0, 0, 1, 1}, {&__pyx_n_s_pxmax, __pyx_k_pxmax, sizeof(__pyx_k_pxmax), 0, 0, 1, 1}, {&__pyx_n_s_pxmin, __pyx_k_pxmin, sizeof(__pyx_k_pxmin), 0, 0, 1, 1}, {&__pyx_n_s_pymax, __pyx_k_pymax, sizeof(__pyx_k_pymax), 0, 0, 1, 1}, {&__pyx_n_s_pymin, __pyx_k_pymin, sizeof(__pyx_k_pymin), 0, 0, 1, 1}, {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1}, {&__pyx_n_s_rectangular_overlap_grid, __pyx_k_rectangular_overlap_grid, sizeof(__pyx_k_rectangular_overlap_grid), 0, 0, 1, 1}, {&__pyx_n_u_rectangular_overlap_grid, __pyx_k_rectangular_overlap_grid, sizeof(__pyx_k_rectangular_overlap_grid), 0, 1, 0, 1}, {&__pyx_n_s_subpixels, __pyx_k_subpixels, sizeof(__pyx_k_subpixels), 0, 0, 1, 1}, {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, {&__pyx_n_s_theta, __pyx_k_theta, sizeof(__pyx_k_theta), 0, 0, 1, 1}, {&__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_k_unknown_dtype_code_in_numpy_pxd, sizeof(__pyx_k_unknown_dtype_code_in_numpy_pxd), 0, 1, 0, 0}, {&__pyx_n_s_use_exact, __pyx_k_use_exact, sizeof(__pyx_k_use_exact), 0, 0, 1, 1}, {&__pyx_n_s_width, __pyx_k_width, sizeof(__pyx_k_width), 0, 0, 1, 1}, {&__pyx_n_s_x, __pyx_k_x, sizeof(__pyx_k_x), 0, 0, 1, 1}, {&__pyx_n_s_xmax, __pyx_k_xmax, sizeof(__pyx_k_xmax), 0, 0, 1, 1}, {&__pyx_n_s_xmin, __pyx_k_xmin, sizeof(__pyx_k_xmin), 0, 0, 1, 1}, {&__pyx_n_s_y, __pyx_k_y, sizeof(__pyx_k_y), 0, 0, 1, 1}, {&__pyx_n_s_ymax, __pyx_k_ymax, sizeof(__pyx_k_ymax), 0, 0, 1, 1}, {&__pyx_n_s_ymin, __pyx_k_ymin, sizeof(__pyx_k_ymin), 0, 0, 1, 1}, {&__pyx_n_s_zeros, __pyx_k_zeros, sizeof(__pyx_k_zeros), 0, 0, 1, 1}, {0, 0, 0, 0, 0, 0, 0} }; static int __Pyx_InitCachedBuiltins(void) { __pyx_builtin_NotImplementedError = __Pyx_GetBuiltinName(__pyx_n_s_NotImplementedError); if (!__pyx_builtin_NotImplementedError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} return 0; __pyx_L1_error:; return -1; } static int __Pyx_InitCachedConstants(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); /* "photutils/geometry/rectangular_overlap.pyx":71 * * if use_exact == 1: * raise NotImplementedError("Exact mode has not been implemented for " # <<<<<<<<<<<<<< * "rectangular apertures") * */ __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_u_Exact_mode_has_not_been_implemen); if (unlikely(!__pyx_tuple_)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple_); __Pyx_GIVEREF(__pyx_tuple_); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":218 * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<< * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) */ __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_C_contiguous); if (unlikely(!__pyx_tuple__2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__2); __Pyx_GIVEREF(__pyx_tuple__2); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":222 * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<< * * info.buf = PyArray_DATA(self) */ __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_Fortran_contiguou); if (unlikely(!__pyx_tuple__3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__3); __Pyx_GIVEREF(__pyx_tuple__3); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":259 * if ((descr.byteorder == c'>' and little_endian) or * (descr.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< * if t == NPY_BYTE: f = "b" * elif t == NPY_UBYTE: f = "B" */ __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__4); __Pyx_GIVEREF(__pyx_tuple__4); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":799 * * if (end - f) - (new_offset - offset[0]) < 15: * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<< * * if ((child.byteorder == c'>' and little_endian) or */ __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor); if (unlikely(!__pyx_tuple__5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__5); __Pyx_GIVEREF(__pyx_tuple__5); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":803 * if ((child.byteorder == c'>' and little_endian) or * (child.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< * # One could encode it in the format string and have Cython * # complain instead, BUT: < and > in format strings also imply */ __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__6); __Pyx_GIVEREF(__pyx_tuple__6); /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":823 * t = child.type_num * if end - f < 5: * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<< * * # Until ticket #99 is fixed, use integers to avoid warnings */ __pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor_2); if (unlikely(!__pyx_tuple__7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__7); __Pyx_GIVEREF(__pyx_tuple__7); /* "photutils/geometry/rectangular_overlap.pyx":26 * * * def rectangular_overlap_grid(double xmin, double xmax, double ymin, # <<<<<<<<<<<<<< * double ymax, int nx, int ny, double width, * double height, double theta, int use_exact, */ __pyx_tuple__8 = PyTuple_Pack(22, __pyx_n_s_xmin, __pyx_n_s_xmax, __pyx_n_s_ymin, __pyx_n_s_ymax, __pyx_n_s_nx, __pyx_n_s_ny, __pyx_n_s_width, __pyx_n_s_height, __pyx_n_s_theta, __pyx_n_s_use_exact, __pyx_n_s_subpixels, __pyx_n_s_i, __pyx_n_s_j, __pyx_n_s_x, __pyx_n_s_y, __pyx_n_s_dx, __pyx_n_s_dy, __pyx_n_s_pxmin, __pyx_n_s_pxmax, __pyx_n_s_pymin, __pyx_n_s_pymax, __pyx_n_s_frac); if (unlikely(!__pyx_tuple__8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__8); __Pyx_GIVEREF(__pyx_tuple__8); __pyx_codeobj__9 = (PyObject*)__Pyx_PyCode_New(11, 0, 22, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__8, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_lbradley_Dropbox_softw_de, __pyx_n_s_rectangular_overlap_grid, 26, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; __Pyx_RefNannyFinishContext(); return -1; } static int __Pyx_InitGlobals(void) { if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; return 0; __pyx_L1_error:; return -1; } #if PY_MAJOR_VERSION < 3 PyMODINIT_FUNC initrectangular_overlap(void); /*proto*/ PyMODINIT_FUNC initrectangular_overlap(void) #else PyMODINIT_FUNC PyInit_rectangular_overlap(void); /*proto*/ PyMODINIT_FUNC PyInit_rectangular_overlap(void) #endif { PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannyDeclarations #if CYTHON_REFNANNY __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); if (!__Pyx_RefNanny) { PyErr_Clear(); __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny"); if (!__Pyx_RefNanny) Py_FatalError("failed to import 'refnanny' module"); } #endif __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit_rectangular_overlap(void)", 0); if (__Pyx_check_binary_version() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #ifdef __Pyx_CyFunction_USED if (__pyx_CyFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif #ifdef __Pyx_FusedFunction_USED if (__pyx_FusedFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif #ifdef __Pyx_Coroutine_USED if (__pyx_Coroutine_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif #ifdef __Pyx_Generator_USED if (__pyx_Generator_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif #ifdef __Pyx_StopAsyncIteration_USED if (__pyx_StopAsyncIteration_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /*--- Library function declarations ---*/ /*--- Threads initialization code ---*/ #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS #ifdef WITH_THREAD /* Python build with threading support? */ PyEval_InitThreads(); #endif #endif /*--- Module creation code ---*/ #if PY_MAJOR_VERSION < 3 __pyx_m = Py_InitModule4("rectangular_overlap", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); #else __pyx_m = PyModule_Create(&__pyx_moduledef); #endif if (unlikely(!__pyx_m)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_INCREF(__pyx_d); __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #if CYTHON_COMPILING_IN_PYPY Py_INCREF(__pyx_b); #endif if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; /*--- Initialize various global constants etc. ---*/ if (__Pyx_InitGlobals() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) if (__Pyx_init_sys_getdefaultencoding_params() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif if (__pyx_module_is_main_photutils__geometry__rectangular_overlap) { if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } #if PY_MAJOR_VERSION >= 3 { PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (!PyDict_GetItemString(modules, "photutils.geometry.rectangular_overlap")) { if (unlikely(PyDict_SetItemString(modules, "photutils.geometry.rectangular_overlap", __pyx_m) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } } #endif /*--- Builtin init code ---*/ if (__Pyx_InitCachedBuiltins() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /*--- Constants init code ---*/ if (__Pyx_InitCachedConstants() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /*--- Global init code ---*/ /*--- Variable export code ---*/ /*--- Function export code ---*/ /*--- Type init code ---*/ /*--- Type import code ---*/ __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "type", #if CYTHON_COMPILING_IN_PYPY sizeof(PyTypeObject), #else sizeof(PyHeapTypeObject), #endif 0); if (unlikely(!__pyx_ptype_7cpython_4type_type)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_7cpython_4bool_bool = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "bool", sizeof(PyBoolObject), 0); if (unlikely(!__pyx_ptype_7cpython_4bool_bool)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_7cpython_7complex_complex = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "complex", sizeof(PyComplexObject), 0); if (unlikely(!__pyx_ptype_7cpython_7complex_complex)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5numpy_dtype = __Pyx_ImportType("numpy", "dtype", sizeof(PyArray_Descr), 0); if (unlikely(!__pyx_ptype_5numpy_dtype)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5numpy_flatiter = __Pyx_ImportType("numpy", "flatiter", sizeof(PyArrayIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_flatiter)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5numpy_broadcast = __Pyx_ImportType("numpy", "broadcast", sizeof(PyArrayMultiIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_broadcast)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5numpy_ndarray = __Pyx_ImportType("numpy", "ndarray", sizeof(PyArrayObject), 0); if (unlikely(!__pyx_ptype_5numpy_ndarray)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5numpy_ufunc = __Pyx_ImportType("numpy", "ufunc", sizeof(PyUFuncObject), 0); if (unlikely(!__pyx_ptype_5numpy_ufunc)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 861; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /*--- Variable import code ---*/ /*--- Function import code ---*/ /*--- Execution code ---*/ #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) if (__Pyx_patch_abc() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /* "photutils/geometry/rectangular_overlap.pyx":5 * from __future__ import (absolute_import, division, print_function, * unicode_literals) * import numpy as np # <<<<<<<<<<<<<< * cimport numpy as np * */ __pyx_t_1 = __Pyx_Import(__pyx_n_s_numpy, 0, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "photutils/geometry/rectangular_overlap.pyx":8 * cimport numpy as np * * __all__ = ['rectangular_overlap_grid'] # <<<<<<<<<<<<<< * * cdef extern from "math.h": */ __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_u_rectangular_overlap_grid); __Pyx_GIVEREF(__pyx_n_u_rectangular_overlap_grid); PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_u_rectangular_overlap_grid); if (PyDict_SetItem(__pyx_d, __pyx_n_s_all, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "photutils/geometry/rectangular_overlap.pyx":20 * from cpython cimport bool * * DTYPE = np.float64 # <<<<<<<<<<<<<< * ctypedef np.float64_t DTYPE_t * */ __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_float64); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_DTYPE, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "photutils/geometry/rectangular_overlap.pyx":26 * * * def rectangular_overlap_grid(double xmin, double xmax, double ymin, # <<<<<<<<<<<<<< * double ymax, int nx, int ny, double width, * double height, double theta, int use_exact, */ __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_9photutils_8geometry_19rectangular_overlap_1rectangular_overlap_grid, NULL, __pyx_n_s_photutils_geometry_rectangular_o); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_rectangular_overlap_grid, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "photutils/geometry/rectangular_overlap.pyx":1 * # Licensed under a 3-clause BSD style license - see LICENSE.rst # <<<<<<<<<<<<<< * * from __future__ import (absolute_import, division, print_function, */ __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "../../../../../../usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":976 * arr.base = baseptr * * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< * if arr.base is NULL: * return None */ /*--- Wrapped vars code ---*/ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); if (__pyx_m) { if (__pyx_d) { __Pyx_AddTraceback("init photutils.geometry.rectangular_overlap", __pyx_clineno, __pyx_lineno, __pyx_filename); } Py_DECREF(__pyx_m); __pyx_m = 0; } else if (!PyErr_Occurred()) { PyErr_SetString(PyExc_ImportError, "init photutils.geometry.rectangular_overlap"); } __pyx_L0:; __Pyx_RefNannyFinishContext(); #if PY_MAJOR_VERSION < 3 return; #else return __pyx_m; #endif } /* --- Runtime support code --- */ #if CYTHON_REFNANNY static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { PyObject *m = NULL, *p = NULL; void *r = NULL; m = PyImport_ImportModule((char *)modname); if (!m) goto end; p = PyObject_GetAttrString(m, (char *)"RefNannyAPI"); if (!p) goto end; r = PyLong_AsVoidPtr(p); end: Py_XDECREF(p); Py_XDECREF(m); return (__Pyx_RefNannyAPIStruct *)r; } #endif static PyObject *__Pyx_GetBuiltinName(PyObject *name) { PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name); if (unlikely(!result)) { PyErr_Format(PyExc_NameError, #if PY_MAJOR_VERSION >= 3 "name '%U' is not defined", name); #else "name '%.200s' is not defined", PyString_AS_STRING(name)); #endif } return result; } static void __Pyx_RaiseArgtupleInvalid( const char* func_name, int exact, Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found) { Py_ssize_t num_expected; const char *more_or_less; if (num_found < num_min) { num_expected = num_min; more_or_less = "at least"; } else { num_expected = num_max; more_or_less = "at most"; } if (exact) { more_or_less = "exactly"; } PyErr_Format(PyExc_TypeError, "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)", func_name, more_or_less, num_expected, (num_expected == 1) ? "" : "s", num_found); } static void __Pyx_RaiseDoubleKeywordsError( const char* func_name, PyObject* kw_name) { PyErr_Format(PyExc_TypeError, #if PY_MAJOR_VERSION >= 3 "%s() got multiple values for keyword argument '%U'", func_name, kw_name); #else "%s() got multiple values for keyword argument '%s'", func_name, PyString_AsString(kw_name)); #endif } static int __Pyx_ParseOptionalKeywords( PyObject *kwds, PyObject **argnames[], PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, const char* function_name) { PyObject *key = 0, *value = 0; Py_ssize_t pos = 0; PyObject*** name; PyObject*** first_kw_arg = argnames + num_pos_args; while (PyDict_Next(kwds, &pos, &key, &value)) { name = first_kw_arg; while (*name && (**name != key)) name++; if (*name) { values[name-argnames] = value; continue; } name = first_kw_arg; #if PY_MAJOR_VERSION < 3 if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) { while (*name) { if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key)) && _PyString_Eq(**name, key)) { values[name-argnames] = value; break; } name++; } if (*name) continue; else { PyObject*** argname = argnames; while (argname != first_kw_arg) { if ((**argname == key) || ( (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key)) && _PyString_Eq(**argname, key))) { goto arg_passed_twice; } argname++; } } } else #endif if (likely(PyUnicode_Check(key))) { while (*name) { int cmp = (**name == key) ? 0 : #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 : #endif PyUnicode_Compare(**name, key); if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; if (cmp == 0) { values[name-argnames] = value; break; } name++; } if (*name) continue; else { PyObject*** argname = argnames; while (argname != first_kw_arg) { int cmp = (**argname == key) ? 0 : #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 : #endif PyUnicode_Compare(**argname, key); if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; if (cmp == 0) goto arg_passed_twice; argname++; } } } else goto invalid_keyword_type; if (kwds2) { if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad; } else { goto invalid_keyword; } } return 0; arg_passed_twice: __Pyx_RaiseDoubleKeywordsError(function_name, key); goto bad; invalid_keyword_type: PyErr_Format(PyExc_TypeError, "%.200s() keywords must be strings", function_name); goto bad; invalid_keyword: PyErr_Format(PyExc_TypeError, #if PY_MAJOR_VERSION < 3 "%.200s() got an unexpected keyword argument '%.200s'", function_name, PyString_AsString(key)); #else "%s() got an unexpected keyword argument '%U'", function_name, key); #endif bad: return -1; } static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) { PyObject *result; #if CYTHON_COMPILING_IN_CPYTHON result = PyDict_GetItem(__pyx_d, name); if (likely(result)) { Py_INCREF(result); } else { #else result = PyObject_GetItem(__pyx_d, name); if (!result) { PyErr_Clear(); #endif result = __Pyx_GetBuiltinName(name); } return result; } #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) { PyObject *result; ternaryfunc call = func->ob_type->tp_call; if (unlikely(!call)) return PyObject_Call(func, arg, kw); if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) return NULL; result = (*call)(func, arg, kw); Py_LeaveRecursiveCall(); if (unlikely(!result) && unlikely(!PyErr_Occurred())) { PyErr_SetString( PyExc_SystemError, "NULL result without error in PyObject_Call"); } return result; } #endif static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { if (unlikely(!type)) { PyErr_SetString(PyExc_SystemError, "Missing type object"); return 0; } if (likely(PyObject_TypeCheck(obj, type))) return 1; PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s", Py_TYPE(obj)->tp_name, type->tp_name); return 0; } static CYTHON_INLINE int __Pyx_IsLittleEndian(void) { unsigned int n = 1; return *(unsigned char*)(&n) != 0; } static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx, __Pyx_BufFmt_StackElem* stack, __Pyx_TypeInfo* type) { stack[0].field = &ctx->root; stack[0].parent_offset = 0; ctx->root.type = type; ctx->root.name = "buffer dtype"; ctx->root.offset = 0; ctx->head = stack; ctx->head->field = &ctx->root; ctx->fmt_offset = 0; ctx->head->parent_offset = 0; ctx->new_packmode = '@'; ctx->enc_packmode = '@'; ctx->new_count = 1; ctx->enc_count = 0; ctx->enc_type = 0; ctx->is_complex = 0; ctx->is_valid_array = 0; ctx->struct_alignment = 0; while (type->typegroup == 'S') { ++ctx->head; ctx->head->field = type->fields; ctx->head->parent_offset = 0; type = type->fields->type; } } static int __Pyx_BufFmt_ParseNumber(const char** ts) { int count; const char* t = *ts; if (*t < '0' || *t > '9') { return -1; } else { count = *t++ - '0'; while (*t >= '0' && *t < '9') { count *= 10; count += *t++ - '0'; } } *ts = t; return count; } static int __Pyx_BufFmt_ExpectNumber(const char **ts) { int number = __Pyx_BufFmt_ParseNumber(ts); if (number == -1) PyErr_Format(PyExc_ValueError,\ "Does not understand character buffer dtype format string ('%c')", **ts); return number; } static void __Pyx_BufFmt_RaiseUnexpectedChar(char ch) { PyErr_Format(PyExc_ValueError, "Unexpected format string character: '%c'", ch); } static const char* __Pyx_BufFmt_DescribeTypeChar(char ch, int is_complex) { switch (ch) { case 'c': return "'char'"; case 'b': return "'signed char'"; case 'B': return "'unsigned char'"; case 'h': return "'short'"; case 'H': return "'unsigned short'"; case 'i': return "'int'"; case 'I': return "'unsigned int'"; case 'l': return "'long'"; case 'L': return "'unsigned long'"; case 'q': return "'long long'"; case 'Q': return "'unsigned long long'"; case 'f': return (is_complex ? "'complex float'" : "'float'"); case 'd': return (is_complex ? "'complex double'" : "'double'"); case 'g': return (is_complex ? "'complex long double'" : "'long double'"); case 'T': return "a struct"; case 'O': return "Python object"; case 'P': return "a pointer"; case 's': case 'p': return "a string"; case 0: return "end"; default: return "unparseable format string"; } } static size_t __Pyx_BufFmt_TypeCharToStandardSize(char ch, int is_complex) { switch (ch) { case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; case 'h': case 'H': return 2; case 'i': case 'I': case 'l': case 'L': return 4; case 'q': case 'Q': return 8; case 'f': return (is_complex ? 8 : 4); case 'd': return (is_complex ? 16 : 8); case 'g': { PyErr_SetString(PyExc_ValueError, "Python does not define a standard format string size for long double ('g').."); return 0; } case 'O': case 'P': return sizeof(void*); default: __Pyx_BufFmt_RaiseUnexpectedChar(ch); return 0; } } static size_t __Pyx_BufFmt_TypeCharToNativeSize(char ch, int is_complex) { switch (ch) { case 'c': case 'b': case 'B': case 's': case 'p': return 1; case 'h': case 'H': return sizeof(short); case 'i': case 'I': return sizeof(int); case 'l': case 'L': return sizeof(long); #ifdef HAVE_LONG_LONG case 'q': case 'Q': return sizeof(PY_LONG_LONG); #endif case 'f': return sizeof(float) * (is_complex ? 2 : 1); case 'd': return sizeof(double) * (is_complex ? 2 : 1); case 'g': return sizeof(long double) * (is_complex ? 2 : 1); case 'O': case 'P': return sizeof(void*); default: { __Pyx_BufFmt_RaiseUnexpectedChar(ch); return 0; } } } typedef struct { char c; short x; } __Pyx_st_short; typedef struct { char c; int x; } __Pyx_st_int; typedef struct { char c; long x; } __Pyx_st_long; typedef struct { char c; float x; } __Pyx_st_float; typedef struct { char c; double x; } __Pyx_st_double; typedef struct { char c; long double x; } __Pyx_st_longdouble; typedef struct { char c; void *x; } __Pyx_st_void_p; #ifdef HAVE_LONG_LONG typedef struct { char c; PY_LONG_LONG x; } __Pyx_st_longlong; #endif static size_t __Pyx_BufFmt_TypeCharToAlignment(char ch, CYTHON_UNUSED int is_complex) { switch (ch) { case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; case 'h': case 'H': return sizeof(__Pyx_st_short) - sizeof(short); case 'i': case 'I': return sizeof(__Pyx_st_int) - sizeof(int); case 'l': case 'L': return sizeof(__Pyx_st_long) - sizeof(long); #ifdef HAVE_LONG_LONG case 'q': case 'Q': return sizeof(__Pyx_st_longlong) - sizeof(PY_LONG_LONG); #endif case 'f': return sizeof(__Pyx_st_float) - sizeof(float); case 'd': return sizeof(__Pyx_st_double) - sizeof(double); case 'g': return sizeof(__Pyx_st_longdouble) - sizeof(long double); case 'P': case 'O': return sizeof(__Pyx_st_void_p) - sizeof(void*); default: __Pyx_BufFmt_RaiseUnexpectedChar(ch); return 0; } } /* These are for computing the padding at the end of the struct to align on the first member of the struct. This will probably the same as above, but we don't have any guarantees. */ typedef struct { short x; char c; } __Pyx_pad_short; typedef struct { int x; char c; } __Pyx_pad_int; typedef struct { long x; char c; } __Pyx_pad_long; typedef struct { float x; char c; } __Pyx_pad_float; typedef struct { double x; char c; } __Pyx_pad_double; typedef struct { long double x; char c; } __Pyx_pad_longdouble; typedef struct { void *x; char c; } __Pyx_pad_void_p; #ifdef HAVE_LONG_LONG typedef struct { PY_LONG_LONG x; char c; } __Pyx_pad_longlong; #endif static size_t __Pyx_BufFmt_TypeCharToPadding(char ch, CYTHON_UNUSED int is_complex) { switch (ch) { case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; case 'h': case 'H': return sizeof(__Pyx_pad_short) - sizeof(short); case 'i': case 'I': return sizeof(__Pyx_pad_int) - sizeof(int); case 'l': case 'L': return sizeof(__Pyx_pad_long) - sizeof(long); #ifdef HAVE_LONG_LONG case 'q': case 'Q': return sizeof(__Pyx_pad_longlong) - sizeof(PY_LONG_LONG); #endif case 'f': return sizeof(__Pyx_pad_float) - sizeof(float); case 'd': return sizeof(__Pyx_pad_double) - sizeof(double); case 'g': return sizeof(__Pyx_pad_longdouble) - sizeof(long double); case 'P': case 'O': return sizeof(__Pyx_pad_void_p) - sizeof(void*); default: __Pyx_BufFmt_RaiseUnexpectedChar(ch); return 0; } } static char __Pyx_BufFmt_TypeCharToGroup(char ch, int is_complex) { switch (ch) { case 'c': return 'H'; case 'b': case 'h': case 'i': case 'l': case 'q': case 's': case 'p': return 'I'; case 'B': case 'H': case 'I': case 'L': case 'Q': return 'U'; case 'f': case 'd': case 'g': return (is_complex ? 'C' : 'R'); case 'O': return 'O'; case 'P': return 'P'; default: { __Pyx_BufFmt_RaiseUnexpectedChar(ch); return 0; } } } static void __Pyx_BufFmt_RaiseExpected(__Pyx_BufFmt_Context* ctx) { if (ctx->head == NULL || ctx->head->field == &ctx->root) { const char* expected; const char* quote; if (ctx->head == NULL) { expected = "end"; quote = ""; } else { expected = ctx->head->field->type->name; quote = "'"; } PyErr_Format(PyExc_ValueError, "Buffer dtype mismatch, expected %s%s%s but got %s", quote, expected, quote, __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex)); } else { __Pyx_StructField* field = ctx->head->field; __Pyx_StructField* parent = (ctx->head - 1)->field; PyErr_Format(PyExc_ValueError, "Buffer dtype mismatch, expected '%s' but got %s in '%s.%s'", field->type->name, __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex), parent->type->name, field->name); } } static int __Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context* ctx) { char group; size_t size, offset, arraysize = 1; if (ctx->enc_type == 0) return 0; if (ctx->head->field->type->arraysize[0]) { int i, ndim = 0; if (ctx->enc_type == 's' || ctx->enc_type == 'p') { ctx->is_valid_array = ctx->head->field->type->ndim == 1; ndim = 1; if (ctx->enc_count != ctx->head->field->type->arraysize[0]) { PyErr_Format(PyExc_ValueError, "Expected a dimension of size %zu, got %zu", ctx->head->field->type->arraysize[0], ctx->enc_count); return -1; } } if (!ctx->is_valid_array) { PyErr_Format(PyExc_ValueError, "Expected %d dimensions, got %d", ctx->head->field->type->ndim, ndim); return -1; } for (i = 0; i < ctx->head->field->type->ndim; i++) { arraysize *= ctx->head->field->type->arraysize[i]; } ctx->is_valid_array = 0; ctx->enc_count = 1; } group = __Pyx_BufFmt_TypeCharToGroup(ctx->enc_type, ctx->is_complex); do { __Pyx_StructField* field = ctx->head->field; __Pyx_TypeInfo* type = field->type; if (ctx->enc_packmode == '@' || ctx->enc_packmode == '^') { size = __Pyx_BufFmt_TypeCharToNativeSize(ctx->enc_type, ctx->is_complex); } else { size = __Pyx_BufFmt_TypeCharToStandardSize(ctx->enc_type, ctx->is_complex); } if (ctx->enc_packmode == '@') { size_t align_at = __Pyx_BufFmt_TypeCharToAlignment(ctx->enc_type, ctx->is_complex); size_t align_mod_offset; if (align_at == 0) return -1; align_mod_offset = ctx->fmt_offset % align_at; if (align_mod_offset > 0) ctx->fmt_offset += align_at - align_mod_offset; if (ctx->struct_alignment == 0) ctx->struct_alignment = __Pyx_BufFmt_TypeCharToPadding(ctx->enc_type, ctx->is_complex); } if (type->size != size || type->typegroup != group) { if (type->typegroup == 'C' && type->fields != NULL) { size_t parent_offset = ctx->head->parent_offset + field->offset; ++ctx->head; ctx->head->field = type->fields; ctx->head->parent_offset = parent_offset; continue; } if ((type->typegroup == 'H' || group == 'H') && type->size == size) { } else { __Pyx_BufFmt_RaiseExpected(ctx); return -1; } } offset = ctx->head->parent_offset + field->offset; if (ctx->fmt_offset != offset) { PyErr_Format(PyExc_ValueError, "Buffer dtype mismatch; next field is at offset %" CYTHON_FORMAT_SSIZE_T "d but %" CYTHON_FORMAT_SSIZE_T "d expected", (Py_ssize_t)ctx->fmt_offset, (Py_ssize_t)offset); return -1; } ctx->fmt_offset += size; if (arraysize) ctx->fmt_offset += (arraysize - 1) * size; --ctx->enc_count; while (1) { if (field == &ctx->root) { ctx->head = NULL; if (ctx->enc_count != 0) { __Pyx_BufFmt_RaiseExpected(ctx); return -1; } break; } ctx->head->field = ++field; if (field->type == NULL) { --ctx->head; field = ctx->head->field; continue; } else if (field->type->typegroup == 'S') { size_t parent_offset = ctx->head->parent_offset + field->offset; if (field->type->fields->type == NULL) continue; field = field->type->fields; ++ctx->head; ctx->head->field = field; ctx->head->parent_offset = parent_offset; break; } else { break; } } } while (ctx->enc_count); ctx->enc_type = 0; ctx->is_complex = 0; return 0; } static CYTHON_INLINE PyObject * __pyx_buffmt_parse_array(__Pyx_BufFmt_Context* ctx, const char** tsp) { const char *ts = *tsp; int i = 0, number; int ndim = ctx->head->field->type->ndim; ; ++ts; if (ctx->new_count != 1) { PyErr_SetString(PyExc_ValueError, "Cannot handle repeated arrays in format string"); return NULL; } if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; while (*ts && *ts != ')') { switch (*ts) { case ' ': case '\f': case '\r': case '\n': case '\t': case '\v': continue; default: break; } number = __Pyx_BufFmt_ExpectNumber(&ts); if (number == -1) return NULL; if (i < ndim && (size_t) number != ctx->head->field->type->arraysize[i]) return PyErr_Format(PyExc_ValueError, "Expected a dimension of size %zu, got %d", ctx->head->field->type->arraysize[i], number); if (*ts != ',' && *ts != ')') return PyErr_Format(PyExc_ValueError, "Expected a comma in format string, got '%c'", *ts); if (*ts == ',') ts++; i++; } if (i != ndim) return PyErr_Format(PyExc_ValueError, "Expected %d dimension(s), got %d", ctx->head->field->type->ndim, i); if (!*ts) { PyErr_SetString(PyExc_ValueError, "Unexpected end of format string, expected ')'"); return NULL; } ctx->is_valid_array = 1; ctx->new_count = 1; *tsp = ++ts; return Py_None; } static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts) { int got_Z = 0; while (1) { switch(*ts) { case 0: if (ctx->enc_type != 0 && ctx->head == NULL) { __Pyx_BufFmt_RaiseExpected(ctx); return NULL; } if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; if (ctx->head != NULL) { __Pyx_BufFmt_RaiseExpected(ctx); return NULL; } return ts; case ' ': case '\r': case '\n': ++ts; break; case '<': if (!__Pyx_IsLittleEndian()) { PyErr_SetString(PyExc_ValueError, "Little-endian buffer not supported on big-endian compiler"); return NULL; } ctx->new_packmode = '='; ++ts; break; case '>': case '!': if (__Pyx_IsLittleEndian()) { PyErr_SetString(PyExc_ValueError, "Big-endian buffer not supported on little-endian compiler"); return NULL; } ctx->new_packmode = '='; ++ts; break; case '=': case '@': case '^': ctx->new_packmode = *ts++; break; case 'T': { const char* ts_after_sub; size_t i, struct_count = ctx->new_count; size_t struct_alignment = ctx->struct_alignment; ctx->new_count = 1; ++ts; if (*ts != '{') { PyErr_SetString(PyExc_ValueError, "Buffer acquisition: Expected '{' after 'T'"); return NULL; } if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; ctx->enc_type = 0; ctx->enc_count = 0; ctx->struct_alignment = 0; ++ts; ts_after_sub = ts; for (i = 0; i != struct_count; ++i) { ts_after_sub = __Pyx_BufFmt_CheckString(ctx, ts); if (!ts_after_sub) return NULL; } ts = ts_after_sub; if (struct_alignment) ctx->struct_alignment = struct_alignment; } break; case '}': { size_t alignment = ctx->struct_alignment; ++ts; if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; ctx->enc_type = 0; if (alignment && ctx->fmt_offset % alignment) { ctx->fmt_offset += alignment - (ctx->fmt_offset % alignment); } } return ts; case 'x': if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; ctx->fmt_offset += ctx->new_count; ctx->new_count = 1; ctx->enc_count = 0; ctx->enc_type = 0; ctx->enc_packmode = ctx->new_packmode; ++ts; break; case 'Z': got_Z = 1; ++ts; if (*ts != 'f' && *ts != 'd' && *ts != 'g') { __Pyx_BufFmt_RaiseUnexpectedChar('Z'); return NULL; } case 'c': case 'b': case 'B': case 'h': case 'H': case 'i': case 'I': case 'l': case 'L': case 'q': case 'Q': case 'f': case 'd': case 'g': case 'O': case 'p': if (ctx->enc_type == *ts && got_Z == ctx->is_complex && ctx->enc_packmode == ctx->new_packmode) { ctx->enc_count += ctx->new_count; ctx->new_count = 1; got_Z = 0; ++ts; break; } case 's': if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; ctx->enc_count = ctx->new_count; ctx->enc_packmode = ctx->new_packmode; ctx->enc_type = *ts; ctx->is_complex = got_Z; ++ts; ctx->new_count = 1; got_Z = 0; break; case ':': ++ts; while(*ts != ':') ++ts; ++ts; break; case '(': if (!__pyx_buffmt_parse_array(ctx, &ts)) return NULL; break; default: { int number = __Pyx_BufFmt_ExpectNumber(&ts); if (number == -1) return NULL; ctx->new_count = (size_t)number; } } } } static CYTHON_INLINE void __Pyx_ZeroBuffer(Py_buffer* buf) { buf->buf = NULL; buf->obj = NULL; buf->strides = __Pyx_zeros; buf->shape = __Pyx_zeros; buf->suboffsets = __Pyx_minusones; } static CYTHON_INLINE int __Pyx_GetBufferAndValidate( Py_buffer* buf, PyObject* obj, __Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack) { if (obj == Py_None || obj == NULL) { __Pyx_ZeroBuffer(buf); return 0; } buf->buf = NULL; if (__Pyx_GetBuffer(obj, buf, flags) == -1) goto fail; if (buf->ndim != nd) { PyErr_Format(PyExc_ValueError, "Buffer has wrong number of dimensions (expected %d, got %d)", nd, buf->ndim); goto fail; } if (!cast) { __Pyx_BufFmt_Context ctx; __Pyx_BufFmt_Init(&ctx, stack, dtype); if (!__Pyx_BufFmt_CheckString(&ctx, buf->format)) goto fail; } if ((unsigned)buf->itemsize != dtype->size) { PyErr_Format(PyExc_ValueError, "Item size of buffer (%" CYTHON_FORMAT_SSIZE_T "d byte%s) does not match size of '%s' (%" CYTHON_FORMAT_SSIZE_T "d byte%s)", buf->itemsize, (buf->itemsize > 1) ? "s" : "", dtype->name, (Py_ssize_t)dtype->size, (dtype->size > 1) ? "s" : ""); goto fail; } if (buf->suboffsets == NULL) buf->suboffsets = __Pyx_minusones; return 0; fail:; __Pyx_ZeroBuffer(buf); return -1; } static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info) { if (info->buf == NULL) return; if (info->suboffsets == __Pyx_minusones) info->suboffsets = NULL; __Pyx_ReleaseBuffer(info); } static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) { #if CYTHON_COMPILING_IN_CPYTHON PyObject *tmp_type, *tmp_value, *tmp_tb; PyThreadState *tstate = PyThreadState_GET(); tmp_type = tstate->curexc_type; tmp_value = tstate->curexc_value; tmp_tb = tstate->curexc_traceback; tstate->curexc_type = type; tstate->curexc_value = value; tstate->curexc_traceback = tb; Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); #else PyErr_Restore(type, value, tb); #endif } static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) { #if CYTHON_COMPILING_IN_CPYTHON PyThreadState *tstate = PyThreadState_GET(); *type = tstate->curexc_type; *value = tstate->curexc_value; *tb = tstate->curexc_traceback; tstate->curexc_type = 0; tstate->curexc_value = 0; tstate->curexc_traceback = 0; #else PyErr_Fetch(type, value, tb); #endif } #if PY_MAJOR_VERSION < 3 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, CYTHON_UNUSED PyObject *cause) { Py_XINCREF(type); if (!value || value == Py_None) value = NULL; else Py_INCREF(value); if (!tb || tb == Py_None) tb = NULL; else { Py_INCREF(tb); if (!PyTraceBack_Check(tb)) { PyErr_SetString(PyExc_TypeError, "raise: arg 3 must be a traceback or None"); goto raise_error; } } if (PyType_Check(type)) { #if CYTHON_COMPILING_IN_PYPY if (!value) { Py_INCREF(Py_None); value = Py_None; } #endif PyErr_NormalizeException(&type, &value, &tb); } else { if (value) { PyErr_SetString(PyExc_TypeError, "instance exception may not have a separate value"); goto raise_error; } value = type; type = (PyObject*) Py_TYPE(type); Py_INCREF(type); if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) { PyErr_SetString(PyExc_TypeError, "raise: exception class must be a subclass of BaseException"); goto raise_error; } } __Pyx_ErrRestore(type, value, tb); return; raise_error: Py_XDECREF(value); Py_XDECREF(type); Py_XDECREF(tb); return; } #else static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) { PyObject* owned_instance = NULL; if (tb == Py_None) { tb = 0; } else if (tb && !PyTraceBack_Check(tb)) { PyErr_SetString(PyExc_TypeError, "raise: arg 3 must be a traceback or None"); goto bad; } if (value == Py_None) value = 0; if (PyExceptionInstance_Check(type)) { if (value) { PyErr_SetString(PyExc_TypeError, "instance exception may not have a separate value"); goto bad; } value = type; type = (PyObject*) Py_TYPE(value); } else if (PyExceptionClass_Check(type)) { PyObject *instance_class = NULL; if (value && PyExceptionInstance_Check(value)) { instance_class = (PyObject*) Py_TYPE(value); if (instance_class != type) { int is_subclass = PyObject_IsSubclass(instance_class, type); if (!is_subclass) { instance_class = NULL; } else if (unlikely(is_subclass == -1)) { goto bad; } else { type = instance_class; } } } if (!instance_class) { PyObject *args; if (!value) args = PyTuple_New(0); else if (PyTuple_Check(value)) { Py_INCREF(value); args = value; } else args = PyTuple_Pack(1, value); if (!args) goto bad; owned_instance = PyObject_Call(type, args, NULL); Py_DECREF(args); if (!owned_instance) goto bad; value = owned_instance; if (!PyExceptionInstance_Check(value)) { PyErr_Format(PyExc_TypeError, "calling %R should have returned an instance of " "BaseException, not %R", type, Py_TYPE(value)); goto bad; } } } else { PyErr_SetString(PyExc_TypeError, "raise: exception class must be a subclass of BaseException"); goto bad; } #if PY_VERSION_HEX >= 0x03030000 if (cause) { #else if (cause && cause != Py_None) { #endif PyObject *fixed_cause; if (cause == Py_None) { fixed_cause = NULL; } else if (PyExceptionClass_Check(cause)) { fixed_cause = PyObject_CallObject(cause, NULL); if (fixed_cause == NULL) goto bad; } else if (PyExceptionInstance_Check(cause)) { fixed_cause = cause; Py_INCREF(fixed_cause); } else { PyErr_SetString(PyExc_TypeError, "exception causes must derive from " "BaseException"); goto bad; } PyException_SetCause(value, fixed_cause); } PyErr_SetObject(type, value); if (tb) { #if CYTHON_COMPILING_IN_PYPY PyObject *tmp_type, *tmp_value, *tmp_tb; PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb); Py_INCREF(tb); PyErr_Restore(tmp_type, tmp_value, tb); Py_XDECREF(tmp_tb); #else PyThreadState *tstate = PyThreadState_GET(); PyObject* tmp_tb = tstate->curexc_traceback; if (tb != tmp_tb) { Py_INCREF(tb); tstate->curexc_traceback = tb; Py_XDECREF(tmp_tb); } #endif } bad: Py_XDECREF(owned_instance); return; } #endif static void __Pyx_RaiseBufferIndexError(int axis) { PyErr_Format(PyExc_IndexError, "Out of bounds on buffer access (axis %d)", axis); } static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno, CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename, int full_traceback, CYTHON_UNUSED int nogil) { PyObject *old_exc, *old_val, *old_tb; PyObject *ctx; #ifdef WITH_THREAD PyGILState_STATE state; if (nogil) state = PyGILState_Ensure(); #endif __Pyx_ErrFetch(&old_exc, &old_val, &old_tb); if (full_traceback) { Py_XINCREF(old_exc); Py_XINCREF(old_val); Py_XINCREF(old_tb); __Pyx_ErrRestore(old_exc, old_val, old_tb); PyErr_PrintEx(1); } #if PY_MAJOR_VERSION < 3 ctx = PyString_FromString(name); #else ctx = PyUnicode_FromString(name); #endif __Pyx_ErrRestore(old_exc, old_val, old_tb); if (!ctx) { PyErr_WriteUnraisable(Py_None); } else { PyErr_WriteUnraisable(ctx); Py_DECREF(ctx); } #ifdef WITH_THREAD if (nogil) PyGILState_Release(state); #endif } static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) { PyErr_Format(PyExc_ValueError, "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected); } static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) { PyErr_Format(PyExc_ValueError, "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack", index, (index == 1) ? "" : "s"); } static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); } static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) { PyObject *empty_list = 0; PyObject *module = 0; PyObject *global_dict = 0; PyObject *empty_dict = 0; PyObject *list; #if PY_VERSION_HEX < 0x03030000 PyObject *py_import; py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import); if (!py_import) goto bad; #endif if (from_list) list = from_list; else { empty_list = PyList_New(0); if (!empty_list) goto bad; list = empty_list; } global_dict = PyModule_GetDict(__pyx_m); if (!global_dict) goto bad; empty_dict = PyDict_New(); if (!empty_dict) goto bad; { #if PY_MAJOR_VERSION >= 3 if (level == -1) { if (strchr(__Pyx_MODULE_NAME, '.')) { #if PY_VERSION_HEX < 0x03030000 PyObject *py_level = PyInt_FromLong(1); if (!py_level) goto bad; module = PyObject_CallFunctionObjArgs(py_import, name, global_dict, empty_dict, list, py_level, NULL); Py_DECREF(py_level); #else module = PyImport_ImportModuleLevelObject( name, global_dict, empty_dict, list, 1); #endif if (!module) { if (!PyErr_ExceptionMatches(PyExc_ImportError)) goto bad; PyErr_Clear(); } } level = 0; } #endif if (!module) { #if PY_VERSION_HEX < 0x03030000 PyObject *py_level = PyInt_FromLong(level); if (!py_level) goto bad; module = PyObject_CallFunctionObjArgs(py_import, name, global_dict, empty_dict, list, py_level, NULL); Py_DECREF(py_level); #else module = PyImport_ImportModuleLevelObject( name, global_dict, empty_dict, list, level); #endif } } bad: #if PY_VERSION_HEX < 0x03030000 Py_XDECREF(py_import); #endif Py_XDECREF(empty_list); Py_XDECREF(empty_dict); return module; } static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { int start = 0, mid = 0, end = count - 1; if (end >= 0 && code_line > entries[end].code_line) { return count; } while (start < end) { mid = start + (end - start) / 2; if (code_line < entries[mid].code_line) { end = mid; } else if (code_line > entries[mid].code_line) { start = mid + 1; } else { return mid; } } if (code_line <= entries[mid].code_line) { return mid; } else { return mid + 1; } } static PyCodeObject *__pyx_find_code_object(int code_line) { PyCodeObject* code_object; int pos; if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) { return NULL; } pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) { return NULL; } code_object = __pyx_code_cache.entries[pos].code_object; Py_INCREF(code_object); return code_object; } static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { int pos, i; __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries; if (unlikely(!code_line)) { return; } if (unlikely(!entries)) { entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry)); if (likely(entries)) { __pyx_code_cache.entries = entries; __pyx_code_cache.max_count = 64; __pyx_code_cache.count = 1; entries[0].code_line = code_line; entries[0].code_object = code_object; Py_INCREF(code_object); } return; } pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) { PyCodeObject* tmp = entries[pos].code_object; entries[pos].code_object = code_object; Py_DECREF(tmp); return; } if (__pyx_code_cache.count == __pyx_code_cache.max_count) { int new_max = __pyx_code_cache.max_count + 64; entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc( __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry)); if (unlikely(!entries)) { return; } __pyx_code_cache.entries = entries; __pyx_code_cache.max_count = new_max; } for (i=__pyx_code_cache.count; i>pos; i--) { entries[i] = entries[i-1]; } entries[pos].code_line = code_line; entries[pos].code_object = code_object; __pyx_code_cache.count++; Py_INCREF(code_object); } #include "compile.h" #include "frameobject.h" #include "traceback.h" static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( const char *funcname, int c_line, int py_line, const char *filename) { PyCodeObject *py_code = 0; PyObject *py_srcfile = 0; PyObject *py_funcname = 0; #if PY_MAJOR_VERSION < 3 py_srcfile = PyString_FromString(filename); #else py_srcfile = PyUnicode_FromString(filename); #endif if (!py_srcfile) goto bad; if (c_line) { #if PY_MAJOR_VERSION < 3 py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); #else py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); #endif } else { #if PY_MAJOR_VERSION < 3 py_funcname = PyString_FromString(funcname); #else py_funcname = PyUnicode_FromString(funcname); #endif } if (!py_funcname) goto bad; py_code = __Pyx_PyCode_New( 0, 0, 0, 0, 0, __pyx_empty_bytes, /*PyObject *code,*/ __pyx_empty_tuple, /*PyObject *consts,*/ __pyx_empty_tuple, /*PyObject *names,*/ __pyx_empty_tuple, /*PyObject *varnames,*/ __pyx_empty_tuple, /*PyObject *freevars,*/ __pyx_empty_tuple, /*PyObject *cellvars,*/ py_srcfile, /*PyObject *filename,*/ py_funcname, /*PyObject *name,*/ py_line, __pyx_empty_bytes /*PyObject *lnotab*/ ); Py_DECREF(py_srcfile); Py_DECREF(py_funcname); return py_code; bad: Py_XDECREF(py_srcfile); Py_XDECREF(py_funcname); return NULL; } static void __Pyx_AddTraceback(const char *funcname, int c_line, int py_line, const char *filename) { PyCodeObject *py_code = 0; PyFrameObject *py_frame = 0; py_code = __pyx_find_code_object(c_line ? c_line : py_line); if (!py_code) { py_code = __Pyx_CreateCodeObjectForTraceback( funcname, c_line, py_line, filename); if (!py_code) goto bad; __pyx_insert_code_object(c_line ? c_line : py_line, py_code); } py_frame = PyFrame_New( PyThreadState_GET(), /*PyThreadState *tstate,*/ py_code, /*PyCodeObject *code,*/ __pyx_d, /*PyObject *globals,*/ 0 /*PyObject *locals*/ ); if (!py_frame) goto bad; py_frame->f_lineno = py_line; PyTraceBack_Here(py_frame); bad: Py_XDECREF(py_code); Py_XDECREF(py_frame); } #if PY_MAJOR_VERSION < 3 static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) { if (PyObject_CheckBuffer(obj)) return PyObject_GetBuffer(obj, view, flags); if (PyObject_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) return __pyx_pw_5numpy_7ndarray_1__getbuffer__(obj, view, flags); PyErr_Format(PyExc_TypeError, "'%.200s' does not have the buffer interface", Py_TYPE(obj)->tp_name); return -1; } static void __Pyx_ReleaseBuffer(Py_buffer *view) { PyObject *obj = view->obj; if (!obj) return; if (PyObject_CheckBuffer(obj)) { PyBuffer_Release(view); return; } if (PyObject_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) { __pyx_pw_5numpy_7ndarray_3__releasebuffer__(obj, view); return; } Py_DECREF(obj); view->obj = NULL; } #endif #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\ __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0) #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\ __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1) #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\ {\ func_type value = func_value;\ if (sizeof(target_type) < sizeof(func_type)) {\ if (unlikely(value != (func_type) (target_type) value)) {\ func_type zero = 0;\ if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\ return (target_type) -1;\ if (is_unsigned && unlikely(value < zero))\ goto raise_neg_overflow;\ else\ goto raise_overflow;\ }\ }\ return (target_type) value;\ } #if CYTHON_USE_PYLONG_INTERNALS #include "longintrepr.h" #endif static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { const int neg_one = (int) -1, const_zero = (int) 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { if (sizeof(int) < sizeof(long)) { __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x)) } else { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { goto raise_neg_overflow; } return (int) val; } } else #endif if (likely(PyLong_Check(x))) { if (is_unsigned) { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (int) 0; case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0]) case 2: if (8 * sizeof(int) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) { return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; case 3: if (8 * sizeof(int) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) { return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; case 4: if (8 * sizeof(int) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) { return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; } #endif #if CYTHON_COMPILING_IN_CPYTHON if (unlikely(Py_SIZE(x) < 0)) { goto raise_neg_overflow; } #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (int) -1; if (unlikely(result == 1)) goto raise_neg_overflow; } #endif if (sizeof(int) <= sizeof(unsigned long)) { __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x)) } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) } } else { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (int) 0; case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, -(sdigit) digits[0]) case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0]) case -2: if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 2: if (8 * sizeof(int) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case -3: if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 3: if (8 * sizeof(int) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case -4: if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 4: if (8 * sizeof(int) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; } #endif if (sizeof(int) <= sizeof(long)) { __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x)) } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x)) } } { #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) PyErr_SetString(PyExc_RuntimeError, "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); #else int val; PyObject *v = __Pyx_PyNumber_Int(x); #if PY_MAJOR_VERSION < 3 if (likely(v) && !PyLong_Check(v)) { PyObject *tmp = v; v = PyNumber_Long(tmp); Py_DECREF(tmp); } #endif if (likely(v)) { int one = 1; int is_little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&val; int ret = _PyLong_AsByteArray((PyLongObject *)v, bytes, sizeof(val), is_little, !is_unsigned); Py_DECREF(v); if (likely(!ret)) return val; } #endif return (int) -1; } } else { int val; PyObject *tmp = __Pyx_PyNumber_Int(x); if (!tmp) return (int) -1; val = __Pyx_PyInt_As_int(tmp); Py_DECREF(tmp); return val; } raise_overflow: PyErr_SetString(PyExc_OverflowError, "value too large to convert to int"); return (int) -1; raise_neg_overflow: PyErr_SetString(PyExc_OverflowError, "can't convert negative value to int"); return (int) -1; } static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { const int neg_one = (int) -1, const_zero = (int) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { if (sizeof(int) < sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(int) <= sizeof(unsigned long)) { return PyLong_FromUnsignedLong((unsigned long) value); } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); } } else { if (sizeof(int) <= sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { return PyLong_FromLongLong((PY_LONG_LONG) value); } } { int one = 1; int little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&value; return _PyLong_FromByteArray(bytes, sizeof(int), little, !is_unsigned); } } static CYTHON_INLINE unsigned int __Pyx_PyInt_As_unsigned_int(PyObject *x) { const unsigned int neg_one = (unsigned int) -1, const_zero = (unsigned int) 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { if (sizeof(unsigned int) < sizeof(long)) { __PYX_VERIFY_RETURN_INT(unsigned int, long, PyInt_AS_LONG(x)) } else { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { goto raise_neg_overflow; } return (unsigned int) val; } } else #endif if (likely(PyLong_Check(x))) { if (is_unsigned) { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (unsigned int) 0; case 1: __PYX_VERIFY_RETURN_INT(unsigned int, digit, digits[0]) case 2: if (8 * sizeof(unsigned int) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(unsigned int) >= 2 * PyLong_SHIFT) { return (unsigned int) (((((unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])); } } break; case 3: if (8 * sizeof(unsigned int) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(unsigned int) >= 3 * PyLong_SHIFT) { return (unsigned int) (((((((unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])); } } break; case 4: if (8 * sizeof(unsigned int) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(unsigned int) >= 4 * PyLong_SHIFT) { return (unsigned int) (((((((((unsigned int)digits[3]) << PyLong_SHIFT) | (unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])); } } break; } #endif #if CYTHON_COMPILING_IN_CPYTHON if (unlikely(Py_SIZE(x) < 0)) { goto raise_neg_overflow; } #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (unsigned int) -1; if (unlikely(result == 1)) goto raise_neg_overflow; } #endif if (sizeof(unsigned int) <= sizeof(unsigned long)) { __PYX_VERIFY_RETURN_INT_EXC(unsigned int, unsigned long, PyLong_AsUnsignedLong(x)) } else if (sizeof(unsigned int) <= sizeof(unsigned PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(unsigned int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) } } else { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (unsigned int) 0; case -1: __PYX_VERIFY_RETURN_INT(unsigned int, sdigit, -(sdigit) digits[0]) case 1: __PYX_VERIFY_RETURN_INT(unsigned int, digit, +digits[0]) case -2: if (8 * sizeof(unsigned int) - 1 > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(unsigned int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(unsigned int) - 1 > 2 * PyLong_SHIFT) { return (unsigned int) (((unsigned int)-1)*(((((unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]))); } } break; case 2: if (8 * sizeof(unsigned int) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(unsigned int) - 1 > 2 * PyLong_SHIFT) { return (unsigned int) ((((((unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]))); } } break; case -3: if (8 * sizeof(unsigned int) - 1 > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(unsigned int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(unsigned int) - 1 > 3 * PyLong_SHIFT) { return (unsigned int) (((unsigned int)-1)*(((((((unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]))); } } break; case 3: if (8 * sizeof(unsigned int) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(unsigned int) - 1 > 3 * PyLong_SHIFT) { return (unsigned int) ((((((((unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]))); } } break; case -4: if (8 * sizeof(unsigned int) - 1 > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(unsigned int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(unsigned int) - 1 > 4 * PyLong_SHIFT) { return (unsigned int) (((unsigned int)-1)*(((((((((unsigned int)digits[3]) << PyLong_SHIFT) | (unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]))); } } break; case 4: if (8 * sizeof(unsigned int) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(unsigned int) - 1 > 4 * PyLong_SHIFT) { return (unsigned int) ((((((((((unsigned int)digits[3]) << PyLong_SHIFT) | (unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]))); } } break; } #endif if (sizeof(unsigned int) <= sizeof(long)) { __PYX_VERIFY_RETURN_INT_EXC(unsigned int, long, PyLong_AsLong(x)) } else if (sizeof(unsigned int) <= sizeof(PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(unsigned int, PY_LONG_LONG, PyLong_AsLongLong(x)) } } { #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) PyErr_SetString(PyExc_RuntimeError, "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); #else unsigned int val; PyObject *v = __Pyx_PyNumber_Int(x); #if PY_MAJOR_VERSION < 3 if (likely(v) && !PyLong_Check(v)) { PyObject *tmp = v; v = PyNumber_Long(tmp); Py_DECREF(tmp); } #endif if (likely(v)) { int one = 1; int is_little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&val; int ret = _PyLong_AsByteArray((PyLongObject *)v, bytes, sizeof(val), is_little, !is_unsigned); Py_DECREF(v); if (likely(!ret)) return val; } #endif return (unsigned int) -1; } } else { unsigned int val; PyObject *tmp = __Pyx_PyNumber_Int(x); if (!tmp) return (unsigned int) -1; val = __Pyx_PyInt_As_unsigned_int(tmp); Py_DECREF(tmp); return val; } raise_overflow: PyErr_SetString(PyExc_OverflowError, "value too large to convert to unsigned int"); return (unsigned int) -1; raise_neg_overflow: PyErr_SetString(PyExc_OverflowError, "can't convert negative value to unsigned int"); return (unsigned int) -1; } #if CYTHON_CCOMPLEX #ifdef __cplusplus static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { return ::std::complex< float >(x, y); } #else static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { return x + y*(__pyx_t_float_complex)_Complex_I; } #endif #else static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { __pyx_t_float_complex z; z.real = x; z.imag = y; return z; } #endif #if CYTHON_CCOMPLEX #else static CYTHON_INLINE int __Pyx_c_eqf(__pyx_t_float_complex a, __pyx_t_float_complex b) { return (a.real == b.real) && (a.imag == b.imag); } static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sumf(__pyx_t_float_complex a, __pyx_t_float_complex b) { __pyx_t_float_complex z; z.real = a.real + b.real; z.imag = a.imag + b.imag; return z; } static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_difff(__pyx_t_float_complex a, __pyx_t_float_complex b) { __pyx_t_float_complex z; z.real = a.real - b.real; z.imag = a.imag - b.imag; return z; } static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prodf(__pyx_t_float_complex a, __pyx_t_float_complex b) { __pyx_t_float_complex z; z.real = a.real * b.real - a.imag * b.imag; z.imag = a.real * b.imag + a.imag * b.real; return z; } static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quotf(__pyx_t_float_complex a, __pyx_t_float_complex b) { __pyx_t_float_complex z; float denom = b.real * b.real + b.imag * b.imag; z.real = (a.real * b.real + a.imag * b.imag) / denom; z.imag = (a.imag * b.real - a.real * b.imag) / denom; return z; } static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_negf(__pyx_t_float_complex a) { __pyx_t_float_complex z; z.real = -a.real; z.imag = -a.imag; return z; } static CYTHON_INLINE int __Pyx_c_is_zerof(__pyx_t_float_complex a) { return (a.real == 0) && (a.imag == 0); } static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conjf(__pyx_t_float_complex a) { __pyx_t_float_complex z; z.real = a.real; z.imag = -a.imag; return z; } #if 1 static CYTHON_INLINE float __Pyx_c_absf(__pyx_t_float_complex z) { #if !defined(HAVE_HYPOT) || defined(_MSC_VER) return sqrtf(z.real*z.real + z.imag*z.imag); #else return hypotf(z.real, z.imag); #endif } static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_powf(__pyx_t_float_complex a, __pyx_t_float_complex b) { __pyx_t_float_complex z; float r, lnr, theta, z_r, z_theta; if (b.imag == 0 && b.real == (int)b.real) { if (b.real < 0) { float denom = a.real * a.real + a.imag * a.imag; a.real = a.real / denom; a.imag = -a.imag / denom; b.real = -b.real; } switch ((int)b.real) { case 0: z.real = 1; z.imag = 0; return z; case 1: return a; case 2: z = __Pyx_c_prodf(a, a); return __Pyx_c_prodf(a, a); case 3: z = __Pyx_c_prodf(a, a); return __Pyx_c_prodf(z, a); case 4: z = __Pyx_c_prodf(a, a); return __Pyx_c_prodf(z, z); } } if (a.imag == 0) { if (a.real == 0) { return a; } r = a.real; theta = 0; } else { r = __Pyx_c_absf(a); theta = atan2f(a.imag, a.real); } lnr = logf(r); z_r = expf(lnr * b.real - theta * b.imag); z_theta = theta * b.real + lnr * b.imag; z.real = z_r * cosf(z_theta); z.imag = z_r * sinf(z_theta); return z; } #endif #endif #if CYTHON_CCOMPLEX #ifdef __cplusplus static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { return ::std::complex< double >(x, y); } #else static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { return x + y*(__pyx_t_double_complex)_Complex_I; } #endif #else static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { __pyx_t_double_complex z; z.real = x; z.imag = y; return z; } #endif #if CYTHON_CCOMPLEX #else static CYTHON_INLINE int __Pyx_c_eq(__pyx_t_double_complex a, __pyx_t_double_complex b) { return (a.real == b.real) && (a.imag == b.imag); } static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum(__pyx_t_double_complex a, __pyx_t_double_complex b) { __pyx_t_double_complex z; z.real = a.real + b.real; z.imag = a.imag + b.imag; return z; } static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff(__pyx_t_double_complex a, __pyx_t_double_complex b) { __pyx_t_double_complex z; z.real = a.real - b.real; z.imag = a.imag - b.imag; return z; } static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod(__pyx_t_double_complex a, __pyx_t_double_complex b) { __pyx_t_double_complex z; z.real = a.real * b.real - a.imag * b.imag; z.imag = a.real * b.imag + a.imag * b.real; return z; } static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot(__pyx_t_double_complex a, __pyx_t_double_complex b) { __pyx_t_double_complex z; double denom = b.real * b.real + b.imag * b.imag; z.real = (a.real * b.real + a.imag * b.imag) / denom; z.imag = (a.imag * b.real - a.real * b.imag) / denom; return z; } static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg(__pyx_t_double_complex a) { __pyx_t_double_complex z; z.real = -a.real; z.imag = -a.imag; return z; } static CYTHON_INLINE int __Pyx_c_is_zero(__pyx_t_double_complex a) { return (a.real == 0) && (a.imag == 0); } static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj(__pyx_t_double_complex a) { __pyx_t_double_complex z; z.real = a.real; z.imag = -a.imag; return z; } #if 1 static CYTHON_INLINE double __Pyx_c_abs(__pyx_t_double_complex z) { #if !defined(HAVE_HYPOT) || defined(_MSC_VER) return sqrt(z.real*z.real + z.imag*z.imag); #else return hypot(z.real, z.imag); #endif } static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow(__pyx_t_double_complex a, __pyx_t_double_complex b) { __pyx_t_double_complex z; double r, lnr, theta, z_r, z_theta; if (b.imag == 0 && b.real == (int)b.real) { if (b.real < 0) { double denom = a.real * a.real + a.imag * a.imag; a.real = a.real / denom; a.imag = -a.imag / denom; b.real = -b.real; } switch ((int)b.real) { case 0: z.real = 1; z.imag = 0; return z; case 1: return a; case 2: z = __Pyx_c_prod(a, a); return __Pyx_c_prod(a, a); case 3: z = __Pyx_c_prod(a, a); return __Pyx_c_prod(z, a); case 4: z = __Pyx_c_prod(a, a); return __Pyx_c_prod(z, z); } } if (a.imag == 0) { if (a.real == 0) { return a; } r = a.real; theta = 0; } else { r = __Pyx_c_abs(a); theta = atan2(a.imag, a.real); } lnr = log(r); z_r = exp(lnr * b.real - theta * b.imag); z_theta = theta * b.real + lnr * b.imag; z.real = z_r * cos(z_theta); z.imag = z_r * sin(z_theta); return z; } #endif #endif static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum__NPY_TYPES(enum NPY_TYPES value) { const enum NPY_TYPES neg_one = (enum NPY_TYPES) -1, const_zero = (enum NPY_TYPES) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { if (sizeof(enum NPY_TYPES) < sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(enum NPY_TYPES) <= sizeof(unsigned long)) { return PyLong_FromUnsignedLong((unsigned long) value); } else if (sizeof(enum NPY_TYPES) <= sizeof(unsigned PY_LONG_LONG)) { return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); } } else { if (sizeof(enum NPY_TYPES) <= sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(enum NPY_TYPES) <= sizeof(PY_LONG_LONG)) { return PyLong_FromLongLong((PY_LONG_LONG) value); } } { int one = 1; int little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&value; return _PyLong_FromByteArray(bytes, sizeof(enum NPY_TYPES), little, !is_unsigned); } } static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { const long neg_one = (long) -1, const_zero = (long) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { if (sizeof(long) < sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(long) <= sizeof(unsigned long)) { return PyLong_FromUnsignedLong((unsigned long) value); } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); } } else { if (sizeof(long) <= sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { return PyLong_FromLongLong((PY_LONG_LONG) value); } } { int one = 1; int little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&value; return _PyLong_FromByteArray(bytes, sizeof(long), little, !is_unsigned); } } static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { const long neg_one = (long) -1, const_zero = (long) 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { if (sizeof(long) < sizeof(long)) { __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x)) } else { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { goto raise_neg_overflow; } return (long) val; } } else #endif if (likely(PyLong_Check(x))) { if (is_unsigned) { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (long) 0; case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0]) case 2: if (8 * sizeof(long) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) { return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; case 3: if (8 * sizeof(long) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) { return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; case 4: if (8 * sizeof(long) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) { return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; } #endif #if CYTHON_COMPILING_IN_CPYTHON if (unlikely(Py_SIZE(x) < 0)) { goto raise_neg_overflow; } #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (long) -1; if (unlikely(result == 1)) goto raise_neg_overflow; } #endif if (sizeof(long) <= sizeof(unsigned long)) { __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x)) } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) } } else { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (long) 0; case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, -(sdigit) digits[0]) case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0]) case -2: if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case 2: if (8 * sizeof(long) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case -3: if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case 3: if (8 * sizeof(long) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case -4: if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case 4: if (8 * sizeof(long) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; } #endif if (sizeof(long) <= sizeof(long)) { __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x)) } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x)) } } { #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) PyErr_SetString(PyExc_RuntimeError, "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); #else long val; PyObject *v = __Pyx_PyNumber_Int(x); #if PY_MAJOR_VERSION < 3 if (likely(v) && !PyLong_Check(v)) { PyObject *tmp = v; v = PyNumber_Long(tmp); Py_DECREF(tmp); } #endif if (likely(v)) { int one = 1; int is_little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&val; int ret = _PyLong_AsByteArray((PyLongObject *)v, bytes, sizeof(val), is_little, !is_unsigned); Py_DECREF(v); if (likely(!ret)) return val; } #endif return (long) -1; } } else { long val; PyObject *tmp = __Pyx_PyNumber_Int(x); if (!tmp) return (long) -1; val = __Pyx_PyInt_As_long(tmp); Py_DECREF(tmp); return val; } raise_overflow: PyErr_SetString(PyExc_OverflowError, "value too large to convert to long"); return (long) -1; raise_neg_overflow: PyErr_SetString(PyExc_OverflowError, "can't convert negative value to long"); return (long) -1; } static int __Pyx_check_binary_version(void) { char ctversion[4], rtversion[4]; PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION); PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion()); if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) { char message[200]; PyOS_snprintf(message, sizeof(message), "compiletime version %s of module '%.100s' " "does not match runtime version %s", ctversion, __Pyx_MODULE_NAME, rtversion); return PyErr_WarnEx(NULL, message, 1); } return 0; } #ifndef __PYX_HAVE_RT_ImportModule #define __PYX_HAVE_RT_ImportModule static PyObject *__Pyx_ImportModule(const char *name) { PyObject *py_name = 0; PyObject *py_module = 0; py_name = __Pyx_PyIdentifier_FromString(name); if (!py_name) goto bad; py_module = PyImport_Import(py_name); Py_DECREF(py_name); return py_module; bad: Py_XDECREF(py_name); return 0; } #endif #ifndef __PYX_HAVE_RT_ImportType #define __PYX_HAVE_RT_ImportType static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict) { PyObject *py_module = 0; PyObject *result = 0; PyObject *py_name = 0; char warning[200]; Py_ssize_t basicsize; #ifdef Py_LIMITED_API PyObject *py_basicsize; #endif py_module = __Pyx_ImportModule(module_name); if (!py_module) goto bad; py_name = __Pyx_PyIdentifier_FromString(class_name); if (!py_name) goto bad; result = PyObject_GetAttr(py_module, py_name); Py_DECREF(py_name); py_name = 0; Py_DECREF(py_module); py_module = 0; if (!result) goto bad; if (!PyType_Check(result)) { PyErr_Format(PyExc_TypeError, "%.200s.%.200s is not a type object", module_name, class_name); goto bad; } #ifndef Py_LIMITED_API basicsize = ((PyTypeObject *)result)->tp_basicsize; #else py_basicsize = PyObject_GetAttrString(result, "__basicsize__"); if (!py_basicsize) goto bad; basicsize = PyLong_AsSsize_t(py_basicsize); Py_DECREF(py_basicsize); py_basicsize = 0; if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred()) goto bad; #endif if (!strict && (size_t)basicsize > size) { PyOS_snprintf(warning, sizeof(warning), "%s.%s size changed, may indicate binary incompatibility", module_name, class_name); if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad; } else if ((size_t)basicsize != size) { PyErr_Format(PyExc_ValueError, "%.200s.%.200s has the wrong size, try recompiling", module_name, class_name); goto bad; } return (PyTypeObject *)result; bad: Py_XDECREF(py_module); Py_XDECREF(result); return NULL; } #endif static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { while (t->p) { #if PY_MAJOR_VERSION < 3 if (t->is_unicode) { *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL); } else if (t->intern) { *t->p = PyString_InternFromString(t->s); } else { *t->p = PyString_FromStringAndSize(t->s, t->n - 1); } #else if (t->is_unicode | t->is_str) { if (t->intern) { *t->p = PyUnicode_InternFromString(t->s); } else if (t->encoding) { *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL); } else { *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1); } } else { *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1); } #endif if (!*t->p) return -1; ++t; } return 0; } static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) { return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str)); } static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) { Py_ssize_t ignore; return __Pyx_PyObject_AsStringAndSize(o, &ignore); } static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { #if CYTHON_COMPILING_IN_CPYTHON && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) if ( #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII __Pyx_sys_getdefaultencoding_not_ascii && #endif PyUnicode_Check(o)) { #if PY_VERSION_HEX < 0x03030000 char* defenc_c; PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); if (!defenc) return NULL; defenc_c = PyBytes_AS_STRING(defenc); #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII { char* end = defenc_c + PyBytes_GET_SIZE(defenc); char* c; for (c = defenc_c; c < end; c++) { if ((unsigned char) (*c) >= 128) { PyUnicode_AsASCIIString(o); return NULL; } } } #endif *length = PyBytes_GET_SIZE(defenc); return defenc_c; #else if (__Pyx_PyUnicode_READY(o) == -1) return NULL; #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII if (PyUnicode_IS_ASCII(o)) { *length = PyUnicode_GET_LENGTH(o); return PyUnicode_AsUTF8(o); } else { PyUnicode_AsASCIIString(o); return NULL; } #else return PyUnicode_AsUTF8AndSize(o, length); #endif #endif } else #endif #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE)) if (PyByteArray_Check(o)) { *length = PyByteArray_GET_SIZE(o); return PyByteArray_AS_STRING(o); } else #endif { char* result; int r = PyBytes_AsStringAndSize(o, &result, length); if (unlikely(r < 0)) { return NULL; } else { return result; } } } static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { int is_true = x == Py_True; if (is_true | (x == Py_False) | (x == Py_None)) return is_true; else return PyObject_IsTrue(x); } static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) { PyNumberMethods *m; const char *name = NULL; PyObject *res = NULL; #if PY_MAJOR_VERSION < 3 if (PyInt_Check(x) || PyLong_Check(x)) #else if (PyLong_Check(x)) #endif return __Pyx_NewRef(x); m = Py_TYPE(x)->tp_as_number; #if PY_MAJOR_VERSION < 3 if (m && m->nb_int) { name = "int"; res = PyNumber_Int(x); } else if (m && m->nb_long) { name = "long"; res = PyNumber_Long(x); } #else if (m && m->nb_int) { name = "int"; res = PyNumber_Long(x); } #endif if (res) { #if PY_MAJOR_VERSION < 3 if (!PyInt_Check(res) && !PyLong_Check(res)) { #else if (!PyLong_Check(res)) { #endif PyErr_Format(PyExc_TypeError, "__%.4s__ returned non-%.4s (type %.200s)", name, name, Py_TYPE(res)->tp_name); Py_DECREF(res); return NULL; } } else if (!PyErr_Occurred()) { PyErr_SetString(PyExc_TypeError, "an integer is required"); } return res; } static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { Py_ssize_t ival; PyObject *x; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_CheckExact(b))) { if (sizeof(Py_ssize_t) >= sizeof(long)) return PyInt_AS_LONG(b); else return PyInt_AsSsize_t(x); } #endif if (likely(PyLong_CheckExact(b))) { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)b)->ob_digit; const Py_ssize_t size = Py_SIZE(b); if (likely(__Pyx_sst_abs(size) <= 1)) { ival = likely(size) ? digits[0] : 0; if (size == -1) ival = -ival; return ival; } else { switch (size) { case 2: if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case -2: if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case 3: if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case -3: if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case 4: if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case -4: if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; } } #endif return PyLong_AsSsize_t(b); } x = PyNumber_Index(b); if (!x) return -1; ival = PyInt_AsSsize_t(x); Py_DECREF(x); return ival; } static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { return PyInt_FromSize_t(ival); } #endif /* Py_PYTHON_H */ photutils-0.2.1/photutils/geometry/rectangular_overlap.pyx0000600000214200020070000000772512627615324026432 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst from __future__ import (absolute_import, division, print_function, unicode_literals) import numpy as np cimport numpy as np __all__ = ['rectangular_overlap_grid'] cdef extern from "math.h": double asin(double x) double sin(double x) double cos(double x) double sqrt(double x) double fabs(double x) from cpython cimport bool DTYPE = np.float64 ctypedef np.float64_t DTYPE_t cimport cython def rectangular_overlap_grid(double xmin, double xmax, double ymin, double ymax, int nx, int ny, double width, double height, double theta, int use_exact, int subpixels): """ rectangular_overlap_grid(xmin, xmax, ymin, ymax, nx, ny, width, height, use_exact, subpixels) Area of overlap between a rectangle and a pixel grid. The rectangle is centered on the origin. Parameters ---------- xmin, xmax, ymin, ymax : float Extent of the grid in the x and y direction. nx, ny : int Grid dimensions. width : float The width of the rectangle height : float The height of the rectangle theta : float The position angle of the rectangle in radians (counterclockwise). use_exact : 0 or 1 If set to 1, calculates the exact overlap, while if set to 0, uses a subpixel sampling method with ``subpixel`` subpixels in each direction. subpixels : int If ``use_exact`` is 0, each pixel is resampled by this factor in each dimension. Thus, each pixel is divided into ``subpixels ** 2`` subpixels. Returns ------- frac : `~numpy.ndarray` 2-d array giving the fraction of the overlap. """ cdef unsigned int i, j cdef double x, y, dx, dy cdef double pxmin, pxmax, pymin, pymax # Define output array cdef np.ndarray[DTYPE_t, ndim=2] frac = np.zeros([ny, nx], dtype=DTYPE) if use_exact == 1: raise NotImplementedError("Exact mode has not been implemented for " "rectangular apertures") # Find the width of each element in x and y dx = (xmax - xmin) / nx dy = (ymax - ymin) / ny # TODO: can implement a bounding box here for efficiency (as for the # circular and elliptical aperture photometry) for i in range(nx): pxmin = xmin + i * dx # lower end of pixel pxmax = pxmin + dx # upper end of pixel for j in range(ny): pymin = ymin + j * dy pymax = pymin + dy frac[j, i] = rectangular_overlap_single_subpixel( pxmin, pymin, pxmax, pymax, width, height, theta, subpixels) return frac cdef double rectangular_overlap_single_subpixel(double x0, double y0, double x1, double y1, double width, double height, double theta, int subpixels): """ Return the fraction of overlap between a rectangle and a single pixel with given extent, using a sub-pixel sampling method. """ cdef unsigned int i, j cdef double x, y cdef double frac = 0. # Accumulator. cdef double cos_theta = cos(theta) cdef double sin_theta = sin(theta) cdef double half_width, half_height half_width = width / 2. half_height = height / 2. dx = (x1 - x0) / subpixels dy = (y1 - y0) / subpixels x = x0 - 0.5 * dx for i in range(subpixels): x += dx y = y0 - 0.5 * dy for j in range(subpixels): y += dy # Transform into frame of rotated rectangle x_tr = y * sin_theta + x * cos_theta y_tr = y * cos_theta - x * sin_theta if fabs(x_tr) < half_width and fabs(y_tr) < half_height: frac += 1. return frac / (subpixels * subpixels) photutils-0.2.1/photutils/geometry/tests/0000700000214200020070000000000012646264032022753 5ustar lbradleySTSCI\science00000000000000photutils-0.2.1/photutils/geometry/tests/__init__.py0000600000214200020070000000010012627615324025060 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst photutils-0.2.1/photutils/geometry/tests/test_circular_overlap_grid.py0000600000214200020070000000162212627615324030733 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst from __future__ import division import itertools from numpy.testing import assert_allclose from astropy.tests.helper import pytest from .. import circular_overlap_grid grid_sizes = [50, 500, 1000] circ_sizes = [0.2, 0.4, 0.8] use_exact = [0, 1] subsamples = [1, 5, 10] arg_list = ['grid_size', 'circ_size', 'use_exact', 'subsample'] @pytest.mark.parametrize(('grid_size', 'circ_size', 'use_exact', 'subsample'), list(itertools.product(grid_sizes, circ_sizes, use_exact, subsamples))) def test_circular_overlap_grid(grid_size, circ_size, use_exact, subsample): """ Test normalization of the overlap grid to make sure that a fully enclosed pixel has a value of 1.0. """ g = circular_overlap_grid(-1.0, 1.0, -1.0, 1.0, grid_size, grid_size, circ_size, use_exact, subsample) assert_allclose(g.max(), 1.0) photutils-0.2.1/photutils/geometry/tests/test_elliptical_overlap_grid.py0000600000214200020070000000204612627615324031252 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst from __future__ import division import itertools from numpy.testing import assert_allclose from astropy.tests.helper import pytest from .. import elliptical_overlap_grid grid_sizes = [50, 500, 1000] maj_sizes = [0.2, 0.4, 0.8] min_sizes = [0.2, 0.4, 0.8] angles = [0.0, 0.5, 1.0] use_exact = [0, 1] subsamples = [1, 5, 10] arg_list = ['grid_size', 'maj_size', 'min_size', 'angle', 'use_exact', 'subsample'] @pytest.mark.parametrize(('grid_size', 'maj_size', 'min_size', 'angle', 'use_exact', 'subsample'), list(itertools.product(grid_sizes, maj_sizes, min_sizes, angles, use_exact, subsamples))) def test_elliptical_overlap_grid(grid_size, maj_size, min_size, angle, use_exact, subsample): """ Test normalization of the overlap grid to make sure that a fully enclosed pixel has a value of 1.0. """ g = elliptical_overlap_grid(-1.0, 1.0, -1.0, 1.0, grid_size, grid_size, maj_size, min_size, angle, use_exact, subsample) assert_allclose(g.max(), 1.0) photutils-0.2.1/photutils/geometry/tests/test_rectangular_overlap_grid.py0000600000214200020070000000163312627615324031440 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst from __future__ import division import itertools from numpy.testing import assert_allclose from astropy.tests.helper import pytest from .. import rectangular_overlap_grid grid_sizes = [50, 500, 1000] rect_sizes = [0.2, 0.4, 0.8] angles = [0.0, 0.5, 1.0] subsamples = [1, 5, 10] arg_list = ['grid_size', 'rect_size', 'angle', 'subsample'] @pytest.mark.parametrize(('grid_size', 'rect_size', 'angle', 'subsample'), list(itertools.product(grid_sizes, rect_sizes, angles, subsamples))) def test_rectangular_overlap_grid(grid_size, rect_size, angle, subsample): """ Test normalization of the overlap grid to make sure that a fully enclosed pixel has a value of 1.0. """ g = rectangular_overlap_grid(-1.0, 1.0, -1.0, 1.0, grid_size, grid_size, rect_size, rect_size, angle, 0, subsample) assert_allclose(g.max(), 1.0) photutils-0.2.1/photutils/morphology.py0000600000214200020070000003574312634600603022540 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst """ Functions for centroiding sources and measuring their morphological properties. """ from __future__ import (absolute_import, division, print_function, unicode_literals) import collections import numpy as np from astropy.modeling.models import Gaussian1D, Gaussian2D, Const1D, Const2D from astropy.modeling.fitting import LevMarLSQFitter from astropy.nddata.utils import overlap_slices from .segmentation import SourceProperties import warnings from astropy.utils.exceptions import AstropyUserWarning __all__ = ['GaussianConst2D', 'centroid_com', 'gaussian1d_moments', 'marginalize_data2d', 'centroid_1dg', 'centroid_2dg', 'fit_2dgaussian', 'data_properties', 'cutout_footprint'] class _GaussianConst1D(Const1D + Gaussian1D): """A 1D Gaussian plus a constant model.""" class GaussianConst2D(Const2D + Gaussian2D): """ A 2D Gaussian plus a constant model. Parameters ---------- amplitude_0 : float Value of the constant. amplitude_1 : float Amplitude of the Gaussian. x_mean_1 : float Mean of the Gaussian in x. y_mean_1 : float Mean of the Gaussian in y. x_stddev_1 : float Standard deviation of the Gaussian in x. ``x_stddev`` and ``y_stddev`` must be specified unless a covariance matrix (``cov_matrix``) is input. y_stddev_1 : float Standard deviation of the Gaussian in y. ``x_stddev`` and ``y_stddev`` must be specified unless a covariance matrix (``cov_matrix``) is input. theta_1 : float, optional Rotation angle in radians. The rotation angle increases counterclockwise. cov_matrix_1 : ndarray, optional A 2x2 covariance matrix. If specified, overrides the ``x_stddev``, ``y_stddev``, and ``theta`` specification. """ def _convert_image(data, mask=None): """ Convert the input data to a float64 (double) `numpy.ndarray`, required for input to `skimage.measure.moments` and `skimage.measure.moments_central`. The input ``data`` is copied unless it already has that `numpy.dtype`. If ``mask`` is input, then masked pixels are set to zero in the output ``data``. Parameters ---------- data : array_like The 2D array of the image. mask : array_like (bool), optional A boolean mask, with the same shape as ``data``, where a `True` value indicates the corresponding element of ``data`` is masked. Masked pixels are set to zero in the output ``data``. Returns ------- image : `numpy.ndarray`, float64 The converted 2D array of the image, where masked pixels have been set to zero. """ try: if mask is None: copy = False else: copy = True image = np.asarray(data).astype(np.float, copy=copy) except TypeError: # pragma: no cover image = np.asarray(data).astype(np.float) # for numpy <= 1.6 if mask is not None: mask = np.asanyarray(mask) if data.shape != mask.shape: raise ValueError('data and mask must have the same shape') image[mask] = 0.0 return image def centroid_com(data, mask=None): """ Calculate the centroid of a 2D array as its center of mass determined from image moments. Parameters ---------- data : array_like The 2D array of the image. mask : array_like (bool), optional A boolean mask, with the same shape as ``data``, where a `True` value indicates the corresponding element of ``data`` is masked. Returns ------- xcen, ycen : float (x, y) coordinates of the centroid. """ from skimage.measure import moments data = _convert_image(data, mask=mask) m = moments(data, 1) xcen = m[1, 0] / m[0, 0] ycen = m[0, 1] / m[0, 0] return xcen, ycen def gaussian1d_moments(data, mask=None): """ Estimate 1D Gaussian parameters from the moments of 1D data. This function can be useful for providing initial parameter values when fitting a 1D Gaussian to the ``data``. Parameters ---------- data : array_like (1D) The 1D array. mask : array_like (1D bool), optional A boolean mask, with the same shape as ``data``, where a `True` value indicates the corresponding element of ``data`` is masked. Returns ------- amplitude, mean, stddev : float The estimated parameters of a 1D Gaussian. """ if mask is not None: mask = np.asanyarray(mask) data = data.copy() data[mask] = 0. x = np.arange(data.size) x_mean = np.sum(x * data) / np.sum(data) x_stddev = np.sqrt(abs(np.sum(data * (x - x_mean)**2) / np.sum(data))) amplitude = np.nanmax(data) - np.nanmin(data) return amplitude, x_mean, x_stddev def marginalize_data2d(data, error=None, mask=None): """ Generate the marginal x and y distributions from a 2D data array. Parameters ---------- data : array_like The 2D data array. error : array_like, optional The 2D array of the 1-sigma errors of the input ``data``. mask : array_like (bool), optional A boolean mask, with the same shape as ``data``, where a `True` value indicates the corresponding element of ``data`` is masked. Returns ------- marginal_data : list of `~numpy.ndarray` The marginal x and y distributions of the input ``data``. marginal_error : list of `~numpy.ndarray` The marginal x and y distributions of the input ``error``. marginal_mask : list of `~numpy.ndarray` (bool) The marginal x and y distributions of the input ``mask``. """ if error is not None: marginal_error = np.array( [np.sqrt(np.sum(error**2, axis=i)) for i in [0, 1]]) else: marginal_error = [None, None] if mask is not None: mask = np.asanyarray(mask) marginal_mask = [np.sum(mask, axis=i).astype(np.bool) for i in [0, 1]] else: marginal_mask = [None, None] marginal_data = [np.sum(data, axis=i) for i in [0, 1]] return marginal_data, marginal_error, marginal_mask def centroid_1dg(data, error=None, mask=None): """ Calculate the centroid of a 2D array by fitting 1D Gaussians to the marginal x and y distributions of the array. Parameters ---------- data : array_like The 2D data array. error : array_like, optional The 2D array of the 1-sigma errors of the input ``data``. mask : array_like (bool), optional A boolean mask, with the same shape as ``data``, where a `True` value indicates the corresponding element of ``data`` is masked. Returns ------- xcen, ycen : float (x, y) coordinates of the centroid. """ mdata, merror, mmask = marginalize_data2d(data, error=error, mask=mask) if merror[0] is None and mmask[0] is None: mweights = [None, None] else: if merror[0] is not None: mweights = [(1.0 / merror[i].clip(min=1.e-30)) for i in [0, 1]] else: mweights = np.array([np.ones(data.shape[1]), np.ones(data.shape[0])]) # down-weight masked pixels for i in [0, 1]: mweights[i][mmask[i]] = 1.e-20 const_init = np.min(data) centroid = [] for (mdata_i, mweights_i, mmask_i) in zip(mdata, mweights, mmask): params_init = gaussian1d_moments(mdata_i, mask=mmask_i) g_init = _GaussianConst1D(const_init, *params_init) fitter = LevMarLSQFitter() x = np.arange(mdata_i.size) g_fit = fitter(g_init, x, mdata_i, weights=mweights_i) centroid.append(g_fit.mean_1.value) return tuple(centroid) def centroid_2dg(data, error=None, mask=None): """ Calculate the centroid of a 2D array by fitting a 2D Gaussian (plus a constant) to the array. Parameters ---------- data : array_like The 2D data array. error : array_like, optional The 2D array of the 1-sigma errors of the input ``data``. mask : array_like (bool), optional A boolean mask, with the same shape as ``data``, where a `True` value indicates the corresponding element of ``data`` is masked. Returns ------- xcen, ycen : float (x, y) coordinates of the centroid. """ gfit = fit_2dgaussian(data, error=error, mask=mask) return gfit.x_mean_1.value, gfit.y_mean_1.value def fit_2dgaussian(data, error=None, mask=None): """ Fit a 2D Gaussian plus a constant to a 2D image. Parameters ---------- data : array_like The 2D array of the image. error : array_like, optional The 2D array of the 1-sigma errors of the input ``data``. mask : array_like (bool), optional A boolean mask, with the same shape as ``data``, where a `True` value indicates the corresponding element of ``data`` is masked. Returns ------- result : A `GaussianConst2D` model instance. The best-fitting Gaussian 2D model. """ if data.size < 7: warnings.warn('data array must have a least 7 values to fit a 2D ' 'Gaussian plus a constant', AstropyUserWarning) return None if error is not None: weights = 1.0 / error else: weights = None if mask is not None: mask = np.asanyarray(mask) if weights is None: weights = np.ones_like(data) # down-weight masked pixels weights[mask] = 1.e-30 # Subtract the minimum of the data as a crude background estimate. # This will also make the data values positive, preventing issues with # the moment estimation in data_properties (moments from negative data # values can yield undefined Gaussian parameters, e.g. x/y_stddev). shift = np.min(data) data = np.copy(data) - shift props = data_properties(data, mask=mask) init_values = np.array([props.xcentroid.value, props.ycentroid.value, props.semimajor_axis_sigma.value, props.semiminor_axis_sigma.value, props.orientation.value]) init_const = 0. # subtracted data minimum above init_amplitude = np.nanmax(data) - np.nanmin(data) g_init = GaussianConst2D(init_const, init_amplitude, *init_values) fitter = LevMarLSQFitter() y, x = np.indices(data.shape) gfit = fitter(g_init, x, y, data, weights=weights) gfit.amplitude_0 = gfit.amplitude_0 + shift return gfit def data_properties(data, mask=None, background=None): """ Calculate the centroid and morphological properties of a 2D array, e.g., an image cutout of an object. Parameters ---------- data : array_like or `~astropy.units.Quantity` The 2D array of the image. mask : array_like (bool), optional A boolean mask, with the same shape as ``data``, where a `True` value indicates the corresponding element of ``data`` is masked. Masked data are excluded from all calculations. background : float, array_like, or `~astropy.units.Quantity`, optional The background level that was previously present in the input ``data``. ``background`` may either be a scalar value or a 2D image with the same shape as the input ``data``. Inputting the ``background`` merely allows for its properties to be measured within each source segment. The input ``background`` does *not* get subtracted from the input ``data``, which should already be background-subtracted. Returns ------- result : `~photutils.segmentation.SourceProperties` instance A `~photutils.segmentation.SourceProperties` object. """ segment_image = np.ones(data.shape, dtype=np.int) return SourceProperties(data, segment_image, label=1, mask=mask, background=background) def cutout_footprint(data, position, box_size=3, footprint=None, mask=None, error=None): """ Cut out a region from data (and optional mask and error) centered at specified (x, y) position. The size of the region is specified via the ``box_size`` or ``footprint`` keywords. The output mask for the cutout region represents the combination of the input mask and footprint mask. Parameters ---------- data : array_like The 2D array of the image. position : 2 tuple The ``(x, y)`` pixel coordinate of the center of the region. box_size : scalar or tuple, optional The size of the region to cutout from ``data``. If ``box_size`` is a scalar, then the region shape will be ``(box_size, box_size)``. Either ``box_size`` or ``footprint`` must be defined. If they are both defined, then ``footprint`` overrides ``box_size``. footprint : `~numpy.ndarray` of bools, optional A boolean array where `True` values describe the local footprint region. ``box_size=(n, m)`` is equivalent to ``footprint=np.ones((n, m))``. Either ``box_size`` or ``footprint`` must be defined. If they are both defined, then ``footprint`` overrides ``box_size``. mask : array_like, bool, optional A boolean mask with the same shape as ``data``, where a `True` value indicates the corresponding element of ``data`` is masked. error : array_like, optional The 2D array of the 1-sigma errors of the input ``data``. Returns ------- region_data : `~numpy.ndarray` The ``data`` cutout. region_mask : `~numpy.ndarray` The ``mask`` cutout. region_error : `~numpy.ndarray` The ``error`` cutout. slices : tuple of slices Slices in each dimension of the ``data`` array used to define the cutout region. """ if len(position) != 2: raise ValueError('position must have a length of 2') if footprint is None: if box_size is None: raise ValueError('box_size or footprint must be defined.') if not isinstance(box_size, collections.Iterable): shape = (box_size, box_size) else: if len(box_size) != 2: raise ValueError('box_size must have a length of 2') shape = box_size footprint = np.ones(shape, dtype=bool) else: footprint = np.asanyarray(footprint, dtype=bool) slices_large, slices_small = overlap_slices(data.shape, footprint.shape, position[::-1]) region_data = data[slices_large] if error is not None: region_error = error[slices_large] else: region_error = None if mask is not None: region_mask = mask[slices_large] else: region_mask = np.zeros_like(region_data, dtype=bool) footprint_mask = ~footprint footprint_mask = footprint_mask[slices_small] # trim if necessary region_mask = np.logical_or(region_mask, footprint_mask) return region_data, region_mask, region_error, slices_large photutils-0.2.1/photutils/psf.py0000600000214200020070000004712012627615324021131 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst """Functions for performing PSF fitting photometry on 2D arrays.""" from __future__ import division import warnings import numpy as np from astropy.modeling.parameters import Parameter from astropy.utils.exceptions import AstropyUserWarning from astropy.modeling.fitting import LevMarLSQFitter from astropy.modeling import Fittable2DModel from astropy.nddata.utils import extract_array, add_array, subpixel_indices from .utils import mask_to_mirrored_num __all__ = ['DiscretePRF', 'create_prf', 'psf_photometry', 'GaussianPSF', 'subtract_psf'] class DiscretePRF(Fittable2DModel): """ A discrete PRF model. The discrete PRF model stores images of the PRF at different subpixel positions or offsets as a lookup table. The resolution is given by the subsampling parameter, which states in how many subpixels a pixel is divided. The discrete PRF model class in initialized with a 4 dimensional array, that contains the PRF images at different subpixel positions. The definition of the axes is as following: 1. Axis: y subpixel position 2. Axis: x subpixel position 3. Axis: y direction of the PRF image 4. Axis: x direction of the PRF image The total array therefore has the following shape (subsampling, subsampling, prf_size, prf_size) Parameters ---------- prf_array : ndarray Array containing PRF images. normalize : bool Normalize PRF images to unity. subsampling : int, optional Factor of subsampling. Default = 1. """ amplitude = Parameter('amplitude') x_0 = Parameter('x_0') y_0 = Parameter('y_0') linear = True def __init__(self, prf_array, normalize=True, subsampling=1): # Array shape and dimension check if subsampling == 1: if prf_array.ndim == 2: prf_array = np.array([[prf_array]]) if prf_array.ndim != 4: raise TypeError('Array must have 4 dimensions.') if prf_array.shape[:2] != (subsampling, subsampling): raise TypeError('Incompatible subsampling and array size') if np.isnan(prf_array).any(): raise Exception("Array contains NaN values. Can't create PRF.") # Normalize if requested if normalize: for i in range(prf_array.shape[0]): for j in range(prf_array.shape[1]): prf_array[i, j] /= prf_array[i, j].sum() # Set PRF asttributes self._prf_array = prf_array self.subsampling = subsampling constraints = {'fixed': {'x_0': True, 'y_0': True}} x_0 = 0 y_0 = 0 amplitude = 1 super(DiscretePRF, self).__init__(n_models=1, x_0=x_0, y_0=y_0, amplitude=amplitude, **constraints) self.fitter = LevMarLSQFitter() # Fix position per default self.x_0.fixed = True self.y_0.fixed = True @property def shape(self): """ Shape of the PRF image. """ return self._prf_array.shape[-2:] def evaluate(self, x, y, amplitude, x_0, y_0): """ Discrete PRF model evaluation. Given a certain position and amplitude the corresponding image of the PSF is chosen and scaled to the amplitude. If x and y are outside the boundaries of the image, zero will be returned. Parameters ---------- x : float x coordinate array in pixel coordinates. y : float y coordinate array in pixel coordinates. amplitude : float Model amplitude. x_0 : float x position of the center of the PRF. y_0 : float y position of the center of the PRF. """ # Convert x and y to index arrays x = (x - x_0 + 0.5 + self.shape[1] // 2).astype('int') y = (y - y_0 + 0.5 + self.shape[0] // 2).astype('int') # Get subpixel indices y_sub, x_sub = subpixel_indices((y_0, x_0), self.subsampling) # Out of boundary masks x_bound = np.logical_or(x < 0, x >= self.shape[1]) y_bound = np.logical_or(y < 0, y >= self.shape[0]) out_of_bounds = np.logical_or(x_bound, y_bound) # Set out of boundary indices to zero x[x_bound] = 0 y[y_bound] = 0 result = amplitude * self._prf_array[int(y_sub), int(x_sub)][y, x] # Set out of boundary values to zero result[out_of_bounds] = 0 return result def fit(self, data, indices): """ Fit PSF/PRF to data. Fits the PSF/PRF to the data and returns the best fitting flux. If the data contains NaN values or if the source is not completely contained in the image data the fitting is omitted and a flux of 0 is returned. For reasons of performance, indices for the data have to be created outside and passed to the function. The fit is performed on a slice of the data with the same size as the PRF. Parameters ---------- data : ndarray Array containig image data. indices : ndarray Array with indices of the data. As returned by np.indices(data.shape) """ # Extract sub array of the data of the size of the PRF grid sub_array_data = extract_array(data, self.shape, (self.y_0.value, self.x_0.value)) # Fit only if PSF is completely contained in the image and no NaN # values are present if (sub_array_data.shape == self.shape and not np.isnan(sub_array_data).any()): y = extract_array(indices[0], self.shape, (self.y_0.value, self.x_0.value)) x = extract_array(indices[1], self.shape, (self.y_0.value, self.x_0.value)) # TODO: It should be discussed whether this is the right # place to fix the warning. Maybe it should be handled better # in astropy.modeling.fitting with warnings.catch_warnings(): warnings.simplefilter("ignore", AstropyUserWarning) m = self.fitter(self, x, y, sub_array_data) return m.amplitude.value else: return 0 class GaussianPSF(Fittable2DModel): """ Symmetrical Gaussian PSF model. The PSF is evaluated by using the `scipy.special.erf` function on a fixed grid of the size of 1 pixel to assure flux conservation on subpixel scale. Parameters ---------- sigma : float Width of the Gaussian PSF. amplitude : float (default 1) The peak amplitude of the PSF. x_0 : float (default 0) Position of the peak in x direction. y_0 : float (default 0) Position of the peak in y direction. Notes ----- The PSF model is evaluated according to the following formula: .. math:: f(x, y) = \\frac{A}{0.02538010595464} \\left[ \\textnormal{erf} \\left(\\frac{x - x_0 + 0.5} {\\sqrt{2} \\sigma} \\right) - \\textnormal{erf} \\left(\\frac{x - x_0 - 0.5} {\\sqrt{2} \\sigma} \\right) \\right] \\left[ \\textnormal{erf} \\left(\\frac{y - y_0 + 0.5} {\\sqrt{2} \\sigma} \\right) - \\textnormal{erf} \\left(\\frac{y - y_0 - 0.5} {\\sqrt{2} \\sigma} \\right) \\right] Where ``erf`` denotes the error function and ``A`` is the amplitude. """ amplitude = Parameter('amplitude') x_0 = Parameter('x_0') y_0 = Parameter('y_0') sigma = Parameter('sigma') _erf = None def __init__(self, sigma, amplitude=1, x_0=0, y_0=0): if self._erf is None: from scipy.special import erf self.__class__._erf = erf constraints = {'fixed': {'x_0': True, 'y_0': True, 'sigma': True}} super(GaussianPSF, self).__init__(n_models=1, sigma=sigma, x_0=x_0, y_0=y_0, amplitude=amplitude, **constraints) # Default size is 8 * sigma self.shape = (int(8 * sigma) + 1, int(8 * sigma) + 1) self.fitter = LevMarLSQFitter() # Fix position per default self.x_0.fixed = True self.y_0.fixed = True def evaluate(self, x, y, amplitude, x_0, y_0, sigma): """ Model function Gaussian PSF model. """ psf = (1.0 * ((self._erf((x - x_0 + 0.5) / (np.sqrt(2) * sigma)) - self._erf((x - x_0 - 0.5) / (np.sqrt(2) * sigma))) * (self._erf((y - y_0 + 0.5) / (np.sqrt(2) * sigma)) - self._erf((y - y_0 - 0.5) / (np.sqrt(2) * sigma))))) return amplitude * psf / psf.max() def fit(self, data, indices): """ Fit PSF/PRF to data. Fits the PSF/PRF to the data and returns the best fitting flux. If the data contains NaN values or if the source is not completely contained in the image data the fitting is omitted and a flux of 0 is returned. For reasons of performance, indices for the data have to be created outside and passed to the function. The fit is performed on a slice of the data with the same size as the PRF. Parameters ---------- data : ndarray Array containig image data. indices : ndarray Array with indices of the data. As returned by np.indices(data.shape) Returns ------- flux : float Best fit flux value. Returns flux = 0 if PSF is not completely contained in the image or if NaN values are present. """ # Set position position = (self.y_0.value, self.x_0.value) # Extract sub array with data of interest sub_array_data = extract_array(data, self.shape, position) # Fit only if PSF is completely contained in the image and no NaN # values are present if (sub_array_data.shape == self.shape and not np.isnan(sub_array_data).any()): y = extract_array(indices[0], self.shape, position) x = extract_array(indices[1], self.shape, position) m = self.fitter(self, x, y, sub_array_data) return m.amplitude.value else: return 0 def psf_photometry(data, positions, psf, mask=None, mode='sequential', tune_coordinates=False): """ Perform PSF/PRF photometry on the data. Given a PSF or PRF model, the model is fitted simultaneously or sequentially to the given positions to obtain an estimate of the flux. If required, coordinates are also tuned to match best the data. If the data contains NaN values or the PSF/PRF is not completely contained in the image, a flux of zero is returned. Parameters ---------- data : ndarray Image data array positions : List or array List of positions in pixel coordinates where to fit the PSF/PRF. psf : `photutils.psf.DiscretePRF` or `photutils.psf.GaussianPSF` PSF/PRF model to fit to the data. mask : ndarray, optional Mask to be applied to the data. mode : {'sequential', 'simultaneous'} One of the following modes to do PSF/PRF photometry: * 'simultaneous' Fit PSF/PRF simultaneous to all given positions. * 'sequential' (default) Fit PSF/PRF one after another to the given positions. tune_coordinates : boolean If ``True`` the peak position of the PSF will be fit, if ``False``, it is frozen to the input value. Examples -------- See `Spitzer PSF Photometry `_ for a short tutorial. """ # Check input array type and dimension. if np.iscomplexobj(data): raise TypeError('Complex type not supported') if data.ndim != 2: raise ValueError('{0}-d array not supported. ' 'Only 2-d arrays supported.'.format(data.ndim)) # Fit coordinates if requested if tune_coordinates: psf.fixed['x_0'] = False psf.fixed['y_0'] = False else: psf.fixed['x_0'] = True psf.fixed['y_0'] = True # Actual photometry result = np.array([]) indices = np.indices(data.shape) if mode == 'simultaneous': raise NotImplementedError('Simultaneous mode not implemented') elif mode == 'sequential': for position in positions: psf.x_0, psf.y_0 = position flux = psf.fit(data, indices) result = np.append(result, flux) else: raise Exception('Invalid photometry mode.') return result def create_prf(data, positions, size, fluxes=None, mask=None, mode='mean', subsampling=1, fix_nan=False): """ Estimate point response function (PRF) from image data. Given a list of positions and size this function estimates an image of the PRF by extracting and combining the individual PRFs from the given positions. Different modes of combining are available. NaN values are either ignored by passing a mask or can be replaced by the mirrored value with respect to the center of the PRF. Furthermore it is possible to specify fluxes to have a correct normalization of the individual PRFs. Otherwise the flux is estimated from a quadratic aperture of the same size as the PRF image. Parameters ---------- data : array Data array positions : List or array List of pixel coordinate source positions to use in creating the PRF. size : odd int Size of the quadratic PRF image in pixels. mask : bool array, optional Boolean array to mask out bad values. fluxes : array, optional Object fluxes to normalize extracted PRFs. mode : {'mean', 'median'} One of the following modes to combine the extracted PRFs: * 'mean' Take the pixelwise mean of the extracted PRFs. * 'median' Take the pixelwise median of the extracted PRFs. subsampling : int Factor of subsampling of the PRF (default = 1). fix_nan : bool Fix NaN values in the data by replacing it with the mirrored value. Assuming that the PRF is symmetrical. Returns ------- prf : `photutils.psf.DiscretePRF` Discrete PRF model estimated from data. Notes ----- In Astronomy different definitions of Point Spread Function (PSF) and Point Response Function (PRF) are used. Here we assume that the PRF is an image of a point source after discretization e.g. with a CCD. This definition is equivalent to the `Spitzer definiton of the PRF `_. References ---------- `Spitzer PSF vs. PRF `_ `Kepler PSF calibration `_ `The Kepler Pixel Response Function `_ """ # Check input array type and dimension. if np.iscomplexobj(data): raise TypeError('Complex type not supported') if data.ndim != 2: raise ValueError('{0}-d array not supported. ' 'Only 2-d arrays supported.'.format(data.ndim)) if size % 2 == 0: raise TypeError("Size must be odd.") if fluxes is not None and len(fluxes) != len(positions): raise TypeError("Position and flux arrays must be of equal length.") if mask is None: mask = np.isnan(data) if isinstance(positions, (list, tuple)): positions = np.array(positions) if isinstance(fluxes, (list, tuple)): fluxes = np.array(fluxes) if mode == 'mean': combine = np.ma.mean elif mode == 'median': combine = np.ma.median else: raise Exception('Invalid mode to combine prfs.') data_internal = np.ma.array(data=data, mask=mask) prf_model = np.ndarray(shape=(subsampling, subsampling, size, size)) positions_subpixel_indices = np.array([subpixel_indices(_, subsampling) for _ in positions], dtype=np.int) for i in range(subsampling): for j in range(subsampling): extracted_sub_prfs = [] sub_prf_indices = np.all(positions_subpixel_indices == [j, i], axis=1) positions_sub_prfs = positions[sub_prf_indices] for k, position in enumerate(positions_sub_prfs): x, y = position extracted_prf = extract_array(data_internal, (size, size), (y, x)) # Check shape to exclude incomplete PRFs at the boundaries # of the image if (extracted_prf.shape == (size, size) and np.ma.sum(extracted_prf) != 0): # Replace NaN values by mirrored value, with respect # to the prf's center if fix_nan: prf_nan = extracted_prf.mask if prf_nan.any(): if (prf_nan.sum() > 3 or prf_nan[size // 2, size // 2]): continue else: extracted_prf = mask_to_mirrored_num( extracted_prf, prf_nan, (size // 2, size // 2)) # Normalize and add extracted PRF to data cube if fluxes is None: extracted_prf_norm = (np.ma.copy(extracted_prf) / np.ma.sum(extracted_prf)) else: fluxes_sub_prfs = fluxes[sub_prf_indices] extracted_prf_norm = (np.ma.copy(extracted_prf) / fluxes_sub_prfs[k]) extracted_sub_prfs.append(extracted_prf_norm) else: continue prf_model[i, j] = np.ma.getdata( combine(np.ma.dstack(extracted_sub_prfs), axis=2)) return DiscretePRF(prf_model, subsampling=subsampling) def subtract_psf(data, psf, positions, fluxes, mask=None): """ Removes PSF/PRF at the given positions. To calculate residual images the PSF/PRF model is subtracted from the data at the given positions. Parameters ---------- data : ndarray Image data. psf : `photutils.psf.DiscretePRF` or `photutils.psf.GaussianPSF` PSF/PRF model to be substracted from the data. positions : ndarray List of center positions where PSF/PRF is removed. fluxes : ndarray List of fluxes of the sources, for correct normalization. """ # Set up indices indices = np.indices(data.shape) data_ = data.copy() # Loop over position for i, position in enumerate(positions): x_0, y_0 = position y = extract_array(indices[0], psf.shape, (y_0, x_0)) x = extract_array(indices[1], psf.shape, (y_0, x_0)) psf.amplitude.value = fluxes[i] psf.x_0.value, psf.y_0.value = x_0, y_0 psf_image = psf(x, y) data_ = add_array(data_, -psf_image, (y_0, x_0)) return data_ photutils-0.2.1/photutils/segmentation.py0000600000214200020070000020577312646242520023043 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst from __future__ import (absolute_import, division, print_function, unicode_literals) from distutils.version import LooseVersion import numpy as np from astropy.table import Table from astropy.utils import lazyproperty import astropy.units as u from astropy.wcs.utils import pixel_to_skycoord from .utils.convolution import _convolve_data from .utils.prepare_data import _prepare_data __all__ = ['SegmentationImage', 'SourceProperties', 'source_properties', 'properties_table'] # outline_segments requires scikit-image >= 0.11 __doctest_skip__ = {'SegmentationImage.outline_segments'} __doctest_requires__ = {('SegmentationImage', 'SegmentationImage.*', 'SourceProperties', 'SourceProperties.*', 'source_properties', 'properties_table'): ['scipy'], ('SegmentationImage', 'SegmentationImage.*', 'SourceProperties', 'SourceProperties.*', 'source_properties', 'properties_table'): ['skimage']} class SegmentationImage(object): """ Class for a segmentation image. Parameters ---------- data : array_like (int) A 2D segmentation image where sources are labeled by different positive integer values. A value of zero is reserved for the background. """ def __init__(self, data): if np.min(data) < 0: raise ValueError('The segmentation image cannot contain ' 'negative integers.') self._data = np.asanyarray(data, dtype=np.int) self._update_slices() def _update_slices(self): """ Update the segmentation slices after changes to self._data made by the class methods. """ from scipy.ndimage import find_objects self.slices = find_objects(self._data) @property def data(self): """ The 2D segmentation image. """ return self._data @property def array(self): """ The 2D segmentation image. """ return self._data def __array__(self): """ Array representation of the segmentation image (e.g., for matplotlib). """ return self._data @property def data_masked(self): """ A `~numpy.ma.MaskedArray` version of the segmentation image where the background (label = 0) has been masked. """ return np.ma.masked_where(self.data == 0, self.data) @staticmethod def _labels(data): """ Return a sorted array of the non-zero labels in the segmentation image. Parameters ---------- data : array_like (int) A 2D segmentation image where sources are labeled by different positive integer values. A value of zero is reserved for the background. Returns ------- result : `~numpy.ndarray` An array of non-zero label numbers. Notes ----- This is a separate static method so it can be used on masked versions of the segmentation image (cf. ``~photutils.SegmentationImage.remove_masked_labels``. Examples -------- >>> from photutils import SegmentationImage >>> segm = SegmentationImage([[1, 1, 0, 0, 4, 4], ... [0, 0, 0, 0, 0, 4], ... [0, 0, 3, 3, 0, 0], ... [7, 0, 0, 0, 0, 5], ... [7, 7, 0, 5, 5, 5], ... [7, 7, 0, 0, 5, 5]]) >>> segm._labels(segm.data) array([1, 3, 4, 5, 7]) """ return np.unique(data[data != 0]) @property def shape(self): """ The shape of the 2D segmentation image. """ return self._data.shape @property def labels(self): """The sorted non-zero labels in the segmentation image.""" return self._labels(self.data) @property def nlabels(self): """The number of non-zero labels in the segmentation image.""" return len(self.labels) @property def max(self): """The maximum non-zero label in the segmentation image.""" return np.max(self.data) @property def is_sequential(self): """ Determine whether or not the non-zero labels in the segmenation image are sequential (with no missing values). """ if (self.labels[-1] - self.labels[0] + 1) == self.nlabels: return True else: return False def check_label(self, label): """ Check for a valid label label number within the segmentation image. Parameters ---------- label : int The label number to check. Raises ------ ValueError If the input ``label`` is invalid. """ if label == 0: raise ValueError('label "0" is reserved for the background') if label < 0: raise ValueError('label must be a positive integer, got ' '"{0}"'.format(label)) if label not in self.data: raise ValueError('label "{0}" is not in the segmentation ' 'image'.format(label)) def outline_segments(self, mask_background=False): """ Outline the labeled segments. The "outlines" represent the pixels *just inside* the segments, leaving the background pixels unmodified. This corresponds to the ``mode='inner'`` in `skimage.segmentation.find_boundaries`. Parameters ---------- mask_background : bool, optional Set to `True` to mask the background pixels (labels = 0) in the returned image. This is useful for overplotting the segment outlines on an image. The default is `False`. Returns ------- boundaries : 2D `~numpy.ndarray` or `~numpy.ma.MaskedArray` An image with the same shape of the segmenation image containing only the outlines of the labeled segments. The pixel values in the outlines correspond to the labels in the segmentation image. If ``mask_background`` is `True`, then a `~numpy.ma.MaskedArray` is returned. Examples -------- >>> from photutils import SegmentationImage >>> segm = SegmentationImage([[0, 0, 0, 0, 0, 0], ... [0, 2, 2, 2, 2, 0], ... [0, 2, 2, 2, 2, 0], ... [0, 2, 2, 2, 2, 0], ... [0, 2, 2, 2, 2, 0], ... [0, 0, 0, 0, 0, 0]]) >>> segm.outline_segments() array([[0, 0, 0, 0, 0, 0], [0, 2, 2, 2, 2, 0], [0, 2, 0, 0, 2, 0], [0, 2, 0, 0, 2, 0], [0, 2, 2, 2, 2, 0], [0, 0, 0, 0, 0, 0]]) """ import skimage if LooseVersion(skimage.__version__) < LooseVersion('0.11'): raise ImportError('The outline_segments() function requires ' 'scikit-image >= 0.11') from skimage.segmentation import find_boundaries outlines = self.data * find_boundaries(self.data, mode='inner') if mask_background: outlines = np.ma.masked_where(outlines == 0, outlines) return outlines def relabel(self, labels, new_label): """ Relabel one or more label numbers. The input ``labels`` will all be relabeled to ``new_label``. Parameters ---------- labels : int, array-like (1D, int) The label numbers(s) to relabel. new_label : int The relabeled label number. Examples -------- >>> from photutils import SegmentationImage >>> segm = SegmentationImage([[1, 1, 0, 0, 4, 4], ... [0, 0, 0, 0, 0, 4], ... [0, 0, 3, 3, 0, 0], ... [7, 0, 0, 0, 0, 5], ... [7, 7, 0, 5, 5, 5], ... [7, 7, 0, 0, 5, 5]]) >>> segm.relabel(labels=[1, 7], new_label=2) >>> segm.data array([[2, 2, 0, 0, 4, 4], [0, 0, 0, 0, 0, 4], [0, 0, 3, 3, 0, 0], [2, 0, 0, 0, 0, 5], [2, 2, 0, 5, 5, 5], [2, 2, 0, 0, 5, 5]]) """ labels = np.atleast_1d(labels) for label in labels: self._data[np.where(self.data == label)] = new_label self._update_slices() def relabel_sequential(self, start_label=1): """ Relabel the label numbers sequentially, such that there are no missing label numbers (up to the maximum label number). Parameters ---------- start_label : int, optional The starting label number, which should be a positive integer. The default is 1. Examples -------- >>> from photutils import SegmentationImage >>> segm = SegmentationImage([[1, 1, 0, 0, 4, 4], ... [0, 0, 0, 0, 0, 4], ... [0, 0, 3, 3, 0, 0], ... [7, 0, 0, 0, 0, 5], ... [7, 7, 0, 5, 5, 5], ... [7, 7, 0, 0, 5, 5]]) >>> segm.relabel_sequential() >>> segm.data array([[1, 1, 0, 0, 3, 3], [0, 0, 0, 0, 0, 3], [0, 0, 2, 2, 0, 0], [5, 0, 0, 0, 0, 4], [5, 5, 0, 4, 4, 4], [5, 5, 0, 0, 4, 4]]) """ if start_label <= 0: raise ValueError('start_label must be > 0.') if self.is_sequential and (self.labels[0] == start_label): return forward_map = np.zeros(self.max + 1, dtype=np.int) forward_map[self.labels] = np.arange(self.nlabels) + start_label self._data = forward_map[self.data] self._update_slices() def keep_labels(self, labels, relabel=False): """ Keep only the specified label numbers. Parameters ---------- labels : int, array-like (1D, int) The label number(s) to keep. Labels of zero and those not in the segmentation image will be ignored. relabel : bool, optional If `True`, then the segmentation image will be relabeled such that the labels are in sequential order starting from 1. Examples -------- >>> from photutils import SegmentationImage >>> segm = SegmentationImage([[1, 1, 0, 0, 4, 4], ... [0, 0, 0, 0, 0, 4], ... [0, 0, 3, 3, 0, 0], ... [7, 0, 0, 0, 0, 5], ... [7, 7, 0, 5, 5, 5], ... [7, 7, 0, 0, 5, 5]]) >>> segm.keep_labels(labels=3) >>> segm.data array([[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 3, 3, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]) >>> segm = SegmentationImage([[1, 1, 0, 0, 4, 4], ... [0, 0, 0, 0, 0, 4], ... [0, 0, 3, 3, 0, 0], ... [7, 0, 0, 0, 0, 5], ... [7, 7, 0, 5, 5, 5], ... [7, 7, 0, 0, 5, 5]]) >>> segm.keep_labels(labels=[5, 3]) >>> segm.data array([[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 3, 3, 0, 0], [0, 0, 0, 0, 0, 5], [0, 0, 0, 5, 5, 5], [0, 0, 0, 0, 5, 5]]) """ labels = np.atleast_1d(labels) labels_tmp = list(set(self.labels) - set(labels)) self.remove_labels(labels_tmp, relabel=relabel) def remove_labels(self, labels, relabel=False): """ Remove one or more label numbers. Parameters ---------- labels : int, array-like (1D, int) The label number(s) to remove. Labels of zero and those not in the segmentation image will be ignored. relabel : bool, optional If `True`, then the segmentation image will be relabeled such that the labels are in sequential order starting from 1. Examples -------- >>> from photutils import SegmentationImage >>> segm = SegmentationImage([[1, 1, 0, 0, 4, 4], ... [0, 0, 0, 0, 0, 4], ... [0, 0, 3, 3, 0, 0], ... [7, 0, 0, 0, 0, 5], ... [7, 7, 0, 5, 5, 5], ... [7, 7, 0, 0, 5, 5]]) >>> segm.remove_labels(labels=5) >>> segm.data array([[1, 1, 0, 0, 4, 4], [0, 0, 0, 0, 0, 4], [0, 0, 3, 3, 0, 0], [7, 0, 0, 0, 0, 0], [7, 7, 0, 0, 0, 0], [7, 7, 0, 0, 0, 0]]) >>> segm = SegmentationImage([[1, 1, 0, 0, 4, 4], ... [0, 0, 0, 0, 0, 4], ... [0, 0, 3, 3, 0, 0], ... [7, 0, 0, 0, 0, 5], ... [7, 7, 0, 5, 5, 5], ... [7, 7, 0, 0, 5, 5]]) >>> segm.remove_labels(labels=[5, 3]) >>> segm.data array([[1, 1, 0, 0, 4, 4], [0, 0, 0, 0, 0, 4], [0, 0, 0, 0, 0, 0], [7, 0, 0, 0, 0, 0], [7, 7, 0, 0, 0, 0], [7, 7, 0, 0, 0, 0]]) """ self.relabel(labels, new_label=0) if relabel: self.relabel_sequential() def remove_border_labels(self, border_width, partial_overlap=True, relabel=False): """ Remove labeled segments near the image border. Labels within the defined border region will be removed. Parameters ---------- border_width : int The width of the border region in pixels. partial_overlap : bool, optional If this is set to `True` (the default), a segment that partially extends into the border region will be removed. Segments that are completely within the border region are always removed. relabel : bool, optional If `True`, then the segmentation image will be relabeled such that the labels are in sequential order starting from 1. Examples -------- >>> from photutils import SegmentationImage >>> segm = SegmentationImage([[1, 1, 0, 0, 4, 4], ... [0, 0, 0, 0, 0, 4], ... [0, 0, 3, 3, 0, 0], ... [7, 0, 0, 0, 0, 5], ... [7, 7, 0, 5, 5, 5], ... [7, 7, 0, 0, 5, 5]]) >>> segm.remove_border_labels(border_width=1) >>> segm.data array([[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 3, 3, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]) >>> segm = SegmentationImage([[1, 1, 0, 0, 4, 4], ... [0, 0, 0, 0, 0, 4], ... [0, 0, 3, 3, 0, 0], ... [7, 0, 0, 0, 0, 5], ... [7, 7, 0, 5, 5, 5], ... [7, 7, 0, 0, 5, 5]]) >>> segm.remove_border_labels(border_width=1, ... partial_overlap=False) >>> segm.data array([[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 3, 3, 0, 0], [7, 0, 0, 0, 0, 5], [7, 7, 0, 5, 5, 5], [7, 7, 0, 0, 5, 5]]) """ if border_width >= min(self.shape) / 2: raise ValueError('border_width must be smaller than half the ' 'image size in either dimension') border = np.zeros(self.shape, dtype=np.bool) border[:border_width, :] = True border[-border_width:, :] = True border[:, :border_width] = True border[:, -border_width:] = True self.remove_masked_labels(border, partial_overlap=partial_overlap, relabel=relabel) def remove_masked_labels(self, mask, partial_overlap=True, relabel=False): """ Remove labeled segments located within a masked region. Parameters ---------- mask : array_like (bool) A boolean mask, with the same shape as the segmentation image (``.data``), where `True` values indicate masked pixels. partial_overlap : bool, optional If this is set to `True` (the default), a segment that partially extends into a masked region will also be removed. Segments that are completely within a masked region are always removed. relabel : bool, optional If `True`, then the segmentation image will be relabeled such that the labels are in sequential order starting from 1. Examples -------- >>> from photutils import SegmentationImage >>> segm = SegmentationImage([[1, 1, 0, 0, 4, 4], ... [0, 0, 0, 0, 0, 4], ... [0, 0, 3, 3, 0, 0], ... [7, 0, 0, 0, 0, 5], ... [7, 7, 0, 5, 5, 5], ... [7, 7, 0, 0, 5, 5]]) >>> mask = np.zeros_like(segm.data, dtype=np.bool) >>> mask[0, :] = True # mask the first row >>> segm.remove_masked_labels(mask) >>> segm.data array([[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 3, 3, 0, 0], [7, 0, 0, 0, 0, 5], [7, 7, 0, 5, 5, 5], [7, 7, 0, 0, 5, 5]]) >>> segm = SegmentationImage([[1, 1, 0, 0, 4, 4], ... [0, 0, 0, 0, 0, 4], ... [0, 0, 3, 3, 0, 0], ... [7, 0, 0, 0, 0, 5], ... [7, 7, 0, 5, 5, 5], ... [7, 7, 0, 0, 5, 5]]) >>> segm.remove_masked_labels(mask, partial_overlap=False) >>> segm.data array([[0, 0, 0, 0, 4, 4], [0, 0, 0, 0, 0, 4], [0, 0, 3, 3, 0, 0], [7, 0, 0, 0, 0, 5], [7, 7, 0, 5, 5, 5], [7, 7, 0, 0, 5, 5]]) """ if mask.shape != self.shape: raise ValueError('mask must have the same shape as the ' 'segmentation image') remove_labels = self._labels(self.data[mask]) if not partial_overlap: interior_labels = self._labels(self.data[~mask]) remove_labels = list(set(remove_labels) - set(interior_labels)) self.remove_labels(remove_labels, relabel=relabel) class SourceProperties(object): """ Class to calculate photometry and morphological properties of a single labeled source. Parameters ---------- data : array_like or `~astropy.units.Quantity` The 2D array from which to calculate the source photometry and properties. If ``filtered_data`` is input, then it will be used instead of ``data`` to calculate the source centroid and morphological properties. Source photometry is always measured from ``data``. ``data`` should be background-subtracted. segment_img : `SegmentationImage` or array_like (int) A 2D segmentation image, either as a `SegmentationImage` object or an `~numpy.ndarray`, with the same shape as ``data`` where sources are labeled by different positive integer values. A value of zero is reserved for the background. label : int The label number of the source whose properties to calculate. filtered_data : array-like or `~astropy.units.Quantity`, optional The filtered version of the background-subtracted ``data`` from which to calculate the source centroid and morphological properties. The kernel used to perform the filtering should be the same one used in defining the source segments (e.g., see :func:`~photutils.detect_sources`). If `None`, then the unfiltered ``data`` will be used instead. Note that `SExtractor`_'s centroid and morphological parameters are calculated from the filtered "detection" image. error : array_like or `~astropy.units.Quantity`, optional The pixel-wise Gaussian 1-sigma errors of the input ``data``. If ``effective_gain`` is input, then ``error`` should include all sources of "background" error but *exclude* the Poisson error of the sources. If ``effective_gain`` is `None`, then ``error`` is assumed to include *all* sources of error, including the Poisson error of the sources. ``error`` must have the same shape as ``data``. See the Notes section below for details on the error propagation. effective_gain : float, array-like, or `~astropy.units.Quantity`, optional Ratio of counts (e.g., electrons or photons) to the units of ``data``. This ratio is used to calculate the Poisson error of the sources when it is not included in ``error``. If ``effective_gain`` is `None`, then ``error`` is assumed to include *all* sources of error. See the Notes section below for details on the error propagation. If you are calculating the properties of many sources from the same data, it is highly recommended that you input a *total* error array instead of using ``effective_gain``. Otherwise a total error array will need to be repeatedly recalculated. mask : array_like (bool), optional A boolean mask with the same shape as ``data`` where a `True` value indicates the corresponding element of ``data`` is masked. Masked data are excluded from all calculations. background : float, array_like, or `~astropy.units.Quantity`, optional The background level that was *previously* present in the input ``data``. ``background`` may either be a scalar value or a 2D image with the same shape as the input ``data``. Inputting the ``background`` merely allows for its properties to be measured within each source segment. The input ``background`` does *not* get subtracted from the input ``data``, which should already be background-subtracted. wcs : `~astropy.wcs.WCS` The WCS transformation to use. If `None`, then `~photutils.SourceProperties.icrs_centroid`, `~photutils.SourceProperties.ra_icrs_centroid`, and `~photutils.SourceProperties.dec_icrs_centroid` will be `None`. Notes ----- `SExtractor`_'s centroid and morphological parameters are always calculated from the filtered "detection" image. The usual downside of the filtering is the sources will be made more circular than they actually are. If you wish to reproduce `SExtractor`_ results, then use the ``filtered_data`` input. If ``filtered_data`` is `None`, then the unfiltered ``data`` will be used for the source centroid and morphological parameters. Negative (background-subtracted) data values within the source segment are set to zero when measuring morphological properties based on image moments. This could occur, for example, if the segmentation image was defined from a different image (e.g., different bandpass) or if the background was oversubtracted. Note that `~photutils.SourceProperties.source_sum` includes the contribution of negative (background-subtracted) data values. `~photutils.SourceProperties.source_sum_err` will ignore such pixels when calculating the source Poission error (i.e. when if ``effective_gain`` is input; see below). If ``effective_gain`` is input, then ``error`` should include all sources of "background" error but *exclude* the Poisson error of the sources. The total error image, :math:`\sigma_{\mathrm{tot}}` is then: .. math:: \\sigma_{\\mathrm{tot}} = \\sqrt{\\sigma_{\\mathrm{b}}^2 + \\frac{(I - B)}{g}} where :math:`\sigma_b`, :math:`(I - B)`, and :math:`g` are the background ``error`` image, the background-subtracted ``data`` image, and ``effective_gain``, respectively. Pixels where :math:`(I_i - B_i)` is negative do not contribute additional Poisson noise to the total error, i.e. :math:`\sigma_{\mathrm{tot}, i} = \sigma_{\mathrm{b}, i}`. Note that this is different from `SExtractor`_, which sums the total variance in the segment, including pixels where :math:`(I_i - B_i)` is negative. In such cases, `SExtractor`_ underestimates the total errors. If ``effective_gain`` is `None`, then ``error`` is assumed to include *all* sources of error, including the Poisson error of the sources, i.e. :math:`\sigma_{\mathrm{tot}} = \sigma_{\mathrm{b}} = \mathrm{error}`. For example, if your input ``data`` are in units of ADU, then ``effective_gain`` should represent electrons/ADU. If your input ``data`` are in units of electrons/s then ``effective_gain`` should be the exposure time or an exposure time map (e.g., for mosaics with non-uniform exposure times). ``effective_gain`` can be a 2D gain image with the same shape as the ``data``. This is useful with mosaic images that have variable depths (i.e., exposure times) across the field. For example, one should use an exposure-time map as the ``effective_gain`` for a variable depth mosaic image in count-rate units. `~photutils.SourceProperties.source_sum_err` is simply the quadrature sum of the pixel-wise total errors over the non-masked pixels within the source segment: .. math:: \\Delta F = \\sqrt{\\sum_{i \\in S} \\sigma_{\\mathrm{tot}, i}^2} where :math:`\Delta F` is `~photutils.SourceProperties.source_sum_err` and :math:`S` are the non-masked pixels in the source segment. Custom errors for source segments can be calculated using the `~photutils.SourceProperties.error_cutout_ma` and `~photutils.SourceProperties.background_cutout_ma` properties, which are 2D `~numpy.ma.MaskedArray` cutout versions of the input ``error`` and ``background``. The mask is `True` for both pixels outside of the source segment and masked pixels. .. _SExtractor: http://www.astromatic.net/software/sextractor """ def __init__(self, data, segment_img, label, filtered_data=None, error=None, effective_gain=None, mask=None, background=None, wcs=None): if not isinstance(segment_img, SegmentationImage): segment_img = SegmentationImage(segment_img) if segment_img.shape != data.shape: raise ValueError('The data and segmentation image must have ' 'the same shape') if mask is not None: if mask.shape != data.shape: raise ValueError('The data and mask must have the same shape') segment_img.check_label(label) self.label = label self._slice = segment_img.slices[label - 1] self._segment_img = segment_img self._mask = mask self._wcs = wcs data, error, background = _prepare_data( data, error=error, effective_gain=effective_gain, background=background) # data and filtered_data should be background-subtracted self._data = data if filtered_data is None: self._filtered_data = data else: self._filtered_data = filtered_data self._error = error # *total* error self._background = background # 2D array def __getitem__(self, key): return getattr(self, key, None) def make_cutout(self, data, masked_array=False): """ Create a (masked) cutout array from the input ``data`` using the minimal bounding box of the source segment. Parameters ---------- data : array-like (2D) The data array from which to create the masked cutout array. ``data`` must have the same shape as the segmentation image input into `SourceProperties`. masked_array : bool, optional If `True` then a `~numpy.ma.MaskedArray` will be created where the mask is `True` for both pixels outside of the source segment and any masked pixels. If `False`, then a `~numpy.ndarray` will be generated. Returns ------- result : `~numpy.ndarray` or `~numpy.ma.MaskedArray` (2D) The 2D cutout array or masked array. """ if data is None: return None data = np.asarray(data) if data.shape != self._data.shape: raise ValueError('data must have the same shape as the ' 'segmentation image input to SourceProperties') if masked_array: return np.ma.masked_array(data[self._slice], mask=self._cutout_total_mask) else: return data[self._slice] def to_table(self, columns=None, exclude_columns=None): """ Create a `~astropy.table.Table` of properties. If ``columns`` or ``exclude_columns`` are not input, then the `~astropy.table.Table` will include all scalar-valued properties. Multi-dimensional properties, e.g. `~photutils.SourceProperties.data_cutout`, can be included in the ``columns`` input. Parameters ---------- columns : str or list of str, optional Names of columns, in order, to include in the output `~astropy.table.Table`. The allowed column names are any of the attributes of `SourceProperties`. exclude_columns : str or list of str, optional Names of columns to exclude from the default properties list in the output `~astropy.table.Table`. The default properties are those with scalar values. Returns ------- table : `~astropy.table.Table` A single-row table of properties of the source. """ return properties_table(self, columns=columns, exclude_columns=exclude_columns) @lazyproperty def _cutout_segment_bool(self): """ _cutout_segment_bool is `True` only for pixels in the source segment of interest. Pixels from other sources within the rectangular cutout are not included. """ return self._segment_img.data[self._slice] == self.label @lazyproperty def _cutout_total_mask(self): """ _cutout_total_mask is `True` for regions outside of the source segment or where the input mask is `True`. """ mask = ~self._cutout_segment_bool if self._mask is not None: mask |= self._mask[self._slice] return mask @lazyproperty def data_cutout(self): """ A 2D cutout from the (background-subtracted) data of the source segment. """ return self.make_cutout(self._data, masked_array=False) @lazyproperty def data_cutout_ma(self): """ A 2D `~numpy.ma.MaskedArray` cutout from the (background-subtracted) data, where the mask is `True` for both pixels outside of the source segment and masked pixels. """ return self.make_cutout(self._data, masked_array=True) @lazyproperty def _data_cutout_maskzeroed_double(self): """ A 2D cutout from the (background-subtracted) (filtered) data, where pixels outside of the source segment and masked pixels are set to zero. Negative data values are also set to zero because negative pixels (especially at large radii) can result in image moments that result in negative variances. The cutout image is double precision, which is required for scikit-image's Cython-based moment functions. """ cutout = self.make_cutout(self._filtered_data, masked_array=False) cutout = np.where(cutout > 0, cutout, 0.) # negative pixels -> 0 return (cutout * ~self._cutout_total_mask).astype(np.float64) @lazyproperty def error_cutout_ma(self): """ A 2D `~numpy.ma.MaskedArray` cutout from the input ``error`` image, where the mask is `True` for both pixels outside of the source segment and masked pixels. If ``error`` is `None`, then ``error_cutout_ma`` is also `None`. """ return self.make_cutout(self._error, masked_array=True) @lazyproperty def background_cutout_ma(self): """ A 2D `~numpy.ma.MaskedArray` cutout from the input ``background``, where the mask is `True` for both pixels outside of the source segment and masked pixels. If ``background`` is `None`, then ``background_cutout_ma`` is also `None`. """ return self.make_cutout(self._background, masked_array=True) @lazyproperty def coords(self): """ A tuple of `~numpy.ndarray`\s containing the ``y`` and ``x`` pixel coordinates of the source segment. Masked pixels are not included. """ yy, xx = np.nonzero(self.data_cutout_ma) coords = (yy + self._slice[0].start, xx + self._slice[1].start) return coords @lazyproperty def values(self): """ A `~numpy.ndarray` of the (background-subtracted) pixel values within the source segment. Masked pixels are not included. """ return self.data_cutout[~self._cutout_total_mask] @lazyproperty def moments(self): """Spatial moments up to 3rd order of the source.""" from skimage.measure import moments return moments(self._data_cutout_maskzeroed_double, 3) @lazyproperty def moments_central(self): """ Central moments (translation invariant) of the source up to 3rd order. """ from skimage.measure import moments_central ycentroid, xcentroid = self.cutout_centroid.value return moments_central(self._data_cutout_maskzeroed_double, ycentroid, xcentroid, 3) @lazyproperty def id(self): """ The source identification number corresponding to the object label in the segmentation image. """ return self.label @lazyproperty def cutout_centroid(self): """ The ``(y, x)`` coordinate, relative to the `data_cutout`, of the centroid within the source segment. """ m = self.moments if m[0, 0] != 0: ycentroid = m[0, 1] / m[0, 0] xcentroid = m[1, 0] / m[0, 0] return (ycentroid, xcentroid) * u.pix else: return (np.nan, np.nan) * u.pix @lazyproperty def centroid(self): """ The ``(y, x)`` coordinate of the centroid within the source segment. """ ycen, xcen = self.cutout_centroid.value return (ycen + self._slice[0].start, xcen + self._slice[1].start) * u.pix @lazyproperty def xcentroid(self): """ The ``x`` coordinate of the centroid within the source segment. """ return self.centroid[1] @lazyproperty def ycentroid(self): """ The ``y`` coordinate of the centroid within the source segment. """ return self.centroid[0] @lazyproperty def icrs_centroid(self): """ The International Celestial Reference System (ICRS) coordinates of the centroid within the source segment, returned as a `~astropy.coordinates.SkyCoord` object. """ if self._wcs is not None: return pixel_to_skycoord(self.xcentroid.value, self.ycentroid.value, self._wcs, origin=1).icrs else: return None @lazyproperty def ra_icrs_centroid(self): """ The ICRS Right Ascension coordinate (in degrees) of the centroid within the source segment. """ if self._wcs is not None: return self.icrs_centroid.ra.degree * u.deg else: return None @lazyproperty def dec_icrs_centroid(self): """ The ICRS Declination coordinate (in degrees) of the centroid within the source segment. """ if self._wcs is not None: return self.icrs_centroid.dec.degree * u.deg else: return None @lazyproperty def bbox(self): """ The bounding box ``(ymin, xmin, ymax, xmax)`` of the minimal rectangular region containing the source segment. """ # (stop - 1) to return the max pixel location, not the slice index return (self._slice[0].start, self._slice[1].start, self._slice[0].stop - 1, self._slice[1].stop - 1) * u.pix @lazyproperty def xmin(self): """ The minimum ``x`` pixel location of the minimal bounding box (`~photutils.SourceProperties.bbox`) of the source segment. """ return self.bbox[1] @lazyproperty def xmax(self): """ The maximum ``x`` pixel location of the minimal bounding box (`~photutils.SourceProperties.bbox`) of the source segment. """ return self.bbox[3] @lazyproperty def ymin(self): """ The minimum ``y`` pixel location of the minimal bounding box (`~photutils.SourceProperties.bbox`) of the source segment. """ return self.bbox[0] @lazyproperty def ymax(self): """ The maximum ``y`` pixel location of the minimal bounding box (`~photutils.SourceProperties.bbox`) of the source segment. """ return self.bbox[2] @lazyproperty def min_value(self): """ The minimum pixel value of the (background-subtracted) data within the source segment. """ return np.min(self.values) @lazyproperty def max_value(self): """ The maximum pixel value of the (background-subtracted) data within the source segment. """ return np.max(self.values) @lazyproperty def minval_cutout_pos(self): """ The ``(y, x)`` coordinate, relative to the `data_cutout`, of the minimum pixel value of the (background-subtracted) data. """ return np.argwhere(self.data_cutout_ma == self.min_value)[0] * u.pix @lazyproperty def maxval_cutout_pos(self): """ The ``(y, x)`` coordinate, relative to the `data_cutout`, of the maximum pixel value of the (background-subtracted) data. """ return np.argwhere(self.data_cutout_ma == self.max_value)[0] * u.pix @lazyproperty def minval_pos(self): """ The ``(y, x)`` coordinate of the minimum pixel value of the (background-subtracted) data. """ yp, xp = np.array(self.minval_cutout_pos) return (yp + self._slice[0].start, xp + self._slice[1].start) * u.pix @lazyproperty def maxval_pos(self): """ The ``(y, x)`` coordinate of the maximum pixel value of the (background-subtracted) data. """ yp, xp = np.array(self.maxval_cutout_pos) return (yp + self._slice[0].start, xp + self._slice[1].start) * u.pix @lazyproperty def minval_xpos(self): """ The ``x`` coordinate of the minimum pixel value of the (background-subtracted) data. """ return self.minval_pos[1] @lazyproperty def minval_ypos(self): """ The ``y`` coordinate of the minimum pixel value of the (background-subtracted) data. """ return self.minval_pos[0] @lazyproperty def maxval_xpos(self): """ The ``x`` coordinate of the maximum pixel value of the (background-subtracted) data. """ return self.maxval_pos[1] @lazyproperty def maxval_ypos(self): """ The ``y`` coordinate of the maximum pixel value of the (background-subtracted) data. """ return self.maxval_pos[0] @lazyproperty def area(self): """The area of the source segment in units of pixels**2.""" return len(self.values) * u.pix**2 @lazyproperty def equivalent_radius(self): """ The radius of a circle with the same `area` as the source segment. """ return np.sqrt(self.area / np.pi) @lazyproperty def perimeter(self): """ The perimeter of the source segment, approximated lines through the centers of the border pixels using a 4-connectivity. """ from skimage.measure import perimeter return perimeter(self._cutout_segment_bool, 4) * u.pix @lazyproperty def inertia_tensor(self): """ The inertia tensor of the source for the rotation around its center of mass. """ mu = self.moments_central a = mu[2, 0] b = -mu[1, 1] c = mu[0, 2] return np.array([[a, b], [b, c]]) * u.pix**2 @lazyproperty def covariance(self): """ The covariance matrix of the 2D Gaussian function that has the same second-order moments as the source. """ mu = self.moments_central if mu[0, 0] != 0: m = mu / mu[0, 0] covariance = self._check_covariance( np.array([[m[2, 0], m[1, 1]], [m[1, 1], m[0, 2]]])) return covariance * u.pix**2 else: return np.empty((2, 2)) * np.nan * u.pix**2 @staticmethod def _check_covariance(covariance): """ Check and modify the covariance matrix in the case of "infinitely" thin detections. This follows SExtractor's prescription of incrementally increasing the diagonal elements by 1/12. """ p = 1. / 12 # arbitrary SExtractor value val = (covariance[0, 0] * covariance[1, 1]) - covariance[0, 1]**2 if val >= p**2: return covariance else: covar = np.copy(covariance) while val < p**2: covar[0, 0] += p covar[1, 1] += p val = (covar[0, 0] * covar[1, 1]) - covar[0, 1]**2 return covar @lazyproperty def covariance_eigvals(self): """ The two eigenvalues of the `covariance` matrix in decreasing order. """ if not np.isnan(np.sum(self.covariance)): eigvals = np.linalg.eigvals(self.covariance) if np.any(eigvals < 0): # negative variance return (np.nan, np.nan) * u.pix**2 return (np.max(eigvals), np.min(eigvals)) * u.pix**2 else: return (np.nan, np.nan) * u.pix**2 @lazyproperty def semimajor_axis_sigma(self): """ The 1-sigma standard deviation along the semimajor axis of the 2D Gaussian function that has the same second-order central moments as the source. """ # this matches SExtractor's A parameter return np.sqrt(self.covariance_eigvals[0]) @lazyproperty def semiminor_axis_sigma(self): """ The 1-sigma standard deviation along the semiminor axis of the 2D Gaussian function that has the same second-order central moments as the source. """ # this matches SExtractor's B parameter return np.sqrt(self.covariance_eigvals[1]) @lazyproperty def eccentricity(self): """ The eccentricity of the 2D Gaussian function that has the same second-order moments as the source. The eccentricity is the fraction of the distance along the semimajor axis at which the focus lies. .. math:: e = \\sqrt{1 - \\frac{b^2}{a^2}} where :math:`a` and :math:`b` are the lengths of the semimajor and semiminor axes, respectively. """ l1, l2 = self.covariance_eigvals if l1 == 0: return 0. return np.sqrt(1. - (l2 / l1)) @lazyproperty def orientation(self): """ The angle in radians between the ``x`` axis and the major axis of the 2D Gaussian function that has the same second-order moments as the source. The angle increases in the counter-clockwise direction. """ a, b, b, c = self.covariance.flat if a < 0 or c < 0: # negative variance return np.nan * u.rad return 0.5 * np.arctan2(2. * b, (a - c)) @lazyproperty def elongation(self): """ The ratio of the lengths of the semimajor and semiminor axes: .. math:: \mathrm{elongation} = \\frac{a}{b} where :math:`a` and :math:`b` are the lengths of the semimajor and semiminor axes, respectively. Note that this is the same as `SExtractor`_'s elongation parameter. """ return self.semimajor_axis_sigma / self.semiminor_axis_sigma @lazyproperty def ellipticity(self): """ ``1`` minus the ratio of the lengths of the semimajor and semiminor axes (or ``1`` minus the `elongation`): .. math:: \mathrm{ellipticity} = 1 - \\frac{b}{a} where :math:`a` and :math:`b` are the lengths of the semimajor and semiminor axes, respectively. Note that this is the same as `SExtractor`_'s ellipticity parameter. """ return 1.0 - (self.semiminor_axis_sigma / self.semimajor_axis_sigma) @lazyproperty def covar_sigx2(self): """ The ``(0, 0)`` element of the `covariance` matrix, representing :math:`\sigma_x^2`, in units of pixel**2. Note that this is the same as `SExtractor`_'s X2 parameter. """ return self.covariance[0, 0] @lazyproperty def covar_sigy2(self): """ The ``(1, 1)`` element of the `covariance` matrix, representing :math:`\sigma_y^2`, in units of pixel**2. Note that this is the same as `SExtractor`_'s Y2 parameter. """ return self.covariance[1, 1] @lazyproperty def covar_sigxy(self): """ The ``(0, 1)`` and ``(1, 0)`` elements of the `covariance` matrix, representing :math:`\sigma_x \sigma_y`, in units of pixel**2. Note that this is the same as `SExtractor`_'s XY parameter. """ return self.covariance[0, 1] @lazyproperty def cxx(self): """ `SExtractor`_'s CXX ellipse parameter in units of pixel**(-2). The ellipse is defined as .. math:: cxx (x - \\bar{x})^2 + cxy (x - \\bar{x}) (y - \\bar{y}) + cyy (y - \\bar{y})^2 = R^2 where :math:`R` is a parameter which scales the ellipse (in units of the axes lengths). `SExtractor`_ reports that the isophotal limit of a source is well represented by :math:`R \\approx 3`. """ return ((np.cos(self.orientation) / self.semimajor_axis_sigma)**2 + (np.sin(self.orientation) / self.semiminor_axis_sigma)**2) @lazyproperty def cyy(self): """ `SExtractor`_'s CYY ellipse parameter in units of pixel**(-2). The ellipse is defined as .. math:: cxx (x - \\bar{x})^2 + cxy (x - \\bar{x}) (y - \\bar{y}) + cyy (y - \\bar{y})^2 = R^2 where :math:`R` is a parameter which scales the ellipse (in units of the axes lengths). `SExtractor`_ reports that the isophotal limit of a source is well represented by :math:`R \\approx 3`. """ return ((np.sin(self.orientation) / self.semimajor_axis_sigma)**2 + (np.cos(self.orientation) / self.semiminor_axis_sigma)**2) @lazyproperty def cxy(self): """ `SExtractor`_'s CXY ellipse parameter in units of pixel**(-2). The ellipse is defined as .. math:: cxx (x - \\bar{x})^2 + cxy (x - \\bar{x}) (y - \\bar{y}) + cyy (y - \\bar{y})^2 = R^2 where :math:`R` is a parameter which scales the ellipse (in units of the axes lengths). `SExtractor`_ reports that the isophotal limit of a source is well represented by :math:`R \\approx 3`. """ return (2. * np.cos(self.orientation) * np.sin(self.orientation) * ((1. / self.semimajor_axis_sigma**2) - (1. / self.semiminor_axis_sigma**2))) @lazyproperty def source_sum(self): """ The sum of the non-masked (background-subtracted) data values within the source segment. .. math:: F = \\sum_{i \\in S} (I_i - B_i) where :math:`F` is ``source_sum``, :math:`(I_i - B_i)` is the background-subtracted input ``data``, and :math:`S` are the non-masked pixels in the source segment. """ return np.sum(np.ma.masked_array(self._data[self._slice], mask=self._cutout_total_mask)) @lazyproperty def source_sum_err(self): """ The uncertainty of `~photutils.SourceProperties.source_sum`, propagated from the input ``error`` array. ``source_sum_err`` is the quadrature sum of the total errors over the non-masked pixels within the source segment: .. math:: \\Delta F = \\sqrt{\\sum_{i \\in S} \\sigma_{\\mathrm{tot}, i}^2} where :math:`\Delta F` is ``source_sum_err``, :math:`\sigma_{\mathrm{tot, i}}` are the pixel-wise total errors, and :math:`S` are the non-masked pixels in the source segment. """ if self._error is not None: # power doesn't work here, see astropy #2968 # return np.sqrt(np.sum(self.error_cutout_ma**2)) return np.sqrt(np.sum( np.ma.masked_array(self.error_cutout_ma.data**2, mask=self.error_cutout_ma.mask))) else: return None @lazyproperty def background_sum(self): """The sum of ``background`` values within the source segment.""" if self._background is not None: return np.sum(self.background_cutout_ma) else: return None @lazyproperty def background_mean(self): """The mean of ``background`` values within the source segment.""" if self._background is not None: return np.mean(self.background_cutout_ma) else: return None @lazyproperty def background_at_centroid(self): """ The value of the ``background`` at the position of the source centroid. Fractional position values are determined using bilinear interpolation. """ from scipy.ndimage import map_coordinates if self._background is None: return None else: return map_coordinates( self._background, [[self.ycentroid.value], [self.xcentroid.value]])[0] def source_properties(data, segment_img, error=None, effective_gain=None, mask=None, background=None, filter_kernel=None, wcs=None, labels=None): """ Calculate photometry and morphological properties of sources defined by a labeled segmentation image. Parameters ---------- data : array_like or `~astropy.units.Quantity` The 2D array from which to calculate the source photometry and properties. ``data`` should be background-subtracted. segment_img : `SegmentationImage` or array_like (int) A 2D segmentation image, either as a `SegmentationImage` object or an `~numpy.ndarray`, with the same shape as ``data`` where sources are labeled by different positive integer values. A value of zero is reserved for the background. error : array_like or `~astropy.units.Quantity`, optional The pixel-wise Gaussian 1-sigma errors of the input ``data``. If ``effective_gain`` is input, then ``error`` should include all sources of "background" error but *exclude* the Poisson error of the sources. If ``effective_gain`` is `None`, then ``error`` is assumed to include *all* sources of error, including the Poisson error of the sources. ``error`` must have the same shape as ``data``. See the Notes section below for details on the error propagation. effective_gain : float, array-like, or `~astropy.units.Quantity`, optional Ratio of counts (e.g., electrons or photons) to the units of ``data``. This ratio is used to calculate the Poisson error of the sources when it is not included in ``error``. If ``effective_gain`` is `None`, then ``error`` is assumed to include *all* sources of error. See the Notes section below for details on the error propagation. If you are calculating the properties of many sources from the same data, it is highly recommended that you input a *total* error array instead of using ``effective_gain``. Otherwise a total error array will need to be repeatedly recalculated. mask : array_like (bool), optional A boolean mask with the same shape as ``data`` where a `True` value indicates the corresponding element of ``data`` is masked. Masked data are excluded from all calculations. background : float, array_like, or `~astropy.units.Quantity`, optional The background level that was *previously* present in the input ``data``. ``background`` may either be a scalar value or a 2D image with the same shape as the input ``data``. Inputting the ``background`` merely allows for its properties to be measured within each source segment. The input ``background`` does *not* get subtracted from the input ``data``, which should already be background-subtracted. filter_kernel : array-like (2D) or `~astropy.convolution.Kernel2D`, optional The 2D array of the kernel used to filter the data prior to calculating the source centroid and morphological parameters. The kernel should be the same one used in defining the source segments (e.g., see :func:`~photutils.detect_sources`). If `None`, then the unfiltered ``data`` will be used instead. Note that `SExtractor`_'s centroid and morphological parameters are calculated from the filtered "detection" image. wcs : `~astropy.wcs.WCS` The WCS transformation to use. If `None`, then `~photutils.SourceProperties.icrs_centroid`, `~photutils.SourceProperties.ra_icrs_centroid`, and `~photutils.SourceProperties.dec_icrs_centroid` will be `None`. labels : int or list of ints Subset of segmentation labels for which to calculate the properties. If `None`, then the properties will be calculated for all labeled sources (the default). Returns ------- output : list of `SourceProperties` objects A list of `SourceProperties` objects, one for each source. The properties can be accessed as attributes or keys. Notes ----- `SExtractor`_'s centroid and morphological parameters are always calculated from the filtered "detection" image. The usual downside of the filtering is the sources will be made more circular than they actually are. If you wish to reproduce `SExtractor`_ results, then use the ``filtered_data`` input. If ``filtered_data`` is `None`, then the unfiltered ``data`` will be used for the source centroid and morphological parameters. Negative (background-subtracted) data values within the source segment are set to zero when measuring morphological properties based on image moments. This could occur, for example, if the segmentation image was defined from a different image (e.g., different bandpass) or if the background was oversubtracted. Note that `~photutils.SourceProperties.source_sum` includes the contribution of negative (background-subtracted) data values. `~photutils.SourceProperties.source_sum_err` will ignore such pixels when calculating the source Poission error (i.e. when if ``effective_gain`` is input; see below). If ``effective_gain`` is input, then ``error`` should include all sources of "background" error but *exclude* the Poisson error of the sources. The total error image, :math:`\sigma_{\mathrm{tot}}` is then: .. math:: \\sigma_{\\mathrm{tot}} = \\sqrt{\\sigma_{\\mathrm{b}}^2 + \\frac{(I - B)}{g}} where :math:`\sigma_b`, :math:`(I - B)`, and :math:`g` are the background ``error`` image, the background-subtracted ``data`` image, and ``effective_gain``, respectively. Pixels where :math:`(I_i - B_i)` is negative do not contribute additional Poisson noise to the total error, i.e. :math:`\sigma_{\mathrm{tot}, i} = \sigma_{\mathrm{b}, i}`. Note that this is different from `SExtractor`_, which sums the total variance in the segment, including pixels where :math:`(I_i - B_i)` is negative. In such cases, `SExtractor`_ underestimates the total errors. If ``effective_gain`` is `None`, then ``error`` is assumed to include *all* sources of error, including the Poisson error of the sources, i.e. :math:`\sigma_{\mathrm{tot}} = \sigma_{\mathrm{b}} = \mathrm{error}`. For example, if your input ``data`` are in units of ADU, then ``effective_gain`` should represent electrons/ADU. If your input ``data`` are in units of electrons/s then ``effective_gain`` should be the exposure time or an exposure time map (e.g., for mosaics with non-uniform exposure times). ``effective_gain`` can be a 2D gain image with the same shape as the ``data``. This is useful with mosaic images that have variable depths (i.e., exposure times) across the field. For example, one should use an exposure-time map as the ``effective_gain`` for a variable depth mosaic image in count-rate units. `~photutils.SourceProperties.source_sum_err` is simply the quadrature sum of the pixel-wise total errors over the non-masked pixels within the source segment: .. math:: \\Delta F = \\sqrt{\\sum_{i \\in S} \\sigma_{\\mathrm{tot}, i}^2} where :math:`\Delta F` is `~photutils.SourceProperties.source_sum_err` and :math:`S` are the non-masked pixels in the source segment. .. _SExtractor: http://www.astromatic.net/software/sextractor See Also -------- SegmentationImage, SourceProperties, properties_table, :func:`photutils.detection.detect_sources` Examples -------- >>> import numpy as np >>> from photutils import SegmentationImage, source_properties >>> image = np.arange(16.).reshape(4, 4) >>> print(image) [[ 0. 1. 2. 3.] [ 4. 5. 6. 7.] [ 8. 9. 10. 11.] [ 12. 13. 14. 15.]] >>> segm = SegmentationImage([[1, 1, 0, 0], ... [1, 0, 0, 2], ... [0, 0, 2, 2], ... [0, 2, 2, 0]]) >>> props = source_properties(image, segm) Print some properties of the first object (labeled with ``1`` in the segmentation image): >>> props[0].id # id corresponds to segment label number 1 >>> props[0].centroid # doctest: +FLOAT_CMP >>> props[0].source_sum # doctest: +FLOAT_CMP 5.0 >>> props[0].area # doctest: +FLOAT_CMP >>> props[0].max_value # doctest: +FLOAT_CMP 4.0 Print some properties of the second object (labeled with ``2`` in the segmentation image): >>> props[1].id # id corresponds to segment label number 2 >>> props[1].centroid # doctest: +FLOAT_CMP >>> props[1].perimeter # doctest: +FLOAT_CMP >>> props[1].orientation # doctest: +FLOAT_CMP """ if not isinstance(segment_img, SegmentationImage): segment_img = SegmentationImage(segment_img) if segment_img.shape != data.shape: raise ValueError('The data and segmentation image must have ' 'the same shape') if labels is None: labels = segment_img.labels labels = np.atleast_1d(labels) # prepare the input data once, instead of repeating for each source data, error_total, background = _prepare_data( data, error=error, effective_gain=effective_gain, background=background) # filter the data once, instead of repeating for each source if filter_kernel is not None: filtered_data = _convolve_data(data, filter_kernel, mode='constant', fill_value=0.0, check_normalization=True) else: filtered_data = None sources_props = [] for label in labels: if label not in segment_img.labels: continue # skip invalid labels (without warnings) sources_props.append(SourceProperties( data, segment_img, label, filtered_data=filtered_data, error=error_total, effective_gain=None, mask=mask, background=background, wcs=wcs)) return sources_props def properties_table(source_props, columns=None, exclude_columns=None): """ Construct a `~astropy.table.Table` of properties from a list of `SourceProperties` objects. If ``columns`` or ``exclude_columns`` are not input, then the `~astropy.table.Table` will include all scalar-valued properties. Multi-dimensional properties, e.g. `~photutils.SourceProperties.data_cutout`, can be included in the ``columns`` input. Parameters ---------- source_props : `SourceProperties` or list of `SourceProperties` A `SourceProperties` object or list of `SourceProperties` objects, one for each source. columns : str or list of str, optional Names of columns, in order, to include in the output `~astropy.table.Table`. The allowed column names are any of the attributes of `SourceProperties`. exclude_columns : str or list of str, optional Names of columns to exclude from the default properties list in the output `~astropy.table.Table`. The default properties are those with scalar values. Returns ------- table : `~astropy.table.Table` A table of properties of the segmented sources, one row per source. See Also -------- SegmentationImage, SourceProperties, source_properties, :func:`photutils.detection.detect_sources` Examples -------- >>> import numpy as np >>> from photutils import source_properties, properties_table >>> image = np.arange(16.).reshape(4, 4) >>> print(image) [[ 0. 1. 2. 3.] [ 4. 5. 6. 7.] [ 8. 9. 10. 11.] [ 12. 13. 14. 15.]] >>> segm = SegmentationImage([[1, 1, 0, 0], ... [1, 0, 0, 2], ... [0, 0, 2, 2], ... [0, 2, 2, 0]]) >>> props = source_properties(image, segm) >>> columns = ['id', 'xcentroid', 'ycentroid', 'source_sum'] >>> tbl = properties_table(props, columns=columns) >>> print(tbl) id xcentroid ycentroid source_sum pix pix --- ------------- ------------- ---------- 1 0.2 0.8 5.0 2 2.09090909091 2.36363636364 55.0 """ if isinstance(source_props, list) and len(source_props) == 0: raise ValueError('source_props is an empty list') source_props = np.atleast_1d(source_props) # all scalar-valued properties columns_all = ['id', 'xcentroid', 'ycentroid', 'ra_icrs_centroid', 'dec_icrs_centroid', 'source_sum', 'source_sum_err', 'background_sum', 'background_mean', 'background_at_centroid', 'xmin', 'xmax', 'ymin', 'ymax', 'min_value', 'max_value', 'minval_xpos', 'minval_ypos', 'maxval_xpos', 'maxval_ypos', 'area', 'equivalent_radius', 'perimeter', 'semimajor_axis_sigma', 'semiminor_axis_sigma', 'eccentricity', 'orientation', 'ellipticity', 'elongation', 'covar_sigx2', 'covar_sigxy', 'covar_sigy2', 'cxx', 'cxy', 'cyy'] table_columns = None if exclude_columns is not None: table_columns = [s for s in columns_all if s not in exclude_columns] if columns is not None: table_columns = np.atleast_1d(columns) if table_columns is None: table_columns = columns_all # it's *much* faster to calculate world coordinates using the # complete list of (x, y) instead of from the individual (x, y). # The assumption here is that the wcs is the same for each # element of source_props. if ('ra_icrs_centroid' in table_columns or 'dec_icrs_centroid' in table_columns or 'icrs_centroid' in table_columns): xcentroid = [props.xcentroid.value for props in source_props] ycentroid = [props.ycentroid.value for props in source_props] if source_props[0]._wcs is not None: icrs_centroid = pixel_to_skycoord( xcentroid, ycentroid, source_props[0]._wcs, origin=1).icrs icrs_ra = icrs_centroid.ra.degree * u.deg icrs_dec = icrs_centroid.dec.degree * u.deg else: nprops = len(source_props) icrs_ra = [None] * nprops icrs_dec = [None] * nprops icrs_centroid = [None] * nprops props_table = Table() for column in table_columns: if column == 'ra_icrs_centroid': props_table[column] = icrs_ra elif column == 'dec_icrs_centroid': props_table[column] = icrs_dec elif column == 'icrs_centroid': props_table[column] = icrs_centroid else: values = [getattr(props, column) for props in source_props] if isinstance(values[0], u.Quantity): # turn list of Quantities into a Quantity array values = u.Quantity(values) props_table[column] = values return props_table photutils-0.2.1/photutils/tests/0000700000214200020070000000000012646264032021120 5ustar lbradleySTSCI\science00000000000000photutils-0.2.1/photutils/tests/__init__.py0000600000214200020070000000017012444404542023227 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst """ This package contains affiliated package tests. """ photutils-0.2.1/photutils/tests/coveragerc0000600000214200020070000000124512444404542023165 0ustar lbradleySTSCI\science00000000000000[run] source = photutils omit = photutils/*__init__* photutils/_astropy_init.py photutils/conftest* photutils/cython_version* photutils/*setup* photutils/*tests/* photutils/version* photutils/extern/* [report] exclude_lines = # Have to re-enable the standard pragma pragma: no cover # Don't complain about packages we have installed except ImportError # Don't complain if tests don't hit assertions raise AssertionError raise NotImplementedError # Don't complain about script hooks def main\(.*\): # Ignore branches that don't pertain to this version of Python pragma: py{ignore_python_version} photutils-0.2.1/photutils/tests/setup_package.py0000600000214200020070000000014012345377273024312 0ustar lbradleySTSCI\science00000000000000def get_package_data(): return { _ASTROPY_PACKAGE_NAME_ + '.tests': ['coveragerc']} photutils-0.2.1/photutils/tests/test_aperture_photometry.py0000600000214200020070000006750712627615324026676 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst # The tests in this file test the accuracy of the photometric results. # Here we test directly with aperture objects since we are checking the # algorithms in aperture_photometry, not in the wrappers. from __future__ import (absolute_import, division, print_function, unicode_literals) import pytest import numpy as np from numpy.testing import assert_allclose, assert_array_equal from astropy.tests.helper import assert_quantity_allclose import astropy.units as u from astropy.io import fits from astropy.nddata import NDData from astropy.tests.helper import remote_data from ..aperture_core import * try: import matplotlib HAS_MATPLOTLIB = True except ImportError: HAS_MATPLOTLIB = False APERTURE_CL = [CircularAperture, CircularAnnulus, EllipticalAperture, EllipticalAnnulus, RectangularAperture, RectangularAnnulus] TEST_APERTURES = list(zip(APERTURE_CL, ((3.,), (3., 5.), (3., 5., 1.), (3., 5., 4., 1.), (5, 8, np.pi / 4), (8, 12, 8, np.pi / 8)))) @pytest.mark.parametrize(('aperture_class', 'params'), TEST_APERTURES) def test_outside_array(aperture_class, params): data = np.ones((10, 10), dtype=np.float) aperture = aperture_class((-60, 60), *params) fluxtable = aperture_photometry(data, aperture) # aperture is fully outside array: assert np.isnan(fluxtable['aperture_sum']) @pytest.mark.parametrize(('aperture_class', 'params'), TEST_APERTURES) def test_inside_array_simple(aperture_class, params): data = np.ones((40, 40), dtype=np.float) aperture = aperture_class((20., 20.), *params) table1 = aperture_photometry(data, aperture, method='center', subpixels=10) table2 = aperture_photometry(data, aperture, method='subpixel', subpixels=10) table3 = aperture_photometry(data, aperture, method='exact', subpixels=10) true_flux = aperture.area() if not isinstance(aperture, (RectangularAperture, RectangularAnnulus)): assert_allclose(table3['aperture_sum'], true_flux) assert_allclose(table2['aperture_sum'], table3['aperture_sum'], atol=0.1) assert table1['aperture_sum'] < table3['aperture_sum'] @pytest.mark.skipif('not HAS_MATPLOTLIB') @pytest.mark.parametrize(('aperture_class', 'params'), TEST_APERTURES) def test_aperture_plots(aperture_class, params): # This test should run without any errors, and there is no return value # TODO for 0.2: check the content of the plot aperture = aperture_class((20., 20.), *params) aperture.plot() def test_aperture_pixel_positions(): pos1 = (10, 20) pos2 = u.Quantity((10, 20), unit=u.pixel) pos3 = ((10, 20, 30), (10, 20, 30)) pos3_pairs = ((10, 10), (20, 20), (30, 30)) r = 3 ap1 = CircularAperture(pos1, r) ap2 = CircularAperture(pos2, r) ap3 = CircularAperture(pos3, r) assert_allclose(np.atleast_2d(pos1), ap1.positions) assert_allclose(np.atleast_2d(pos2.value), ap2.positions) assert_allclose(pos3_pairs, ap3.positions) class BaseTestAperturePhotometry(object): def test_scalar_error_no_effective_gain(self): # Scalar error, no effective_gain. error = 1. if not hasattr(self, 'mask'): mask = None else: mask = self.mask table1 = aperture_photometry(self.data, self.aperture, method='center', mask=mask, error=error) table2 = aperture_photometry(self.data, self.aperture, method='subpixel', subpixels=12, mask=mask, error=error) table3 = aperture_photometry(self.data, self.aperture, method='exact', mask=mask, error=error) if not isinstance(self.aperture, (RectangularAperture, RectangularAnnulus)): assert_allclose(table3['aperture_sum'], self.true_flux) assert_allclose(table2['aperture_sum'], table3['aperture_sum'], atol=0.1) assert np.all(table1['aperture_sum'] < table3['aperture_sum']) true_error = np.sqrt(self.area) if not isinstance(self.aperture, (RectangularAperture, RectangularAnnulus)): assert_allclose(table3['aperture_sum_err'], true_error) assert_allclose(table2['aperture_sum'], table3['aperture_sum'], atol=0.1) assert np.all(table1['aperture_sum_err'] < table3['aperture_sum_err']) def test_scalar_error_scalar_effective_gain(self): # Scalar error, scalar effective_gain. error = 1. effective_gain = 1. if not hasattr(self, 'mask'): mask = None else: mask = self.mask table1 = aperture_photometry(self.data, self.aperture, method='center', mask=mask, error=error, effective_gain=effective_gain) table2 = aperture_photometry(self.data, self.aperture, method='subpixel', subpixels=12, mask=mask, error=error, effective_gain=effective_gain) table3 = aperture_photometry(self.data, self.aperture, method='exact', mask=mask, error=error, effective_gain=effective_gain) if not isinstance(self.aperture, (RectangularAperture, RectangularAnnulus)): assert_allclose(table3['aperture_sum'], self.true_flux) assert_allclose(table2['aperture_sum'], table3['aperture_sum'], atol=0.1) assert np.all(table1['aperture_sum'] < table3['aperture_sum']) true_error = np.sqrt(self.area + self.true_flux) if not isinstance(self.aperture, (RectangularAperture, RectangularAnnulus)): assert_allclose(table3['aperture_sum_err'], true_error) assert_allclose(table2['aperture_sum'], table3['aperture_sum'], atol=0.1) assert np.all(table1['aperture_sum_err'] < table3['aperture_sum_err']) def test_quantity_scalar_error_scalar_effective_gain(self): # Scalar error, scalar effective_gain. error = u.Quantity(1.) effective_gain = u.Quantity(1.) if not hasattr(self, 'mask'): mask = None else: mask = self.mask table1 = aperture_photometry(self.data, self.aperture, method='center', mask=mask, error=error, effective_gain=effective_gain) assert np.all(table1['aperture_sum'] < self.true_flux) true_error = np.sqrt(self.area + self.true_flux) assert np.all(table1['aperture_sum_err'] < true_error) def test_scalar_error_array_effective_gain(self): # Scalar error, Array effective_gain. error = 1. effective_gain = np.ones(self.data.shape, dtype=np.float) if not hasattr(self, 'mask'): mask = None true_error = np.sqrt(self.area + self.true_flux) else: mask = self.mask # 1 masked pixel true_error = np.sqrt(self.area - 1 + self.true_flux) table1 = aperture_photometry(self.data, self.aperture, method='center', mask=mask, error=error, effective_gain=effective_gain) table2 = aperture_photometry(self.data, self.aperture, method='subpixel', subpixels=12, mask=mask, error=error, effective_gain=effective_gain) table3 = aperture_photometry(self.data, self.aperture, method='exact', mask=mask, error=error, effective_gain=effective_gain) if not isinstance(self.aperture, (RectangularAperture, RectangularAnnulus)): assert_allclose(table3['aperture_sum'], self.true_flux) assert_allclose(table2['aperture_sum'], table3['aperture_sum'], atol=0.1) assert np.all(table1['aperture_sum'] < table3['aperture_sum']) if not isinstance(self.aperture, (RectangularAperture, RectangularAnnulus)): assert_allclose(table3['aperture_sum_err'], true_error) assert_allclose(table2['aperture_sum'], table3['aperture_sum'], atol=0.1) assert np.all(table1['aperture_sum_err'] < table3['aperture_sum_err']) def test_array_error_no_effective_gain(self): # Array error, no effective_gain. error = np.ones(self.data.shape, dtype=np.float) if not hasattr(self, 'mask'): mask = None true_error = np.sqrt(self.area) else: mask = self.mask # 1 masked pixel true_error = np.sqrt(self.area - 1) table1 = aperture_photometry(self.data, self.aperture, method='center', mask=mask, error=error) table2 = aperture_photometry(self.data, self.aperture, method='subpixel', subpixels=12, mask=mask, error=error) table3 = aperture_photometry(self.data, self.aperture, method='exact', mask=mask, error=error) if not isinstance(self.aperture, (RectangularAperture, RectangularAnnulus)): assert_allclose(table3['aperture_sum'], self.true_flux) assert_allclose(table2['aperture_sum'], table3['aperture_sum'], atol=0.1) assert np.all(table1['aperture_sum'] < table3['aperture_sum']) if not isinstance(self.aperture, (RectangularAperture, RectangularAnnulus)): assert_allclose(table3['aperture_sum_err'], true_error) assert_allclose(table2['aperture_sum_err'], table3['aperture_sum_err'], atol=0.1) assert np.all(table1['aperture_sum_err'] < table3['aperture_sum_err']) def test_array_error_array_effective_gain(self): error = np.ones(self.data.shape, dtype=np.float) effective_gain = np.ones(self.data.shape, dtype=np.float) if not hasattr(self, 'mask'): mask = None true_error = np.sqrt(self.area + self.true_flux) else: mask = self.mask # 1 masked pixel true_error = np.sqrt(self.area - 1 + self.true_flux) table1 = aperture_photometry(self.data, self.aperture, method='center', mask=mask, error=error, effective_gain=effective_gain) table2 = aperture_photometry(self.data, self.aperture, method='subpixel', subpixels=12, mask=mask, error=error, effective_gain=effective_gain) table3 = aperture_photometry(self.data, self.aperture, method='exact', mask=mask, error=error, effective_gain=effective_gain) if not isinstance(self.aperture, (RectangularAperture, RectangularAnnulus)): assert_allclose(table3['aperture_sum'], self.true_flux) assert_allclose(table2['aperture_sum'], table3['aperture_sum'], atol=0.1) assert np.all(table1['aperture_sum'] < table3['aperture_sum']) if not isinstance(self.aperture, (RectangularAperture, RectangularAnnulus)): assert_allclose(table3['aperture_sum_err'], true_error) assert_allclose(table2['aperture_sum_err'], table3['aperture_sum_err'], atol=0.1) assert np.all(table1['aperture_sum_err'] < table3['aperture_sum_err']) class TestCircular(BaseTestAperturePhotometry): def setup_class(self): self.data = np.ones((40, 40), dtype=np.float) position = (20., 20.) r = 10. self.aperture = CircularAperture(position, r) self.area = np.pi * r * r self.true_flux = self.area class TestCircularArray(BaseTestAperturePhotometry): def setup_class(self): self.data = np.ones((40, 40), dtype=np.float) position = ((20., 20.), (25., 25.)) r = 10. self.aperture = CircularAperture(position, r) self.area = np.pi * r * r self.area = np.array((self.area, ) * 2) self.true_flux = self.area class TestCircularAnnulus(BaseTestAperturePhotometry): def setup_class(self): self.data = np.ones((40, 40), dtype=np.float) position = (20., 20.) r_in = 8. r_out = 10. self.aperture = CircularAnnulus(position, r_in, r_out) self.area = np.pi * (r_out * r_out - r_in * r_in) self.true_flux = self.area class TestCircularAnnulusArray(BaseTestAperturePhotometry): def setup_class(self): self.data = np.ones((40, 40), dtype=np.float) position = ((20., 20.), (25., 25.)) r_in = 8. r_out = 10. self.aperture = CircularAnnulus(position, r_in, r_out) self.area = np.pi * (r_out * r_out - r_in * r_in) self.area = np.array((self.area, ) * 2) self.true_flux = self.area class TestElliptical(BaseTestAperturePhotometry): def setup_class(self): self.data = np.ones((40, 40), dtype=np.float) position = (20., 20.) a = 10. b = 5. theta = -np.pi / 4. self.aperture = EllipticalAperture(position, a, b, theta) self.area = np.pi * a * b self.true_flux = self.area class TestEllipticalAnnulus(BaseTestAperturePhotometry): def setup_class(self): self.data = np.ones((40, 40), dtype=np.float) position = (20., 20.) a_in = 5. a_out = 8. b_out = 5. theta = -np.pi / 4. self.aperture = EllipticalAnnulus(position, a_in, a_out, b_out, theta) self.area = (np.pi * (a_out * b_out) - np.pi * (a_in * b_out * a_in / a_out)) self.true_flux = self.area class TestRectangularAperture(BaseTestAperturePhotometry): def setup_class(self): self.data = np.ones((40, 40), dtype=np.float) position = (20., 20.) h = 5. w = 8. theta = np.pi / 4. self.aperture = RectangularAperture(position, w, h, theta) self.area = h * w self.true_flux = self.area class TestRectangularAnnulus(BaseTestAperturePhotometry): def setup_class(self): self.data = np.ones((40, 40), dtype=np.float) position = (20., 20.) h_out = 8. w_in = 8. w_out = 12. h_in = w_in * h_out / w_out theta = np.pi / 8. self.aperture = RectangularAnnulus(position, w_in, w_out, h_out, theta) self.area = h_out * w_out - h_in * w_in self.true_flux = self.area class TestMaskedSkipCircular(BaseTestAperturePhotometry): def setup_class(self): self.data = np.ones((40, 40), dtype=np.float) self.mask = np.zeros((40, 40), dtype=bool) self.mask[20, 20] = True position = (20., 20.) r = 10. self.aperture = CircularAperture(position, r) self.area = np.pi * r * r self.true_flux = self.area - 1 class BaseTestDifferentData(object): def test_basic_circular_aperture_photometry(self): aperture = CircularAperture(self.position, self.radius) table = aperture_photometry(self.data, aperture, method='exact', unit='adu') assert_allclose(table['aperture_sum'], self.true_flux) assert table['aperture_sum'].unit, self.fluxunit assert np.all(table['xcenter'] == np.transpose(self.position)[0]) assert np.all(table['ycenter'] == np.transpose(self.position)[1]) class TestInputPrimaryHDU(BaseTestDifferentData): def setup_class(self): data = np.ones((40, 40), dtype=np.float) self.data = fits.ImageHDU(data=data) self.data.header['BUNIT'] = 'adu' self.radius = 3 self.position = (20, 20) self.true_flux = np.pi * self.radius * self.radius self.fluxunit = u.adu class TestInputHDUList(BaseTestDifferentData): def setup_class(self): data0 = np.ones((40, 40), dtype=np.float) data1 = np.empty((40, 40), dtype=np.float) data1.fill(2) self.data = fits.HDUList([fits.ImageHDU(data=data0), fits.ImageHDU(data=data1)]) self.radius = 3 self.position = (20, 20) # It should stop at the first extension self.true_flux = np.pi * self.radius * self.radius class TestInputHDUDifferentBUNIT(BaseTestDifferentData): def setup_class(self): data = np.ones((40, 40), dtype=np.float) self.data = fits.ImageHDU(data=data) self.data.header['BUNIT'] = 'Jy' self.radius = 3 self.position = (20, 20) self.true_flux = np.pi * self.radius * self.radius self.fluxunit = u.adu class TestInputNDData(BaseTestDifferentData): def setup_class(self): data = np.ones((40, 40), dtype=np.float) self.data = NDData(data, unit=u.adu) self.radius = 3 self.position = [(20, 20), (30, 30)] self.true_flux = np.pi * self.radius * self.radius self.fluxunit = u.adu @remote_data def test_wcs_based_photometry_to_catalogue(): from astropy.coordinates import SkyCoord from astropy.table import Table from ..datasets import get_path pathcat = get_path('spitzer_example_catalog.xml', location='remote') pathhdu = get_path('spitzer_example_image.fits', location='remote') hdu = fits.open(pathhdu) scale = hdu[0].header['PIXSCAL1'] catalog = Table.read(pathcat) pos_skycoord = SkyCoord(catalog['l'], catalog['b'], frame='galactic') photometry_skycoord = aperture_photometry( hdu, SkyCircularAperture(pos_skycoord, 4 * u.arcsec)) photometry_skycoord_pix = aperture_photometry( hdu, SkyCircularAperture(pos_skycoord, 4. / scale * u.pixel)) assert_allclose(photometry_skycoord['aperture_sum'], photometry_skycoord_pix['aperture_sum']) # Photometric unit conversion is needed to match the catalogue factor = (1.2 * u.arcsec) ** 2 / u.pixel converted_aperture_sum = (photometry_skycoord['aperture_sum'] * factor).to(u.mJy / u.pixel) fluxes_catalog = catalog['f4_5'].filled() # There shouldn't be large outliers, but some differences is OK, as # fluxes_catalog is based on PSF photometry, etc. assert_allclose(fluxes_catalog, converted_aperture_sum.value, rtol=1e0) assert(np.mean(np.fabs(((fluxes_catalog - converted_aperture_sum.value) / fluxes_catalog))) < 0.1) def test_wcs_based_photometry(): from astropy.wcs import WCS from astropy.wcs.utils import pixel_to_skycoord from ..datasets import make_4gaussians_image hdu = make_4gaussians_image(hdu=True, wcs=True) wcs = WCS(header=hdu.header) # hard wired positions in make_4gaussian_image pos_orig_pixel = u.Quantity(([160., 25., 150., 90.], [70., 40., 25., 60.]), unit=u.pixel) pos_skycoord = pixel_to_skycoord(pos_orig_pixel[0], pos_orig_pixel[1], wcs) pos_skycoord_s = pos_skycoord[2] photometry_skycoord_circ = aperture_photometry( hdu, SkyCircularAperture(pos_skycoord, 3 * u.deg)) photometry_skycoord_circ_2 = aperture_photometry( hdu, SkyCircularAperture(pos_skycoord, 2 * u.deg)) photometry_skycoord_circ_s = aperture_photometry( hdu, SkyCircularAperture(pos_skycoord_s, 3 * u.deg)) assert_allclose(photometry_skycoord_circ['aperture_sum'][2], photometry_skycoord_circ_s['aperture_sum']) photometry_skycoord_circ_ann = aperture_photometry( hdu, SkyCircularAnnulus(pos_skycoord, 2 * u.deg, 3 * u.deg)) photometry_skycoord_circ_ann_s = aperture_photometry( hdu, SkyCircularAnnulus(pos_skycoord_s, 2 * u.deg, 3 * u.deg)) assert_allclose(photometry_skycoord_circ_ann['aperture_sum'][2], photometry_skycoord_circ_ann_s['aperture_sum']) assert_allclose(photometry_skycoord_circ_ann['aperture_sum'], photometry_skycoord_circ['aperture_sum'] - photometry_skycoord_circ_2['aperture_sum']) photometry_skycoord_ell = aperture_photometry( hdu, SkyEllipticalAperture(pos_skycoord, 3 * u.deg, 3.0001 * u.deg, 45 * u.deg)) photometry_skycoord_ell_2 = aperture_photometry( hdu, SkyEllipticalAperture(pos_skycoord, 2 * u.deg, 2.0001 * u.deg, 45 * u.deg)) photometry_skycoord_ell_s = aperture_photometry( hdu, SkyEllipticalAperture(pos_skycoord_s, 3 * u.deg, 3.0001 * u.deg, 45 * u.deg)) photometry_skycoord_ell_ann = aperture_photometry( hdu, SkyEllipticalAnnulus(pos_skycoord, 2 * u.deg, 3 * u.deg, 3.0001 * u.deg, 45 * u.deg)) photometry_skycoord_ell_ann_s = aperture_photometry( hdu, SkyEllipticalAnnulus(pos_skycoord_s, 2 * u.deg, 3 * u.deg, 3.0001 * u.deg, 45 * u.deg)) assert_allclose(photometry_skycoord_ell['aperture_sum'][2], photometry_skycoord_ell_s['aperture_sum']) assert_allclose(photometry_skycoord_ell_ann['aperture_sum'][2], photometry_skycoord_ell_ann_s['aperture_sum']) assert_allclose(photometry_skycoord_ell['aperture_sum'], photometry_skycoord_circ['aperture_sum'], rtol=5e-3) assert_allclose(photometry_skycoord_ell_ann['aperture_sum'], photometry_skycoord_ell['aperture_sum'] - photometry_skycoord_ell_2['aperture_sum'], rtol=1e-4) photometry_skycoord_rec = aperture_photometry( hdu, SkyRectangularAperture(pos_skycoord, 6 * u.deg, 6 * u.deg, 0 * u.deg), method='subpixel', subpixels=20) photometry_skycoord_rec_4 = aperture_photometry( hdu, SkyRectangularAperture(pos_skycoord, 4 * u.deg, 4 * u.deg, 0 * u.deg), method='subpixel', subpixels=20) photometry_skycoord_rec_s = aperture_photometry( hdu, SkyRectangularAperture(pos_skycoord_s, 6 * u.deg, 6 * u.deg, 0 * u.deg), method='subpixel', subpixels=20) photometry_skycoord_rec_ann = aperture_photometry( hdu, SkyRectangularAnnulus(pos_skycoord, 4 * u.deg, 6 * u.deg, 6 * u.deg, 0 * u.deg), method='subpixel', subpixels=20) photometry_skycoord_rec_ann_s = aperture_photometry( hdu, SkyRectangularAnnulus(pos_skycoord_s, 4 * u.deg, 6 * u.deg, 6 * u.deg, 0 * u.deg), method='subpixel', subpixels=20) assert_allclose(photometry_skycoord_rec['aperture_sum'][2], photometry_skycoord_rec_s['aperture_sum']) assert np.all(photometry_skycoord_rec['aperture_sum'] > photometry_skycoord_circ['aperture_sum']) assert_allclose(photometry_skycoord_rec_ann['aperture_sum'][2], photometry_skycoord_rec_ann_s['aperture_sum']) assert_allclose(photometry_skycoord_rec_ann['aperture_sum'], photometry_skycoord_rec['aperture_sum'] - photometry_skycoord_rec_4['aperture_sum'], rtol=1e-4) def test_basic_circular_aperture_photometry_unit(): data1 = np.ones((40, 40), dtype=np.float) data2 = u.Quantity(data1, unit=u.adu) data3 = u.Quantity(data1, unit=u.Jy) radius = 3 position = (20, 20) true_flux = np.pi * radius * radius unit = u.adu table1 = aperture_photometry(data1, CircularAperture(position, radius), unit=unit) table2 = aperture_photometry(data2, CircularAperture(position, radius), unit=unit) with pytest.raises(u.UnitConversionError) as err: aperture_photometry(data3, CircularAperture(position, radius), unit=unit) assert ("UnitConversionError: 'Jy' (spectral flux density) and 'adu' are " "not convertible" in str(err)) assert_allclose(table1['aperture_sum'], true_flux) assert_allclose(table2['aperture_sum'], true_flux) assert table1['aperture_sum'].unit == unit assert table2['aperture_sum'].unit == data2.unit == unit def test_aperture_photometry_with_error_units(): """Test aperture_photometry when error has units (see #176).""" data1 = np.ones((40, 40), dtype=np.float) data2 = u.Quantity(data1, unit=u.adu) error = u.Quantity(data1, unit=u.adu) radius = 3 true_flux = np.pi * radius * radius unit = u.adu position = (20, 20) table1 = aperture_photometry(data2, CircularAperture(position, radius), error=error) assert_allclose(table1['aperture_sum'], true_flux) assert_allclose(table1['aperture_sum_err'], np.sqrt(true_flux)) assert table1['aperture_sum'].unit == unit assert table1['aperture_sum_err'].unit == unit def test_aperture_photometry_inputs_with_mask(): """ Test that aperture_photometry does not modify the input data or error array when a mask is input. """ data = np.ones((5, 5)) aperture = CircularAperture((2, 2), 2.) mask = np.zeros_like(data, dtype=bool) data[2, 2] = 100. # bad pixel mask[2, 2] = True error = np.sqrt(data) data_in = data.copy() error_in = error.copy() t1 = aperture_photometry(data, aperture, error=error, mask=mask) assert_array_equal(data, data_in) assert_array_equal(error, error_in) assert_allclose(t1['aperture_sum'][0], 11.5663706144) t2 = aperture_photometry(data, aperture) assert_allclose(t2['aperture_sum'][0], 111.566370614) TEST_ELLIPSE_EXACT_APERTURES = [(3.469906, 3.923861394, 3.), (0.3834415188257778, 0.3834415188257778, 0.3)] @pytest.mark.parametrize('x,y,r', TEST_ELLIPSE_EXACT_APERTURES) def test_ellipse_exact_grid(x, y, r): """ Test elliptical exact aperture photometry on a grid of pixel positions. This is a regression test for the bug discovered in this issue: https://github.com/astropy/photutils/issues/198 """ data = np.ones((10, 10)) aperture = EllipticalAperture((x, y), r, r, 0.) t = aperture_photometry(data, aperture, method='exact') actual = t['aperture_sum'][0] / (np.pi * r ** 2) assert_allclose(actual, 1) @pytest.mark.parametrize('value', [np.nan, np.inf]) def test_nan_inf_mask(value): """Test that nans and infs are properly masked [267].""" data = np.ones((9, 9)) mask = np.zeros_like(data, dtype=bool) data[4, 4] = value mask[4, 4] = True radius = 2. aper = CircularAperture((4, 4), radius) tbl = aperture_photometry(data, aper, mask=mask) desired = (np.pi * radius**2) - 1 assert_allclose(tbl['aperture_sum'], desired) photutils-0.2.1/photutils/tests/test_background.py0000600000214200020070000001230312444404542024647 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst from __future__ import (absolute_import, division, print_function, unicode_literals) import numpy as np from numpy.testing import assert_allclose from astropy.tests.helper import pytest import itertools from ..background import Background try: import scipy HAS_SCIPY = True except ImportError: HAS_SCIPY = False DATA = np.ones((100, 100)) BKG_RMS = np.zeros((100, 100)) BKG_LOW_RES = np.ones((4, 4)) BKG_RMS_LOW_RES = np.zeros((4, 4)) PADBKG_LOW_RES = np.ones((5, 5)) PADBKG_RMS_LOW_RES = np.zeros((5, 5)) FILTER_SHAPES = [(1, 1), (3, 3)] METHODS = ['mean', 'median', 'sextractor', 'mode_estimate'] def custom_backfunc(data): """Same as method='mean'.""" bkg = np.ma.mean(data, axis=2) return np.ma.filled(bkg, np.ma.median(bkg)) @pytest.mark.skipif('not HAS_SCIPY') class TestBackground(object): def test_mask_badshape(self): with pytest.raises(ValueError): Background(DATA, (25, 25), (1, 1), mask=np.zeros((2, 2))) def test_invalid_method(self): with pytest.raises(ValueError): Background(DATA, (25, 25), (1, 1), method='not_valid') @pytest.mark.parametrize(('filter_shape', 'method'), list(itertools.product(FILTER_SHAPES, METHODS))) def test_background(self, filter_shape, method): b = Background(DATA, (25, 25), filter_shape, method=method) assert_allclose(b.background, DATA) assert_allclose(b.background_rms, BKG_RMS) assert_allclose(b.background_low_res, BKG_LOW_RES) assert_allclose(b.background_rms_low_res, BKG_RMS_LOW_RES) assert b.background_median == 1.0 assert b.background_rms_median == 0.0 def test_background_nonconstant(self): data = np.copy(DATA) data[25:50, 50:75] = 10. bkg_low_res = np.copy(BKG_LOW_RES) bkg_low_res[1, 2] = 10. b = Background(data, (25, 25), (1, 1), method='mean') assert_allclose(b.background_low_res, bkg_low_res) assert b.background.shape == data.shape @pytest.mark.parametrize(('filter_shape', 'method'), list(itertools.product(FILTER_SHAPES, METHODS))) def test_background_padding(self, filter_shape, method): b = Background(DATA, (22, 22), filter_shape, method=method) assert_allclose(b.background, DATA) assert_allclose(b.background_rms, BKG_RMS) assert_allclose(b.background_low_res, PADBKG_LOW_RES) assert_allclose(b.background_rms_low_res, PADBKG_RMS_LOW_RES) @pytest.mark.parametrize('box_shape', ([(25, 25), (22, 22)])) def test_background_mask(self, box_shape): data = np.copy(DATA) data[25:50, 25:50] = 100. mask = np.zeros_like(DATA, dtype=np.bool) mask[25:50, 25:50] = True b = Background(data, box_shape, (1, 1), mask=mask) assert_allclose(b.background, DATA) assert_allclose(b.background_rms, BKG_RMS) def test_filter_threshold(self): """Only meshes greater than filter_threshold are filtered.""" data = np.copy(DATA) data[25:50, 50:75] = 10. b = Background(data, (25, 25), (3, 3), filter_threshold=1.) assert_allclose(b.background, DATA) assert_allclose(b.background_low_res, BKG_LOW_RES) def test_filter_threshold_high(self): """No filtering because filter_threshold is too large.""" data = np.copy(DATA) data[25:50, 50:75] = 10. ref_data = np.copy(BKG_LOW_RES) ref_data[1, 2] = 10. b = Background(data, (25, 25), (3, 3), filter_threshold=100.) assert_allclose(b.background_low_res, ref_data) def test_filter_threshold_nofilter(self): """No filtering because filter_shape is (1, 1).""" data = np.copy(DATA) data[25:50, 50:75] = 10. ref_data = np.copy(BKG_LOW_RES) ref_data[1, 2] = 10. b = Background(data, (25, 25), (1, 1), filter_threshold=1.) assert_allclose(b.background_low_res, ref_data) def test_custom_method(self): b0 = Background(DATA, (25, 25), (3, 3), method='mean') b1 = Background(DATA, (25, 25), (3, 3), method='custom', backfunc=custom_backfunc) assert_allclose(b0.background, b1.background) assert_allclose(b0.background_rms, b1.background_rms) def test_custom_return_nonarray(self): def backfunc(data): return 1 with pytest.raises(ValueError): b = Background(DATA, (25, 25), (3, 3), method='custom', backfunc=backfunc) b.background_low_res def test_custom_return_masked_array(self): def backfunc(data): return np.ma.masked_array([1], mask=False) with pytest.raises(ValueError): b = Background(DATA, (25, 25), (3, 3), method='custom', backfunc=backfunc) b.background_low_res def test_custom_return_badshape(self): def backfunc(data): return np.ones((2, 2)) with pytest.raises(ValueError): b = Background(DATA, (25, 25), (3, 3), method='custom', backfunc=backfunc) b.background_low_res photutils-0.2.1/photutils/tests/test_morphology.py0000600000214200020070000001410012627615324024731 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst from __future__ import (absolute_import, division, print_function, unicode_literals) from astropy.tests.helper import pytest import numpy as np from numpy.testing import assert_allclose import itertools from ..morphology import (centroid_com, centroid_1dg, centroid_2dg, gaussian1d_moments, data_properties, fit_2dgaussian, cutout_footprint) from astropy.modeling.models import Gaussian1D, Gaussian2D try: import skimage HAS_SKIMAGE = True except ImportError: HAS_SKIMAGE = False XCS = [25.7] YCS = [26.2] XSTDDEVS = [3.2, 4.0] YSTDDEVS = [5.7, 4.1] THETAS = np.array([30., 45.]) * np.pi / 180. DATA = np.zeros((3, 3)) DATA[0:2, 1] = 1. DATA[1, 0:2] = 1. DATA[1, 1] = 2. @pytest.mark.parametrize( ('xc_ref', 'yc_ref', 'x_stddev', 'y_stddev', 'theta'), list(itertools.product(XCS, YCS, XSTDDEVS, YSTDDEVS, THETAS))) @pytest.mark.skipif('not HAS_SKIMAGE') def test_centroids(xc_ref, yc_ref, x_stddev, y_stddev, theta): model = Gaussian2D(2.4, xc_ref, yc_ref, x_stddev=x_stddev, y_stddev=y_stddev, theta=theta) y, x = np.mgrid[0:50, 0:50] data = model(x, y) xc, yc = centroid_com(data) assert_allclose([xc_ref, yc_ref], [xc, yc], rtol=0, atol=1.e-3) xc2, yc2 = centroid_1dg(data) assert_allclose([xc_ref, yc_ref], [xc2, yc2], rtol=0, atol=1.e-3) xc3, yc3 = centroid_2dg(data) assert_allclose([xc_ref, yc_ref], [xc3, yc3], rtol=0, atol=1.e-3) @pytest.mark.parametrize( ('xc_ref', 'yc_ref', 'x_stddev', 'y_stddev', 'theta'), list(itertools.product(XCS, YCS, XSTDDEVS, YSTDDEVS, THETAS))) @pytest.mark.skipif('not HAS_SKIMAGE') def test_centroids_witherror(xc_ref, yc_ref, x_stddev, y_stddev, theta): model = Gaussian2D(2.4, xc_ref, yc_ref, x_stddev=x_stddev, y_stddev=y_stddev, theta=theta) y, x = np.mgrid[0:50, 0:50] data = model(x, y) error = np.sqrt(data) xc2, yc2 = centroid_1dg(data, error=error) assert_allclose([xc_ref, yc_ref], [xc2, yc2], rtol=0, atol=1.e-3) xc3, yc3 = centroid_2dg(data, error=error) assert_allclose([xc_ref, yc_ref], [xc3, yc3], rtol=0, atol=1.e-3) @pytest.mark.skipif('not HAS_SKIMAGE') def test_centroids_withmask(): xc_ref, yc_ref = 24.7, 25.2 model = Gaussian2D(2.4, xc_ref, yc_ref, x_stddev=5.0, y_stddev=5.0) y, x = np.mgrid[0:50, 0:50] data = model(x, y) mask = np.zeros_like(data, dtype=bool) data[0, 0] = 1. mask[0, 0] = True xc, yc = centroid_com(data, mask=mask) assert_allclose([xc, yc], [xc_ref, yc_ref], rtol=0, atol=1.e-3) xc2, yc2 = centroid_1dg(data, mask=mask) assert_allclose([xc2, yc2], [xc_ref, yc_ref], rtol=0, atol=1.e-3) xc3, yc3 = centroid_2dg(data, mask=mask) assert_allclose([xc3, yc3], [xc_ref, yc_ref], rtol=0, atol=1.e-3) @pytest.mark.skipif('not HAS_SKIMAGE') def test_centroids_mask(): """Test centroid_com with and without an image_mask.""" data = np.ones((2, 2)).astype(np.float) mask = [[False, False], [True, True]] centroid = centroid_com(data, mask=None) centroid_mask = centroid_com(data, mask=mask) assert_allclose([0.5, 0.5], centroid, rtol=0, atol=1.e-6) assert_allclose([0.5, 0.0], centroid_mask, rtol=0, atol=1.e-6) @pytest.mark.skipif('not HAS_SKIMAGE') def test_centroid_com_mask_shape(): """ Test if ValueError raises if mask shape doesn't match data shape. """ with pytest.raises(ValueError): mask = np.zeros((2, 2), dtype=bool) centroid_com(np.zeros((4, 4)), mask=mask) @pytest.mark.skipif('not HAS_SKIMAGE') def test_data_properties(): data = np.ones((2, 2)).astype(np.float) mask = np.array([[False, False], [True, True]]) props = data_properties(data, mask=None) props2 = data_properties(data, mask=mask) properties = ['xcentroid', 'ycentroid', 'area'] result = [props[i].value for i in properties] result2 = [props2[i].value for i in properties] assert_allclose([0.5, 0.5, 4.0], result, rtol=0, atol=1.e-6) assert_allclose([0.5, 0.0, 2.0], result2, rtol=0, atol=1.e-6) def test_gaussian1d_moments(): x = np.arange(100) desired = (75, 50, 5) g = Gaussian1D(*desired) data = g(x) result = gaussian1d_moments(data) assert_allclose(result, desired, rtol=0, atol=1.e-6) def test_fit2dgaussian_dof(): data = np.ones((2, 2)) result = fit_2dgaussian(data) assert result is None class TestCutoutFootprint(object): def test_dataonly(self): data = np.ones((5, 5)) position = (2, 2) result1 = cutout_footprint(data, position, 3) result2 = cutout_footprint(data, position, footprint=np.ones((3, 3))) assert_allclose(result1[:-2], result2[:-2]) assert result1[-2] is None assert result2[-2] is None assert result1[-1] == result2[-1] def test_mask_error(self): data = error = np.ones((5, 5)) mask = np.zeros_like(data, dtype=bool) position = (2, 2) box_size1 = 3 box_size2 = (3, 3) footprint = np.ones((3, 3)) result1 = cutout_footprint(data, position, box_size1, mask=mask, error=error) result2 = cutout_footprint(data, position, box_size2, mask=mask, error=error) result3 = cutout_footprint(data, position, box_size1, footprint=footprint, mask=mask, error=error) assert_allclose(result1[:-1], result2[:-1]) assert_allclose(result1[:-1], result3[:-1]) assert result1[-1] == result2[-1] def test_position_len(self): with pytest.raises(ValueError): cutout_footprint(np.ones((3, 3)), [1]) def test_nofootprint(self): with pytest.raises(ValueError): cutout_footprint(np.ones((3, 3)), (1, 1), box_size=None, footprint=None) def test_wrongboxsize(self): with pytest.raises(ValueError): cutout_footprint(np.ones((3, 3)), (1, 1), box_size=(1, 2, 3)) photutils-0.2.1/photutils/tests/test_psf_photometry.py0000600000214200020070000001133312445205327025615 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst from __future__ import division import numpy as np from numpy.testing import assert_allclose from astropy.tests.helper import pytest from astropy.modeling.models import Gaussian2D from astropy.convolution.utils import discretize_model from ..psf import (create_prf, DiscretePRF, psf_photometry, GaussianPSF, subtract_psf) try: from scipy import optimize HAS_SCIPY = True except ImportError: HAS_SCIPY = False PSF_SIZE = 11 GAUSSIAN_WIDTH = 1. IMAGE_SIZE = 101 # Position and FLUXES of test sources POSITIONS = [(50, 50), (23, 83), (12, 80), (86, 84)] FLUXES = [np.pi * 10, 3.654, 20., 80 / np.sqrt(3)] # Create test psf psf_model = Gaussian2D(1. / (2 * np.pi * GAUSSIAN_WIDTH ** 2), PSF_SIZE // 2, PSF_SIZE // 2, GAUSSIAN_WIDTH, GAUSSIAN_WIDTH) test_psf = discretize_model(psf_model, (0, PSF_SIZE), (0, PSF_SIZE), mode='oversample') # Set up grid for test image image = np.zeros((IMAGE_SIZE, IMAGE_SIZE)) # Add sources to test image for flux, position in zip(FLUXES, POSITIONS): x, y = position model = Gaussian2D(flux / (2 * np.pi * GAUSSIAN_WIDTH ** 2), x, y, GAUSSIAN_WIDTH, GAUSSIAN_WIDTH) image += discretize_model(model, (0, IMAGE_SIZE), (0, IMAGE_SIZE), mode='oversample') def test_create_prf_mean(): """ Check if create_prf works correctly on simulated data. """ prf = create_prf(image, POSITIONS, PSF_SIZE, subsampling=1, mode='mean') assert_allclose(prf._prf_array[0, 0], test_psf, atol=1E-8) def test_create_prf_median(): """ Check if create_prf works correctly on simulated data. """ prf = create_prf(image, POSITIONS, PSF_SIZE, subsampling=1, mode='median') assert_allclose(prf._prf_array[0, 0], test_psf, atol=1E-8) def test_create_prf_nan(): """ Check if create_prf deals correctly with nan values. """ image_nan = image.copy() image_nan[52, 52] = np.nan image_nan[52, 48] = np.nan prf = create_prf(image_nan, POSITIONS, PSF_SIZE, subsampling=1, fix_nan=True) assert not np.isnan(prf._prf_array[0, 0]).any() def test_create_prf_flux(): """ Check if create_prf works correctly when FLUXES are specified. """ prf = create_prf(image, POSITIONS, PSF_SIZE, fluxes=FLUXES, subsampling=1) assert_allclose(prf._prf_array[0, 0].sum(), 1) assert_allclose(prf._prf_array[0, 0], test_psf, atol=1E-8) @pytest.mark.skipif('not HAS_SCIPY') def test_discrete_prf_fit(): """ Check if fitting of discrete PSF model works. """ prf = DiscretePRF(test_psf, subsampling=1) prf.x_0 = 50 prf.y_0 = 50 # test_psf is normalized to unity indices = np.indices(image.shape) flux = prf.fit(image, indices) assert_allclose(flux, FLUXES[0], rtol=1E-5) @pytest.mark.skipif('not HAS_SCIPY') def test_psf_photometry_discrete(): """ Test psf_photometry with discrete PRF model. """ prf = DiscretePRF(test_psf, subsampling=1) f = psf_photometry(image, POSITIONS, prf) assert_allclose(f, FLUXES, rtol=1E-6) @pytest.mark.skipif('not HAS_SCIPY') def test_tune_coordinates(): """ Test psf_photometry with discrete PRF model and tune_coordinates=True. """ prf = DiscretePRF(test_psf, subsampling=1) # Shift all sources by 0.3 pixels positions = [(_[0] + 0.3, _[1] + 0.3) for _ in POSITIONS] f = psf_photometry(image, positions, prf, tune_coordinates=True) assert_allclose(f, FLUXES, rtol=1E-6) @pytest.mark.skipif('not HAS_SCIPY') def test_psf_boundary(): """ Test psf_photometry with discrete PRF model at the boundary of the data. """ prf = DiscretePRF(test_psf, subsampling=1) # Shift all sources by 0.3 pixels f = psf_photometry(image, [(1, 1)], prf) assert f == 0 @pytest.mark.skipif('not HAS_SCIPY') def test_psf_boundary_gaussian(): """ Test psf_photometry with discrete PRF model at the boundary of the data. """ psf = GaussianPSF(GAUSSIAN_WIDTH) # Shift all sources by 0.3 pixels f = psf_photometry(image, [(1, 1)], psf) assert f == 0 @pytest.mark.skipif('not HAS_SCIPY') def test_psf_photometry_gaussian(): """ Test psf_photometry with Gaussian PSF model. """ prf = GaussianPSF(GAUSSIAN_WIDTH) f = psf_photometry(image, POSITIONS, prf) fluxes = [4.60833518, 0.53599746, 2.93375729, 6.77522225] assert_allclose(f, fluxes, rtol=1E-3) @pytest.mark.skipif('not HAS_SCIPY') def test_subtract_psf(): """ Test subtract_psf """ prf = DiscretePRF(test_psf, subsampling=1) residuals = subtract_psf(image, prf, POSITIONS, FLUXES) assert_allclose(residuals, np.zeros_like(image), atol=1E-6) photutils-0.2.1/photutils/tests/test_psfs.py0000600000214200020070000000177712460257762023530 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst from __future__ import division import numpy as np from numpy.testing import assert_allclose from astropy.tests.helper import pytest from ..psf import GaussianPSF try: from scipy import optimize HAS_SCIPY = True except ImportError: HAS_SCIPY = False widths = [0.001, 0.01, 0.1, 1] sigmas = [0.5, 1., 2., 10., 12.34] @pytest.mark.skipif('not HAS_SCIPY') @pytest.mark.parametrize('width', widths) def test_subpixel_gauss_psf(width): """ Test subpixel accuracy of Gaussian PSF by checking the peak amplitude. """ gauss_psf = GaussianPSF(width) y, x = np.mgrid[-10:11, -10:11] assert_allclose(gauss_psf(x, y).max(), 1) @pytest.mark.skipif('not HAS_SCIPY') @pytest.mark.parametrize('sigma', sigmas) def test_gaussian_psf_integral(sigma): """ Test if Gaussian PSF peak matches amplitude. """ psf = GaussianPSF(sigma=sigma) y, x = np.mgrid[-100:101, -100:101] assert_allclose(psf(y, x).max(), 1) photutils-0.2.1/photutils/tests/test_segmentation.py0000600000214200020070000005430312646242520025233 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst from __future__ import (absolute_import, division, print_function, unicode_literals) from distutils.version import LooseVersion import itertools import numpy as np from numpy.testing import assert_allclose from astropy.tests.helper import pytest, assert_quantity_allclose from astropy.modeling import models from astropy.table import Table import astropy.units as u from astropy.utils.misc import isiterable import astropy.wcs as WCS from ..segmentation import (SegmentationImage, SourceProperties, source_properties, properties_table) try: import scipy HAS_SCIPY = True except ImportError: HAS_SCIPY = False try: import skimage HAS_SKIMAGE = True if LooseVersion(skimage.__version__) < LooseVersion('0.11'): SKIMAGE_LT_0P11 = True else: SKIMAGE_LT_0P11 = False except ImportError: HAS_SKIMAGE = False XCEN = 51. YCEN = 52.7 MAJOR_SIG = 8. MINOR_SIG = 3. THETA = np.pi / 6. g = models.Gaussian2D(111., XCEN, YCEN, MAJOR_SIG, MINOR_SIG, theta=THETA) y, x = np.mgrid[0:100, 0:100] IMAGE = g(x, y) THRESHOLD = 0.1 SEGM = (IMAGE >= THRESHOLD).astype(np.int) ERR_VALS = [0., 2.5] EFFGAIN_VALS = [None, 2., 1.e10] BACKGRD_VALS = [None, 0., 1., 3.5] @pytest.mark.skipif('not HAS_SKIMAGE') @pytest.mark.skipif('not HAS_SCIPY') class TestSegmentationImage(object): def setup_class(self): self.data = [[1, 1, 0, 0, 4, 4], [0, 0, 0, 0, 0, 4], [0, 0, 3, 3, 0, 0], [7, 0, 0, 0, 0, 5], [7, 7, 0, 5, 5, 5], [7, 7, 0, 0, 5, 5]] def test_array(self): segm = SegmentationImage(self.data) assert_allclose(segm.data, segm.array) assert_allclose(segm.data, segm.__array__()) def test_negative_data(self): data = np.arange(-1, 8).reshape(3, 3) with pytest.raises(ValueError): SegmentationImage(data) def test_zero_label(self): with pytest.raises(ValueError): segm = SegmentationImage(self.data) segm.check_label(0) def test_negative_label(self): with pytest.raises(ValueError): segm = SegmentationImage(self.data) segm.check_label(-1) def test_invalid_label(self): with pytest.raises(ValueError): segm = SegmentationImage(self.data) segm.check_label(2) def test_data_masked(self): segm = SegmentationImage(self.data) assert isinstance(segm.data_masked, np.ma.MaskedArray) assert np.ma.count(segm.data_masked) == 18 assert np.ma.count_masked(segm.data_masked) == 18 def test_labels(self): segm = SegmentationImage(self.data) assert_allclose(segm.labels, [1, 3, 4, 5, 7]) def test_nlabels(self): segm = SegmentationImage(self.data) assert segm.nlabels == 5 def test_max(self): segm = SegmentationImage(self.data) assert segm.max == 7 def test_outline_segments(self): if SKIMAGE_LT_0P11: return # skip this test segm_array = np.zeros((5, 5)).astype(int) segm_array[1:4, 1:4] = 2 segm = SegmentationImage(segm_array) segm_array_ref = np.copy(segm_array) segm_array_ref[2, 2] = 0 assert_allclose(segm.outline_segments(), segm_array_ref) def test_outline_segments_masked_background(self): if SKIMAGE_LT_0P11: return # skip this test segm_array = np.zeros((5, 5)).astype(int) segm_array[1:4, 1:4] = 2 segm = SegmentationImage(segm_array) segm_array_ref = np.copy(segm_array) segm_array_ref[2, 2] = 0 segm_outlines = segm.outline_segments(mask_background=True) assert isinstance(segm_outlines, np.ma.MaskedArray) assert np.ma.count(segm_outlines) == 8 assert np.ma.count_masked(segm_outlines) == 17 def test_relabel(self): segm = SegmentationImage(self.data) segm.relabel(labels=[1, 7], new_label=2) ref_data = np.array([[2, 2, 0, 0, 4, 4], [0, 0, 0, 0, 0, 4], [0, 0, 3, 3, 0, 0], [2, 0, 0, 0, 0, 5], [2, 2, 0, 5, 5, 5], [2, 2, 0, 0, 5, 5]]) assert_allclose(segm.data, ref_data) assert segm.nlabels == len(segm.slices) - segm.slices.count(None) @pytest.mark.parametrize('start_label', [1, 5]) def test_relabel_sequential(self, start_label): segm = SegmentationImage(self.data) ref_data = np.array([[1, 1, 0, 0, 3, 3], [0, 0, 0, 0, 0, 3], [0, 0, 2, 2, 0, 0], [5, 0, 0, 0, 0, 4], [5, 5, 0, 4, 4, 4], [5, 5, 0, 0, 4, 4]]) ref_data[ref_data != 0] += (start_label - 1) segm.relabel_sequential(start_label=start_label) assert_allclose(segm.data, ref_data) # relabel_sequential should do nothing if already sequential segm.relabel_sequential(start_label=start_label) assert_allclose(segm.data, ref_data) assert segm.nlabels == len(segm.slices) - segm.slices.count(None) @pytest.mark.parametrize('start_label', [0, -1]) def test_relabel_sequential_start_invalid(self, start_label): with pytest.raises(ValueError): segm = SegmentationImage(self.data) segm.relabel_sequential(start_label=start_label) def test_keep_labels(self): ref_data = np.array([[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 3, 3, 0, 0], [0, 0, 0, 0, 0, 5], [0, 0, 0, 5, 5, 5], [0, 0, 0, 0, 5, 5]]) segm = SegmentationImage(self.data) segm.keep_labels([5, 3]) assert_allclose(segm.data, ref_data) def test_keep_labels_relabel(self): ref_data = np.array([[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 0, 0], [0, 0, 0, 0, 0, 2], [0, 0, 0, 2, 2, 2], [0, 0, 0, 0, 2, 2]]) segm = SegmentationImage(self.data) segm.keep_labels([5, 3], relabel=True) assert_allclose(segm.data, ref_data) def test_remove_labels(self): ref_data = np.array([[1, 1, 0, 0, 4, 4], [0, 0, 0, 0, 0, 4], [0, 0, 0, 0, 0, 0], [7, 0, 0, 0, 0, 0], [7, 7, 0, 0, 0, 0], [7, 7, 0, 0, 0, 0]]) segm = SegmentationImage(self.data) segm.remove_labels(labels=[5, 3]) assert_allclose(segm.data, ref_data) def test_remove_labels_relabel(self): ref_data = np.array([[1, 1, 0, 0, 2, 2], [0, 0, 0, 0, 0, 2], [0, 0, 0, 0, 0, 0], [3, 0, 0, 0, 0, 0], [3, 3, 0, 0, 0, 0], [3, 3, 0, 0, 0, 0]]) segm = SegmentationImage(self.data) segm.remove_labels(labels=[5, 3], relabel=True) assert_allclose(segm.data, ref_data) def test_remove_border_labels(self): ref_data = np.array([[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 3, 3, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]) segm = SegmentationImage(self.data) segm.remove_border_labels(border_width=1) assert_allclose(segm.data, ref_data) def test_remove_border_labels_border_width(self): with pytest.raises(ValueError): segm = SegmentationImage(self.data) segm.remove_border_labels(border_width=3) def test_remove_masked_labels(self): ref_data = np.array([[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 3, 3, 0, 0], [7, 0, 0, 0, 0, 5], [7, 7, 0, 5, 5, 5], [7, 7, 0, 0, 5, 5]]) segm = SegmentationImage(self.data) mask = np.zeros_like(segm.data, dtype=np.bool) mask[0, :] = True segm.remove_masked_labels(mask) assert_allclose(segm.data, ref_data) def test_remove_masked_labels_without_partial_overlap(self): ref_data = np.array([[0, 0, 0, 0, 4, 4], [0, 0, 0, 0, 0, 4], [0, 0, 3, 3, 0, 0], [7, 0, 0, 0, 0, 5], [7, 7, 0, 5, 5, 5], [7, 7, 0, 0, 5, 5]]) segm = SegmentationImage(self.data) mask = np.zeros_like(segm.data, dtype=np.bool) mask[0, :] = True segm.remove_masked_labels(mask, partial_overlap=False) assert_allclose(segm.data, ref_data) def test_remove_masked_segments_mask_shape(self): segm = SegmentationImage(np.ones((5, 5))) mask = np.zeros((3, 3), dtype=np.bool) with pytest.raises(ValueError): segm.remove_masked_labels(mask) @pytest.mark.skipif('not HAS_SKIMAGE') @pytest.mark.skipif('not HAS_SCIPY') class TestSourceProperties(object): def test_segment_shape(self): with pytest.raises(ValueError): SourceProperties(IMAGE, np.zeros((2, 2)), label=1) @pytest.mark.parametrize('label', (0, -1)) def test_label_invalid(self, label): with pytest.raises(ValueError): SourceProperties(IMAGE, SEGM, label=label) @pytest.mark.parametrize('label', (0, -1)) def test_label_missing(self, label): segm = SEGM.copy() segm[0:2, 0:2] = 3 # skip label 2 with pytest.raises(ValueError): SourceProperties(IMAGE, segm, label=2) def test_wcs(self): mywcs = WCS.WCS(naxis=2) rho = np.pi / 3. scale = 0.1 / 3600. mywcs.wcs.cd = [[scale*np.cos(rho), -scale*np.sin(rho)], [scale*np.sin(rho), scale*np.cos(rho)]] mywcs.wcs.ctype = ['RA---TAN', 'DEC--TAN'] props = SourceProperties(IMAGE, SEGM, wcs=mywcs, label=1) assert props.icrs_centroid is not None assert props.ra_icrs_centroid is not None assert props.dec_icrs_centroid is not None def test_nowcs(self): props = SourceProperties(IMAGE, SEGM, wcs=None, label=1) assert props.icrs_centroid is None assert props.ra_icrs_centroid is None assert props.dec_icrs_centroid is None def test_to_table(self): props = SourceProperties(IMAGE, SEGM, label=1) t1 = props.to_table() t2 = properties_table(props) assert isinstance(t1, Table) assert isinstance(t2, Table) assert len(t1) == 1 assert t1 == t2 @pytest.mark.skipif('not HAS_SKIMAGE') @pytest.mark.skipif('not HAS_SCIPY') class TestSourcePropertiesFunctionInputs(object): def test_segment_shape(self): wrong_shape = np.zeros((2, 2)) with pytest.raises(ValueError): source_properties(IMAGE, wrong_shape) def test_error_shape(self): wrong_shape = np.zeros((2, 2)) with pytest.raises(ValueError): source_properties(IMAGE, SEGM, error=wrong_shape) def test_effective_gain_shape(self): wrong_shape = np.zeros((2, 2)) with pytest.raises(ValueError): source_properties(IMAGE, SEGM, error=IMAGE, effective_gain=wrong_shape) def test_background_shape(self): wrong_shape = np.zeros((2, 2)) with pytest.raises(ValueError): source_properties(IMAGE, SEGM, background=wrong_shape) def test_mask_shape(self): wrong_shape = np.zeros((2, 2)) with pytest.raises(ValueError): source_properties(IMAGE, SEGM, mask=wrong_shape) def test_labels(self): props = source_properties(IMAGE, SEGM, labels=1) assert props[0].id == 1 def test_invalidlabels(self): props = source_properties(IMAGE, SEGM, labels=-1) assert len(props) == 0 @pytest.mark.skipif('not HAS_SKIMAGE') @pytest.mark.skipif('not HAS_SCIPY') class TestSourcePropertiesFunction(object): def test_properties(self): props = source_properties(IMAGE, SEGM) assert props[0].id == 1 assert_quantity_allclose(props[0].xcentroid, XCEN*u.pix, rtol=1.e-2) assert_quantity_allclose(props[0].ycentroid, YCEN*u.pix, rtol=1.e-2) assert_allclose(props[0].source_sum, IMAGE[IMAGE >= THRESHOLD].sum()) assert_quantity_allclose(props[0].semimajor_axis_sigma, MAJOR_SIG*u.pix, rtol=1.e-2) assert_quantity_allclose(props[0].semiminor_axis_sigma, MINOR_SIG*u.pix, rtol=1.e-2) assert_quantity_allclose(props[0].orientation, THETA*u.rad, rtol=1.e-3) assert_allclose(props[0].bbox.value, [35, 25, 70, 77]) assert_quantity_allclose(props[0].area, 1058.0*u.pix**2) assert_allclose(len(props[0].values), props[0].area.value) assert_allclose(len(props[0].coords), 2) assert_allclose(len(props[0].coords[0]), props[0].area.value) properties = ['background_at_centroid', 'background_mean', 'eccentricity', 'ellipticity', 'elongation', 'equivalent_radius', 'max_value', 'maxval_xpos', 'maxval_ypos', 'min_value', 'minval_xpos', 'minval_ypos', 'perimeter', 'cxx', 'cxy', 'cyy', 'covar_sigx2', 'covar_sigxy', 'covar_sigy2', 'xmax', 'xmin', 'ymax', 'ymin'] for propname in properties: assert not isiterable(getattr(props[0], propname)) properties = ['centroid', 'covariance_eigvals', 'cutout_centroid', 'maxval_cutout_pos', 'minval_cutout_pos'] shapes = [getattr(props[0], p).shape for p in properties] for shape in shapes: assert shape == (2,) properties = ['covariance', 'inertia_tensor'] shapes = [getattr(props[0], p).shape for p in properties] for shape in shapes: assert shape == (2, 2) properties = ['moments', 'moments_central'] shapes = [getattr(props[0], p).shape for p in properties] for shape in shapes: assert shape == (4, 4) def test_properties_background_notNone(self): value = 1. props = source_properties(IMAGE, SEGM, background=value) assert props[0].background_mean == value assert_allclose(props[0].background_at_centroid, value) def test_properties_error_background_None(self): props = source_properties(IMAGE, SEGM) assert props[0].background_cutout_ma is None assert props[0].error_cutout_ma is None def test_cutout_shapes(self): error = np.ones_like(IMAGE) * 1. props = source_properties(IMAGE, SEGM, error=error, background=1.) bbox = props[0].bbox.value true_shape = (bbox[2] - bbox[0] + 1, bbox[3] - bbox[1] + 1) properties = ['background_cutout_ma', 'data_cutout', 'data_cutout_ma', 'error_cutout_ma'] shapes = [getattr(props[0], p).shape for p in properties] for shape in shapes: assert shape == true_shape def test_make_cutout(self): props = source_properties(IMAGE, SEGM) data = np.ones((2, 2)) with pytest.raises(ValueError): props[0].make_cutout(data) @pytest.mark.parametrize(('error_value', 'effective_gain', 'background'), list(itertools.product( ERR_VALS, EFFGAIN_VALS, BACKGRD_VALS))) def test_segmentation_inputs(self, error_value, effective_gain, background): error = np.ones_like(IMAGE) * error_value props = source_properties(IMAGE, SEGM, error=error, effective_gain=effective_gain, background=background) assert_quantity_allclose(props[0].xcentroid, XCEN*u.pix, rtol=1.e-2) assert_quantity_allclose(props[0].ycentroid, YCEN*u.pix, rtol=1.e-2) assert_quantity_allclose(props[0].semimajor_axis_sigma, MAJOR_SIG*u.pix, rtol=1.e-2) assert_quantity_allclose(props[0].semiminor_axis_sigma, MINOR_SIG*u.pix, rtol=1.e-2) assert_quantity_allclose(props[0].orientation, THETA*u.rad, rtol=1.e-3) assert_allclose(props[0].bbox.value, [35, 25, 70, 77]) area = props[0].area.value assert_allclose(area, 1058.0) if background is not None: assert_allclose(props[0].background_sum, area * background) true_sum = IMAGE[IMAGE >= THRESHOLD].sum() assert_allclose(props[0].source_sum, true_sum) true_error = np.sqrt(props[0].area.value) * error_value if effective_gain is not None: true_error = np.sqrt( (props[0].source_sum / effective_gain) + true_error**2) assert_allclose(props[0].source_sum_err, true_error) def test_data_allzero(self): props = source_properties(IMAGE*0., SEGM) proplist = ['xcentroid', 'ycentroid', 'semimajor_axis_sigma', 'semiminor_axis_sigma', 'eccentricity', 'orientation', 'ellipticity', 'elongation', 'cxx', 'cxy', 'cyy'] for prop in proplist: assert np.isnan(getattr(props[0], prop)) def test_mask(self): data = np.zeros((3, 3)) data[0, 1] = 1. data[1, 1] = 1. mask = np.zeros_like(data, dtype=np.bool) mask[0, 1] = True segm = data.astype(np.int) props = source_properties(data, segm, mask=mask) assert_allclose(props[0].xcentroid.value, 1) assert_allclose(props[0].ycentroid.value, 1) assert_allclose(props[0].source_sum, 1) assert_allclose(props[0].area.value, 1) def test_effective_gain_negative(self, effective_gain=-1): error = np.ones_like(IMAGE) * 2. with pytest.raises(ValueError): source_properties(IMAGE, SEGM, error=error, effective_gain=effective_gain) def test_single_pixel_segment(self): segm = np.zeros_like(SEGM) segm[50, 50] = 1 props = source_properties(IMAGE, segm) assert props[0].eccentricity == 0 def test_filtering(self): from astropy.convolution import Gaussian2DKernel FWHM2SIGMA = 1.0 / (2.0 * np.sqrt(2.0 * np.log(2.0))) filter_kernel = Gaussian2DKernel(2.*FWHM2SIGMA, x_size=3, y_size=3) error = np.sqrt(IMAGE) props1 = source_properties(IMAGE, SEGM, error=error) props2 = source_properties(IMAGE, SEGM, error=error, filter_kernel=filter_kernel.array) p1, p2 = props1[0], props2[0] keys = ['source_sum', 'source_sum_err'] for key in keys: assert p1[key] == p2[key] keys = ['semimajor_axis_sigma', 'semiminor_axis_sigma'] for key in keys: assert p1[key] != p2[key] def test_filtering_kernel(self): data = np.zeros((3, 3)) data[1, 1] = 1. from astropy.convolution import Gaussian2DKernel FWHM2SIGMA = 1.0 / (2.0 * np.sqrt(2.0 * np.log(2.0))) filter_kernel = Gaussian2DKernel(2.*FWHM2SIGMA, x_size=3, y_size=3) error = np.sqrt(IMAGE) props1 = source_properties(IMAGE, SEGM, error=error) props2 = source_properties(IMAGE, SEGM, error=error, filter_kernel=filter_kernel) p1, p2 = props1[0], props2[0] keys = ['source_sum', 'source_sum_err'] for key in keys: assert p1[key] == p2[key] keys = ['semimajor_axis_sigma', 'semiminor_axis_sigma'] for key in keys: assert p1[key] != p2[key] @pytest.mark.skipif('not HAS_SKIMAGE') @pytest.mark.skipif('not HAS_SCIPY') class TestPropertiesTable(object): def test_properties_table(self): props = source_properties(IMAGE, SEGM) t = properties_table(props) assert isinstance(t, Table) assert len(t) == 1 def test_properties_table_include(self): props = source_properties(IMAGE, SEGM) columns = ['id', 'xcentroid'] t = properties_table(props, columns=columns) assert isinstance(t, Table) assert len(t) == 1 assert t.colnames == columns def test_properties_table_include_invalidname(self): props = source_properties(IMAGE, SEGM) columns = ['idzz', 'xcentroidzz'] with pytest.raises(AttributeError): properties_table(props, columns=columns) def test_properties_table_exclude(self): props = source_properties(IMAGE, SEGM) exclude = ['id', 'xcentroid'] t = properties_table(props, exclude_columns=exclude) assert isinstance(t, Table) assert len(t) == 1 with pytest.raises(KeyError): t['id'] def test_properties_table_empty_props(self): props = source_properties(IMAGE, SEGM, labels=-1) with pytest.raises(ValueError): properties_table(props) def test_properties_table_empty_list(self): with pytest.raises(ValueError): properties_table([]) def test_properties_table_wcs(self): mywcs = WCS.WCS(naxis=2) rho = np.pi / 3. scale = 0.1 / 3600. mywcs.wcs.cd = [[scale*np.cos(rho), -scale*np.sin(rho)], [scale*np.sin(rho), scale*np.cos(rho)]] mywcs.wcs.ctype = ['RA---TAN', 'DEC--TAN'] props = source_properties(IMAGE, SEGM, wcs=mywcs) columns = ['icrs_centroid', 'ra_icrs_centroid', 'dec_icrs_centroid'] t = properties_table(props, columns=columns) assert t[0]['icrs_centroid'] is not None assert t[0]['ra_icrs_centroid'] is not None assert t[0]['dec_icrs_centroid'] is not None photutils-0.2.1/photutils/utils/0000700000214200020070000000000012646264032021116 5ustar lbradleySTSCI\science00000000000000photutils-0.2.1/photutils/utils/__init__.py0000600000214200020070000000033712632337152023233 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst """ General-purpose utility functions. """ from .check_random_state import * from .colormaps import * from .interpolation import * from .prepare_data import * photutils-0.2.1/photutils/utils/check_random_state.py0000600000214200020070000000264012460257762025317 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst """ This subpackage contains developer-oriented utilities. """ from __future__ import (absolute_import, division, print_function, unicode_literals) import numpy as np import numbers __all__ = ['check_random_state'] def check_random_state(seed): """ Turn seed into a `numpy.random.RandomState` instance. Parameters ---------- seed : `None`, int, or `numpy.random.RandomState` If ``seed`` is `None`, return the `~numpy.random.RandomState` singleton used by ``numpy.random``. If ``seed`` is an `int`, return a new `~numpy.random.RandomState` instance seeded with ``seed``. If ``seed`` is already a `~numpy.random.RandomState`, return it. Otherwise raise ``ValueError``. Returns ------- random_state : `numpy.random.RandomState` RandomState object. Notes ----- This routine is from scikit-learn. See http://scikit-learn.org/stable/developers/utilities.html#validation-tools. """ if seed is None or seed is np.random: return np.random.mtrand._rand if isinstance(seed, (numbers.Integral, np.integer)): return np.random.RandomState(seed) if isinstance(seed, np.random.RandomState): return seed raise ValueError('%r cannot be used to seed a numpy.random.RandomState' ' instance' % seed) photutils-0.2.1/photutils/utils/colormaps.py0000600000214200020070000000364412634600603023473 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst from __future__ import (absolute_import, division, print_function, unicode_literals) import numpy as np from .check_random_state import check_random_state __all__ = ['random_cmap'] def random_cmap(ncolors=256, background_color='black', random_state=None): """ Generate a matplotlib colormap consisting of random (muted) colors. A random colormap is very useful for plotting segmentation images. Parameters ---------- ncolors : int, optional The number of colors in the colormap. For use with segmentation images, ``ncolors`` should be set to the number of labels. The default is 256. background_color : str, optional The name of the background (first) color in the colormap. Valid colors names are defined by ``matplotlib.colors.cnames``. The default is ``'black'``. random_state : int or `~numpy.random.RandomState`, optional The pseudo-random number generator state used for random sampling. Separate function calls with the same ``random_state`` will generate the same colormap. Returns ------- cmap : `matplotlib.colors.Colormap` The matplotlib colormap with random colors. """ from matplotlib import colors prng = check_random_state(random_state) h = prng.uniform(low=0.0, high=1.0, size=ncolors) s = prng.uniform(low=0.2, high=0.7, size=ncolors) v = prng.uniform(low=0.5, high=1.0, size=ncolors) hsv = np.dstack((h, s, v)) rgb = np.squeeze(colors.hsv_to_rgb(hsv)) if background_color is not None: if background_color not in colors.cnames: raise ValueError('"{0}" is not a valid background color ' 'name'.format(background_color)) rgb[0] = colors.hex2color(colors.cnames[background_color]) return colors.ListedColormap(rgb) photutils-0.2.1/photutils/utils/convolution.py0000600000214200020070000000415612634600603024052 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst from __future__ import (absolute_import, division, print_function, unicode_literals) import numpy as np import warnings from astropy.convolution import Kernel2D from astropy.utils.exceptions import AstropyUserWarning def _convolve_data(data, kernel, mode='constant', fill_value=0.0, check_normalization=False): """ Convolve a 2D image with a 2D kernel. The kernel may either be a 2D `~numpy.ndarray` or a `~astropy.convolution.Kernel2D` object. Parameters ---------- data : array_like The 2D array of the image. kernel : array-like (2D) or `~astropy.convolution.Kernel2D` The 2D kernel used to filter the input ``data``. Filtering the ``data`` will smooth the noise and maximize detectability of objects with a shape similar to the kernel. mode : {'constant', 'reflect', 'nearest', 'mirror', 'wrap'}, optional The ``mode`` determines how the array borders are handled. For the ``'constant'`` mode, values outside the array borders are set to ``fill_value``. The default is ``'constant'``. fill_value : scalar, optional Value to fill data values beyond the array borders if ``mode`` is ``'constant'``. The default is ``0.0``. check_normalization : bool, optional If `True` then a warning will be issued if the kernel is not normalized to 1. """ from scipy import ndimage if kernel is not None: if isinstance(kernel, Kernel2D): kernel_array = kernel.array else: kernel_array = kernel if check_normalization: if not np.allclose(np.sum(kernel_array), 1.0): warnings.warn('The kernel is not normalized.', AstropyUserWarning) # NOTE: astropy.convolution.convolve fails with zero-sum # kernels (used in findstars) (cf. astropy #1647) return ndimage.convolve(data, kernel_array, mode=mode, cval=fill_value) else: return data photutils-0.2.1/photutils/utils/interpolation.py0000600000214200020070000004141412641253247024366 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst from __future__ import (absolute_import, division, print_function, unicode_literals) import numpy as np import warnings from astropy.utils.exceptions import AstropyUserWarning __all__ = ['ShepardIDWInterpolator', 'interpolate_masked_data', 'mask_to_mirrored_num'] __doctest_requires__ = {('ShepardIDWInterpolator'): ['scipy']} class ShepardIDWInterpolator(object): """ Class to perform Inverse Distance Weighted (IDW) interpolation. This interpolator uses a modified version of `Shepard's method `_ (see the Notes section for details). Parameters ---------- coordinates : float, 1D array-like, or NxM-array-like Coordinates of the known data points. In general, it is expected that these coordinates are in a form of a NxM-like array where N is the number of points and M is dimension of the coordinate space. When M=1 (1D space), then the ``coordinates`` parameter may be entered as a 1D array or, if only one data point is available, ``coordinates`` can be a scalar number representing the 1D coordinate of the data point. .. note:: If the dimensionality of ``coordinates`` is larger than 2, e.g., if it is of the form N1 x N2 x N3 x ... x Nn x M, then it will be flattened to form an array of size NxM where N = N1 * N2 * ... * Nn. values : float or 1D array-like Values of the data points corresponding to each coordinate provided in ``coordinates``. In general a 1D array is expected. When a single data point is available, then ``values`` can be a scalar number. .. note:: If the dimensionality of ``values`` is larger than 1 then it will be flattened. weights : float or 1D array-like, optional Weights to be associated with each data value. These weights, if provided, will be combined with inverse distance weights (see the Notes section for details). When ``weights`` is `None` (default), then only inverse distance weights will be used. When provided, this input parameter must have the same form as ``values``. leafsize : float, optional The number of points at which the k-d tree algorithm switches over to brute-force. ``leafsize`` must be positive. See `scipy.spatial.cKDTree` for further information. Notes ----- This interpolator uses a slightly modified version of `Shepard's method `_. The essential difference is the introduction of a "regularization" parameter (``reg``) that is used when computing the inverse distance weights: .. math:: w_i = 1 / (d(x, x_i)^{power} + r) By supplying a positive regularization parameter one can avoid singularities at the locations of the data points as well as control the "smoothness" of the interpolation (e.g., make the weights of the neighbors less varied). The "smoothness" of interpolation can also be controlled by the power parameter (``power``). Examples -------- This class can can be instantiated using the following syntax:: >>> from photutils.utils import ShepardIDWInterpolator as idw Example of interpolating 1D data:: >>> import numpy as np >>> np.random.seed(123) >>> x = np.random.random(100) >>> y = np.sin(x) >>> f = idw(x, y) >>> f(0.4) # doctest: +FLOAT_CMP 0.38862424043228855 >>> np.sin(0.4) # doctest: +FLOAT_CMP 0.38941834230865052 >>> xi = np.random.random(4) >>> xi array([ 0.51312815, 0.66662455, 0.10590849, 0.13089495]) >>> f(xi) # doctest: +FLOAT_CMP array([ 0.49086423, 0.62647862, 0.1056854 , 0.13048335]) >>> np.sin(xi) array([ 0.49090493, 0.6183367 , 0.10571061, 0.13052149]) NOTE: In the last example, ``xi`` may be a ``Nx1`` array instead of a 1D vector. Example of interpolating 2D data:: >>> pos = np.random.rand(1000, 2) >>> val = np.sin(pos[:, 0] + pos[:, 1]) >>> f = idw(pos, val) >>> f([0.5, 0.6]) # doctest: +FLOAT_CMP 0.89312649587405657 >>> np.sin(0.5 + 0.6) 0.89120736006143542 """ def __init__(self, coordinates, values, weights=None, leafsize=10): from scipy.spatial import cKDTree coordinates = np.atleast_2d(coordinates) if coordinates.shape[0] == 1: coordinates = np.transpose(coordinates) if coordinates.ndim != 2: coordinates = np.reshape(coordinates, (-1, coordinates.shape[-1])) values = np.asanyarray(values).ravel() ncoords = coordinates.shape[0] if ncoords < 1: raise ValueError('You must enter at least one data point.') if values.shape[0] != ncoords: raise ValueError('The number of values must match the number ' 'of coordinates.') if weights is not None: weights = np.asanyarray(weights).ravel() if weights.shape[0] != ncoords: raise ValueError('The number of weights must match the ' 'number of coordinates.') if np.any(weights < 0.0): raise ValueError('All weight values must be non-negative ' 'numbers.') self.coordinates = coordinates self.ncoords = ncoords self.coords_ndim = coordinates.shape[1] self.values = values self.weights = weights self.kdtree = cKDTree(coordinates, leafsize=leafsize) def __call__(self, positions, n_neighbors=8, eps=0.0, power=1.0, reg=0.0, conf_dist=1e-12, dtype=np.float): """ Evaluate the interpolator at the given positions. Parameters ---------- positions : float, 1D array-like, or NxM-array-like Coordinates of the position(s) at which the interpolator should be evaluated. In general, it is expected that these coordinates are in a form of a NxM-like array where N is the number of points and M is dimension of the coordinate space. When M=1 (1D space), then the ``positions`` parameter may be input as a 1D-like array or, if only one data point is available, ``positions`` can be a scalar number representing the 1D coordinate of the data point. .. note:: If the dimensionality of the ``positions`` argument is larger than 2, e.g., if it is of the form N1 x N2 x N3 x ... x Nn x M, then it will be flattened to form an array of size NxM where N = N1 * N2 * ... * Nn. .. warning:: The dimensionality of ``positions`` must match the dimensionality of the ``coordinates`` used during the initialization of the interpolator. n_neighbors : int, optional The maximum number of nearest neighbors to use during the interpolation. eps : float, optional Set to use approximate nearest neighbors; the kth neighbor is guaranteed to be no further than (1 + ``eps``) times the distance to the real *k*-th nearest neighbor. See `scipy.spatial.cKDTree.query` for further information. power : float, optional The power of the inverse distance used for the interpolation weights. See the Notes section for more details. reg : float, optional The regularization parameter. It may be used to control the smoothness of the interpolator. See the Notes section for more details. conf_dist : float, optional The confusion distance below which the interpolator should use the value of the closest data point instead of attempting to interpolate. This is used to avoid singularities at the known data points, especially if ``reg`` is 0.0. dtype : data-type The data type of the output interpolated values. If `None` then the type will be inferred from the type of the ``values`` parameter used during the initialization of the interpolator. """ n_neighbors = int(n_neighbors) if n_neighbors < 1: raise ValueError('n_neighbors must be a positive integer') if conf_dist is not None and conf_dist <= 0.0: conf_dist = None positions = np.asanyarray(positions) if positions.ndim == 0: # assume we have a single 1D coordinate if self.coords_ndim != 1: raise ValueError('The dimensionality of the input position ' 'does not match the dimensionality of the ' 'coordinates used to initialize the ' 'interpolator.') elif positions.ndim == 1: # assume we have a single point if (self.coords_ndim != 1 and (positions.shape[-1] != self.coords_ndim)): raise ValueError('The input position was provided as a 1D ' 'array, but its length does not match the ' 'dimensionality of the coordinates used ' 'to initialize the interpolator.') elif positions.ndim != 2: raise ValueError('The input positions must be an array-like ' 'object of dimensionality no larger than 2.') positions = np.reshape(positions, (-1, self.coords_ndim)) npositions = positions.shape[0] distances, idx = self.kdtree.query(positions, k=n_neighbors, eps=eps) if n_neighbors == 1: return self.values[idx] if dtype is None: dtype = self.values.dtype interp_values = np.zeros(npositions, dtype=dtype) for k in range(npositions): valid_idx = np.isfinite(distances[k]) idk = idx[k][valid_idx] dk = distances[k][valid_idx] if dk.shape[0] == 0: interp_values[k] = np.nan continue if conf_dist is not None: # check if we are close to a known data point confused = (dk <= conf_dist) if np.any(confused): interp_values[k] = self.values[idk[confused][0]] continue w = 1.0 / ((dk ** power) + reg) if self.weights is not None: w *= self.weights[idk] wtot = np.sum(w) if wtot > 0.0: interp_values[k] = np.dot(w, self.values[idk]) / wtot else: interp_values[k] = np.nan if len(interp_values) == 1: return interp_values[0] else: return interp_values def interpolate_masked_data(data, mask, error=None, background=None): """ Interpolate over masked pixels in data and optional error or background images. The value of masked pixels are replaced by the mean value of the connected neighboring non-masked pixels. This function is intended for single, isolated masked pixels (e.g. hot/warm pixels). Parameters ---------- data : array_like or `~astropy.units.Quantity` The data array. mask : array_like (bool) A boolean mask, with the same shape as ``data``, where a `True` value indicates the corresponding element of ``data`` is masked. error : array_like or `~astropy.units.Quantity`, optional The pixel-wise Gaussian 1-sigma errors of the input ``data``. ``error`` must have the same shape as ``data``. background : array_like, or `~astropy.units.Quantity`, optional The pixel-wise background level of the input ``data``. ``background`` must have the same shape as ``data``. Returns ------- data : `~numpy.ndarray` or `~astropy.units.Quantity` Input ``data`` with interpolated masked pixels. error : `~numpy.ndarray` or `~astropy.units.Quantity` Input ``error`` with interpolated masked pixels. `None` if input ``error`` is not input. background : `~numpy.ndarray` or `~astropy.units.Quantity` Input ``background`` with interpolated masked pixels. `None` if input ``background`` is not input. """ if data.shape != mask.shape: raise ValueError('data and mask must have the same shape') data_out = np.copy(data) # do not alter input data mask_idx = mask.nonzero() if mask_idx[0].size == 0: raise ValueError('All items in data are masked') for x in zip(*mask_idx): X = np.array([[max(x[i] - 1, 0), min(x[i] + 1, data.shape[i] - 1)] for i in range(len(data.shape))]) goodpix = ~mask[X] if not np.any(goodpix): warnings.warn('The masked pixel at "{}" is completely ' 'surrounded by (connected) masked pixels, ' 'thus unable to interpolate'.format(x,), AstropyUserWarning) continue data_out[x] = np.mean(data[X][goodpix]) if background is not None: if background.shape != data.shape: raise ValueError('background and data must have the same ' 'shape') background_out = np.copy(background) background_out[x] = np.mean(background[X][goodpix]) else: background_out = None if error is not None: if error.shape != data.shape: raise ValueError('error and data must have the same ' 'shape') error_out = np.copy(error) error_out[x] = np.sqrt(np.mean(error[X][goodpix]**2)) else: error_out = None return data_out, error_out, background_out def mask_to_mirrored_num(image, mask_image, center_position, bbox=None): """ Replace masked pixels with the value of the pixel mirrored across a given ``center_position``. If the mirror pixel is unavailable (i.e. itself masked or outside of the image), then the masked pixel value is set to zero. Parameters ---------- image : `numpy.ndarray`, 2D The 2D array of the image. mask_image : array-like, bool A boolean mask with the same shape as ``image``, where a `True` value indicates the corresponding element of ``image`` is considered bad. center_position : 2-tuple (x, y) center coordinates around which masked pixels will be mirrored. bbox : list, tuple, `numpy.ndarray`, optional The bounding box (x_min, x_max, y_min, y_max) over which to replace masked pixels. Returns ------- result : `numpy.ndarray`, 2D A 2D array with replaced masked pixels. Examples -------- >>> import numpy as np >>> from photutils.utils import mask_to_mirrored_num >>> image = np.arange(16).reshape(4, 4) >>> mask = np.zeros_like(image, dtype=bool) >>> mask[0, 0] = True >>> mask[1, 1] = True >>> mask_to_mirrored_num(image, mask, (1.5, 1.5)) array([[15, 1, 2, 3], [ 4, 10, 6, 7], [ 8, 9, 10, 11], [12, 13, 14, 15]]) """ if bbox is None: ny, nx = image.shape bbox = [0, nx, 0, ny] subdata = np.copy(image[bbox[2]:bbox[3]+1, bbox[0]:bbox[1]+1]) submask = mask_image[bbox[2]:bbox[3]+1, bbox[0]:bbox[1]+1] y_masked, x_masked = np.nonzero(submask) x_mirror = (2 * (center_position[0] - bbox[0]) - x_masked + 0.5).astype('int32') y_mirror = (2 * (center_position[1] - bbox[2]) - y_masked + 0.5).astype('int32') # Reset mirrored pixels that go out of the image. outofimage = ((x_mirror < 0) | (y_mirror < 0) | (x_mirror >= subdata.shape[1]) | (y_mirror >= subdata.shape[0])) if outofimage.any(): x_mirror[outofimage] = x_masked[outofimage].astype('int32') y_mirror[outofimage] = y_masked[outofimage].astype('int32') subdata[y_masked, x_masked] = subdata[y_mirror, x_mirror] # Set pixels that mirrored to another masked pixel to zero. # This will also set to zero any pixels that mirrored out of # the image. mirror_is_masked = submask[y_mirror, x_mirror] x_bad = x_masked[mirror_is_masked] y_bad = y_masked[mirror_is_masked] subdata[y_bad, x_bad] = 0.0 outimage = np.copy(image) outimage[bbox[2]:bbox[3]+1, bbox[0]:bbox[1]+1] = subdata return outimage photutils-0.2.1/photutils/utils/prepare_data.py0000600000214200020070000001247212633635542024133 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst from __future__ import (absolute_import, division, print_function, unicode_literals) import numpy as np import astropy.units as u from astropy.utils.misc import isiterable __all__ = ['calculate_total_error'] def calculate_total_error(data, error, effective_gain): """ Calculate a total error array, combining a background error array with the Poisson noise of sources. Parameters ---------- data : array_like or `~astropy.units.Quantity` The (background-subtracted) data array. error : array_like or `~astropy.units.Quantity` The pixel-wise Gaussian 1-sigma background errors of the input ``data``. ``error`` should include all sources of "background" error but *exclude* the Poisson error of the sources. ``error`` must have the same shape as ``data``. effective_gain : float, array-like, or `~astropy.units.Quantity` Ratio of counts (e.g., electrons or photons) to the units of ``data`` used to calculate the Poisson error of the sources. Returns ------- total_error : `~numpy.ndarray` or `~astropy.units.Quantity` Total error. Notes ----- The total error array, :math:`\sigma_{\mathrm{tot}}` is: .. math:: \\sigma_{\\mathrm{tot}} = \\sqrt{\\sigma_{\\mathrm{b}}^2 + \\frac{I}{g}} where :math:`\sigma_b`, :math:`I`, and :math:`g` are the background ``error`` image, (background-subtracted) ``data`` image, and ``effective_gain``, respectively. ``data`` here should be background-subtracted to match SExtractor. """ data = np.asanyarray(data) error = np.asanyarray(error) has_unit = [hasattr(x, 'unit') for x in [data, effective_gain]] if any(has_unit) and not all(has_unit): raise ValueError('If either data or effective_gain has units, then ' 'they both must have units.') if all(has_unit): count_units = [u.electron, u.photon] datagain_unit = (data * effective_gain).unit if datagain_unit not in count_units: raise u.UnitsError('(data * effective_gain) has units of "{0}", ' 'but it must have count units (u.electron ' 'or u.photon).'.format(datagain_unit)) if not isiterable(effective_gain): effective_gain = np.zeros(data.shape) + effective_gain else: effective_gain = np.asanyarray(effective_gain) if effective_gain.shape != data.shape: raise ValueError('If input effective_gain is 2D, then it must ' 'have the same shape as the input data.') if np.any(effective_gain <= 0): raise ValueError('effective_gain must be strictly positive ' 'everywhere') if all(has_unit): source_variance = np.maximum((data * data.unit) / effective_gain.value, 0. * error.unit**2) variance_total = error**2 + source_variance else: source_variance = np.maximum(data / effective_gain, 0) variance_total = error**2 + source_variance return np.sqrt(variance_total) def _check_units(inputs): """Check for consistent units on data, error, and background.""" has_unit = [hasattr(x, 'unit') for x in inputs] if any(has_unit) and not all(has_unit): raise ValueError('If any of data, error, or background has units, ' 'then they all must all have units.') if all(has_unit): if any([inputs[0].unit != getattr(x, 'unit') for x in inputs[1:]]): raise u.UnitsError( 'data, error, and background units do not match.') def _prepare_data(data, error=None, effective_gain=None, background=None): """ Prepare the data, error, and background arrays. If any of ``data``, ``error``, and ``background`` have units, then they all are checked that they have units and the units are the same. If ``effective_gain`` is input, then the total error array including source Poisson noise is calculated. If ``background`` is input, then it is returned as a 2D array with the same shape as ``data`` (if necessary). It is *not* subtracted from the input ``data``. Notes ----- ``data``, ``error``, and ``background`` must all have the same units if they are `~astropy.units.Quantity`\s. If ``effective_gain`` is a `~astropy.units.Quantity`, then it must have units such that ``effective_gain * data`` is in units of counts (e.g. counts, electrons, or photons). """ inputs = [data, error, background] _check_units(inputs) # generate a 2D background array, if necessary if background is not None: if not isiterable(background): background = np.zeros(data.shape) + background else: if background.shape != data.shape: raise ValueError('If input background is 2D, then it must ' 'have the same shape as the input data.') if error is not None: if data.shape != error.shape: raise ValueError('data and error must have the same shape') if effective_gain is not None: error = calculate_total_error(data, error, effective_gain) return data, error, background photutils-0.2.1/photutils/utils/tests/0000700000214200020070000000000012646264032022260 5ustar lbradleySTSCI\science00000000000000photutils-0.2.1/photutils/utils/tests/__init__.py0000600000214200020070000000000012412546122024353 0ustar lbradleySTSCI\science00000000000000photutils-0.2.1/photutils/utils/tests/test_colormaps.py0000600000214200020070000000155512634600424025674 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst from __future__ import (absolute_import, division, print_function, unicode_literals) from astropy.tests.helper import pytest from ..colormaps import random_cmap try: import matplotlib HAS_MATPLOTLIB = True except ImportError: HAS_MATPLOTLIB = False @pytest.mark.skipif('not HAS_MATPLOTLIB') def test_colormap(): cmap = random_cmap(100, random_state=12345) assert cmap(0) == (0., 0., 0., 1.0) @pytest.mark.skipif('not HAS_MATPLOTLIB') def test_colormap_background(): cmap = random_cmap(100, background_color='white', random_state=12345) assert cmap(0) == (1., 1., 1., 1.0) @pytest.mark.skipif('not HAS_MATPLOTLIB') def test_invalid_background(): with pytest.raises(ValueError): random_cmap(100, background_color='invalid', random_state=12345) photutils-0.2.1/photutils/utils/tests/test_interpolation.py0000600000214200020070000001547212634600603026566 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst from __future__ import (absolute_import, division, print_function, unicode_literals) import numpy as np from numpy.testing import assert_allclose from astropy.tests.helper import pytest from .. import ShepardIDWInterpolator as idw from .. import interpolate_masked_data, mask_to_mirrored_num try: import scipy HAS_SCIPY = True except ImportError: HAS_SCIPY = False SHAPE = (5, 5) DATA = np.ones(SHAPE) * 2.0 MASK = np.zeros_like(DATA, dtype=bool) MASK[2, 2] = True ERROR = np.ones(SHAPE) BACKGROUND = np.ones(SHAPE) WRONG_SHAPE = np.ones((2, 2)) @pytest.mark.skipif('not HAS_SCIPY') class TestShepardIDWInterpolator(object): def setup_class(self): np.random.seed(123) self.x = np.random.random(100) self.y = np.sin(self.x) self.f = idw(self.x, self.y) @pytest.mark.parametrize('positions', [0.4, np.arange(2, 5)*0.1]) def test_idw_1d(self, positions): f = idw(self.x, self.y) assert_allclose(f(positions), np.sin(positions), atol=1e-2) def test_idw_weights(self): weights = self.y * 0.1 f = idw(self.x, self.y, weights=weights) pos = 0.4 assert_allclose(f(pos), np.sin(pos), atol=1e-2) def test_idw_2d(self): pos = np.random.rand(1000, 2) val = np.sin(pos[:, 0] + pos[:, 1]) f = idw(pos, val) x = 0.5 y = 0.6 assert_allclose(f([x, y]), np.sin(x + y), atol=1e-2) def test_idw_3d(self): val = np.ones((3, 3, 3)) pos = np.indices(val.shape) f = idw(pos, val) assert_allclose(f([0.5, 0.5, 0.5]), 1.0) def test_no_coordinates(self): with pytest.raises(ValueError): idw([], 0) def test_values_invalid_shape(self): with pytest.raises(ValueError): idw(self.x, 0) def test_weights_invalid_shape(self): with pytest.raises(ValueError): idw(self.x, self.y, weights=10) def test_weights_negative(self): with pytest.raises(ValueError): idw(self.x, self.y, weights=-self.y) def test_n_neighbors_one(self): assert_allclose(self.f(0.5, n_neighbors=1), 0.48103656) def test_n_neighbors_negative(self): with pytest.raises(ValueError): self.f(0.5, n_neighbors=-1) def test_conf_dist_negative(self): assert_allclose(self.f(0.5, conf_dist=-1), self.f(0.5, conf_dist=None)) def test_dtype_none(self): result = self.f(0.5, dtype=None) assert result.dtype.type == np.float64 def test_positions_0d_nomatch(self): """test when position ndim doesn't match coordinates ndim""" pos = np.random.rand(10, 2) val = np.sin(pos[:, 0] + pos[:, 1]) f = idw(pos, val) with pytest.raises(ValueError): f(0.5) def test_positions_1d_nomatch(self): """test when position ndim doesn't match coordinates ndim""" pos = np.random.rand(10, 2) val = np.sin(pos[:, 0] + pos[:, 1]) f = idw(pos, val) with pytest.raises(ValueError): f([0.5]) def test_positions_3d(self): with pytest.raises(ValueError): self.f(np.ones((3, 3, 3))) class TestInterpolateMaskedData(object): def test_mask_shape(self): with pytest.raises(ValueError): interpolate_masked_data(DATA, WRONG_SHAPE) def test_error_shape(self): with pytest.raises(ValueError): interpolate_masked_data(DATA, MASK, error=WRONG_SHAPE) def test_background_shape(self): with pytest.raises(ValueError): interpolate_masked_data(DATA, MASK, background=WRONG_SHAPE) def test_interpolation(self): data2 = DATA.copy() data2[2, 2] = 100. error2 = ERROR.copy() error2[2, 2] = 100. background2 = BACKGROUND.copy() background2[2, 2] = 100. data, error, background = interpolate_masked_data( data2, MASK, error=error2, background=background2) assert_allclose(data, DATA) assert_allclose(error, ERROR) assert_allclose(background, BACKGROUND) def test_interpolation_larger_mask(self): data2 = DATA.copy() data2[2, 2] = 100. error2 = ERROR.copy() error2[2, 2] = 100. background2 = BACKGROUND.copy() background2[2, 2] = 100. mask2 = MASK.copy() mask2[1:4, 1:4] = True data, error, background = interpolate_masked_data( data2, MASK, error=error2, background=background2) assert_allclose(data, DATA) assert_allclose(error, ERROR) assert_allclose(background, BACKGROUND) class TestMaskToMirroredNum(object): def test_mask_to_mirrored_num(self): """ Test mask_to_mirrored_num. """ center = (1.5, 1.5) data = np.arange(16).reshape(4, 4) mask = np.zeros_like(data, dtype=bool) mask[0, 0] = True mask[1, 1] = True data_ref = data.copy() data_ref[0, 0] = data[3, 3] data_ref[1, 1] = data[2, 2] mirror_data = mask_to_mirrored_num(data, mask, center) assert_allclose(mirror_data, data_ref, rtol=0, atol=1.e-6) def test_mask_to_mirrored_num_range(self): """ Test mask_to_mirrored_num when mirrored pixels are outside of the image. """ center = (2.5, 2.5) data = np.arange(16).reshape(4, 4) mask = np.zeros_like(data, dtype=bool) mask[0, 0] = True mask[1, 1] = True data_ref = data.copy() data_ref[0, 0] = 0. data_ref[1, 1] = 0. mirror_data = mask_to_mirrored_num(data, mask, center) assert_allclose(mirror_data, data_ref, rtol=0, atol=1.e-6) def test_mask_to_mirrored_num_masked(self): """ Test mask_to_mirrored_num when mirrored pixels are also masked. """ center = (0.5, 0.5) data = np.arange(16).reshape(4, 4) data[0, 0] = 100 mask = np.zeros_like(data, dtype=bool) mask[0, 0] = True mask[1, 1] = True data_ref = data.copy() data_ref[0, 0] = 0. data_ref[1, 1] = 0. mirror_data = mask_to_mirrored_num(data, mask, center) assert_allclose(mirror_data, data_ref, rtol=0, atol=1.e-6) def test_mask_to_mirrored_num_bbox(self): """ Test mask_to_mirrored_num with a bounding box. """ center = (1.5, 1.5) data = np.arange(16).reshape(4, 4) data[0, 0] = 100 mask = np.zeros_like(data, dtype=bool) mask[0, 0] = True mask[1, 1] = True data_ref = data.copy() data_ref[1, 1] = data[2, 2] bbox = (1, 2, 1, 2) mirror_data = mask_to_mirrored_num(data, mask, center, bbox=bbox) assert_allclose(mirror_data, data_ref, rtol=0, atol=1.e-6) photutils-0.2.1/photutils/utils/tests/test_prepare_data.py0000600000214200020070000000316412445175423026330 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst from __future__ import (absolute_import, division, print_function, unicode_literals) import numpy as np from numpy.testing import assert_allclose from astropy.tests.helper import pytest from .. import calculate_total_error SHAPE = (5, 5) DATAVAL = 2. DATA = np.ones(SHAPE) * DATAVAL MASK = np.zeros_like(DATA, dtype=bool) MASK[2, 2] = True ERROR = np.ones(SHAPE) EFFGAIN = np.ones(SHAPE) * DATAVAL BACKGROUND = np.ones(SHAPE) WRONG_SHAPE = np.ones((2, 2)) class TestCalculateTotalError(object): def test_error_shape(self): with pytest.raises(ValueError): calculate_total_error(DATA, error=WRONG_SHAPE, effective_gain=EFFGAIN) def test_gain_shape(self): with pytest.raises(ValueError): calculate_total_error(DATA, error=ERROR, effective_gain=WRONG_SHAPE) @pytest.mark.parametrize('effective_gain', (0, -1)) def test_gain_le_zero(self, effective_gain): with pytest.raises(ValueError): calculate_total_error(DATA, error=ERROR, effective_gain=effective_gain) def test_gain_scalar(self): error_tot = calculate_total_error(DATA, error=ERROR, effective_gain=2.) assert_allclose(error_tot, np.sqrt(2.) * ERROR) def test_gain_array(self): error_tot = calculate_total_error(DATA, error=ERROR, effective_gain=EFFGAIN) assert_allclose(error_tot, np.sqrt(2.) * ERROR) photutils-0.2.1/photutils/utils/tests/test_random_state.py0000600000214200020070000000115612413313775026357 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst from __future__ import (absolute_import, division, print_function, unicode_literals) from astropy.tests.helper import pytest import numpy as np from .. import check_random_state @pytest.mark.parametrize('seed', [None, np.random, 1, np.random.RandomState(1)]) def test_seed(seed): assert isinstance(check_random_state(seed), np.random.RandomState) @pytest.mark.parametrize('seed', [1., [1, 2]]) def test_invalid_seed(seed): with pytest.raises(ValueError): check_random_state(seed) photutils-0.2.1/photutils/utils/wcs_helpers.py0000600000214200020070000000764112627615324024023 0ustar lbradleySTSCI\science00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst import numpy as np from astropy import units as u from astropy.coordinates import UnitSphericalRepresentation from astropy.wcs.utils import skycoord_to_pixel, pixel_to_skycoord skycoord_to_pixel_mode = 'all' def skycoord_to_pixel_scale_angle(coords, wcs): """ Convert a set of SkyCoord coordinates into pixel coordinates, pixel scales, and position angles. Parameters ---------- coords : `~astropy.coordinates.SkyCoord` The coordinates to convert wcs : `~astropy.wcs.WCS` The WCS transformation to use Returns ------- x, y : `~numpy.ndarray` The x and y pixel coordinates corresponding to the input coordinates scale : `~astropy.units.Quantity` The pixel scale at each location, in degrees/pixel angle : `~astropy.units.Quantity` The position angle of the celestial coordinate system in pixel space. """ # Convert to pixel coordinates x, y = skycoord_to_pixel(coords, wcs, mode=skycoord_to_pixel_mode) # We take a point directly 'above' (in latitude) the position requested # and convert it to pixel coordinates, then we use that to figure out the # scale and position angle of the coordinate system at the location of # the points. # Find the coordinates as a representation object r_old = coords.represent_as('unitspherical') # Add a a small perturbation in the latitude direction (since longitude # is more difficult because it is not directly an angle). dlat = 1 * u.arcsec r_new = UnitSphericalRepresentation(r_old.lon, r_old.lat + dlat) coords_offset = coords.realize_frame(r_new) # Find pixel coordinates of offset coordinates x_offset, y_offset = skycoord_to_pixel(coords_offset, wcs, mode=skycoord_to_pixel_mode) # Find vector dx = x_offset - x dy = y_offset - y # Find the length of the vector scale = np.hypot(dx, dy) * u.pixel / dlat # Find the position angle angle = np.arctan2(dy, dx) * u.radian return x, y, scale, angle def assert_angle_or_pixel(name, q): """ Check that ``q`` is either an angular or a pixel :class:`~astropy.units.Quantity`. """ if isinstance(q, u.Quantity): if q.unit.physical_type == 'angle' or q.unit is u.pixel: pass else: raise ValueError("{0} should have angular or pixel " "units".format(name)) else: raise TypeError("{0} should be a Quantity instance".format(name)) def assert_angle(name, q): """ Check that ``q`` is an angular :class:`~astropy.units.Quantity`. """ if isinstance(q, u.Quantity): if q.unit.physical_type == 'angle': pass else: raise ValueError("{0} should have angular units".format(name)) else: raise TypeError("{0} should be a Quantity instance".format(name)) def pixel_to_icrs_coords(x, y, wcs): """ Convert pixel coordinates to ICRS Right Ascension and Declination. This is merely a convenience function to extract RA and Dec. from a `~astropy.coordinates.SkyCoord` instance so they can be put in separate columns in a `~astropy.table.Table`. Parameters ---------- x : float or array-like The x pixel coordinate. y : float or array-like The y pixel coordinate. wcs : `~astropy.wcs.WCS` The WCS transformation to use to convert from pixel coordinates to ICRS world coordinates. `~astropy.table.Table`. Returns ------- ra : `~astropy.units.Quantity` The ICRS Right Ascension in degrees. dec : `~astropy.units.Quantity` The ICRS Declination in degrees. """ icrs_coords = pixel_to_skycoord(x, y, wcs, origin=1).icrs icrs_ra = icrs_coords.ra.degree * u.deg icrs_dec = icrs_coords.dec.degree * u.deg return icrs_ra, icrs_dec photutils-0.2.1/photutils/version.py0000600000214200020070000001546112646264021022024 0ustar lbradleySTSCI\science00000000000000# Autogenerated by Astropy-affiliated package photutils's setup.py on 2016-01-15 16:43:45.994418 from __future__ import unicode_literals import datetime import locale import os import subprocess import warnings def _decode_stdio(stream): try: stdio_encoding = locale.getdefaultlocale()[1] or 'utf-8' except ValueError: stdio_encoding = 'utf-8' try: text = stream.decode(stdio_encoding) except UnicodeDecodeError: # Final fallback text = stream.decode('latin1') return text def update_git_devstr(version, path=None): """ Updates the git revision string if and only if the path is being imported directly from a git working copy. This ensures that the revision number in the version string is accurate. """ try: # Quick way to determine if we're in git or not - returns '' if not devstr = get_git_devstr(sha=True, show_warning=False, path=path) except OSError: return version if not devstr: # Probably not in git so just pass silently return version if 'dev' in version: # update to the current git revision version_base = version.split('.dev', 1)[0] devstr = get_git_devstr(sha=False, show_warning=False, path=path) return version_base + '.dev' + devstr else: #otherwise it's already the true/release version return version def get_git_devstr(sha=False, show_warning=True, path=None): """ Determines the number of revisions in this repository. Parameters ---------- sha : bool If True, the full SHA1 hash will be returned. Otherwise, the total count of commits in the repository will be used as a "revision number". show_warning : bool If True, issue a warning if git returns an error code, otherwise errors pass silently. path : str or None If a string, specifies the directory to look in to find the git repository. If `None`, the current working directory is used, and must be the root of the git repository. If given a filename it uses the directory containing that file. Returns ------- devversion : str Either a string with the revision number (if `sha` is False), the SHA1 hash of the current commit (if `sha` is True), or an empty string if git version info could not be identified. """ if path is None: path = os.getcwd() if not _get_repo_path(path, levels=0): return '' if not os.path.isdir(path): path = os.path.abspath(os.path.dirname(path)) if sha: # Faster for getting just the hash of HEAD cmd = ['rev-parse', 'HEAD'] else: cmd = ['rev-list', '--count', 'HEAD'] def run_git(cmd): try: p = subprocess.Popen(['git'] + cmd, cwd=path, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE) stdout, stderr = p.communicate() except OSError as e: if show_warning: warnings.warn('Error running git: ' + str(e)) return (None, b'', b'') if p.returncode == 128: if show_warning: warnings.warn('No git repository present at {0!r}! Using ' 'default dev version.'.format(path)) return (p.returncode, b'', b'') if p.returncode == 129: if show_warning: warnings.warn('Your git looks old (does it support {0}?); ' 'consider upgrading to v1.7.2 or ' 'later.'.format(cmd[0])) return (p.returncode, stdout, stderr) elif p.returncode != 0: if show_warning: warnings.warn('Git failed while determining revision ' 'count: {0}'.format(_decode_stdio(stderr))) return (p.returncode, stdout, stderr) return p.returncode, stdout, stderr returncode, stdout, stderr = run_git(cmd) if not sha and returncode == 129: # git returns 129 if a command option failed to parse; in # particular this could happen in git versions older than 1.7.2 # where the --count option is not supported # Also use --abbrev-commit and --abbrev=0 to display the minimum # number of characters needed per-commit (rather than the full hash) cmd = ['rev-list', '--abbrev-commit', '--abbrev=0', 'HEAD'] returncode, stdout, stderr = run_git(cmd) # Fall back on the old method of getting all revisions and counting # the lines if returncode == 0: return str(stdout.count(b'\n')) else: return '' elif sha: return _decode_stdio(stdout)[:40] else: return _decode_stdio(stdout).strip() def _get_repo_path(pathname, levels=None): """ Given a file or directory name, determine the root of the git repository this path is under. If given, this won't look any higher than ``levels`` (that is, if ``levels=0`` then the given path must be the root of the git repository and is returned if so. Returns `None` if the given path could not be determined to belong to a git repo. """ if os.path.isfile(pathname): current_dir = os.path.abspath(os.path.dirname(pathname)) elif os.path.isdir(pathname): current_dir = os.path.abspath(pathname) else: return None current_level = 0 while levels is None or current_level <= levels: if os.path.exists(os.path.join(current_dir, '.git')): return current_dir current_level += 1 if current_dir == os.path.dirname(current_dir): break current_dir = os.path.dirname(current_dir) return None _packagename = "photutils" _last_generated_version = "0.2.1" _last_githash = "f9f9bf1bf60827e5803d0b713a245903d1709048" # Determine where the source code for this module # lives. If __file__ is not a filesystem path then # it is assumed not to live in a git repo at all. if _get_repo_path(__file__, levels=len(_packagename.split('.'))): version = update_git_devstr(_last_generated_version, path=__file__) githash = get_git_devstr(sha=True, show_warning=False, path=__file__) or _last_githash else: # The file does not appear to live in a git repo so don't bother # invoking git version = _last_generated_version githash = _last_githash major = 0 minor = 2 bugfix = 1 release = True timestamp = datetime.datetime(2016, 1, 15, 16, 43, 45, 994418) debug = False try: from ._compiler import compiler except ImportError: compiler = "unknown" try: from .cython_version import cython_version except ImportError: cython_version = "unknown" photutils-0.2.1/PKG-INFO0000600000214200020070000000261112646264032017022 0ustar lbradleySTSCI\science00000000000000Metadata-Version: 1.1 Name: photutils Version: 0.2.1 Summary: An Astropy package for photometry Home-page: http://photutils.readthedocs.org/ Author: The Photutils Developers Author-email: astropy.team@gmail.com License: BSD Description: * Code: https://github.com/astropy/photutils * Docs: https://photutils.readthedocs.org/ **Photutils** is an in-development `affiliated package `_ of `Astropy `_ to provide tools for detecting and performing photometry of astronomical sources. It is an open source (BSD licensed) Python package. Contributions welcome! Platform: UNKNOWN Classifier: Development Status :: 4 - Beta Classifier: Intended Audience :: Science/Research Classifier: License :: OSI Approved :: BSD License Classifier: Operating System :: OS Independent Classifier: Programming Language :: C Classifier: Programming Language :: Cython Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.3 Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: Implementation :: CPython Classifier: Topic :: Scientific/Engineering :: Astronomy photutils-0.2.1/README.rst0000600000214200020070000000271212634600424017412 0ustar lbradleySTSCI\science00000000000000Photutils ========= .. image:: http://img.shields.io/pypi/v/photutils.svg?text=version :target: https://pypi.python.org/pypi/photutils/ :alt: Latest release .. image:: https://readthedocs.org/projects/photutils/badge/?version=stable :target: http://photutils.readthedocs.org/en/stable/ :alt: Stable Documentation Status .. image:: https://readthedocs.org/projects/photutils/badge/?version=latest :target: http://photutils.readthedocs.org/en/latest/ :alt: Latest Documentation Status .. image:: http://img.shields.io/badge/powered%20by-AstroPy-orange.svg?style=flat :target: http://www.astropy.org/ Photutils is an `AstroPy`_ affiliated package to provide tools for detecting and performing photometry of astronomical sources. .. image:: https://travis-ci.org/astropy/photutils.svg?branch=master :target: https://travis-ci.org/astropy/photutils .. image:: https://coveralls.io/repos/astropy/photutils/badge.svg?branch=master :target: https://coveralls.io/r/astropy/photutils .. image:: https://ci.appveyor.com/api/projects/status/by27a71echj18b4f/branch/master?svg=true :target: https://ci.appveyor.com/project/Astropy/photutils/branch/master .. image:: http://img.shields.io/badge/benchmarked%20by-asv-green.svg?style=flat :target: http://astropy.org/photutils-benchmarks/ License ------- Photutils is licensed under a 3-clause BSD style license (see the ``licenses/LICENSE.rst`` file). .. _AstroPy: http://www.astropy.org/ photutils-0.2.1/setup.cfg0000600000214200020070000000102712641260235017542 0ustar lbradleySTSCI\science00000000000000[build_sphinx] source-dir = docs build-dir = docs/_build all_files = 1 [upload_docs] upload-dir = docs/_build/html show-response = 1 [pytest] minversion = 2.2 norecursedirs = build docs/_build doctest_plus = enabled [ah_bootstrap] auto_use = True [metadata] package_name = photutils description = An Astropy package for photometry author = The Photutils Developers author_email = astropy.team@gmail.com license = BSD url = http://photutils.readthedocs.org/ edit_on_github = False github_project = astropy/photutils [entry_points] photutils-0.2.1/setup.py0000700000214200020070000001116112646263745017452 0ustar lbradleySTSCI\science00000000000000#!/usr/bin/env python # Licensed under a 3-clause BSD style license - see LICENSE.rst import glob import os import sys import ah_bootstrap from setuptools import setup #A dirty hack to get around some early import/configurations ambiguities if sys.version_info[0] >= 3: import builtins else: import __builtin__ as builtins builtins._ASTROPY_SETUP_ = True from astropy_helpers.setup_helpers import ( register_commands, get_debug_option, get_package_info) from astropy_helpers.git_helpers import get_git_devstr from astropy_helpers.version_helpers import generate_version_py # Get some values from the setup.cfg from distutils import config conf = config.ConfigParser() conf.read(['setup.cfg']) metadata = dict(conf.items('metadata')) PACKAGENAME = metadata.get('package_name', 'packagename') DESCRIPTION = metadata.get('description', 'Astropy affiliated package') AUTHOR = metadata.get('author', '') AUTHOR_EMAIL = metadata.get('author_email', '') LICENSE = metadata.get('license', 'unknown') URL = metadata.get('url', 'http://astropy.org') # Get the long description from the package's docstring #__import__(PACKAGENAME) #package = sys.modules[PACKAGENAME] #LONG_DESCRIPTION = package.__doc__ LONG_DESCRIPTION = open('LONG_DESCRIPTION.rst').read() # Store the package name in a built-in variable so it's easy # to get from other parts of the setup infrastructure builtins._ASTROPY_PACKAGE_NAME_ = PACKAGENAME # VERSION should be PEP386 compatible (http://www.python.org/dev/peps/pep-0386) VERSION = '0.2.1' # Indicates if this version is a release version RELEASE = 'dev' not in VERSION if not RELEASE: VERSION += get_git_devstr(False) # Populate the dict of setup command overrides; this should be done before # invoking any other functionality from distutils since it can potentially # modify distutils' behavior. cmdclassd = register_commands(PACKAGENAME, VERSION, RELEASE) # Freeze build information in version.py generate_version_py(PACKAGENAME, VERSION, RELEASE, get_debug_option(PACKAGENAME)) # Treat everything in scripts except README.rst as a script to be installed scripts = [fname for fname in glob.glob(os.path.join('scripts', '*')) if os.path.basename(fname) != 'README.rst'] # Get configuration information from all of the various subpackages. # See the docstring for setup_helpers.update_package_files for more # details. package_info = get_package_info() # Add the project-global data package_info['package_data'].setdefault(PACKAGENAME, []) package_info['package_data'][PACKAGENAME].append('data/*') # Define entry points for command-line scripts entry_points = {'console_scripts': []} entry_point_list = conf.items('entry_points') for entry_point in entry_point_list: entry_points['console_scripts'].append('{0} = {1}'.format(entry_point[0], entry_point[1])) # Include all .c files, recursively, including those generated by # Cython, since we can not do this in MANIFEST.in with a "dynamic" # directory name. c_files = [] for root, dirs, files in os.walk(PACKAGENAME): for filename in files: if filename.endswith('.c'): c_files.append( os.path.join( os.path.relpath(root, PACKAGENAME), filename)) package_info['package_data'][PACKAGENAME].extend(c_files) # Note that requires and provides should not be included in the call to # ``setup``, since these are now deprecated. See this link for more details: # https://groups.google.com/forum/#!topic/astropy-dev/urYO8ckB2uM setup(name=PACKAGENAME, version=VERSION, description=DESCRIPTION, scripts=scripts, install_requires=['astropy'], author=AUTHOR, author_email=AUTHOR_EMAIL, license=LICENSE, url=URL, long_description=LONG_DESCRIPTION, classifiers=[ 'Development Status :: 4 - Beta', 'Intended Audience :: Science/Research', 'License :: OSI Approved :: BSD License', 'Operating System :: OS Independent', 'Programming Language :: C', 'Programming Language :: Cython', 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: Implementation :: CPython', 'Topic :: Scientific/Engineering :: Astronomy', ], cmdclass=cmdclassd, zip_safe=False, use_2to3=False, entry_points=entry_points, **package_info )