<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-

""" Check density inversion QC test
"""

from numpy import ma

from cotede.qctests import density_inversion


def test():
    dummy_data = {
        'PRES': ma.masked_array([0.0, 100, 5000]),
        'TEMP': ma.masked_array([25.18, 19.73, 2.13]),
        'PSAL': ma.masked_array([36.00, 34.74, 34.66])
        }

    cfg = {
            'threshold': -0.03,
            'flag_good': 1,
            'flag_bad': 4
            }

    f, x = density_inversion(dummy_data, cfg, saveaux=True)

    assert (f == [0,4,4]).all()<commit_msg>Exit density inversion test if gsw is not available.<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-

""" Check density inversion QC test
"""

from numpy import ma

from cotede.qctests import density_inversion


def test():
    try:
        import gsw
    except:
        print('GSW package not available. Can\'t run density_inversion test.')
        return

    dummy_data = {
        'PRES': ma.masked_array([0.0, 100, 5000]),
        'TEMP': ma.masked_array([25.18, 19.73, 2.13]),
        'PSAL': ma.masked_array([36.00, 34.74, 34.66])
        }

    cfg = {
            'threshold': -0.03,
            'flag_good': 1,
            'flag_bad': 4
            }

    f, x = density_inversion(dummy_data, cfg, saveaux=True)

    assert (f == [0,4,4]).all()
{'fraction_non_alphanumeric': 0.15979381443298968, 'fraction_numerical': 0.060382916053019146, 'mean_word_length': 2.167832167832168, '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': '4215292', 'n_tokens_mistral': 539, 'n_tokens_neox': 474, 'n_words': 114}