<commit_before>#================================================================================
#
# Imports
#
#================================================================================
import sys
import re
import numpy as np
import basis
import copy
import enhance

#================================================================================
#
# Class definitions
#
#================================================================================
class Solution:
    'Generate the solution (initialize, ic, mesh, etc)'

    #================================================================================
    def __init__(self,icline,system,order,enhancement_type=''):
        
        print("Generating the solution.")

        # A solution contains a basis
        self.basis = basis.Basis(order)

        # It also contains initial condition information
        # parse the input parameters: name and extra parameters
        self.icname = icline.split()[0]
        self.params = icline.split()[1:]

        # And, of course, the solution information itself
        self.t   = 0
        self.n   = 0
        self.N_E = 0
        self.x   = np.empty(self.N_E+1)
        self.xc  = np.empty(self.N_E)
        self.dx  = 0
        self.u   = np.empty([self.basis.N_s, self.N_E])
        self.scaled_minv = np.empty([self.basis.N_s])

        # Manipulation functions
        self.keywords = {
            'system'  : system,
            'printer' : self.print_advection,
            'loader'  : self.load_advection,
            'riemann' : self.riemann_advection,
            'interior_flux' : self.interior_flux_advection,
            'max_wave_speed': self.max_wave_speed_advection,
            'sinewave': self.sinewave,
            'ictest'  : self.ictest,
            'evaluate_face_solution' : self.collocate_faces,
        }

        # Boundary condition type (left/right)
        self.bc_l = ''
        self.bc_r = ''

        # Apply the initial condition
        try:
            self.keywords[self.icname]()
        except Exception as e:
            print("Invalid initial condition. Exiting.\n",e)
            sys.exit()

        # Enhancement (if necessary)
        if (enhancement_type is not ''):
            self.keywords['evaluate_face_solution'] = self.enhanced_faces
            self.enhance = enhance.Enhance(order,enhancement_type,self.u.shape[1])
            
    #================================================================================
    def printer(self,nout,dt):
        """Outputs the solution to a file"""

        print("Solution written to file at step {0:7d} and time {1:e} (current time step:{2:e}).".format(self.n,self.t,dt));
        
        # Call the printing function for the specific problem type
        self.keywords['printer'](nout)


    #================================================================================
    def print_advection(self,nout):
        """Print the solution for linear advection PDE system.

        The format is chosen so that it is easy to plot using matplotlib
        """<commit_msg>Minor change to an error message.<commit_after>#================================================================================
#
# Imports
#
#================================================================================
import sys
import re
import numpy as np
import basis
import copy
import enhance

#================================================================================
#
# Class definitions
#
#================================================================================
class Solution:
    'Generate the solution (initialize, ic, mesh, etc)'

    #================================================================================
    def __init__(self,icline,system,order,enhancement_type=''):
        
        print("Generating the solution.")

        # A solution contains a basis
        self.basis = basis.Basis(order)

        # It also contains initial condition information
        # parse the input parameters: name and extra parameters
        self.icname = icline.split()[0]
        self.params = icline.split()[1:]

        # And, of course, the solution information itself
        self.t   = 0
        self.n   = 0
        self.N_E = 0
        self.x   = np.empty(self.N_E+1)
        self.xc  = np.empty(self.N_E)
        self.dx  = 0
        self.u   = np.empty([self.basis.N_s, self.N_E])
        self.scaled_minv = np.empty([self.basis.N_s])

        # Manipulation functions
        self.keywords = {
            'system'  : system,
            'printer' : self.print_advection,
            'loader'  : self.load_advection,
            'riemann' : self.riemann_advection,
            'interior_flux' : self.interior_flux_advection,
            'max_wave_speed': self.max_wave_speed_advection,
            'sinewave': self.sinewave,
            'ictest'  : self.ictest,
            'evaluate_face_solution' : self.collocate_faces,
        }

        # Boundary condition type (left/right)
        self.bc_l = ''
        self.bc_r = ''

        # Apply the initial condition
        try:
            self.keywords[self.icname]()
        except Exception as e:
            print("Invalid initial condition. This will be an empty solution.\n",e)

        # Enhancement (if necessary)
        if (enhancement_type is not ''):
            self.keywords['evaluate_face_solution'] = self.enhanced_faces
            self.enhance = enhance.Enhance(order,enhancement_type,self.u.shape[1])
            
    #================================================================================
    def printer(self,nout,dt):
        """Outputs the solution to a file"""

        print("Solution written to file at step {0:7d} and time {1:e} (current time step:{2:e}).".format(self.n,self.t,dt));
        
        # Call the printing function for the specific problem type
        self.keywords['printer'](nout)


    #================================================================================
    def print_advection(self,nout):
        """Print the solution for linear advection PDE system.

        The format is chosen so that it is easy to plot using matplotlib
        """
{'fraction_non_alphanumeric': 0.26744186046511625, 'fraction_numerical': 0.003875968992248062, 'mean_word_length': 2.7900856793145654, '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': '4776165', 'n_tokens_mistral': 1673, 'n_tokens_neox': 1550, 'n_words': 385}