Description
Contributor: Michael Bussieck, November 2019
Small Model of Type : GAMS
Category : GAMS Test library
Main file : embpy05.gms
$title 'Test merge/replace when loading data from embedded code' (EMBPY05,SEQ=804)
$onText
Contributor: Michael Bussieck, November 2019
$offText
$log --- Using Python library %sysEnv.GMSPYTHONLIB%
Set universe / i1*i3 /
s(universe);
$onEmbeddedCode Python:
gams.set('s', [('I2')])
$offEmbeddedCode s
$if not errorFree $abort 'No error expected'
$eval.Set STL s.firstTL
$if not %STL%==i2 $abort 'Expected i2 but got %STL%'
$onEmbeddedCode Python:
gams.set('s', [('I1')])
$offEmbeddedCode s
$if errorFree $abort 'Error expected'
$clearErrors
$kill s
$onEmbeddedCode Python:
gams.set('s', [('I2')])
$offEmbeddedCode s
$if not errorFree $abort 'No error expected'
$eval.Set STL s.firstTL
$if not %STL%==i2 $abort 'Expected i2 but got %STL%'
$onMulti
$onEmbeddedCode Python:
gams.set('s', [('I1')])
$offEmbeddedCode s
$if not errorFree $abort 'No error expected'
$eval.Set STL s.firstTL
$if not %STL%==i1 $abort 'Expected i1 but got %STL%'
$onMultiR
$onEmbeddedCode Python:
gams.set('s', [('I3')])
$offEmbeddedCode s
$if not errorFree $abort 'No error expected'
$eval.Set STL s.firstTL
$if not %STL%==i3 $abort 'Expected i3 but got %STL%'
$offMulti
$kill s
$onEmbeddedCode Python:
gams.set('s', [('I2')])
$offEmbeddedCode s
$if not errorFree $abort 'No error expected'
$eval.Set STL s.firstTL
$if not %STL%==i2 $abort 'Expected i2 but got %STL%'
$onEmbeddedCode Python:
gams.set('s', [('I1')], mergeType=MergeType.MERGE)
$offEmbeddedCode s
$if not errorFree $abort 'No error expected'
$eval.Set STL s.firstTL
$if not %STL%==i1 $abort 'Expected i1 but got %STL%'
$onEmbeddedCode Python:
gams.set('s', [('I3')], mergeType=MergeType.REPLACE)
$offEmbeddedCode s
$if not errorFree $abort 'No error expected'
$eval.Set STL s.firstTL
$if not %STL%==i3 $abort 'Expected i3 but got %STL%'
option clear=s;
* Need to decide to change docs or behavior
$onText
EmbeddedCode Python:
gams.set('s', [('I2')])
endEmbeddedCode s
abort$(card(s)<>1 or not s('i2')) 'expect just i2 in s', s;
EmbeddedCode Python:
gams.set('s', [('I1')])
endEmbeddedCode s
abort$(card(s)<>1 or not s('i1')) 'expect just i1 in s', s;
option clear=s;
EmbeddedCode Python:
gams.set('s', [('I2')])
endEmbeddedCode s
abort$(card(s)<>1 or not s('i2')) 'expect just i2 in s', s;
EmbeddedCode Python:
gams.set('s', [('I1')], mergeType=MergeType.DEFAULT)
endEmbeddedCode s
abort$(card(s)<>1 or not s('i1')) 'expect just i1 in s', s;
$offText
option clear=s;
EmbeddedCode Python:
gams.set('s', [('I2')])
endEmbeddedCode s
abort$(card(s)<>1 or not s('i2')) 'expect just i2 in s', s;
EmbeddedCode Python:
gams.set('s', [('I1')], mergeType=MergeType.REPLACE)
endEmbeddedCode s
abort$(card(s)<>1 or not s('i1')) 'expect just i1 in s', s;
option clear=s;
EmbeddedCode Python:
gams.set('s', [('I2')])
endEmbeddedCode s
abort$(card(s)<>1 or not s('i2')) 'expect just i2 in s', s;
EmbeddedCode Python:
gams.set('s', [('I1')], mergeType=MergeType.MERGE)
endEmbeddedCode s
abort$(card(s)<>2 or not s('i1') or not s('i2')) 'expect just i1 in s', s;