<commit_before>import os.path

import pytest
from astropy.tests.helper import remote_data
from astropy.table import Table
from astropy.units import arcsec

from ...xmatch import XMatch


DATA_DIR = os.path.join(os.path.dirname(__file__), 'data')


# fixture only used here to save creating XMatch instances in each
# of the following test functions
@pytest.fixture
def xmatch():
    return XMatch()


@remote_data
def test_xmatch_avail_tables(xmatch):
    tables = xmatch.get_available_tables()
    assert tables
    # those example tables are from
    # http://cdsxmatch.u-strasbg.fr/xmatch/doc/API-calls.html
    assert 'II/311/wise' in tables
    assert 'II/246/out' in tables


@remote_data
def test_xmatch_is_avail_table(xmatch):
    assert xmatch.is_table_available('II/311/wise')
    assert xmatch.is_table_available('II/246/out')
    assert not xmatch.is_table_available('vizier:II/311/wise')


@remote_data
def test_xmatch_query(xmatch):
    with open(os.path.join(DATA_DIR, 'posList.csv')) as pos_list:
        table = xmatch.query(
            cat1=pos_list, cat2='vizier:II/246/out', max_distance=5 * arcsec,
            colRA1='ra', colDec1='dec')
        assert isinstance(table, Table)
        assert table.colnames == [
            'angDist', 'ra', 'dec', '2MASS', 'RAJ2000', 'DEJ2000',
            'errHalfMaj', 'errHalfMin', 'errPosAng', 'Jmag', 'Hmag', 'Kmag',
            'e_Jmag', 'e_Hmag', 'e_Kmag', 'Qfl', 'Rfl', 'X', 'MeasureJD']
        assert len(table) == 11


@remote_data
def test_xmatch_query_astropy_table(xmatch):
    with open(os.path.join(DATA_DIR, 'posList.csv')) as pos_list:
        input_table = Table.read(pos_list, names=['ra', 'dec'], format='ascii')
    table = xmatch.query(
        cat1=input_table, cat2='vizier:II/246/out', max_distance=5 * arcsec)<commit_msg>[trivial] outdent unnecessarily indented code in test function<commit_after>import os.path

import pytest
from astropy.tests.helper import remote_data
from astropy.table import Table
from astropy.units import arcsec

from ...xmatch import XMatch


DATA_DIR = os.path.join(os.path.dirname(__file__), 'data')


# fixture only used here to save creating XMatch instances in each
# of the following test functions
@pytest.fixture
def xmatch():
    return XMatch()


@remote_data
def test_xmatch_avail_tables(xmatch):
    tables = xmatch.get_available_tables()
    assert tables
    # those example tables are from
    # http://cdsxmatch.u-strasbg.fr/xmatch/doc/API-calls.html
    assert 'II/311/wise' in tables
    assert 'II/246/out' in tables


@remote_data
def test_xmatch_is_avail_table(xmatch):
    assert xmatch.is_table_available('II/311/wise')
    assert xmatch.is_table_available('II/246/out')
    assert not xmatch.is_table_available('vizier:II/311/wise')


@remote_data
def test_xmatch_query(xmatch):
    with open(os.path.join(DATA_DIR, 'posList.csv')) as pos_list:
        table = xmatch.query(
            cat1=pos_list, cat2='vizier:II/246/out', max_distance=5 * arcsec,
            colRA1='ra', colDec1='dec')
    assert isinstance(table, Table)
    assert table.colnames == [
        'angDist', 'ra', 'dec', '2MASS', 'RAJ2000', 'DEJ2000',
        'errHalfMaj', 'errHalfMin', 'errPosAng', 'Jmag', 'Hmag', 'Kmag',
        'e_Jmag', 'e_Hmag', 'e_Kmag', 'Qfl', 'Rfl', 'X', 'MeasureJD']
    assert len(table) == 11


@remote_data
def test_xmatch_query_astropy_table(xmatch):
    with open(os.path.join(DATA_DIR, 'posList.csv')) as pos_list:
        input_table = Table.read(pos_list, names=['ra', 'dec'], format='ascii')
    table = xmatch.query(
        cat1=input_table, cat2='vizier:II/246/out', max_distance=5 * arcsec)
{'fraction_non_alphanumeric': 0.1325268078086335, 'fraction_numerical': 0.021996150673632114, 'mean_word_length': 3.956403269754768, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6951082', 'n_tokens_mistral': 1342, 'n_tokens_neox': 1277, 'n_words': 280}