Пример #1
0
def test_create_set_dimension():
    s = GAMSSet(SET2)
    assert s.dimension == 2
Пример #2
0
def test_set_with_associated_texts():
    s = GAMSSet(SET1, assoc_texts=SET1_ASSOC_TEXTS)
    assert s.assoc_texts == SET1_ASSOC_TEXTS
Пример #3
0
def test_set_with_associated_texts_fail():
    with pytest.raises(ValueError):
        GAMSSet(SET1, assoc_texts=['alpha'])
Пример #4
0
def test_create_set_with_domain():
    domain = ['super']
    s = GAMSSet(SET1, domain)
    assert s.domain == domain
Пример #5
0
def test_create_set_expl_text():
    s = GAMSSet(SET1, expl_text=SET1_TEXT)
    assert s.expl_text == SET1_TEXT
Пример #6
0
def test_try_write_when_reading(example_gdx):
    with pytest.raises(IOError):
        example_gdx['set1'] = GAMSSet(SET1, expl_text=SET1_TEXT)
Пример #7
0
def test_create_set_without_domain():
    s = GAMSSet(SET1)
    assert s.domain is None
Пример #8
0
def test_create_set():
    s = GAMSSet(SET1)
    assert s.elements == SET1
Пример #9
0
def test_set_as_list():
    s = GAMSSet(SET1)
    assert list(s) == SET1
Пример #10
0
def test_interpret_dimensiom_from_domain():
    domain = ['set1', 'set1']
    empty_set = GAMSSet(list(), domain=domain)
    assert empty_set.dimension == len(domain)
Пример #11
0
def test_empty_symbol_with_domain():
    domain = ['set1', 'set1']
    empty_set = GAMSSet(list(), domain=domain)
    assert empty_set.domain == domain
Пример #12
0
def test_empty_set():
    empty_set = GAMSSet(list())
    assert not list(empty_set)
Пример #13
0
def test_write_empty(tmp_path):
    filepath = tmp_path / 'test.gdx'
    with GdxFile(filepath, mode='w') as gdx:
        gdx['set1'] = GAMSSet(list())
        gdx['par1'] = GAMSParameter(dict())
Пример #14
0
def test_write_set_with_domain(tmp_path):
    filepath = tmp_path / 'test.gdx'
    with GdxFile(filepath, mode='w') as gdx:
        gdx['set2'] = GAMSSet(SET2, SET2_DOMAIN, expl_text=SET1_TEXT)
    with GdxFile(filepath, mode='r') as gdx:
        assert gdx['set2'].domain == SET2_DOMAIN
Пример #15
0
def test_multidim_set_length():
    s = GAMSSet(SET2)
    assert len(s) == len(SET2)
Пример #16
0
def test_set_length():
    s = GAMSSet(SET1)
    assert len(s) == len(SET1)
Пример #17
0
def test_create_set_multidim():
    s = GAMSSet(SET2)
    assert s.elements == SET2
Пример #18
0
def test_write_same_again(tmp_path):
    filepath = tmp_path / 'test.gdx'
    with GdxFile(filepath, mode='w') as gdx:
        gdx['set1'] = GAMSSet(SET1, expl_text=SET1_TEXT)
        with pytest.raises(NotImplementedError):
            gdx['set1'] = GAMSSet(SET1, expl_text=SET1_TEXT)