repo
stringclasses
454 values
file_path
stringlengths
5
201
extension
stringclasses
1 value
content
stringlengths
8
509k
num_lines
int64
3
16.9k
size_bytes
int64
8
511k
astropy
astropy/tests/figures/helpers.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst from functools import wraps import pytest from astropy.utils.compat.optional_deps import HAS_PYTEST_MPL def figure_test(*args, **kwargs): """ A decorator that defines a figure test. This automatically decorates tests with mpl_image_compar...
47
1,516
astropy
astropy/utils/misc.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ A "grab bag" of relatively small general-purpose utilities that don't have a clear module/package to live in. """ import contextlib import difflib import inspect import json import locale import re import sys import threading import traceback import u...
551
15,994
astropy
astropy/utils/state.py
.py
""" A simple class to manage a piece of global science state. See :ref:`astropy:config-developer` for more details. """ __all__ = ["ScienceState"] class _ScienceStateContext: def __init__(self, parent, value): self._value = value self._parent = parent def __enter__(self): pass ...
79
2,127
astropy
astropy/utils/introspection.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """Functions related to Python runtime introspection.""" import inspect import os import sys from importlib import import_module, metadata from importlib.metadata import packages_distributions from importlib.util import find_spec from operator import ge, ...
407
14,223
astropy
astropy/utils/exceptions.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ This module contains errors/exceptions and warnings of general use for astropy. Exceptions that are specific to a given subpackage should *not* be here, but rather in the particular subpackage. """ __all__ = [ "AstropyBackwardsIncompatibleChangeWa...
95
2,502
astropy
astropy/utils/codegen.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """Utilities for generating new Python code at runtime.""" import inspect import keyword import os import re import textwrap from .introspection import find_current_module __all__ = ["make_function_with_signature"] _ARGNAME_RE = re.compile(r"^[A-Za-z]...
133
4,039
astropy
astropy/utils/diff.py
.py
import difflib import functools import math import sys from textwrap import indent import numpy as np __all__ = [ "diff_values", "report_diff_values", "where_not_allclose", ] def diff_values(a, b, rtol=0.0, atol=0.0): """ Diff two scalar values. If both values are floats, they are compared to ...
214
6,225
astropy
astropy/utils/__init__.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ This subpackage contains developer-oriented utilities used by Astropy. Public functions and classes in this subpackage are safe to be used by other packages, but this subpackage is for utilities that are primarily of use for developers or to implement...
22
813
astropy
astropy/utils/data.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """Functions for accessing, downloading, and caching data files.""" import atexit import contextlib import errno import fnmatch import ftplib import functools import hashlib import io import os import re import shutil import sys import urllib.error impor...
2,459
89,313
astropy
astropy/utils/console.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ Utilities for console input and output. """ import codecs import locale import math import multiprocessing import os import struct import sys import threading import time from shutil import get_terminal_size # concurrent.futures imports moved inside ...
1,065
31,591
astropy
astropy/utils/system_info.py
.py
r""" A helper script to automate system info in bug reports. This can be run as:: python -c "import astropy; astropy.system_info()" (note that the interpreter might be called python3 instead of python, depending on your system's details) This script should not require anything else than the standard library and...
87
1,944
astropy
astropy/utils/parsing.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ Wrappers for PLY to provide thread safety. """ import contextlib import functools import re import threading from collections.abc import Generator from pathlib import Path from types import ModuleType from astropy.extern.ply.lex import Lexer from ast...
146
4,843
astropy
astropy/utils/decorators.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """Sundry function and class decorators.""" import functools import inspect import sys import textwrap import threading import types import warnings from functools import wraps from inspect import signature from types import FunctionType from .exceptions...
1,274
45,419
astropy
astropy/utils/data_info.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """This module contains functions and methods that relate to the DataInfo class which provides a container for informational attributes as well as summary info methods. A DataInfo object is attached to the Quantity, SkyCoord, and Time classes in astropy....
814
28,143
astropy
astropy/utils/shapes.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """The ShapedLikeNDArray mixin class and shape-related functions.""" import abc import numbers from collections.abc import Sequence from itertools import zip_longest from math import prod from types import EllipsisType from typing import Self, TypeVar im...
529
19,074
astropy
astropy/utils/collections.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ A module containing specialized collection classes. """ class HomogeneousList(list): """ A subclass of list that contains only elements of a given type or types. If an item that is not of the specified type is added to the list, a `T...
59
1,508
astropy
astropy/utils/iers/iers.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ The astropy.utils.iers package provides access to the tables provided by the International Earth Rotation and Reference Systems Service, in particular allowing interpolation of published UT1-UTC values for given times. These are used in `astropy.time`...
1,348
51,373
astropy
astropy/utils/iers/tests/test_leap_second.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import locale import os import pkgutil import platform import urllib.request import erfa import numpy as np import pytest from numpy.testing import assert_array_equal import astropy from astropy.tests.helper import CI from astropy.time import Time, TimeD...
510
21,325
astropy
astropy/utils/iers/tests/test_iers.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import os import re import warnings from pathlib import Path import numpy as np import pytest from astropy_iers_data import ( IERS_A_README, IERS_B_FILE, IERS_B_README, IERS_LEAP_SECOND_FILE, ) from astropy import units as u from astropy...
583
23,760
astropy
astropy/utils/metadata/utils.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """This module contains helper functions handling metadata.""" import numpy as np from .exceptions import MergeConflictError __all__ = ["common_dtype"] def dtype(arr): return getattr(arr, "dtype", np.dtype("O")) def common_dtype(arrs): """ ...
70
2,075
astropy
astropy/utils/metadata/exceptions.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """Metadata exceptions and warnings.""" from astropy.utils.exceptions import AstropyWarning __all__ = ["MergeConflictError", "MergeConflictWarning"] class MergeConflictError(TypeError): pass class MergeConflictWarning(AstropyWarning): pass
15
318
astropy
astropy/utils/metadata/__init__.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """This module contains helper functions and classes for handling metadata.""" from . import core as _core from . import exceptions as _exceptions from . import merge as _merge from . import utils as _utils from .core import * from .exceptions import * fr...
18
482
astropy
astropy/utils/metadata/merge.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """Metadata merging.""" import warnings from contextlib import contextmanager from copy import deepcopy import numpy as np from .exceptions import MergeConflictError, MergeConflictWarning from .utils import result_type __all__ = [ "MERGE_STRATEGIES...
301
10,348
astropy
astropy/utils/metadata/core.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """Classes for handling metadata.""" __all__ = ["MetaAttribute", "MetaData"] import inspect from collections import OrderedDict from collections.abc import Mapping from copy import deepcopy from dataclasses import is_dataclass class MetaData: """ ...
215
7,678
astropy
astropy/utils/metadata/tests/test_metadata.py
.py
from collections import OrderedDict, defaultdict from dataclasses import dataclass import numpy as np import pytest from astropy.io import fits from astropy.utils import metadata from astropy.utils.metadata import ( MergeConflictError, MetaData, common_dtype, enable_merge_strategies, merge, ) from...
368
9,658
astropy
astropy/utils/xml/writer.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ Contains a class that makes it simple to stream out well-formed and nicely-indented XML. """ import contextlib import textwrap from astropy.utils.compat.optional_deps import HAS_BLEACH from ._iterparser import escape_xml as xml_escape from ._iterpar...
334
10,211
astropy
astropy/utils/xml/setup_package.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import os import sys from collections import defaultdict from os.path import join from setuptools import Extension from extension_helpers import pkg_config def get_extensions(build_type="release"): XML_DIR = "astropy/utils/xml/src" cfg = defa...
49
1,656
astropy
astropy/utils/xml/unescaper.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """URL unescaper functions.""" # STDLIB from xml.sax import saxutils __all__ = ["unescape_all"] # This is DIY _bytes_entities = { b"&amp;": b"&", b"&lt;": b"<", b"&gt;": b">", b"&amp;&amp;": b"&", b"&&": b"&", b"%2F": b"/", } _by...
64
1,420
astropy
astropy/utils/xml/check.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ A collection of functions for checking various XML-related strings for standards compliance. """ import re import urllib.parse def check_id(ID): """ Returns `True` if *ID* is a valid XML ID. """ return re.match(r"^[A-Za-z_][A-Za-z0-9...
85
2,189
astropy
astropy/utils/xml/validate.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ Functions to do XML schema and DTD validation. At the moment, this makes a subprocess call to xmllint. This could use a Python-based library at some point in the future, if something appropriate could be found. """ import os import subprocess from ...
56
1,518
astropy
astropy/utils/xml/iterparser.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ This module includes a fast iterator-based XML parser. """ # STDLIB import contextlib import io import sys # ASTROPY from astropy.utils import data from ._iterparser import IterParser as _fast_iterparse __all__ = ["get_xml_encoding", "get_xml_itera...
211
5,915
astropy
astropy/utils/xml/tests/test_iterparse.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst # LOCAL # SYSTEM import io import zlib from astropy.utils.xml.iterparser import _fast_iterparse # The C-based XML parser for VOTables previously used fixed-sized # buffers (allocated at __init__() time). This test will # only pass with the patch that a...
133
4,758
astropy
astropy/utils/xml/tests/test_c_iterparse.py
.py
import io from dataclasses import dataclass from typing import Any import pytest from astropy.utils.xml import _iterparser @dataclass(kw_only=True, slots=True, frozen=True) class XMLTestData: """Strictly typed container for XML parsing validation.""" xml_bytes: bytes expected_events: tuple[tuple[bool, ...
81
2,677
astropy
astropy/utils/masked/__init__.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ Built-in mask mixin class. The design uses `Masked` as a factory class which automatically generates new subclasses for any data class that is itself a subclass of a predefined masked class, with `MaskedNDArray` providing such a predefined class for `...
12
362
astropy
astropy/utils/masked/function_helpers.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """Helpers for letting numpy functions interact with Masked arrays. The module supplies helper routines for numpy functions that propagate masks appropriately, for use in the ``__array_function__`` implementation of `~astropy.utils.masked.MaskedNDArray`. ...
1,458
46,052
astropy
astropy/utils/masked/core.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ Built-in mask mixin class. The design uses `Masked` as a factory class which automatically generates new subclasses for any data class that is itself a subclass of a predefined masked class, with `MaskedNDArray` providing such a predefined class for `...
1,463
56,361
astropy
astropy/utils/masked/tests/test_functions.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """Test numpy functions and ufuncs on Masked arrays and quantities. The tests here are fairly detailed but do not aim for complete coverage. Complete coverage of all numpy functions is done with less detailed tests in test_function_helpers. """ # We gen...
631
26,436
astropy
astropy/utils/masked/tests/test_masked.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """Test masked class initialization, methods, and operators. Functions, including ufuncs, are tested in test_functions.py """ import operator import sys import numpy as np import pytest from numpy.testing import assert_array_equal from astropy import u...
1,627
60,731
astropy
astropy/utils/masked/tests/test_dynamic_subclasses.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """Test importability of common Masked classes and their info classes.""" import pytest from astropy.coordinates.angles.core import Angle, Latitude, Longitude from astropy.units.quantity import Quantity from astropy.utils.masked import core @pytest.mar...
22
751
astropy
astropy/utils/masked/tests/test_table.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import numpy as np import pytest from numpy.testing import assert_array_equal from astropy import units as u from astropy.table import QTable, hstack, join, vstack from astropy.utils.compat.optional_deps import HAS_H5PY from astropy.utils.masked import M...
172
6,605
astropy
astropy/utils/masked/tests/test_function_helpers.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """Test all functions covered by __array_function__. Here, run through all functions, with simple tests just to check the helpers. More complicated tests of functionality, including with subclasses, are done in test_functions. TODO: finish full coverage ...
1,771
63,774
astropy
astropy/utils/masked/tests/test_pickle.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import pickle import numpy as np import pytest import astropy.units as u from astropy.coordinates import Angle, Latitude, Longitude from astropy.units import Quantity from astropy.utils.masked import Masked @pytest.mark.parametrize( "data", [ ...
38
900
astropy
astropy/utils/masked/tests/test_containers.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import numpy as np import pytest from numpy.testing import assert_array_equal from astropy import units as u from astropy.coordinates import SkyCoord from astropy.coordinates import representation as r from astropy.time import Time from astropy.utils.mas...
174
6,946
astropy
astropy/utils/tests/test_data_info.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import pickle import numpy as np import pytest import astropy.units as u from astropy.coordinates import SkyCoord from astropy.table import QTable from astropy.table.index import SlicedIndex from astropy.time import Time from astropy.utils.data_info imp...
118
3,356
astropy
astropy/utils/tests/test_misc.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import json import locale import urllib.error from datetime import datetime import numpy as np import pytest from astropy.io import fits from astropy.tests.helper import CI from astropy.utils import misc from astropy.utils.exceptions import AstropyDepre...
164
5,237
astropy
astropy/utils/tests/test_compat.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ Just deprecation tests, the rest is tested throughout astropy. """ import pytest from astropy.utils.exceptions import AstropyPendingDeprecationWarning def test_copy_if_needed_deprecation(): with pytest.warns(AstropyPendingDeprecationWarning, ma...
19
617
astropy
astropy/utils/tests/test_console.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import io import sys import pytest from astropy import units as u from astropy.utils import console from . import test_progress_bar_func class FakeTTY(io.StringIO): """IOStream that fakes a TTY; provide an encoding to emulate an output strea...
209
5,303
astropy
astropy/utils/tests/test_introspection.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst # ruff: noqa: PYI024 # namedtuple is needed for find_mod_objs so it can have a non-local module from collections import namedtuple from unittest import mock import pytest import yaml from astropy.utils import introspection from astropy.utils.exceptions ...
155
5,435
astropy
astropy/utils/tests/test_shapes.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import numpy as np import pytest from hypothesis import given from hypothesis.extra.numpy import basic_indices from numpy.testing import assert_equal from astropy.utils.exceptions import AstropyDeprecationWarning from astropy.utils.shapes import ( Sh...
99
2,966
astropy
astropy/utils/tests/test_codegen.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import sys import traceback import pytest from astropy.utils.codegen import make_function_with_signature def test_make_function_with_signature_lineno(): """ Tests that a function made with ``make_function_with_signature`` is give the corre...
41
1,321
astropy
astropy/utils/tests/test_collections.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import pytest from astropy.utils import collections def test_homogeneous_list(): l = collections.HomogeneousList(int) with pytest.raises(TypeError): l.append(5.0) def test_homogeneous_list2(): l = collections.HomogeneousList(int) ...
76
1,737
astropy
astropy/utils/tests/test_parsing.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import importlib import secrets from py_compile import compile from textwrap import dedent import pytest from astropy.utils.parsing import _TAB_HEADER def _docstring_canary(): """Docstring that's here just to check for -OO.""" @pytest.mark.skipi...
98
3,079
astropy
astropy/utils/tests/test_diff.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ Some might be indirectly tested already in ``astropy.io.fits.tests``. """ import io import numpy as np import pytest from astropy.table import Table from astropy.utils.diff import diff_values, report_diff_values, where_not_allclose @pytest.mark.pa...
188
5,154
astropy
astropy/utils/tests/test_progress_bar_func.py
.py
import time import numpy as np from astropy.utils.misc import NumpyRNGContext def func(i): """An identity function that jitters its execution time by a pseudo-random amount. FIXME: This function should be defined in test_console.py, but Astropy's test runner interacts strangely with Python's `multi...
20
585
astropy
astropy/utils/tests/test_xml.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import io import pytest from astropy.utils.compat.optional_deps import HAS_BLEACH from astropy.utils.xml import check, unescaper, writer def test_writer(): fh = io.StringIO() w = writer.XMLWriter(fh) with w.tag("html"): with w.tag(...
120
3,235
astropy
astropy/utils/tests/test_decorators.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import concurrent.futures import inspect import pickle import sys import pytest from astropy.tests.helper import _skip_docstring_tests_with_optimized_python from astropy.utils.decorators import ( classproperty, deprecated, deprecated_attribu...
948
28,427
astropy
astropy/utils/tests/test_data.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst # NOTE: All the tests here might non-deterministically emit # ResourceWarning about unclosed socket or SSLSocket, # which we tell pytest to ignore. See GH Issue 9619. import base64 import contextlib import errno import hashlib import io import...
2,434
82,656
astropy
astropy/utils/tests/test_state.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst from astropy.utils.state import ScienceState def test_ScienceState_and_Context(): """ Tests a ScienceState and spawned contexts. """ class MyState(ScienceState): _value = "A" _state = dict(foo="bar") state = {"foo":...
26
601
astropy
astropy/utils/tests/data/test_package/__init__.py
.py
from astropy.utils.data import get_pkg_data_filename def get_data_filename(): return get_pkg_data_filename("data/foo.txt")
6
129
astropy
astropy/utils/compat/numpycompat.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ This is a collection of monkey patches and workarounds for bugs in earlier versions of Numpy. """ import warnings import numpy as np from astropy.utils import minversion from astropy.utils.exceptions import ( AstropyDeprecationWarning, Astro...
92
3,088
astropy
astropy/utils/compat/__init__.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ The content of this module is solely for internal use of ``astropy`` and subject to changes without deprecations. Do not use it in external packages or code. """ # Importing this module will also install monkey-patches defined in it from .numpycompat...
20
565
astropy
astropy/utils/compat/optional_deps.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """Checks for optional dependencies using lazy import from `PEP 562 <https://www.python.org/dev/peps/pep-0562/>`_. """ from importlib.util import find_spec # First, the top-level packages: # TODO: This list is a duplicate of the dependencies in pyproject...
63
1,487
astropy
astropy/constants/astropyconst40.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ Astronomical and physics constants for Astropy v4.0. See :mod:`astropy.constants` for a complete listing of constants defined in Astropy. """ import warnings from astropy.utils import find_current_module from . import codata2018, iau2015 from . impo...
71
2,028
astropy
astropy/constants/utils.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """Utility functions for ``constants`` sub-package.""" __all__ = [] def _get_c(codata, iaudata, module, not_in_module_only=True): """ Generator to return a Constant object. Parameters ---------- codata, iaudata : obj Modules...
85
2,365
astropy
astropy/constants/codata2010.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ Astronomical and physics constants in SI units. See :mod:`astropy.constants` for a complete listing of constants defined in Astropy. """ import numpy as np from .constant import Constant, EMConstant # PHYSICAL CONSTANTS class CODATA2010(Constant)...
173
3,814
astropy
astropy/constants/codata2014.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ Astronomical and physics constants in SI units. See :mod:`astropy.constants` for a complete listing of constants defined in Astropy. """ import numpy as np from .constant import Constant, EMConstant # PHYSICAL CONSTANTS class CODATA2014(Constant)...
158
3,480
astropy
astropy/constants/codata2018.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ Astronomical and physics constants in SI units. See :mod:`astropy.constants` for a complete listing of constants defined in Astropy. """ import math from .constant import Constant, EMConstant # PHYSICAL CONSTANTS # https://en.wikipedia.org/wiki/201...
156
3,794
astropy
astropy/constants/__init__.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ Contains astronomical and physical constants for use in Astropy or other places. A typical use case might be:: >>> from astropy.constants import c, m_e >>> # ... define the mass of something you want the rest energy of as m ... >>> m = m_...
63
1,563
astropy
astropy/constants/iau2012.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ Astronomical and physics constants in SI units. See :mod:`astropy.constants` for a complete listing of constants defined in Astropy. """ import numpy as np from .constant import Constant # ASTRONOMICAL CONSTANTS class IAU2012(Constant): defau...
149
2,570
astropy
astropy/constants/cgs.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ Astronomical and physics constants in cgs units. See :mod:`astropy.constants` for a complete listing of constants defined in Astropy. """ from .config import codata, iaudata from .constant import Constant for _nm, _c in (*sorted(vars(codata).items()...
17
525
astropy
astropy/constants/codata2022.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ Astronomical and physics constants in SI units. See :mod:`astropy.constants` for a complete listing of constants defined in Astropy. """ import math from .constant import Constant, EMConstant # PHYSICAL CONSTANTS # https://en.wikipedia.org/wiki/201...
155
3,793
astropy
astropy/constants/astropyconst20.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ Astronomical and physics constants for Astropy v2.0. See :mod:`astropy.constants` for a complete listing of constants defined in Astropy. """ import warnings from astropy.utils import find_current_module from . import codata2014, iau2015 from . impo...
71
2,028
astropy
astropy/constants/si.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ Astronomical and physics constants in SI units. See :mod:`astropy.constants` for a complete listing of constants defined in Astropy. """ from .config import codata, iaudata from .constant import Constant for _nm, _c in (*sorted(vars(codata).items())...
13
473
astropy
astropy/constants/constant.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import functools import types import warnings import numpy as np from astropy.units.core import Unit from astropy.units.errors import UnitsError from astropy.units.quantity import Quantity from astropy.utils import lazyproperty from astropy.utils.except...
281
9,417
astropy
astropy/constants/iau2015.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ Astronomical and physics constants in SI units. See :mod:`astropy.constants` for a complete listing of constants defined in Astropy. """ import numpy as np from .config import codata from .constant import Constant # ASTRONOMICAL CONSTANTS class I...
183
3,555
astropy
astropy/constants/astropyconst80.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ Astronomical and physics constants for Astropy v8.0. See :mod:`astropy.constants` for a complete listing of constants defined in Astropy. """ import warnings from astropy.utils import find_current_module from . import codata2022, iau2015 from . impo...
71
2,028
astropy
astropy/constants/config.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ Configures the codata and iaudata used, possibly using user configuration. """ # Note: doing this in __init__ causes import problems with units, # as si.py and cgs.py have to import the result. import importlib import astropy phys_version = astropy....
17
549
astropy
astropy/constants/astropyconst13.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ Astronomical and physics constants for Astropy v1.3 and earlier. See :mod:`astropy.constants` for a complete listing of constants defined in Astropy. """ from astropy.utils import find_current_module from . import codata2010, iau2012 from . import ut...
21
485
astropy
astropy/constants/tests/test_prior_version.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import copy import numpy as np import pytest import astropy.constants as const import astropy.units as u from astropy import astronomical_constants, physical_constants from astropy.constants import Constant, EMConstant def test_c(): from astropy.c...
242
7,317
astropy
astropy/constants/tests/test_constant.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import copy import pytest import astropy.units as u from astropy.constants import Constant def test_c(): from astropy.constants import c # c is an exactly defined constant, so it shouldn't be changing assert c.value == 2.99792458e8 # def...
162
4,713
astropy
astropy/constants/tests/test_sciencestate.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import subprocess import sys from textwrap import dedent import pytest import astropy.constants as const from astropy import astronomical_constants, physical_constants def test_version_match(): pversion = physical_constants.get() refpversion = ...
51
1,749
astropy
astropy/constants/tests/test_pickle.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import pytest from astropy import constants as const from astropy.tests.helper import check_pickling_recovery, pickle_protocol # noqa: F401 originals = [ const.Constant("h_fake", "Not Planck", 0.0, "J s", 0.0, "fakeref", system="si"), const.h, ...
18
507
astropy
astropy/_dev/__init__.py
.py
""" This package contains utilities that are only used when developing astropy in a copy of the source repository. These files are not installed, and should not be assumed to exist at runtime. """
7
198
astropy
astropy/_dev/scm_version.py
.py
# Try to use setuptools_scm to get the current version; this is only used # in development installations from the git repository. from pathlib import Path try: from setuptools_scm import get_version version = get_version(root=Path(__file__).parents[2]) except Exception: raise ImportError("setuptools_scm b...
11
345
astropy
astropy/wcs/utils.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import copy from functools import lru_cache import numpy as np import astropy.units as u from astropy.coordinates import ( ITRS, BaseBodycentricRepresentation, BaseCoordinateFrame, BaseGeodeticRepresentation, CartesianRepresentation,...
1,363
46,913
astropy
astropy/wcs/setup_package.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import io import os import os.path import shutil import sys from collections import defaultdict from os.path import join from pathlib import Path from numpy import get_include as get_numpy_include from setuptools import Extension from extension_helpers ...
361
10,528
astropy
astropy/wcs/__init__.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """World Coordinate System (WCS) transformations in FITS files. .. _wcslib: https://www.atnf.csiro.au/people/mcalabre/WCS/wcslib/index.html .. _distortion paper: https://www.atnf.csiro.au/people/mcalabre/WCS/dcs_20040422.pdf .. _SIP: https://irsa.ipac.cal...
76
3,038
astropy
astropy/wcs/docstrings.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst # It gets to be really tedious to type long docstrings in ANSI C # syntax (since multi-line string literals are not valid). # Therefore, the docstrings are written here in doc/docstrings.py, # which are then converted by setup.py into docstrings.h, which ...
3,002
82,617
astropy
astropy/wcs/wcs.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst # Under the hood, there are 3 separate classes that perform different # parts of the transformation: # # - `~astropy.wcs.Wcsprm`: Is a direct wrapper of the core WCS # functionality in `wcslib`_. (This includes TPV and TPD # polynomial disto...
3,997
143,452
astropy
astropy/wcs/wcslint.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ Script support for validating the WCS keywords in a FITS file. """ def main(args=None): import argparse from . import wcs parser = argparse.ArgumentParser( description=( "Check the WCS keywords in a FITS file for com...
24
633
astropy
astropy/wcs/wcsapi/fitswcs.py
.py
# This file includes the definition of a mix-in class that provides the low- # and high-level WCS API to the astropy.wcs.WCS object. We keep this code # isolated in this mix-in class to avoid making the main wcs.py file too # long. import warnings import numpy as np import astropy.constants from astropy import units...
834
32,077
astropy
astropy/wcs/wcsapi/utils.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import importlib import numpy as np __all__ = ["deserialize_class", "wcs_info_str"] def deserialize_class(tpl, construct=True): """ Deserialize classes recursively. """ if not isinstance(tpl, tuple) or len(tpl) != 3: raise Valu...
153
5,224
astropy
astropy/wcs/wcsapi/high_level_api.py
.py
import abc import numbers from collections import OrderedDict, defaultdict from collections.abc import Callable from typing import Any, Protocol import numpy as np from numpy.typing import ArrayLike from astropy.utils.masked import Masked, MaskedNDArray, combine_masks from .utils import deserialize_class __all__ = ...
437
15,690
astropy
astropy/wcs/wcsapi/high_level_wcs_wrapper.py
.py
from .high_level_api import HighLevelWCSMixin from .low_level_api import BaseLowLevelWCS from .utils import wcs_info_str __all__ = ["HighLevelWCSWrapper"] class HighLevelWCSWrapper(HighLevelWCSMixin): """ Wrapper class that can take any :class:`~astropy.wcs.wcsapi.BaseLowLevelWCS` object and expose the h...
86
2,332
astropy
astropy/wcs/wcsapi/low_level_api.py
.py
import abc import os import numpy as np __all__ = ["BaseLowLevelWCS", "validate_physical_types"] class BaseLowLevelWCS(metaclass=abc.ABCMeta): """ Abstract base class for the low-level WCS interface. This is described in `APE 14: A shared Python interface for World Coordinate Systems <https://zenod...
371
15,924
astropy
astropy/wcs/wcsapi/conftest.py
.py
import numpy as np import pytest from astropy.coordinates import SkyCoord from astropy.units import Quantity from astropy.wcs import WCS from astropy.wcs.wcsapi import BaseLowLevelWCS @pytest.fixture def spectral_1d_fitswcs(): wcs = WCS(naxis=1) wcs.wcs.ctype = ("FREQ",) wcs.wcs.cunit = ("Hz",) wcs.w...
186
4,405
astropy
astropy/wcs/wcsapi/wrappers/sliced_wcs.py
.py
import numbers from collections import defaultdict import numpy as np from astropy.utils.decorators import lazyproperty from .base import BaseWCSWrapper __all__ = ["SlicedLowLevelWCS", "sanitize_slices"] def sanitize_slices(slices, ndim): """ Given a slice as input sanitise it to an easier to parse format...
337
11,924
astropy
astropy/wcs/wcsapi/wrappers/base.py
.py
import abc from astropy.wcs.wcsapi import BaseLowLevelWCS, wcs_info_str class BaseWCSWrapper(BaseLowLevelWCS, metaclass=abc.ABCMeta): """ A base wrapper class for things that modify Low Level WCSes. This wrapper implements a transparent wrapper to many of the properties, with the idea that not all o...
84
2,014
astropy
astropy/wcs/wcsapi/wrappers/tests/test_sliced_wcs.py
.py
import warnings import numpy as np import pytest from numpy.testing import assert_allclose, assert_equal import astropy.units as u from astropy.coordinates import ICRS, Galactic, SkyCoord from astropy.io.fits import Header from astropy.io.fits.verify import VerifyWarning from astropy.time import Time from astropy.uni...
1,050
33,912
astropy
astropy/wcs/wcsapi/tests/test_high_level_api.py
.py
import re import numpy as np import pytest from numpy.testing import assert_allclose from astropy import units as u from astropy.coordinates import SkyCoord from astropy.units import Quantity from astropy.wcs import WCS from astropy.wcs.wcsapi.high_level_api import ( HighLevelWCSMixin, high_level_objects_to_v...
358
9,945