<commit_before># -*- coding: utf-8 -*-
from __future__ import division, absolute_import, unicode_literals

import datetime as dt
import numpy as np
import pytest
import aacgmv2

<EMAIL>(reason="Not meant to be run alone")
class TestModuleStructure:
    def setup(self):

        # Define the acceptable output
        if not hasattr(self, "reference_list"):
            self.reference_list = list()
        if not hasattr(self, "module_name"):
            self.module_name = None

    def teardown(self):
        del self.reference_list, self.module_name

    def test_module_existence(self):
        """Test the module existence"""

        # Get the dictionary of functions for the specified module
        retrieved_dict = aacgmv2.__dict__

        # Submodules only go one level down
        if self.module_name is None:
            assert True
        elif self.module_name != "aacgmv2":
            assert self.module_name in retrieved_dict.keys()
        else:
            assert isinstance(retrieved_dict, dict)

    def test_module_functions(self):
        """Test module function structure"""

        # Get the dictionary of functions for the specified module
        retrieved_dict = aacgmv2.__dict__

        if self.module_name is None:
            assert True
        else:
            if self.module_name != "aacgmv2":
                assert self.module_name in retrieved_dict.keys()
                retrieved_dict = retrieved_dict[self.module_name].__dict__

            # Get the functions attached to this module and make sure they
            # are supposed to be there
            retrieved_list = list()
            for name in retrieved_dict.keys():
                if callable(retrieved_dict[name]):
                    assert name in self.reference_list
                    retrieved_list.append(name)

            # Test to see if all of the modules match
            assert len(retrieved_list) == len(self.reference_list)

    def test_modules(self):
        """Test module submodule structure"""
        import os
        import pkgutil

        if self.module_name is None:
            assert True
        else:
            # Get the submodules and make sure they are supposed to be there
            retrieved_list = list()
            for imp,name,ispkg in pkgutil.iter_modules(path=aacgmv2.__path__):
                assert name in self.reference_list
                retrieved_list.append(name)                

            # Test to see if all of the modules match
            assert len(retrieved_list) == len(self.reference_list)

class TestDepStructure(TestModuleStructure):
    def setup(self):
        self.module_name = None
        self.reference_list = ["convert", "subsol", "gc2gd_lat",
                               "igrf_dipole_axis"]

    def teardown(self):
        del self.module_name, self.reference_list

    def test_dep_existence(self):
        """ Test the deprecated functions"""
        self.module_name = "deprecated"
        self.test_module_existence()

    def test_dep_functions(self):
        """ Test the deprecated functions"""
        self.module_name = "deprecated"
        self.test_module_functions()

class TestCStructure(TestModuleStructure):
    def setup(self):
        self.module_name = None
        self.reference_list = ["set_datetime", "convert", "inv_mlt_convert",
                               "inv_mlt_convert_yrsec", "mlt_convert",
                               "mlt_convert_yrsec"]

    def teardown(self):
        del self.module_name, self.reference_list

    def test_c_existence(self):
        """ Test the C module existence"""
        self.module_name = "_aacgmv2"
        self.test_module_existence()

    def test_c_functions(self):
        """ Test the C functions"""
        self.module_name = "_aacgmv2"
        self.test_module_functions()


class TestPyStructure(TestModuleStructure):
    def setup(self):
        self.module_name = None
        self.reference_list = ["convert_bool_to_bit", "convert_str_to_bit",
                               "convert_mlt", "convert_latlon",
                               "convert_latlon_arr", "get_aacgm_coord",
                               "get_aacgm_coord_arr", "set_coeff_path"]

    def teardown(self):
        del self.module_name, self.reference_list

    def test_py_existence(self):
        """ Test the python module existence"""
        self.module_name = "wrapper"
        self.test_module_existence()

    def test_py_functions(self):
        """ Test the python functions"""
        self.module_name = "wrapper"
        self.test_module_functions()


class TestTopStructure(TestModuleStructure):
    def setup(self):
        self.module_name = None
        self.reference_list = list()

    def teardown(self):
        del self.module_name, self.reference_list

    def test_top_existence(self):
        """ Test the top level existence"""
        self.module_name = "aacgmv2"
        self.test_module_existence()

    def test_top_functions(self):
        """ Test the deprecated functions"""
        self.module_name = "aacgmv2"
        self.reference_list = ["convert_bool_to_bit", "convert_str_to_bit",
                               "convert_mlt", "convert_latlon",
                               "convert_latlon_arr", "get_aacgm_coord",
                               "get_aacgm_coord_arr", "convert"]
        self.test_module_functions()

    def test_top_modules(self):
        """ Test the deprecated functions"""
        self.module_name = "aacgmv2"
        self.reference_list = ["_aacgmv2", "wrapper",
                               "deprecated", "__main__"]
        self.test_modules()

    @classmethod
    def test_top_parameters(self):
        """Test module constants"""
        from os import path

        path1 = path.join("aacgmv2", "aacgmv2", "aacgm_coeffs",
                          "aacgm_coeffs-12-")
        if aacgmv2.AACGM_v2_DAT_PREFIX.find(path1) < 0:
            raise AssertionError()

        path2 = path.join("aacgmv2", "aacgmv2", "magmodel_1590-2015.txt")
        if aacgmv2.IGRF_COEFFS.find(path2) < 0:
            raise AssertionError()

        del path1, path2<commit_msg>Update test_struct_aacgmv2.py<commit_after># -*- coding: utf-8 -*-
