File tree Expand file tree Collapse file tree 2 files changed +13
-11
lines changed
Expand file tree Collapse file tree 2 files changed +13
-11
lines changed Original file line number Diff line number Diff line change @@ -1233,7 +1233,11 @@ def convert_constraint_lambdas(restrictions):
12331233 new_c = unparse_constraint_lambda (lambda_ast )
12341234 res .append (new_c )
12351235
1236- return list (set (res ))
1236+ result = list (set (res ))
1237+ if not len (result ) == len (restrictions ):
1238+ raise ValueError ("An error occured when parsing restrictions. If you mix lambdas and string-based restrictions, please define the lambda first." )
1239+
1240+ return result
12371241
12381242
12391243def compile_restrictions (
Original file line number Diff line number Diff line change @@ -783,22 +783,20 @@ def test_convert_constraint_lambdas_illformatted():
783783 """ Test a number of different ways to define the restrictions.
784784
785785 These are currently not supported but we would like to support them in the future.
786- That is why these tests exist and are expected to fail.
787-
788- When there is time to fix this, we can change the test to
789- assert result == expected
790- and work on the code until the test passes.
791-
792- But for now we assert result != expected
786+ That is why this test expects an exception
793787
794788 """
795789
796790 restrictions = ["32 <= block_size_x*block_size_y <= 512" ,
797791 lambda p : 32 <= p ["block_size_x" ]* p ["block_size_y" ] <= 1024 ,
798792 lambda p : p ["block_size_z" ] < 8 ]
799793
800- result = convert_constraint_lambdas (restrictions )
801- print (result )
802794 expected = ['32 <= block_size_x * block_size_y <= 1024' , 'block_size_z < 8' , '32 <= block_size_x*block_size_y <= 512' ]
803795
804- assert result != expected
796+ try :
797+ result = convert_constraint_lambdas (restrictions )
798+ print (result )
799+ except ValueError :
800+ pass
801+
802+
You can’t perform that action at this time.
0 commit comments