<commit_before>############################################################################
# Copyright 2016 <NAME>                                          #
#                                                                          #
# Licensed under the Apache License, Version 2.0 (the "License");          #
# you may not use this file except in compliance with the License.         #
# You may obtain a copy of the License at                                  #
#                                                                          #
#     http://www.apache.org/licenses/LICENSE-2.0                           #
#                                                                          #
# Unless required by applicable law or agreed to in writing, software      #
# distributed under the License is distributed on an "AS IS" BASIS,        #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and      #
# limitations under the License.                                           #
############################################################################

""" This module emulates an assignment solver, but actually loades an
assignment matrix from disk and hands it back. """

import model

class AssignmentLoader(object):
    """ This module emulates an assignment solver, but actually loades an
    assignment matrix from disk and hands it back. """
    def __init__(self, directory):
        """ Create an assignment loader.

        Args:
        directory: Directory to load the assignment from.
        """

        assert isinstance(directory, str)
        self.directory = directory
        return

    def solve(self, par, verbose=False):
        """ Load assignment from disk.

        Args:
        par: System parameters
        verbose: Print extra messages if True

        Returns:
        The loaded assignment
        """

        if verbose:
            print('Loading assignment from', self.directory)

        return model.Assignment.load(par, directory=self.directory)

    @property
    def identifier(self):
        """ Return a string identifier for this object. """
        return self.__class__.__name__<commit_msg>Use logging module.<commit_after>############################################################################
# Copyright 2016 <NAME>                                          #
#                                                                          #
# Licensed under the Apache License, Version 2.0 (the "License");          #
# you may not use this file except in compliance with the License.         #
# You may obtain a copy of the License at                                  #
#                                                                          #
#     http://www.apache.org/licenses/LICENSE-2.0                           #
#                                                                          #
# Unless required by applicable law or agreed to in writing, software      #
# distributed under the License is distributed on an "AS IS" BASIS,        #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and      #
# limitations under the License.                                           #
############################################################################

'''This module emulates an assignment solver, but actually loades an
assignment matrix from disk and hands it back.

'''

import logging
import model
from assignments.cached import CachedAssignment

class AssignmentLoader(object):
    '''This module emulates an assignment solver, but actually loades an
    assignment matrix from disk and hands it back.

    '''
    def __init__(self, directory):
        '''Create an assignment loader.

        Args:

        directory: Directory to load the assignment from.

        '''

        assert isinstance(directory, str)
        self.directory = directory
        return

    def solve(self, parameters):
        '''Load assignment from disk.

        Args:

        par: System parameters

        Returns: The loaded assignment

        '''
        assert isinstance(parameters, model.SystemParameters)
        logging.debug('Loading assignment from %s.', self.directory)
        return CachedAssignment.load(parameters, directory=self.directory)

    @property
    def identifier(self):
        """ Return a string identifier for this object. """
        return self.__class__.__name__
{'fraction_non_alphanumeric': 0.12757562472599737, 'fraction_numerical': 0.0035072336694432268, 'mean_word_length': 1.735611510791367, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 24, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5295814', 'n_tokens_mistral': 903, 'n_tokens_neox': 859, 'n_words': 374}