<commit_before># -*- coding: utf-8 -*-

"""
test examples given in paper by comparison against reference solution.

the actual comparison is done by checking the equality of the interaction-term
with a numerical solution (generated with numerical_evaluation.py)

"""

import unittest
import numpy as np

import sys

#sys.path.append(os.path.join('..', 'mintrend'))
sys.path.append('..')
from rt1.rt1 import RT1
from rt1.volume import Rayleigh, HenyeyGreenstein
from rt1.surface import Isotropic, CosineLobe


class TestExamples(unittest.TestCase):

    def setUp(self):
        # read reference solutions for backscattering case
        fname1 = 'example1_int.csv'
        x1 = np.loadtxt('tests/' + fname1, delimiter=',',skiprows=0)
        self.inc1 = x1[:,0]
        self.int_num_1 = x1[:,1]

        fname2 = 'example2_int.csv'
        x2 = np.loadtxt('tests/' + fname2, delimiter=',',skiprows=0)
        self.inc2 = x2[:,0]
        self.int_num_2 = x2[:,1]

    def test_example_1_int(self):
        print('Testing Example 1 ...')
       
    
        inc = self.inc1
        
        # initialize output fields for faster processing
        Itot = np.ones_like(inc)*np.nan
        Isurf = np.ones_like(inc)*np.nan
        Ivol = np.ones_like(inc)*np.nan
        Iint = np.ones_like(inc)*np.nan
        
        
        
        # ---- evaluation of first example
        V = Rayleigh(tau=0.7, omega=0.3)
        SRF = CosineLobe(ncoefs=11, i=5) # 11 instead of 10 coefficients used to assure 7 digit precision
        
        fn = None
        for i in xrange(len(inc)):
            # set geometries
            mu_0 = np.cos(np.deg2rad(inc[i]))
            phi_0 = np.deg2rad(0.)
            phi_ex = phi_0 + np.pi
        
        
            R = RT1(1., mu_0, mu_0, phi_0, phi_ex, RV=V, SRF=SRF, fn=fn, geometry='mono')
            fn = R.fn  # store coefficients for faster itteration
            Itot[i], Isurf[i], Ivol[i], Iint[i] = R.calc()
    

        #for i in range(0,len(self.inc1)):
            self.assertAlmostEqual(self.int_num_1[i],Iint[i])
        

    def test_example_2_int(self):
        print('Testing Example 2 ...')

    
        inc = self.inc2
        
        # initialize output fields for faster processing
        Itot = np.ones_like(inc)*np.nan
        Isurf = np.ones_like(inc)*np.nan
        Ivol = np.ones_like(inc)*np.nan
        Iint = np.ones_like(inc)*np.nan
        
        
        # ---- evaluation of second example
        V = HenyeyGreenstein(tau=0.7, omega=0.3, t=0.7, ncoefs=20)
        SRF = CosineLobe(ncoefs=11, i=5) # 11 instead of 10 coefficients used to assure 7 digit precision
        
        
        fn = None
        for i in xrange(len(inc)):
            # set geometries
            mu_0 = np.cos(np.deg2rad(inc[i]))
            phi_0 = np.deg2rad(0.)
            phi_ex = phi_0 + np.pi
        
        
            R = RT1(1., mu_0, mu_0, phi_0, phi_ex, RV=V, SRF=SRF, fn=fn, geometry='mono')
            fn = R.fn  # store coefficients for faster itteration
            Itot[i], Isurf[i], Ivol[i], Iint[i] = R.calc()


        #for i in range(0,len(self.inc1)):
            self.assertAlmostEqual(self.int_num_2[i],Iint[i])



if __name__ == "__main__":
    unittest.main()


    
    
    <commit_msg>fixed minor path problem for example tests<commit_after># -*- coding: utf-8 -*-

"""
test examples given in paper by comparison against reference solution.

the actual comparison is done by checking the equality of the interaction-term
with a numerical solution (generated with numerical_evaluation.py)

"""

import unittest
import numpy as np

import os
import sys

#sys.path.append(os.path.join('..', 'mintrend'))
sys.path.append('..')
from rt1.rt1 import RT1
from rt1.volume import Rayleigh, HenyeyGreenstein
from rt1.surface import Isotropic, CosineLobe


class TestExamples(unittest.TestCase):

    def setUp(self):
        # read reference solutions for backscattering case
        fname1 = os.path.dirname(__file__) + os.sep + 'example1_int.csv'
        x1 = np.loadtxt(fname1, delimiter=',',skiprows=0)
        self.inc1 = x1[:,0]
        self.int_num_1 = x1[:,1]

        fname2 = os.path.dirname(__file__) + os.sep + 'example2_int.csv'
        x2 = np.loadtxt(fname2, delimiter=',',skiprows=0)
        self.inc2 = x2[:,0]
        self.int_num_2 = x2[:,1]

    def test_example_1_int(self):
        print('Testing Example 1 ...')


        inc = self.inc1

        # initialize output fields for faster processing
        Itot = np.ones_like(inc)*np.nan
        Isurf = np.ones_like(inc)*np.nan
        Ivol = np.ones_like(inc)*np.nan
        Iint = np.ones_like(inc)*np.nan



        # ---- evaluation of first example
        V = Rayleigh(tau=0.7, omega=0.3)
        SRF = CosineLobe(ncoefs=11, i=5) # 11 instead of 10 coefficients used to assure 7 digit precision

        fn = None
        for i in xrange(len(inc)):
            # set geometries
            mu_0 = np.cos(np.deg2rad(inc[i]))
            phi_0 = np.deg2rad(0.)
            phi_ex = phi_0 + np.pi


            R = RT1(1., mu_0, mu_0, phi_0, phi_ex, RV=V, SRF=SRF, fn=fn, geometry='mono')
            fn = R.fn  # store coefficients for faster itteration
            Itot[i], Isurf[i], Ivol[i], Iint[i] = R.calc()


        #for i in range(0,len(self.inc1)):
            self.assertAlmostEqual(self.int_num_1[i],Iint[i])


    def test_example_2_int(self):
        print('Testing Example 2 ...')


        inc = self.inc2

        # initialize output fields for faster processing
        Itot = np.ones_like(inc)*np.nan
        Isurf = np.ones_like(inc)*np.nan
        Ivol = np.ones_like(inc)*np.nan
        Iint = np.ones_like(inc)*np.nan


        # ---- evaluation of second example
        V = HenyeyGreenstein(tau=0.7, omega=0.3, t=0.7, ncoefs=20)
        SRF = CosineLobe(ncoefs=11, i=5) # 11 instead of 10 coefficients used to assure 7 digit precision


        fn = None
        for i in xrange(len(inc)):
            # set geometries
            mu_0 = np.cos(np.deg2rad(inc[i]))
            phi_0 = np.deg2rad(0.)
            phi_ex = phi_0 + np.pi


            R = RT1(1., mu_0, mu_0, phi_0, phi_ex, RV=V, SRF=SRF, fn=fn, geometry='mono')
            fn = R.fn  # store coefficients for faster itteration
            Itot[i], Isurf[i], Ivol[i], Iint[i] = R.calc()


        #for i in range(0,len(self.inc1)):
            self.assertAlmostEqual(self.int_num_2[i],Iint[i])



if __name__ == "__main__":
    unittest.main()





{'fraction_non_alphanumeric': 0.12503849707422235, 'fraction_numerical': 0.027717893440098552, 'mean_word_length': 2.1559766763848396, 'pattern_counts': {'":': 2, '<': 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': '5079650', 'n_tokens_mistral': 2346, 'n_tokens_neox': 2232, 'n_words': 532}