<commit_before># Copyright (c) 2009-2019 The Regents of the University of Michigan
# This file is part of the HOOMD-blue project, released under the BSD 3-Clause
# License.

import hoomd
import hoomd.trigger


def test_periodic_properties():
    """ Test construction and properties of Periodic
    """

    a = hoomd.trigger.Periodic(123)

    assert a.period == 123
    assert a.phase == 0

    a.period = 10000000000

    assert a.period == 10000000000
    assert a.phase == 0

    a.phase = 6000000000

    assert a.period == 10000000000
    assert a.phase == 6000000000

    b = hoomd.trigger.Periodic(phase=3, period=456)

    assert b.period == 456
    assert b.phase == 3


def test_periodic_eval():
    a = hoomd.trigger.Periodic(period=456, phase=18)

    for i in range(10000):
        assert a(i) == ((i - 18) % 456 == 0)

    for i in range(10000000000, 10000010000):
        assert a(i) == ((i - 18) % 456 == 0)

    b = hoomd.trigger.Periodic(period=10000000000, phase=6000000000)

    assert b(6000000000)
    assert not b(6000000001)
    assert b(16000000000)
    assert not b(16000000001)


def test_custom():
    class CustomTrigger(hoomd.trigger.Trigger):
        def __init__(self):
            hoomd.trigger.Trigger.__init__(self)

        def compute(self, timestep):
            return (timestep**(1 / 2)).is_integer()<commit_msg>Add testing for triggers<commit_after># Copyright (c) 2009-2019 The Regents of the University of Michigan
# This file is part of the HOOMD-blue project, released under the BSD 3-Clause
# License.

import hoomd
import hoomd.trigger


def test_periodic_properties():
    """ Test construction and properties of Periodic
    """

    a = hoomd.trigger.Periodic(123)

    assert a.period == 123
    assert a.phase == 0

    a.period = 10000000000

    assert a.period == 10000000000
    assert a.phase == 0

    a.phase = 6000000000

    assert a.period == 10000000000
    assert a.phase == 6000000000

    b = hoomd.trigger.Periodic(phase=3, period=456)

    assert b.period == 456
    assert b.phase == 3


def test_periodic_eval():
    a = hoomd.trigger.Periodic(period=456, phase=18)

    for i in range(10000):
        assert a(i) == ((i - 18) % 456 == 0)

    # Test values greater than 2^32
    for i in range(10000000000, 10000010000):
        assert a(i) == ((i - 18) % 456 == 0)

    # Test trigger with values greater than 2^32
    b = hoomd.trigger.Periodic(period=10000000000, phase=6000000000)

    assert b(6000000000)
    assert not b(6000000001)
    assert b(16000000000)
    assert not b(16000000001)


def test_before_eval():
    """Test the Before trigger."""
    a = hoomd.trigger.Before(1000)
    assert all(a(i) for i in range(1000))
    assert not any(a(i) for i in range(1000, 10000))

    # tests for values greater than 2^32
    assert not any(a(i) for i in range(10000000000, 10000010000))
    a = hoomd.trigger.Before(10000000000)
    assert all(a(i) for i in range(9999990000, 10000000000))
    assert not any(a(i) for i in range(10000000000, 10000010000))


def test_after_eval():
    """"Test the After trigger."""
    a = hoomd.trigger.After(1000)
    assert not any(a(i) for i in range(1001))
    assert all(a(i) for i in range(1001, 10000))

    # tests for values greater than 2^32
    assert all(a(i) for i in range(10000000000, 10000010000))
    a = hoomd.trigger.After(10000000000)
    assert not any(a(i) for i in range(9999990000, 10000000001))
    assert all(a(i) for i in range(10000000001, 10000010000))


def test_on_eval():
    """Test the On trigger."""
    a = hoomd.trigger.On(1000)
    assert not any(a(i) for i in range(1000))
    assert a(1000)
    assert not any(a(i) for i in range(1001, 10000))

    # tests for values greater than 2^32
    assert not any(a(i) for i in range(10000000000, 10000010000))
    a = hoomd.trigger.On(10000000000)
    assert not any(a(i) for i in range(9999990000, 10000000000))
    assert a(10000000000)
    assert not any(a(i) for i in range(10000000001, 10000010000))


def test_not_eval():
    """Test the Not Trigger."""
    a = hoomd.trigger.Not(hoomd.trigger.After(1000))
    assert all(a(i) for i in range(1001))
    assert not any(a(i) for i in range(1001, 10000))

    # tests for values greater than 2^32
    assert not any(a(i) for i in range(10000000000, 10000010000))
    a = hoomd.trigger.Not(hoomd.trigger.After(10000000000))
    assert all(a(i) for i in range(9999990000, 10000000001))
    assert not any(a(i) for i in range(10000000001, 10000010000))


def test_and_eval():
    """Test the and trigger."""
    a = hoomd.trigger.And([hoomd.trigger.Before(1000),
                           hoomd.trigger.After(1000)])
    assert not any(a(i) for i in range(1000))
    assert not any(a(i) for i in range(1000, 10000))

    # tests for values greater than 2^32
    assert not any(a(i) for i in range(10000000000, 10000010000))
    a = hoomd.trigger.And([hoomd.trigger.Before(10000000000),
                           hoomd.trigger.After(10000000000)])
    assert not any(a(i) for i in range(9999990000, 10000010000))


def test_or_eval():
    """Test the and trigger."""
    a = hoomd.trigger.Or([hoomd.trigger.Before(1000),
                           hoomd.trigger.On(1000),
                           hoomd.trigger.After(1000)])
    assert all(a(i) for i in range(10000))

    # tests for values greater than 2^32
    assert all(a(i) for i in range(10000000000, 10000010000))
    a = hoomd.trigger.Or([hoomd.trigger.Before(10000000000),
                           hoomd.trigger.On(10000000000),
                           hoomd.trigger.After(10000000000)])
    assert all(a(i) for i in range(9999990000, 10000010000))


def test_custom():
    class CustomTrigger(hoomd.trigger.Trigger):
        def __init__(self):
            hoomd.trigger.Trigger.__init__(self)

        def compute(self, timestep):
            return (timestep**(1 / 2)).is_integer()
{'fraction_non_alphanumeric': 0.11694915254237288, 'fraction_numerical': 0.16338983050847458, 'mean_word_length': 2.9550938337801607, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 48, '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': '4011748', 'n_tokens_mistral': 2741, 'n_tokens_neox': 1948, 'n_words': 564}