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/wcs/wcsapi/tests/test_high_level_wcs_wrapper.py | .py | import numpy as np
import pytest
from numpy.testing import assert_allclose
from astropy.coordinates import SkyCoord
from astropy.wcs.wcsapi.high_level_wcs_wrapper import HighLevelWCSWrapper
from astropy.wcs.wcsapi.low_level_api import BaseLowLevelWCS
class CustomLowLevelWCS(BaseLowLevelWCS):
@property
def pi... | 82 | 2,106 |
astropy | astropy/wcs/wcsapi/tests/test_fitswcs.py | .py | # Note that we test the main astropy.wcs.WCS class directly rather than testing
# the mix-in class on its own (since it's not functional without being used as
# a mix-in)
import re
import warnings
import numpy as np
import pytest
from numpy.testing import assert_allclose, assert_array_equal, assert_equal
from packagi... | 1,704 | 53,918 |
astropy | astropy/wcs/wcsapi/tests/helpers.py | .py | def assert_celestial_component(component, index):
assert component[:2] == ("celestial", index)
assert callable(component[2])
| 4 | 133 |
astropy | astropy/wcs/wcsapi/tests/test_low_level_api.py | .py | import pytest
from astropy.wcs.wcsapi.low_level_api import validate_physical_types
def test_validate_physical_types():
# Check valid cases
validate_physical_types(["pos.eq.ra", "pos.eq.ra"])
validate_physical_types(["spect.dopplerVeloc.radio", "custom:spam"])
validate_physical_types(["time", None])
... | 23 | 738 |
astropy | astropy/wcs/wcsapi/tests/test_utils.py | .py | import pytest
from astropy import units as u
from astropy.tests.helper import assert_quantity_allclose
from astropy.wcs import WCS
from astropy.wcs.wcsapi.utils import deserialize_class, wcs_info_str
def test_construct():
result = deserialize_class(("astropy.units.Quantity", (10,), {"unit": "deg"}))
assert_q... | 56 | 1,475 |
astropy | astropy/wcs/tests/test_tab.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
from copy import deepcopy
import numpy as np
import pytest
from packaging.version import Version
from astropy import wcs
from astropy.io import fits
from astropy.utils.data import get_pkg_data_filename
from astropy.wcs.wcs import WCSLIB_VERSION
from .he... | 107 | 3,499 |
astropy | astropy/wcs/tests/test_celprm.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
from copy import copy, deepcopy
import numpy as np
import pytest
from astropy import wcs
_WCS_UNDEFINED = 987654321.0e99
def test_celprm_init():
# test Celprm_cnew
assert wcs.WCS().wcs.cel
# test Celprm_new
assert wcs.Celprm()
wi... | 144 | 2,758 |
astropy | astropy/wcs/tests/test_auxprm.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
# Tests for the auxiliary parameters contained in wcsaux
from numpy.testing import assert_allclose
from astropy.io import fits
from astropy.wcs import WCS
STR_PLANETARY_EXPECTED_EMPTY = """
a_radius:
b_radius:
c_radius:
bdis_obs:
blon_obs:
blat_obs:"""... | 199 | 6,097 |
astropy | astropy/wcs/tests/test_wtbarr.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
def test_wtbarr_i(tab_wcs_2di):
assert tab_wcs_2di.wcs.wtb[0].i == 1
def test_wtbarr_m(tab_wcs_2di):
assert tab_wcs_2di.wcs.wtb[0].m == 1
def test_wtbarr_kind(tab_wcs_2di):
assert tab_wcs_2di.wcs.wtb[0].kind == "c"
def test_wtbarr_extna... | 59 | 1,531 |
astropy | astropy/wcs/tests/test_wcs.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import io
import os
import re
from contextlib import nullcontext
from datetime import datetime
from multiprocessing.pool import ThreadPool
import numpy as np
import pytest
from numpy.random import default_rng
from numpy.testing import (
assert_allclo... | 2,858 | 98,331 |
astropy | astropy/wcs/tests/test_wcsprm.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import gc
import locale
import re
import numpy as np
import pytest
from numpy.testing import assert_array_almost_equal, assert_array_equal
from packaging.version import Version
from astropy import units as u
from astropy.io import fits
from astropy.unit... | 1,250 | 28,851 |
astropy | astropy/wcs/tests/test_profiling.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import os
import numpy as np
import pytest
from astropy import wcs
from astropy.utils.data import get_pkg_data_contents, get_pkg_data_filenames
from astropy.utils.misc import NumpyRNGContext
from astropy.wcs.wcs import FITSFixedWarning
# use the base n... | 80 | 2,570 |
astropy | astropy/wcs/tests/test_pickle.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import os
import pickle
import numpy as np
import pytest
from numpy.testing import assert_array_almost_equal
from astropy import wcs
from astropy.io import fits
from astropy.utils.data import (
get_pkg_data_contents,
get_pkg_data_filename,
g... | 205 | 6,073 |
astropy | astropy/wcs/tests/helper.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import numpy as np
from astropy.io import fits
class SimModelTAB:
def __init__(
self,
nx=150,
ny=200,
crpix=[1, 1],
crval=[1, 1],
cdelt=[1, 1],
pc={"PC1_1": 1, "PC2_2": 1},
):
# set... | 117 | 3,787 |
astropy | astropy/wcs/tests/test_prjprm.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
from copy import copy, deepcopy
import numpy as np
import pytest
from astropy import wcs
def test_prjprm_init():
# test Prjprm_cnew
assert wcs.WCS().wcs.cel.prj
# test Prjprm_new
assert wcs.Prjprm()
with pytest.raises(wcs.InvalidP... | 248 | 5,441 |
astropy | astropy/wcs/tests/test_utils.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
from contextlib import nullcontext
import numpy as np
import pytest
from numpy.testing import assert_allclose, assert_almost_equal, assert_equal
from packaging.version import Version
from astropy import units as u
from astropy.coordinates import ITRS, Ba... | 1,781 | 58,761 |
astropy | astropy/wcs/tests/test_tabprm.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
from copy import deepcopy
import numpy as np
def test_wcsprm_tab_basic(tab_wcs_2di):
assert len(tab_wcs_2di.wcs.tab) == 1
t = tab_wcs_2di.wcs.tab[0]
assert tab_wcs_2di.wcs.tab[0] is not t
def test_tabprm_coord(tab_wcs_2di_f):
t = tab_... | 135 | 3,064 |
astropy | astropy/wcs/tests/conftest.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import pytest
from astropy import wcs
from .helper import SimModelTAB
@pytest.fixture(scope="module")
def tab_wcs_2di():
model = SimModelTAB(nx=150, ny=200)
# generate FITS HDU list:
hdulist = model.hdulist
# create WCS object:
w... | 55 | 983 |
astropy | astropy/wcs/tests/extension/test_extension.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""Build a small C extension against the public ``astropy.wcs`` C API.
The extension links against the headers published by ``astropy.wcs.get_include()``,
exactly as a downstream package such as drizzlepac does. It is used to check
that the members of th... | 184 | 6,011 |
astropy | astropy/nddata/_testing.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""Testing utilities. Not part of the public API!"""
from astropy.wcs import WCS
from astropy.wcs.wcsapi import BaseHighLevelWCS
def assert_wcs_seem_equal(wcs1, wcs2):
"""Just checks a few attributes to make sure wcs instances seem to be
equal.
... | 73 | 1,851 |
astropy | astropy/nddata/utils.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
This module includes helper functions for array operations.
"""
import functools
from collections.abc import Callable
from copy import deepcopy
from typing import Literal, TypeAlias, TypeVar, overload
import numpy as np
from numpy.typing import NDArr... | 955 | 34,850 |
astropy | astropy/nddata/nddata.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
# This module implements the base NDData class.
from copy import deepcopy
import numpy as np
from astropy import log
from astropy.units import Quantity, Unit
from astropy.utils.compat.optional_deps import HAS_DASK
from astropy.utils.masked import Maske... | 448 | 16,581 |
astropy | astropy/nddata/covariance.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
Implements a class used to store and manipulate covariance matrices.
"""
import warnings
import numpy as np
from astropy import table
from astropy.units import Quantity
from astropy.utils.compat.optional_deps import HAS_SCIPY
from astropy.utils.exce... | 1,064 | 38,197 |
astropy | astropy/nddata/__init__.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
The `astropy.nddata` subpackage provides the `~astropy.nddata.NDData`
class and related tools to manage n-dimensional array-based data (e.g.
CCD images, IFU Data, grid-based simulation data, ...). This is more than
just `numpy.ndarray` objects, becaus... | 51 | 1,551 |
astropy | astropy/nddata/nddata_withmixins.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
This module implements a class based on NDData with all Mixins.
"""
from .mixins.ndarithmetic import NDArithmeticMixin
from .mixins.ndio import NDIOMixin
from .mixins.ndslicing import NDSlicingMixin
from .nddata import NDData
__all__ = ["NDDataRef"]... | 70 | 2,209 |
astropy | astropy/nddata/decorators.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import warnings
from copy import deepcopy
from functools import wraps
from inspect import signature
from itertools import islice
from astropy.utils.exceptions import AstropyUserWarning
from .nddata import NDData
__all__ = ["support_nddata"]
# All su... | 288 | 11,689 |
astropy | astropy/nddata/compat.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
# This module contains a class equivalent to pre-1.0 NDData.
import numpy as np
from astropy import log
from astropy.units import Unit, UnitConversionError, UnitsError # noqa: F401
from .flag_collection import FlagCollection
from .mixins.ndarithmetic ... | 305 | 10,196 |
astropy | astropy/nddata/ccddata.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""This module implements the base CCDData class."""
import itertools
import numpy as np
from astropy import log
from astropy import units as u
from astropy.io import fits, registry
from astropy.utils.decorators import sharedmethod
from astropy.wcs impo... | 867 | 32,936 |
astropy | astropy/nddata/flag_collection.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import numpy as np
__all__ = ["FlagCollection"]
class FlagCollection(dict):
"""
The purpose of this class is to provide a dictionary for
containing arrays of flags for the `NDData` class. Flags should be
stored in Numpy arrays that hav... | 45 | 1,491 |
astropy | astropy/nddata/nduncertainty.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import weakref
from abc import ABCMeta, abstractmethod
from copy import deepcopy
import numpy as np
# from astropy.utils.compat import ignored
from astropy import log
from astropy.units import Quantity, Unit, UnitConversionError
__all__ = [
"Incomp... | 1,222 | 44,787 |
astropy | astropy/nddata/blocks.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
This module includes helper functions for array operations.
"""
import numpy as np
from .decorators import support_nddata
__all__ = ["block_reduce", "block_replicate", "reshape_as_blocks"]
def _process_block_inputs(data, block_size):
data = np... | 214 | 6,794 |
astropy | astropy/nddata/bitmask.py | .py | """
A module that provides functions for manipulating bit masks and data quality
(DQ) arrays.
"""
import numbers
import warnings
import numpy as np
__all__ = [
"BitFlagNameMap",
"InvalidBitFlag",
"bitfield_to_boolean_mask",
"extend_bit_flag_map",
"interpret_bit_flags",
]
_ENABLE_BITFLAG_CACHIN... | 711 | 27,392 |
astropy | astropy/nddata/nddata_base.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
# This module implements the base NDDataBase class.
from abc import ABCMeta, abstractmethod
__all__ = ["NDDataBase"]
class NDDataBase(metaclass=ABCMeta):
"""Base metaclass that defines the interface for N-dimensional datasets
with associated m... | 81 | 1,994 |
astropy | astropy/nddata/tests/test_blocks.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import numpy as np
import pytest
from astropy.nddata import block_reduce, block_replicate, reshape_as_blocks
class TestReshapeAsBlocks:
def test_1d(self):
data = np.arange(16)
reshaped = reshape_as_blocks(data, 2)
assert res... | 174 | 5,977 |
astropy | astropy/nddata/tests/test_compat.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
# This module contains tests of a class equivalent to pre-1.0 NDData.
import numpy as np
import pytest
from astropy import units as u
from astropy.nddata.compat import NDDataArray
from astropy.nddata.nddata import NDData
from astropy.nddata.nduncertaint... | 158 | 4,855 |
astropy | astropy/nddata/tests/test_nddata_base.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
# Tests of NDDataBase
from astropy.nddata.nddata_base import NDDataBase
class MinimalSubclass(NDDataBase):
def __init__(self):
super().__init__()
@property
def data(self):
return None
@property
def mask(self):
... | 85 | 1,562 |
astropy | astropy/nddata/tests/test_flag_collection.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import numpy as np
import pytest
from astropy.nddata import FlagCollection
def test_init():
FlagCollection(shape=(1, 2, 3))
def test_init_noshape():
with pytest.raises(Exception) as exc:
FlagCollection()
assert (
exc.valu... | 51 | 1,436 |
astropy | astropy/nddata/tests/test_bitmask.py | .py | """
A module containing unit tests for the `bitmask` module.
Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
import warnings
import numpy as np
import pytest
from astropy.nddata import bitmask
MAX_INT_TYPE = np.int64
MAX_UINT_TYPE = np.uint64
MAX_UINT_FLAG = np.left_shift(
MAX_UINT_TYPE(1), ... | 443 | 11,495 |
astropy | astropy/nddata/tests/test_nduncertainty.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import pickle
from collections import defaultdict
from gc import get_objects
import numpy as np
import pytest
from numpy.testing import assert_allclose, assert_array_equal
from astropy import units as u
from astropy.nddata.ccddata import CCDData
from as... | 431 | 15,536 |
astropy | astropy/nddata/tests/test_nddata.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import pickle
import textwrap
from itertools import chain, permutations
import numpy as np
import pytest
from numpy.testing import assert_array_equal
from astropy import units as u
from astropy.nddata import NDDataArray
from astropy.nddata import _test... | 708 | 22,202 |
astropy | astropy/nddata/tests/test_decorators.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import inspect
import numpy as np
import pytest
from astropy import units as u
from astropy.nddata.decorators import support_nddata
from astropy.nddata.nddata import NDData
from astropy.utils.exceptions import AstropyUserWarning
from astropy.wcs import ... | 485 | 12,516 |
astropy | astropy/nddata/tests/test_utils.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import numpy as np
import pytest
from numpy.testing import assert_allclose, assert_array_equal
from packaging.version import Version
from astropy import units as u
from astropy.coordinates import SkyCoord
from astropy.io import fits
from astropy.nddata i... | 810 | 26,962 |
astropy | astropy/nddata/tests/test_covariance.py | .py | from pathlib import Path
import numpy as np
import pytest
from astropy import units
from astropy.nddata import covariance
from astropy.table import Table
from astropy.utils.compat.optional_deps import HAS_SCIPY
from astropy.utils.exceptions import AstropyUserWarning
scipy_required = pytest.mark.skipif(not HAS_SCIPY,... | 671 | 23,417 |
astropy | astropy/nddata/tests/test_ccddata.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import os
import sys
import textwrap
import numpy as np
import pytest
from astropy import log
from astropy import units as u
from astropy.io import fits
from astropy.nddata import _testing as nd_testing
from astropy.nddata.ccddata import CCDData
from as... | 1,249 | 44,089 |
astropy | astropy/nddata/mixins/ndslicing.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
# This module implements the Slicing mixin to the NDData class.
from astropy import log
from astropy.wcs.wcsapi import (
BaseHighLevelWCS, # noqa: F401
BaseLowLevelWCS, # noqa: F401
HighLevelWCSWrapper,
SlicedLowLevelWCS,
)
__all__ = [... | 141 | 4,498 |
astropy | astropy/nddata/mixins/ndio.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
# This module implements the I/O mixin to the NDData class.
from astropy.io import registry
__all__ = ["NDIOMixin"]
__doctest_skip__ = ["NDDataRead", "NDDataWrite"]
class NDDataRead(registry.UnifiedReadWrite):
"""Read and parse gridded N-dimension... | 115 | 3,689 |
astropy | astropy/nddata/mixins/ndarithmetic.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
# This module implements the Arithmetic mixin to the NDData class.
import warnings
from copy import deepcopy
from typing import TypeVar
import numpy as np
from astropy.nddata.nduncertainty import NDUncertainty
from astropy.units import Quantity, dimensi... | 859 | 34,195 |
astropy | astropy/nddata/mixins/tests/test_ndarithmetic.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import operator
from copy import deepcopy
import numpy as np
import pytest
from numpy.testing import assert_array_almost_equal, assert_array_equal
from astropy import units as u
from astropy.nddata import CCDData, NDDataRef
from astropy.nddata import _t... | 1,593 | 59,516 |
astropy | astropy/nddata/mixins/tests/test_ndio.py | .py | from astropy.nddata import NDData, NDDataRef, NDIOMixin # noqa: F401
# Alias NDDataAllMixins in case this will be renamed ... :-)
NDDataIO = NDDataRef
def test_simple_write_read():
ndd = NDDataIO([1, 2, 3])
assert hasattr(ndd, "read")
assert hasattr(ndd, "write")
| 11 | 280 |
astropy | astropy/nddata/mixins/tests/test_ndslicing.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.nddata import NDData, NDSlicingMixin
from astropy.nddata import _testing as nd_testing
from astropy.nddata.nduncertainty import (
... | 204 | 6,024 |
astropy | astropy/stats/histogram.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
Methods for selecting the bin width of histograms.
Ported from the astroML project: https://www.astroml.org/
"""
from typing import Literal
import numpy as np
from numpy.typing import ArrayLike, NDArray
from .bayesian_blocks import bayesian_blocks... | 463 | 13,919 |
astropy | astropy/stats/nanfunctions.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
The functions in this module provide faster versions of np.nan*
functions using the optional bottleneck package if it is installed. If
bottleneck is not installed, then the np.nan* functions are used.
"""
import functools
from collections.abc import C... | 153 | 5,202 |
astropy | astropy/stats/circstats.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
This module contains simple functions for dealing with circular statistics, for
instance, mean, variance, standard deviation, correlation coefficient, and so
on. This module also cover tests of uniformity, e.g., the Rayleigh and V tests.
The Maximum L... | 615 | 22,174 |
astropy | astropy/stats/spatial.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
This module implements functions and classes for spatial statistics.
"""
import math
from typing import Literal, TypeAlias
import numpy as np
from numpy.typing import NDArray
__all__ = ["RipleysKEstimator"]
# TODO: consider replacing with `StrEnum`... | 384 | 13,966 |
astropy | astropy/stats/setup_package.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import os
from numpy import get_include as get_numpy_include
from setuptools import Extension
ROOT = os.path.relpath(os.path.dirname(__file__))
SRCFILES = ["wirth_select.c", "compute_bounds.c", "fast_sigma_clip.c"]
SRCFILES = [os.path.join(ROOT, "src", ... | 27 | 795 |
astropy | astropy/stats/__init__.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
This subpackage contains statistical tools provided for or used by Astropy.
While the `scipy.stats` package contains a wide range of statistical
tools, it is a general-purpose package, and is missing some that are
particularly useful to astronomy or a... | 45 | 1,199 |
astropy | astropy/stats/funcs.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
This module contains simple statistical algorithms that are
straightforwardly implemented as a single python function (or family of
functions).
This module should generally not be used directly. Everything in
`__all__` is imported into `astropy.stats... | 1,688 | 62,177 |
astropy | astropy/stats/biweight.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
This module contains functions for computing robust statistics using
Tukey's biweight function.
"""
from collections.abc import Callable
import numpy as np
from numpy.typing import ArrayLike, NDArray
from astropy.stats.funcs import median_absolute_d... | 800 | 29,030 |
astropy | astropy/stats/jackknife.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
from collections.abc import Callable
from typing import TypeVar
import numpy as np
from numpy.typing import NDArray
__all__ = ["jackknife_resampling", "jackknife_stats"]
__doctest_requires__ = {"jackknife_stats": ["scipy"]}
DT = TypeVar("DT", bound=np.... | 188 | 6,218 |
astropy | astropy/stats/bayesian_blocks.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""Bayesian Blocks for Time Series Analysis.
Bayesian Blocks for Time Series Analysis
========================================
Dynamic programming algorithm for solving a piecewise-constant model for
various datasets. This is based on the algorithm pres... | 603 | 21,459 |
astropy | astropy/stats/info_theory.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
This module contains simple functions for model selection.
"""
import numpy as np
__all__ = [
"akaike_info_criterion",
"akaike_info_criterion_lsq",
"bayesian_info_criterion",
"bayesian_info_criterion_lsq",
]
__doctest_requires__ = {... | 424 | 15,139 |
astropy | astropy/stats/sigma_clipping.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import warnings
from collections.abc import Callable
from typing import Literal
import numpy as np
from numpy.lib.array_utils import normalize_axis_index
from numpy.typing import ArrayLike, NDArray
from astropy.stats._fast_sigma_clip import _sigma_clip_... | 1,359 | 50,741 |
astropy | astropy/stats/tests/test_jackknife.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import numpy as np
import pytest
from numpy.testing import assert_allclose, assert_equal
from astropy.stats.jackknife import jackknife_resampling, jackknife_stats
from astropy.utils.compat.optional_deps import HAS_SCIPY
def test_jackknife_resampling():... | 63 | 2,094 |
astropy | astropy/stats/tests/test_bayesian_blocks.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import numpy as np
import pytest
from numpy.testing import assert_allclose
from astropy.stats import RegularEvents, bayesian_blocks
def test_single_change_point():
rng = np.random.default_rng(0)
x = np.concatenate([rng.random(100), 1 + rng.rand... | 206 | 6,316 |
astropy | astropy/stats/tests/test_spatial.py | .py | import numpy as np
import pytest
from numpy.testing import assert_allclose
from astropy.stats.spatial import RipleysKEstimator
from astropy.utils.misc import NumpyRNGContext
a = np.array([[1, 4], [2, 5], [3, 6]])
b = np.array([[-1, 1], [-2, 2], [-3, 3]])
@pytest.mark.parametrize("points, x_min, x_max", [(a, 0, 10),... | 138 | 5,473 |
astropy | astropy/stats/tests/test_circstats.py | .py | import numpy as np
import pytest
from numpy.testing import assert_allclose, assert_equal
from astropy import units as u
from astropy.stats.circstats import (
_length,
circcorrcoef,
circmean,
circmoment,
circvar,
rayleightest,
vonmisesmle,
vtest,
)
from astropy.utils.compat.optional_deps... | 208 | 6,194 |
astropy | astropy/stats/tests/test_biweight.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import numpy as np
import pytest
from numpy.testing import assert_allclose, assert_array_almost_equal_nulp, assert_equal
import astropy.units as u
from astropy.stats.biweight import (
biweight_location,
biweight_midcorrelation,
biweight_midco... | 589 | 19,405 |
astropy | astropy/stats/tests/test_fast_sigma_clip.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
Tests for the _sigma_clip_fast C extension in astropy.stats.
Note: The underlying C implementation assumes input data arrays are sorted.
"""
import warnings
import numpy as np
import pytest
from astropy.stats._fast_sigma_clip import _sigma_clip_fas... | 120 | 4,493 |
astropy | astropy/stats/tests/test_funcs.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import numpy as np
import pytest
from numpy.testing import assert_allclose, assert_equal
from astropy import units as u
from astropy.stats import funcs
from astropy.utils.compat.optional_deps import HAS_BOTTLENECK, HAS_MPMATH, HAS_SCIPY
from astropy.util... | 925 | 30,693 |
astropy | astropy/stats/tests/test_histogram.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import numpy as np
import pytest
from numpy.testing import assert_allclose
from astropy.stats import (
calculate_bin_edges,
freedman_bin_width,
histogram,
knuth_bin_width,
scott_bin_width,
)
from astropy.utils.compat.optional_deps imp... | 193 | 5,969 |
astropy | astropy/stats/tests/test_ks_2samp.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import numpy as np
import pytest
from numpy.testing import assert_allclose
from astropy.stats._stats import ks_2samp
def test_identical_array():
a = np.array([1.0, 2.0, 3.0, 4.0], dtype=np.float64)
assert_allclose(ks_2samp(a, a), 0.0, atol=1e-15... | 46 | 1,572 |
astropy | astropy/stats/tests/test_info_theory.py | .py | from numpy.testing import assert_allclose
from astropy.stats.info_theory import (
akaike_info_criterion,
akaike_info_criterion_lsq,
bayesian_info_criterion,
bayesian_info_criterion_lsq,
)
def test_bayesian_info_criterion():
# This test is from an example presented in Ref [1]
lnL = (-176.4, -1... | 79 | 2,339 |
astropy | astropy/stats/tests/test_sigma_clipping.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import pickle
import numpy as np
import pytest
from numpy.testing import assert_allclose, assert_equal
from astropy import units as u
from astropy.coordinates import Angle
from astropy.stats import mad_std
from astropy.stats.sigma_clipping import (
... | 741 | 24,889 |
astropy | astropy/io/__init__.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
This subpackage contains modules and packages for interpreting data storage
formats used by and in astropy.
"""
| 6 | 180 |
astropy | astropy/io/typing.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""Type annotations for ``astropy.io``.
These are type annotations for I/O-related functions and classes. Some of the type
objects can also be used as runtime-checkable :class:`~typing.Protocol` objects.
"""
__all__ = ["PathLike", "ReadableFileLike", "Wr... | 47 | 1,612 |
astropy | astropy/io/registry/__init__.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
Unified I/O Registry.
"""
from . import base, compat, core, interface
from .base import *
from .compat import *
from .compat import _identifiers, _readers, _writers # for backwards compat
from .core import *
from .interface import *
__all__ = core._... | 14 | 379 |
astropy | astropy/io/registry/compat.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import functools
from .core import UnifiedIORegistry
__all__ = [ # noqa: F822
"delay_doc_updates",
"get_formats",
"get_reader",
"get_writer",
"identify_format",
"read",
"register_identifier",
"register_reader",
"regi... | 71 | 1,896 |
astropy | astropy/io/registry/interface.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import inspect
import os
import pydoc
import re
import sys
from .base import IORegistryError
__all__ = ["UnifiedReadWrite", "UnifiedReadWriteMethod"]
# -----------------------------------------------------------------------------
class UnifiedReadWr... | 171 | 5,997 |
astropy | astropy/io/registry/base.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import contextlib
import re
import sys
import warnings
from operator import itemgetter
import numpy as np
__all__ = ["IORegistryError"]
class IORegistryError(Exception):
"""Custom error for registry clashes."""
# --------------------------------... | 481 | 18,263 |
astropy | astropy/io/registry/core.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import os
import sys
from typing import TypeVar, overload
from .base import IORegistryError, _UnifiedIORegistryBase
__all__ = ["UnifiedIORegistry", "UnifiedInputRegistry", "UnifiedOutputRegistry"]
PATH_TYPES = (str, os.PathLike) # TODO! include bytes... | 432 | 14,633 |
astropy | astropy/io/registry/tests/test_registry_help.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
from io import StringIO
import pytest
from astropy.nddata import CCDData
from astropy.table import Table
@pytest.mark.no_optimized_interpreter
def test_table_read_help_fits():
"""
Test dynamically created documentation help via the I/O registr... | 183 | 5,485 |
astropy | astropy/io/registry/tests/test_registries.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
Test :mod:`astropy.io.registry`.
.. todo::
Don't rely on Table for tests
"""
import os
from collections import Counter
from copy import deepcopy
from io import StringIO
import numpy as np
import pytest
import astropy.units as u
from astropy.... | 1,305 | 49,834 |
astropy | astropy/io/ascii/rst.py | .py | # Licensed under a 3-clause BSD style license
"""
:Author: Simon Gibbons (simongibbons@gmail.com).
"""
from .core import DefaultSplitter
from .fixedwidth import (
FixedWidth,
FixedWidthData,
FixedWidthHeader,
FixedWidthTwoLineDataSplitter,
)
class SimpleRSTHeader(FixedWidthHeader):
position_line ... | 100 | 2,826 |
astropy | astropy/io/ascii/daophot.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
An extensible ASCII table reader and writer.
Classes to read DAOphot table format
:Copyright: Smithsonian Astrophysical Observatory (2011)
:Author: Tom Aldcroft (aldcroft@head.cfa.harvard.edu)
"""
import itertools as itt
import re
from collections i... | 395 | 14,751 |
astropy | astropy/io/ascii/ipac.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""An extensible ASCII table reader and writer.
ipac.py:
Classes to read IPAC table format
:Copyright: Smithsonian Astrophysical Observatory (2011)
:Author: Tom Aldcroft (aldcroft@head.cfa.harvard.edu)
"""
import re
from collections import defaultdict... | 566 | 21,010 |
astropy | astropy/io/ascii/misc.py | .py | """A Collection of useful miscellaneous functions.
misc.py:
Collection of useful miscellaneous functions.
:Author: Hannes Breytenbach (hannes@saao.ac.za)
"""
import collections.abc
import itertools
import operator
def first_true_index(iterable, pred=None, default=None):
"""find the first index position for t... | 128 | 4,112 |
astropy | astropy/io/ascii/setup_package.py | .py | # Licensed under a 3-clause BSD style license
from pathlib import Path
from numpy import get_include as get_numpy_include
from setuptools import Extension
ROOT = Path(__file__).parent.relative_to(Path.cwd())
def get_extensions():
sources = [
str(ROOT / "cparser.pyx"),
str(ROOT / "src" / "tokeni... | 22 | 501 |
astropy | astropy/io/ascii/tdat.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""This package contains functions for reading and writing TDAT tables that are
not meant to be used directly, but instead are available as readers/writers in
`astropy.table`. See :ref:`astropy:table_io` for more details.
:Author: Daniel Giles (daniel.k.g... | 851 | 31,336 |
astropy | astropy/io/ascii/__init__.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""An extensible ASCII table reader and writer."""
from astropy import config as _config
from . import connect
from .basic import (
Basic,
BasicData,
BasicHeader,
CommentedHeader,
Csv,
NoHeader,
Rdb,
Tab,
)
from .cds impor... | 87 | 1,953 |
astropy | astropy/io/ascii/ecsv.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
Define the Enhanced Character-Separated-Values (ECSV) which allows for reading and
writing all the meta data associated with an astropy Table object.
"""
import csv
import json
import re
import warnings
from collections import OrderedDict
import nump... | 572 | 22,466 |
astropy | astropy/io/ascii/sextractor.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""sextractor.py:
Classes to read SExtractor table format.
Built on daophot.py:
:Copyright: Smithsonian Astrophysical Observatory (2011)
:Author: Tom Aldcroft (aldcroft@head.cfa.harvard.edu)
"""
import re
from . import core
class SExtractorHeader(co... | 166 | 6,254 |
astropy | astropy/io/ascii/mesa.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""mesa.py:
Classes to read MESA stellar evolution code output files (history and profile).
MESA (Modules for Experiments in Stellar Astrophysics) is a widely-used
stellar evolution code. This reader handles the standard MESA history and
profile file fo... | 278 | 9,757 |
astropy | astropy/io/ascii/connect.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
# This file connects the readers/writers to the astropy.table.Table class
import re
from astropy.io import registry as io_registry # noqa: F401
from astropy.table import Table
__all__ = []
def io_read(format, filename, **kwargs):
from .ui import... | 58 | 1,741 |
astropy | astropy/io/ascii/html.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""An extensible HTML table reader and writer.
html.py:
Classes to read and write HTML tables
`BeautifulSoup <https://www.crummy.com/software/BeautifulSoup/>`_
must be installed to read HTML tables.
"""
import warnings
from copy import deepcopy
from ... | 504 | 18,567 |
astropy | astropy/io/ascii/docs.py | .py | READ_DOCSTRING = """
Read the input ``table`` and return the table. Most of the default behavior for
various parameters is determined by the ``format`` argument.
Help on the ``read()`` function arguments is available as shown in this example::
from astropy.io import ascii
ascii.read.help() #... | 202 | 8,127 |
astropy | astropy/io/ascii/ui.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""An extensible ASCII table reader and writer.
ui.py:
Provides the main user functions for reading and writing tables.
:Copyright: Smithsonian Astrophysical Observatory (2010)
:Author: Tom Aldcroft (aldcroft@head.cfa.harvard.edu)
"""
import collectio... | 1,122 | 41,001 |
astropy | astropy/io/ascii/qdp.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
This package contains functions for reading and writing QDP tables that are
not meant to be used directly, but instead are available as readers/writers in
`astropy.table`. See :ref:`astropy:table_io` for more details.
"""
import copy
import os
import ... | 666 | 20,885 |
astropy | astropy/io/ascii/fixedwidth.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""An extensible ASCII table reader and writer.
fixedwidth.py:
Read or write a table with fixed width columns.
:Copyright: Smithsonian Astrophysical Observatory (2011)
:Author: Tom Aldcroft (aldcroft@head.cfa.harvard.edu)
"""
from . import basic, core... | 486 | 17,292 |
astropy | astropy/io/ascii/basic.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""An extensible ASCII table reader and writer.
basic.py:
Basic table read / write functionality for simple character
delimited files with various options for column header definition.
:Copyright: Smithsonian Astrophysical Observatory (2011)
:Author:... | 442 | 12,363 |
astropy | astropy/io/ascii/mrt.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""Classes to read AAS MRT table format.
Ref: https://journals.aas.org/mrt-standards
:Copyright: Smithsonian Astrophysical Observatory (2021)
:Author: Tom Aldcroft (aldcroft@head.cfa.harvard.edu), \
Suyog Garg (suyog7130@gmail.com)
"""
import r... | 688 | 28,775 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.