Ejemplo n.º 1
0
def test_create_set_dimension():
    s = GAMSSet(SET2)
    assert s.dimension == 2
Ejemplo n.º 2
0
def test_set_with_associated_texts():
    s = GAMSSet(SET1, assoc_texts=SET1_ASSOC_TEXTS)
    assert s.assoc_texts == SET1_ASSOC_TEXTS
Ejemplo n.º 3
0
def test_set_with_associated_texts_fail():
    with pytest.raises(ValueError):
        GAMSSet(SET1, assoc_texts=['alpha'])
Ejemplo n.º 4
0
def test_create_set_with_domain():
    domain = ['super']
    s = GAMSSet(SET1, domain)
    assert s.domain == domain
Ejemplo n.º 5
0
def test_create_set_expl_text():
    s = GAMSSet(SET1, expl_text=SET1_TEXT)
    assert s.expl_text == SET1_TEXT
Ejemplo n.º 6
0
def test_try_write_when_reading(example_gdx):
    with pytest.raises(IOError):
        example_gdx['set1'] = GAMSSet(SET1, expl_text=SET1_TEXT)
Ejemplo n.º 7
0
def test_create_set_without_domain():
    s = GAMSSet(SET1)
    assert s.domain is None
Ejemplo n.º 8
0
def test_create_set():
    s = GAMSSet(SET1)
    assert s.elements == SET1
Ejemplo n.º 9
0
def test_set_as_list():
    s = GAMSSet(SET1)
    assert list(s) == SET1
Ejemplo n.º 10
0
def test_interpret_dimensiom_from_domain():
    domain = ['set1', 'set1']
    empty_set = GAMSSet(list(), domain=domain)
    assert empty_set.dimension == len(domain)
Ejemplo n.º 11
0
def test_empty_symbol_with_domain():
    domain = ['set1', 'set1']
    empty_set = GAMSSet(list(), domain=domain)
    assert empty_set.domain == domain
Ejemplo n.º 12
0
def test_empty_set():
    empty_set = GAMSSet(list())
    assert not list(empty_set)
Ejemplo n.º 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())
Ejemplo n.º 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
Ejemplo n.º 15
0
def test_multidim_set_length():
    s = GAMSSet(SET2)
    assert len(s) == len(SET2)
Ejemplo n.º 16
0
def test_set_length():
    s = GAMSSet(SET1)
    assert len(s) == len(SET1)
Ejemplo n.º 17
0
def test_create_set_multidim():
    s = GAMSSet(SET2)
    assert s.elements == SET2
Ejemplo n.º 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)