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/units/function/logarithmic.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import numbers from functools import cached_property import numpy as np from astropy.units import ( CompositeUnit, Unit, UnitConversionError, UnitsError, UnitTypeError, dimensionless_unscaled, ) from .core import FunctionQuantity...
434
15,155
astropy
astropy/units/function/units.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ This package defines units that can also be used as functions of other units. If called, their arguments are used to initialize the corresponding function unit (e.g., ``u.mag(u.ct/u.s)``). Note that the prefixed versions cannot be called, as it would ...
120
3,477
astropy
astropy/units/function/core.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """Function Units and Quantities.""" from abc import ABCMeta, abstractmethod from collections.abc import Collection from functools import cached_property from typing import Self import numpy as np from numpy._core import umath as np_umath from astropy.u...
837
31,017
astropy
astropy/units/format/cds_lextab.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst # This file was automatically generated from ply. To re-generate this file, # remove it from this folder, then build astropy and run the tests in-place: # # python setup.py build_ext --inplace # pytest astropy/units # # You can then commit the changes...
21
1,397
astropy
astropy/units/format/unicode_format.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ Handles the "Unicode" unit format. """ from typing import ClassVar from astropy.units.core import NamedUnit from astropy.units.typing import UnitPower from . import console class Unicode(console.Console): """ Output-only format to display...
72
2,010
astropy
astropy/units/format/ogip.py
.py
# Licensed under a 3-clause BSD style license - see LICNSE.rst # This module includes files automatically generated from ply (these end in # _lextab.py and _parsetab.py). To generate these files, remove them from this # folder, then build astropy and run the tests in-place: # # python setup.py build_ext --inplace # ...
339
11,578
astropy
astropy/units/format/__init__.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ A collection of different unit formats. General usage is by their name in the |Unit| constructor or in the :meth:`~astropy.units.UnitBase.to_string` method, i.e., these classes rarely if ever need to be imported directly. """ import warnings from a...
89
2,318
astropy
astropy/units/format/console.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ Handles the "Console" unit format. """ from typing import ClassVar, Literal from astropy.units.core import UnitBase from astropy.units.enums import DeprecatedUnitAction from . import base class Console(base.Base): """ Output-only format f...
65
1,869
astropy
astropy/units/format/fits.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ Handles the "FITS" unit format. """ from typing import Literal import numpy as np from astropy.units.core import CompositeUnit, UnitBase from astropy.units.enums import DeprecatedUnitAction from astropy.units.errors import UnitScaleError from astro...
101
3,448
astropy
astropy/units/format/generic.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst # This module includes files automatically generated from ply (these end in # _lextab.py and _parsetab.py). To generate these files, remove them from this # folder, then build astropy and run the tests in-place: # # python setup.py build_ext --inplace #...
518
16,954
astropy
astropy/units/format/generic_lextab.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst # This file was automatically generated from ply. To re-generate this file, # remove it from this folder, then build astropy and run the tests in-place: # # python setup.py build_ext --inplace # pytest astropy/units # # You can then commit the changes...
21
1,450
astropy
astropy/units/format/vounit.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ Handles the "VOUnit" unit format. """ import re import warnings from re import Pattern from typing import ClassVar, Literal import numpy as np from astropy.extern.ply.lex import LexToken from astropy.units.core import ( CompositeUnit, NamedU...
223
8,093
astropy
astropy/units/format/latex.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ Handles the "LaTeX" unit format. """ import re from typing import ClassVar, Literal from astropy.units.core import NamedUnit, UnitBase from astropy.units.enums import DeprecatedUnitAction from astropy.units.typing import UnitPower from . import con...
93
3,006
astropy
astropy/units/format/base.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import warnings from collections.abc import Iterable from typing import ClassVar, Literal, assert_never import numpy as np from astropy.extern.ply.lex import LexToken from astropy.units.core import ( CompositeUnit, NamedUnit, Unit, UnitB...
335
11,817
astropy
astropy/units/format/ogip_lextab.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst # This file was automatically generated from ply. To re-generate this file, # remove it from this folder, then build astropy and run the tests in-place: # # python setup.py build_ext --inplace # pytest astropy/units # # You can then commit the changes...
21
1,685
astropy
astropy/units/format/cds.py
.py
# Licensed under a 3-clause BSD style license - see LICNSE.rst # This module includes files automatically generated from ply (these end in # _lextab.py and _parsetab.py). To generate these files, remove them from this # folder, then build astropy and run the tests in-place: # # python setup.py build_ext --inplace # ...
253
7,820
astropy
astropy/units/tests/test_photometric.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ Tests for the photometric module. Note that this is shorter than might be expected because a lot of the relevant tests that deal with magnidues are in `test_logarithmic.py` """ from astropy.tests.helper import assert_quantity_allclose from astropy.u...
45
1,167
astropy
astropy/units/tests/test_format.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ Regression tests for the units.format package """ import re import warnings from collections.abc import Iterable from contextlib import nullcontext from fractions import Fraction from typing import NamedTuple import numpy as np import pytest from num...
1,238
40,665
astropy
astropy/units/tests/test_quantity_decorator.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst # STDLIB import typing # THIRD PARTY import numpy as np import pytest # LOCAL from astropy import units as u # list of pairs (target unit/physical type, input unit) x_inputs = [ (u.arcsec, u.deg), ("angle", u.deg), (u.kpc / u.Myr, u.km / u....
490
12,358
astropy
astropy/units/tests/test_quantity_erfa_ufuncs.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ Test Structured units and quantities specifically with the ERFA ufuncs. """ import numpy as np import pytest from erfa import ufunc as erfa_ufunc from numpy.testing import assert_array_equal from astropy import units as u from astropy.tests.helper im...
703
27,525
astropy
astropy/units/tests/test_quantity_annotations.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import pytest from astropy import units as u from astropy.units import Quantity def test_ignore_generic_type_annotations(): """Test annotations that are not unit related are ignored. This test passes if the function works. """ # one u...
354
9,880
astropy
astropy/units/tests/test_deprecated.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import warnings import pytest from astropy import units as u from astropy.units import deprecated from astropy.utils.exceptions import AstropyDeprecationWarning with warnings.catch_warnings(action="ignore", category=AstropyDeprecationWarning): emu ...
71
2,053
astropy
astropy/units/tests/test_quantity_info.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """Test the propagation of info on Quantity during operations.""" import copy import numpy as np import pytest from astropy import units as u def assert_info_equal(a, b, ignore=set()): a_info = a.info b_info = b.info for attr in (a_info.at...
180
5,092
astropy
astropy/units/tests/test_quantity.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """Test the Quantity class and related.""" import copy import decimal import numbers import operator import pickle from fractions import Fraction import numpy as np import pytest from numpy.testing import assert_allclose, assert_array_almost_equal, asser...
2,138
70,399
astropy
astropy/units/tests/test_units.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """Regression tests for the units package.""" import itertools import operator import pickle from contextlib import nullcontext from fractions import Fraction import numpy as np import pytest from numpy.testing import assert_allclose from astropy import...
1,344
39,733
astropy
astropy/units/tests/test_quantity_typing.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """Test the Quantity class and related.""" from typing import Annotated, Any, get_args, get_origin, get_type_hints import numpy as np from astropy import units as u class TestQuantityTyping: """Test Quantity Typing Annotations.""" def test_qu...
79
2,573
astropy
astropy/units/tests/test_logarithmic.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ Test the Logarithmic Units and Quantities """ import pickle import numpy as np import pytest from numpy.testing import assert_allclose from astropy import constants as c from astropy import units as u from astropy.tests.helper import assert_quantity...
1,064
37,293
astropy
astropy/units/tests/test_structured.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ Test Structured units and quantities. """ import copy import numpy as np import numpy.lib.recfunctions as rfn import pytest from numpy.testing import assert_array_equal from astropy import units as u from astropy.tests.helper import check_pickling_r...
769
30,756
astropy
astropy/units/tests/test_equivalencies.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """Separate tests specifically for equivalencies.""" import numpy as np # THIRD-PARTY import pytest from numpy.testing import assert_allclose # LOCAL from astropy import constants from astropy import units as u from astropy.tests.helper import assert_qu...
1,045
35,154
astropy
astropy/units/tests/test_quantity_array_methods.py
.py
# The purpose of these tests are to ensure that calling quantities using # array methods returns quantities with the right units, or raises exceptions. import numpy as np import pytest from numpy.testing import assert_array_equal from astropy import units as u from astropy.utils.compat.optional_deps import HAS_ARRAY_...
609
21,367
astropy
astropy/units/tests/test_aliases.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """Test setting and adding unit aliases.""" import pytest import astropy.units as u trials = [ ({"Angstroms": u.AA}, "Angstroms", u.AA), ({"counts": u.count}, "counts/s", u.count / u.s), ( {"ergs": u.erg, "Angstroms": u.AA}, ...
90
3,058
astropy
astropy/units/tests/test_quantity_ufuncs.py
.py
# The purpose of these tests are to ensure that calling ufuncs with quantities # returns quantities with the right units, or raises exceptions. import concurrent.futures import dataclasses import warnings from collections.abc import Callable from typing import NamedTuple import numpy as np import pytest from erfa imp...
1,716
61,929
astropy
astropy/units/tests/test_physical.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ Unit tests for the handling of physical types in `astropy.units`. """ import pickle import pytest from astropy import units as u from astropy.constants import hbar from astropy.units import physical unit_physical_type_pairs = [ (u.m, "length")...
530
19,101
astropy
astropy/units/tests/test_quantity_helpers.py
.py
""" Test ``allclose`` and ``isclose``. ``allclose`` was ``quantity_allclose`` in ``astropy.tests.helper``. """ import numpy as np import pytest from astropy import units as u @pytest.mark.parametrize( ("a", "b"), [ ([1, 2], [1, 2]), ([1, 2] * u.m, [100, 200] * u.cm), (1 * u.s, 1000 *...
35
724
astropy
astropy/units/tests/test_docgen.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst # ruff: noqa: FLY002 import textwrap from importlib.util import module_from_spec, spec_from_file_location import pytest from astropy.tests.helper import _skip_docstring_tests_with_optimized_python def test_composite_unit_definition(tmp_path): # R...
140
4,116
astropy
astropy/units/tests/test_quantity_non_ufuncs.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import inspect import itertools from io import StringIO from types import FunctionType, ModuleType import numpy as np import numpy.lib.recfunctions as rfn import pytest from numpy.testing import assert_allclose, assert_array_equal from numpy.testing.over...
2,924
100,316
astropy
astropy/units/quantity_helper/scipy_special.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """Quantity helpers for the scipy.special ufuncs. Available ufuncs in this module are at https://docs.scipy.org/doc/scipy/reference/special.html """ from astropy.units.core import dimensionless_unscaled from astropy.units.errors import UnitsError, UnitTy...
91
3,051
astropy
astropy/units/quantity_helper/erfa.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """Quantity helpers for the ERFA ufuncs.""" # Tests for these are in coordinates, not in units. # Note that when this is imported, the unit definitions have not yet # been completed, so we import units locally. # We also avoid importing erfa up front since...
534
15,415
astropy
astropy/units/quantity_helper/__init__.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """Helper functions for Quantity. In particular, this implements the logic that determines scaling and result units for a given ufunc, given input units. """ from .converters import * # isort: split # By importing helpers, all the unit conversion functi...
17
588
astropy
astropy/units/quantity_helper/function_helpers.py
.py
# Licensed under a 3-clause BSD style license. See LICENSE.rst except # for parts explicitly labelled as being (largely) copies of numpy # implementations; for those, see licenses/NUMPY_LICENSE.rst. """Helpers for overriding numpy functions. We override numpy functions in `~astropy.units.Quantity.__array_function__`. ...
1,654
52,686
astropy
astropy/units/quantity_helper/converters.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """Converters for Quantity.""" import threading import numpy as np from astropy.units.core import dimensionless_unscaled from astropy.units.errors import UnitConversionError, UnitsError, UnitTypeError __all__ = [ "UFUNC_HELPERS", "UNSUPPORTED_U...
395
15,899
astropy
astropy/units/quantity_helper/helpers.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst # The idea for this module (but no code) was borrowed from the # quantities (http://pythonhosted.org/quantities/) package. """Helper functions for Quantity. In particular, this implements the logic that determines scaling and result units for a given ufun...
607
18,678
astropy
astropy/table/operations.py
.py
"""High-level table operations. - join() - setdiff() - hstack() - vstack() - dstack() """ # Licensed under a 3-clause BSD style license - see LICENSE.rst import collections import itertools import warnings from collections import Counter, OrderedDict from collections.abc import Sequence from copy import deepcopy imp...
1,882
68,753
astropy
astropy/table/table.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import itertools import sys import types import warnings import weakref from collections import OrderedDict, defaultdict from collections.abc import Mapping from copy import deepcopy from pathlib import Path from typing import Any import numpy as np from ...
4,437
161,389
astropy
astropy/table/index.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ Table Indexing Implementation for Astropy Tables ================================================ This module implements indexing functionality for astropy Table objects, enabling fast lookups and range queries on table columns. The indexing system u...
1,326
46,851
astropy
astropy/table/column.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import itertools import warnings import weakref from copy import deepcopy import numpy as np from numpy import ma from astropy.units import Quantity, StructuredUnit, Unit from astropy.utils.compat import NUMPY_LT_2_5 from astropy.utils.console import co...
1,899
69,294
astropy
astropy/table/_dataframes.py
.py
""" DataFrame conversion utilities for Astropy Tables. This module provides utility functions for converting between Astropy Tables and various DataFrame formats (pandas, polars, pyarrow, etc) via the narwhals library. """ from __future__ import annotations import math import warnings from collections.abc import Map...
560
19,841
astropy
astropy/table/setup_package.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst 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 = [ROOT / "_np_utils.pyx", ROOT / "_column_mixins.pyx"...
26
582
astropy
astropy/table/row.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import collections from collections import OrderedDict from operator import index as operator_index import numpy as np class Row: """A class to represent one row of a Table object. A Row object is returned when a Table object is indexed with a...
225
7,122
astropy
astropy/table/pandas.py
.py
ascii_coded = ( "Ò♙♙♙♙♙♙♙♙♌♐♐♌♙♙♙♙♙♙♌♌♙♙Ò♙♙♙♙♙♙♙♘♐♐♐♈♙♙♙♙♙♌♐♐♐♔Ò♙♙♌♈♙♙♌♐♈♈♙♙♙♙♙♙♙♙♈♐♐♙Ò♙♐♙♙♙♐♐♙♙♙" "♙♙♙♙♙♙♙♙♙♙♙♙Ò♐♔♙♙♘♐♐♙♙♌♐♐♔♙♙♌♌♌♙♙♙♌Ò♐♐♙♙♘♐♐♌♙♈♐♈♙♙♙♈♐♐♙♙♘♔Ò♐♐♌♙♘♐♐♐♌♌♙♙♌♌♌♙♈♈♙♌♐" "♐Ò♘♐♐♐♌♐♐♐♐♐♐♌♙♈♙♌♐♐♐♐♐♔Ò♘♐♐♐♐♐♐♐♐♐♐♐♐♈♈♐♐♐♐♐♐♙Ò♙♘♐♐♐♐♈♐♐♐♐♐♐♙♙♐♐♐♐♐♙♙Ò♙♙♙♈♈♈♙♙♐" "♐♐♐♐♔♙♐♐♐♐♈♙♙Ò♙♙♙♙♙♙♙♙♙♈♈♐♐♐♙♈♈♈♙♙♙♙Ò"...
34
1,724
astropy
astropy/table/info.py
.py
""" Table property for providing information about table. """ import os # Licensed under a 3-clause BSD style license - see LICENSE.rst import sys from contextlib import contextmanager import numpy as np from astropy.utils.data_info import DataInfo __all__ = ["TableInfo", "serialize_method_as", "table_info"] def...
220
7,454
astropy
astropy/table/pprint.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import fnmatch import os import re import sys from shutil import get_terminal_size import numpy as np from astropy import log, table from astropy.utils.console import Getch, color_print, conf from astropy.utils.data_info import dtype_info_name __all__ ...
894
31,750
astropy
astropy/table/__init__.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import astropy.config as _config from astropy.utils.compat import optional_deps from .column import Column, ColumnInfo, MaskedColumn, StringTruncateWarning __all__ = [ "BST", "Column", "ColumnGroups", "ColumnInfo", "Conf", "JSVie...
142
3,996
astropy
astropy/table/connect.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst from __future__ import annotations import itertools import warnings from typing import TYPE_CHECKING, Literal, NotRequired, TypedDict from astropy.io import registry from astropy.utils.exceptions import AstropyWarning from .info import serialize_method_...
328
11,714
astropy
astropy/table/table_helpers.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ Helper functions for table development, mostly creating useful tables for testing. """ import string import warnings from itertools import cycle import numpy as np from astropy.io.votable.table import parse from astropy.utils.data import get_pkg_da...
177
5,190
astropy
astropy/table/groups.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import warnings import numpy as np from astropy.utils.exceptions import AstropyUserWarning from .index import get_index_by_names __all__ = ["ColumnGroups", "TableGroups"] def table_group_by(table, keys): # index copies are unnecessary and slow d...
441
14,959
astropy
astropy/table/soco.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ The SCEngine class uses the ``sortedcontainers`` package to implement an Index engine for Tables. """ from collections import OrderedDict from collections.abc import Hashable, Mapping, Sequence from numbers import Integral from astropy.utils.compat....
196
5,741
astropy
astropy/table/serialize.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import itertools from collections import OrderedDict from copy import deepcopy from importlib import import_module import numpy as np from astropy.units.quantity import QuantityInfo from astropy.utils.data_info import MixinInfo from .column import Colum...
539
22,677
astropy
astropy/table/notebook_backends.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """Backend implementations for `~astropy.table.Table` interface with Jupyter notebooks. """ __all__ = ["classic", "ipydatagrid"] # NOTE: The actual deprecation warning is emitted in show_in_notebook # method in table.py module. def classic( table, ...
132
4,487
astropy
astropy/table/bst.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import operator from collections.abc import Hashable, Mapping, Sequence from numbers import Integral import numpy as np from astropy.utils.decorators import deprecated __all__ = ["BST"] class MaxValue: """ Represents an infinite value for purp...
518
15,095
astropy
astropy/table/jsviewer.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst from pathlib import Path from warnings import warn import astropy.config as _config import astropy.io.registry as io_registry from astropy import extern from .table import Table class Conf(_config.ConfigNamespace): """ Configuration parameters...
250
7,508
astropy
astropy/table/ndarray_mixin.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import numpy as np from astropy.utils.data_info import ParentDtypeInfo class NdarrayMixinInfo(ParentDtypeInfo): _represent_as_dict_primary_data = "data" def _represent_as_dict(self): """Represent Column as a dict that can be serialized...
66
2,118
astropy
astropy/table/sorted_array.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst from collections.abc import Hashable, Mapping, Sequence from numbers import Integral from typing import TYPE_CHECKING import numpy as np if TYPE_CHECKING: from .table import Column, Table def _searchsorted(array, val, side="left"): """ Call...
346
10,651
astropy
astropy/table/meta.py
.py
import copy import json import textwrap from collections import OrderedDict import numpy as np import yaml __all__ = ["get_header_from_yaml", "get_yaml_from_header", "get_yaml_from_table"] class ColumnOrderList(list): """ List of tuples that sorts in a specific order that makes sense for astropy table c...
422
13,553
astropy
astropy/table/tests/test_subclass.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst from astropy import table from astropy.table import pprint class MyRow(table.Row): def __str__(self): return str(self.as_void()) class MyColumn(table.Column): pass class MyMaskedColumn(table.MaskedColumn): pass class MyTableCo...
98
2,425
astropy
astropy/table/tests/test_df.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import io import json import numpy as np import pytest from numpy.testing import assert_allclose, assert_array_equal from astropy import table from astropy import units as u from astropy.table import MaskedColumn, Table from astropy.time import Time, Tim...
773
29,283
astropy
astropy/table/tests/test_masked.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """Test behavior related to masked tables""" import numpy as np import numpy.ma as ma import pytest from numpy.testing import assert_array_equal import astropy.units as u from astropy.table import Column, MaskedColumn, QTable, Table from astropy.table.co...
697
26,842
astropy
astropy/table/tests/test_np_utils.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst from dataclasses import dataclass import numpy as np import pytest from numpy.testing import assert_array_equal from astropy.table._np_utils import join_inner # Strict type aliases for 1D index arrays and 1D boolean mask arrays IndexArray = np.ndarray[...
359
13,248
astropy
astropy/table/tests/test_jsviewer.py
.py
import textwrap from os.path import abspath, dirname, join import pytest from astropy import extern from astropy.coordinates import SkyCoord from astropy.table.table import Table from astropy.time import Time from astropy.utils.compat.optional_deps import ( HAS_BLEACH, HAS_IPYDATAGRID, HAS_IPYTHON, HA...
255
7,515
astropy
astropy/table/tests/test_pprint.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import sys from io import StringIO from shutil import get_terminal_size import numpy as np import pytest from astropy import table from astropy import units as u from astropy.io import ascii from astropy.table import Column, QTable, Table from astropy....
1,266
41,992
astropy
astropy/table/tests/test_init_table.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst from collections import OrderedDict, UserDict from collections.abc import Mapping import numpy as np import pytest from numpy.testing import assert_array_equal import astropy.units as u from astropy.table import Column, MaskedColumn, QTable, Table, Tabl...
666
23,870
astropy
astropy/table/tests/test_mixin.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import copy import pickle from io import StringIO import numpy as np import pytest from astropy import coordinates, time from astropy import units as u from astropy.coordinates import EarthLocation, SkyCoord from astropy.coordinates.tests.test_represen...
1,062
34,338
astropy
astropy/table/tests/test_serialize.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """Tests for functions in astropy.table.serialize""" import numpy as np import pytest from astropy.table import QTable, Table from astropy.table.serialize import represent_nd_columns_as_1d_columns from astropy.time import Time class TestRepresentNdColu...
138
5,605
astropy
astropy/table/tests/test_array.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import numpy as np import pytest from astropy.table.sorted_array import SortedArray from astropy.table.table import Table @pytest.fixture def array(): # composite index col0 = np.array([x % 2 for x in range(1, 11)]) col1 = np.array(list(ran...
46
1,331
astropy
astropy/table/tests/test_info.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import warnings from collections import OrderedDict from copy import deepcopy from io import StringIO import numpy as np import pytest from astropy import coordinates, table, time from astropy import units as u from astropy.table.info import serialize_...
401
12,182
astropy
astropy/table/tests/test_column.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import copy import operator import warnings from inspect import currentframe, getframeinfo import numpy as np import pytest from numpy.testing import assert_array_equal from astropy import table, time from astropy import units as u from astropy.table.co...
1,250
40,690
astropy
astropy/table/tests/test_column_mixins.py
.py
from dataclasses import dataclass from typing import Generic, TypeVar import numpy as np import pytest from numpy.typing import NDArray from astropy.table._column_mixins import _ColumnGetitemShim, _MaskedColumnGetitemShim class MinimalColumn(_ColumnGetitemShim, np.ndarray): """Minimal concrete class derived fro...
149
4,711
astropy
astropy/table/tests/test_table.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import copy import gc import os import pathlib import pickle import sys from collections import OrderedDict from contextlib import nullcontext from inspect import currentframe, getframeinfo from io import StringIO import numpy as np import pytest from nu...
3,412
113,994
astropy
astropy/table/tests/test_row.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import sys import numpy as np import pytest from numpy.testing import assert_array_equal from astropy import table from astropy import units as u from astropy.table import Row from .conftest import MaskedTable def test_masked_row_with_object_col(): ...
389
12,508
astropy
astropy/table/tests/test_bst.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import pytest from astropy.table.bst import BST from astropy.utils.exceptions import AstropyDeprecationWarning def get_tree(TreeType): # BST is deprecated, so its constructor emits the warning here. with pytest.warns(AstropyDeprecationWarning, ...
112
2,859
astropy
astropy/table/tests/test_groups.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 arrays from hypothesis.strategies import integers from astropy import coordinates, time from astropy import units as u from astropy.table import Column, Nda...
787
24,771
astropy
astropy/table/tests/test_showtable.py
.py
import os import re import numpy as np import pytest from astropy.table.scripts import showtable from astropy.units import UnitsWarning ROOT = os.path.abspath(os.path.dirname(__file__)) ASCII_ROOT = os.path.join(ROOT, "..", "..", "io", "ascii", "tests") FITS_ROOT = os.path.join(ROOT, "..", "..", "io", "fits", "tests...
217
6,395
astropy
astropy/table/tests/test_pickle.py
.py
import pickle import numpy as np from astropy.coordinates import Angle, SkyCoord from astropy.table import Column, MaskedColumn, QTable, Table from astropy.table.table_helpers import simple_table from astropy.time import Time from astropy.units import Quantity, deg def test_pickle_column(protocol): c = Column( ...
181
4,924
astropy
astropy/table/tests/test_operations.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import re from collections import OrderedDict from contextlib import nullcontext import numpy as np import pytest from numpy.testing import assert_array_equal import astropy.table.operations as ato from astropy import table from astropy import units as ...
2,748
94,970
astropy
astropy/table/tests/test_item_access.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """Verify item access API in: https://github.com/astropy/astropy/wiki/Table-item-access-definition """ import numpy as np import pytest from astropy.table import Row @pytest.mark.usefixtures("table_data") class BaseTestItems: pass @pytest.mark....
262
9,267
astropy
astropy/table/tests/test_index.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import io import warnings import numpy as np import numpy.testing as npt import pytest from astropy import units as u from astropy.table import Column, QTable, Row, Table, hstack from astropy.table.bst import BST from astropy.table.column import BaseCol...
1,179
39,782
astropy
astropy/table/tests/conftest.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ All of the pytest fixtures used by astropy.table are defined here. `conftest.py` is a "special" module name for pytest that is always imported, but is not looked in for tests, and it is the recommended place to put fixtures that are shared between mod...
271
7,719
astropy
astropy/table/scripts/showtable.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ ``showtable-astropy`` is a command-line script based on ``astropy.io`` and ``astropy.table`` for printing ASCII, FITS, HDF5 or VOTable files(s) to the standard output. Example usage of ``showtable-astropy``: 1. FITS:: $ showtable-astropy astropy...
199
6,114
astropy
astropy/table/mixins/registry.py
.py
# This module handles the definition of mixin 'handlers' which are functions # that given an arbitrary object (e.g. a dask array) will return an object that # can be used as a mixin column. This is useful because it means that users can # then add objects to tables that are not formally mixin columns and where # adding...
81
2,711
astropy
astropy/table/mixins/dask.py
.py
import dask.array as da from astropy.utils.data_info import ParentDtypeInfo __all__ = ["as_dask_column"] class DaskInfo(ParentDtypeInfo): @staticmethod def default_format(val): return f"{val.compute()}" class DaskColumn(da.Array): info = DaskInfo() def copy(self): # Array hard-cod...
38
1,008
astropy
astropy/table/mixins/tests/test_registry.py
.py
from copy import copy import pytest from numpy.testing import assert_equal from astropy.table import Column, Table from astropy.table.mixins.registry import ( MixinRegistryError, _handlers, get_mixin_handler, register_mixin_handler, ) from astropy.table.table_helpers import ArrayWrapper ORIGINAL = {}...
125
3,125
astropy
astropy/table/mixins/tests/test_dask.py
.py
import numpy as np import pytest from numpy.testing import assert_equal from astropy.table import Table da = pytest.importorskip("dask.array") class TestDaskHandler: def setup_method(self, method): self.t = Table() self.t["a"] = da.arange(10) def test_add_row(self): self.t.add_row(s...
71
2,041
astropy
astropy/tests/runner.py
.py
"""Implements the Astropy TestRunner which is a thin wrapper around pytest.""" import copy import glob import inspect import os import shlex import sys import tempfile import warnings from functools import wraps from importlib.util import find_spec from astropy.utils import deprecated, find_current_module from astrop...
591
21,643
astropy
astropy/tests/__init__.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ This package contains utilities to run the astropy test suite, tools for writing tests, and general tests that are not associated with a particular package. """
7
229
astropy
astropy/tests/test_logger.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import importlib import locale import logging import sys import warnings import pytest from astropy import log from astropy.logger import _WITHIN_IPYTHON, LoggingError, conf from astropy.utils.exceptions import AstropyUserWarning, AstropyWarning # Save...
504
15,770
astropy
astropy/tests/helper.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ This module provides the tools used to internally run the astropy test suite from the installed astropy. It makes use of the |pytest| testing framework. """ import os import pickle import sys import pytest from astropy.units import allclose as quan...
151
5,183
astropy
astropy/tests/tests/test_imports.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import pkgutil import subprocess import sys from pathlib import Path from textwrap import dedent from types import ModuleType import pytest import astropy @pytest.mark.parametrize( "subpkg", [subpkg.name for subpkg in pkgutil.walk_packages(ast...
70
1,872
astropy
astropy/tests/tests/test_runner.py
.py
import pytest from astropy.tests.helper import _skip_docstring_tests_with_optimized_python # Renamed these imports so that them being in the namespace will not # cause pytest 3 to discover them as tests and then complain that # they have __init__ defined. from astropy.tests.runner import TestRunner as _TestRunner fro...
108
3,000
astropy
astropy/tests/tests/test_run_tests.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import pytest # test helper.run_tests function from astropy import test as run_tests from astropy.utils.exceptions import AstropyDeprecationWarning # run_tests should raise ValueError when asked to run on a module it can't find def test_module_not_found...
25
770
astropy
astropy/tests/tests/test_quantity_helpers.py
.py
import pytest from astropy import units as u from astropy.tests.helper import assert_quantity_allclose def test_assert_quantity_allclose(): assert_quantity_allclose([1, 2], [1, 2]) assert_quantity_allclose([1, 2] * u.m, [100, 200] * u.cm) assert_quantity_allclose([1, 2] * u.m, [101, 201] * u.cm, atol=2...
46
1,538