<commit_before># pylint: disable-msg=W0611, W0612, W0511,R0201
"""Tests suite for miscellaneous functions in timeseries module.
Adapted from the original test_ma by <NAME>

:author: <NAME> & <NAME>
:contact: pierregm_at_uga_dot_edu & mattknox_ca_at_hotmail_dot_com
:version: $Id: test_timeseries.py 2578 2007-01-17 19:25:10Z mattknox_ca $
"""
__author__ = "<NAME> & <NAME> ($Author: mattknox_ca $)"
__version__ = '1.0'
__revision__ = "$Revision: 2578 $"
__date__     = '$Date: 2007-01-17 14:25:10 -0500 (Wed, 17 Jan 2007) $'

import numpy as N
from numpy import bool_, complex_, float_, int_, object_
import numpy.core.fromnumeric  as fromnumeric
import numpy.core.numeric as numeric
from numpy.testing import NumpyTest, NumpyTestCase
from numpy.testing.utils import build_err_msg

import maskedarray
from maskedarray import masked_array, masked, nomask

import maskedarray.testutils
from maskedarray.testutils import assert_equal, assert_array_equal, approx

from timeseries import tcore

class test_funcs(NumpyTestCase):
    
    def __init__(self, *args, **kwds):
        NumpyTestCase.__init__(self, *args, **kwds)
        self.mask = [1,0,1,0,0,1,1,0,0,0]
        self.data = numeric.arange(10)
        self.test_array = masked_array(self.data, mask=self.mask)

    def test_backward_fill (self):
        result = masked_array(self.data, mask=self.mask)
        result[0] = 1
        result[2] = 3
       
        assert_equal(tcore.backward_fill(self.test_array, maxgap=1), result)
        
        result[5] = 7
        result[6] = 7
        
        assert_equal(tcore.backward_fill(self.test_array), result)

    def test_forward_fill (self):
        result = masked_array(self.data, mask=self.mask)
        result[2] = 1
       
        assert_equal(tcore.forward_fill(self.test_array, maxgap=1), result)
        
        result[5] = 4
        result[6] = 4
        
        assert_equal(tcore.forward_fill(self.test_array), result)

    def test_interp_fill(self):
        result_lin = masked_array(self.data).astype(float_)
        result_lin[0] = masked
        
        approx(tcore.interp_masked1d(self.test_array.astype(float_), kind='linear'), result_lin)
        
        
###############################################################################
#------------------------------------------------------------------------------
if __name__ == "__main__":
    NumpyTest().run()        <commit_msg>updated to reflect moving some functions from tcore to extras<commit_after># pylint: disable-msg=W0611, W0612, W0511,R0201
"""Tests suite for miscellaneous functions in timeseries module.
Adapted from the original test_ma by <NAME>

:author: <NAME> & <NAME>
:contact: pierregm_at_uga_dot_edu & mattknox_ca_at_hotmail_dot_com
:version: $Id: test_timeseries.py 2578 2007-01-17 19:25:10Z mattknox_ca $
"""
__author__ = "<NAME> & <NAME> ($Author: mattknox_ca $)"
__version__ = '1.0'
__revision__ = "$Revision: 2578 $"
__date__     = '$Date: 2007-01-17 14:25:10 -0500 (Wed, 17 Jan 2007) $'

import numpy as N
from numpy import bool_, complex_, float_, int_, object_
import numpy.core.fromnumeric  as fromnumeric
import numpy.core.numeric as numeric
from numpy.testing import NumpyTest, NumpyTestCase
from numpy.testing.utils import build_err_msg

import maskedarray
from maskedarray import masked_array, masked, nomask

import maskedarray.testutils
from maskedarray.testutils import assert_equal, assert_array_equal, approx

from timeseries import extras

class test_funcs(NumpyTestCase):
    
    def __init__(self, *args, **kwds):
        NumpyTestCase.__init__(self, *args, **kwds)
        self.mask = [1,0,1,0,0,1,1,0,0,0]
        self.data = numeric.arange(10)
        self.test_array = masked_array(self.data, mask=self.mask)

    def test_backward_fill (self):
        result = masked_array(self.data, mask=self.mask)
        result[0] = 1
        result[2] = 3
       
        assert_equal(extras.backward_fill(self.test_array, maxgap=1), result)
        
        result[5] = 7
        result[6] = 7
        
        assert_equal(extras.backward_fill(self.test_array), result)

    def test_forward_fill (self):
        result = masked_array(self.data, mask=self.mask)
        result[2] = 1
       
        assert_equal(extras.forward_fill(self.test_array, maxgap=1), result)
        
        result[5] = 4
        result[6] = 4
        
        assert_equal(extras.forward_fill(self.test_array), result)

    def test_interp_fill(self):
        result_lin = masked_array(self.data).astype(float_)
        result_lin[0] = masked
        
        approx(extras.interp_masked1d(self.test_array.astype(float_), kind='linear'), result_lin)
        
        
###############################################################################
#------------------------------------------------------------------------------
if __name__ == "__main__":
    NumpyTest().run()        
{'fraction_non_alphanumeric': 0.16639411283728536, 'fraction_numerical': 0.038430089942763694, 'mean_word_length': 3.037128712871287, 'pattern_counts': {'":': 2, '<': 13, '<?xml version=': 0, '>': 13, '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': '1355859', 'n_tokens_mistral': 1702, 'n_tokens_neox': 1555, 'n_words': 341}