<commit_before>import unittest

from streamsx.topology.topology import *
from streamsx.topology import context
from streamsx.topology.schema import CommonSchema, StreamSchema
from streamsx.topology.state import ConsistentRegionConfig
from streamsx.topology.tester import Tester
from streamsx.spl import op

def ModTwo(arg):
    return arg % 2;

# Test partitioned windows in python topology operators.
class TestPythonWindowPartition(unittest.TestCase):
    _multiprocess_can_split_ = True

    def setUp(self):
        Tester.setup_standalone(self)

    # Partition by attribute not supported for common schema
    def test_common_schema_python(self):
        topo = Topology()
        s = topo.source([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15])
        self.assertIs(s.oport.schema, CommonSchema.Python)
        # We cannot partition by attribute because the attributes are not
        # named
        with self.assertRaises(ValueError):
            s = s.last(10).trigger(2).partition('a').aggregate(lambda x: float(sum(x))/float(len(x)))<commit_msg>Remove unneeded import from test2_python_window_partition.py<commit_after>import unittest

from streamsx.topology.topology import *
from streamsx.topology import context
from streamsx.topology.schema import CommonSchema, StreamSchema
from streamsx.topology.tester import Tester
from streamsx.spl import op

def ModTwo(arg):
    return arg % 2;

# Test partitioned windows in python topology operators.
class TestPythonWindowPartition(unittest.TestCase):
    _multiprocess_can_split_ = True

    def setUp(self):
        Tester.setup_standalone(self)

    # Partition by attribute not supported for common schema
    def test_common_schema_python(self):
        topo = Topology()
        s = topo.source([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15])
        self.assertIs(s.oport.schema, CommonSchema.Python)
        # We cannot partition by attribute because the attributes are not
        # named
        with self.assertRaises(ValueError):
            s = s.last(10).trigger(2).partition('a').aggregate(lambda x: float(sum(x))/float(len(x)))
{'fraction_non_alphanumeric': 0.0935700575815739, 'fraction_numerical': 0.024472168905950095, 'mean_word_length': 4.110294117647059, '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': '5559070', 'n_tokens_mistral': 652, 'n_tokens_neox': 621, 'n_words': 157}