from __future__ import division, absolute_import, unicode_literals

import datetime as dt
import numpy as np
import pytest
import aacgmv2

<EMAIL>(reason="Not meant to be run alone")
class TestModuleStructure:
    def setup(self):

        # Define the acceptable output
        if not hasattr(self, "reference_list"):
            self.reference_list = list()
        if not hasattr(self, "module_name"):
            self.module_name = None

    def teardown(self):
        del self.reference_list, self.module_name

    def test_module_existence(self):
        """Test the module existence"""

        # Get the dictionary of functions for the specified module
        retrieved_dict = aacgmv2.__dict__

        # Submodules only go one level down
        if self.module_name is None:
            assert True
        elif self.module_name != "aacgmv2":
            assert self.module_name in retrieved_dict.keys()
        else:
            assert isinstance(retrieved_dict, dict)

    def test_module_functions(self):
        """Test module function structure"""

        # Get the dictionary of functions for the specified module
        retrieved_dict = aacgmv2.__dict__

        if self.module_name is None:
            assert True
        else:
            if self.module_name != "aacgmv2":
                assert self.module_name in retrieved_dict.keys()
                retrieved_dict = retrieved_dict[self.module_name].__dict__

            # Get the functions attached to this module and make sure they
            # are supposed to be there
            retrieved_list = list()
            for name in retrieved_dict.keys():
                if callable(retrieved_dict[name]):
                    assert name in self.reference_list
                    retrieved_list.append(name)

            # Test to see if all of the modules match
            assert len(retrieved_list) == len(self.reference_list)

    def test_modules(self):
        """Test module submodule structure"""
        import os
        import pkgutil

        if self.module_name is None:
            assert True
        else:
            # Get the submodules and make sure they are supposed to be there
            retrieved_list = list()
            for imp,name,ispkg in pkgutil.iter_modules(path=aacgmv2.__path__):
                assert name in self.reference_list
                retrieved_list.append(name)                

            # Test to see if all of the modules match
            assert len(retrieved_list) == len(self.reference_list)

class TestDepStructure(TestModuleStructure):
    def setup(self):
        self.module_name = None
        self.reference_list = ["convert", "subsol", "gc2gd_lat",
                               "igrf_dipole_axis"]

    def teardown(self):
        del self.module_name, self.reference_list

    def test_dep_existence(self):
        """ Test the deprecated functions"""
        self.module_name = "deprecated"
        self.test_module_existence()

    def test_dep_functions(self):
        """ Test the deprecated functions"""
        self.module_name = "deprecated"
        self.test_module_functions()

class TestCStructure(TestModuleStructure):
    def setup(self):
        self.module_name = None
        self.reference_list = ["set_datetime", "convert", "inv_mlt_convert",
                               "inv_mlt_convert_yrsec", "mlt_convert",
                               "mlt_convert_yrsec"]

    def teardown(self):
        del self.module_name, self.reference_list

    def test_c_existence(self):
        """ Test the C module existence"""
        self.module_name = "_aacgmv2"
        self.test_module_existence()

    def test_c_functions(self):
        """ Test the C functions"""
        self.module_name = "_aacgmv2"
        self.test_module_functions()


class TestPyStructure(TestModuleStructure):
    def setup(self):
        self.module_name = None
        self.reference_list = ["convert_bool_to_bit", "convert_str_to_bit",
                               "convert_mlt", "convert_latlon",
                               "convert_latlon_arr", "get_aacgm_coord",
                               "get_aacgm_coord_arr", "set_coeff_path"]

    def teardown(self):
        del self.module_name, self.reference_list

    def test_py_existence(self):
        """ Test the python module existence"""
        self.module_name = "wrapper"
        self.test_module_existence()

    def test_py_functions(self):
        """ Test the python functions"""
        self.module_name = "wrapper"
        self.test_module_functions()


class TestTopStructure(TestModuleStructure):
    def setup(self):
        self.module_name = None
        self.reference_list = list()

    def teardown(self):
        del self.module_name, self.reference_list

    def test_top_existence(self):
        """ Test the top level existence"""
        self.module_name = "aacgmv2"
        self.test_module_existence()

    def test_top_functions(self):
        """ Test the deprecated functions"""
        self.module_name = "aacgmv2"
        self.reference_list = ["convert_bool_to_bit", "convert_str_to_bit",
                               "convert_mlt", "convert_latlon",
                               "convert_latlon_arr", "get_aacgm_coord",
                               "get_aacgm_coord_arr", "convert"]
        self.test_module_functions()

    def test_top_modules(self):
        """ Test the deprecated functions"""
        self.module_name = "aacgmv2"
        self.reference_list = ["_aacgmv2", "wrapper",
                               "deprecated", "__main__"]
        self.test_modules()
{'fraction_non_alphanumeric': 0.08605692086816992, 'fraction_numerical': 0.004560425639726374, 'mean_word_length': 2.1587089890637503, 'pattern_counts': {'":': 4, '<': 7, '<?xml version=': 0, '>': 5, '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': '7571511', 'n_tokens_mistral': 3384, 'n_tokens_neox': 3254, 'n_words': 798}