Beispiel #1
0
def test_filter_cases_works_with_predicate():
    # Given
    sims = [
        Simulation(root='', base_command='python', param1=i, param2=i + 1)
        for i in range(5)
    ]

    # When
    result = filter_cases(sims,
                          predicate=lambda x: x.params.get('param1', 0) % 2)

    # Then
    assert len(result) == 2
    assert result[0].params['param1'] == 1
    assert result[1].params['param1'] == 3

    # When
    result = filter_cases(sims, predicate=2)

    # Then
    assert len(result) == 0

    # Given
    sims = [
        Simulation(root='', base_command='python', predicate=i)
        for i in range(5)
    ]

    # When
    result = filter_cases(sims, predicate=2)

    # Then
    assert len(result) == 1
    assert result[0].params['predicate'] == 2
Beispiel #2
0
def test_filter_cases_works_with_params():
    # Given
    sims = [
        Simulation(root='', base_command='python', param1=i, param2=i + 1)
        for i in range(5)
    ]
    # When
    result = filter_cases(sims, param1=2)

    # Then
    assert len(result) == 1
    assert result[0].params['param1'] == 2

    # When
    result = filter_cases(sims, param1=2, param2=2)

    # Then
    assert len(result) == 0

    # When
    result = filter_cases(sims, param1=3, param2=4)

    # Then
    assert len(result) == 1
    assert result[0].params['param1'] == 3
    assert result[0].params['param2'] == 4
Beispiel #3
0
def test_simulation_get_labels():
    # Given
    s = Simulation('junk',
                   'pysph run taylor_green',
                   nx=25,
                   perturb=0.1,
                   correction=None)

    # When
    l = s.get_labels('nx')

    # Then
    assert l == r'nx=25'

    # When
    l = s.get_labels(['nx', 'perturb', 'correction'])

    # Then
    assert l == r'nx=25, perturb=0.1, correction'
Beispiel #4
0
 def setup(self):
     cmd = 'python -c "import time; print(time.time())"'
     s1 = Simulation(self.input_path('1'), cmd)
     s2 = Simulation(self.input_path('2'), cmd, depends=[s1])
     s3 = Simulation(self.input_path('3'), cmd, depends=[s1, s2])
     self.cases = [s1, s2, s3]