@@ -201,6 +201,16 @@ def test_setattr_dataframe(self):
201
201
with self .assertRaises (TypeError ):
202
202
x .gppd .Start = pd .DataFrame (index = index , data = {"start" : [1 , 2 , 3 , 4 , 5 ]})
203
203
204
+ def test_setattr_single_int (self ):
205
+ index = pd .Index ([0 , 1 ])
206
+ x = gppd .add_vars (self .model , index )
207
+ x .gppd .Partition = 0
208
+
209
+ def test_setattr_series_int (self ):
210
+ index = pd .Index ([0 , 1 ])
211
+ x = gppd .add_vars (self .model , index )
212
+ x .gppd .Partition = pd .Series (index = index , data = [0 , 1 ])
213
+
204
214
205
215
class TestSeriesGetAttrSetAttr (GurobiModelTestCase ):
206
216
def test_var_getattr_X (self ):
@@ -225,6 +235,17 @@ def test_var_setattr_bounds(self):
225
235
self .assertEqual (result .loc [i + 5 ].lb , 1.0 )
226
236
self .assertEqual (result .loc [i + 5 ].ub , i + 2 )
227
237
238
+ def test_var_setattr_bounds_fractional (self ):
239
+ index = pd .RangeIndex (5 , 10 )
240
+ x = gppd .add_vars (self .model , index , name = "x" )
241
+ lb = 1.4
242
+ ub = pd .Series (index = index , data = [2.2 , 3.3 , 4.4 , 5.5 , 6.6 ])
243
+ result = x .gppd .set_attr ("LB" , lb ).gppd .set_attr ("UB" , ub )
244
+ self .model .update ()
245
+ for i in range (5 ):
246
+ self .assertEqual (result .loc [i + 5 ].lb , 1.4 )
247
+ self .assertLess (abs (result .loc [i + 5 ].ub - (i + 2 ) * 1.1 ), 1e-6 )
248
+
228
249
def test_var_setattr_vtype (self ):
229
250
index = pd .RangeIndex (5 , 10 )
230
251
x = gppd .add_vars (self .model , index , name = "x" )
0 commit comments