@@ -82,13 +82,13 @@ def test_reshape_size_mismatch(self, scope):
8282 def test_quad_form_wrong_Q_size (self , scope ):
8383 x = scope .Variable (3 , 1 )
8484 Q = np .eye (4 )
85- with pytest .raises (ValueError , match = "doesn't match " ):
85+ with pytest .raises (ValueError , match = "need x " ):
8686 sp .quad_form (x , Q )
8787
8888 def test_quad_form_non_column (self , scope ):
8989 x = scope .Variable (1 , 3 )
9090 Q = np .eye (3 )
91- with pytest .raises (ValueError , match = "column vector " ):
91+ with pytest .raises (ValueError , match = "need x " ):
9292 sp .quad_form (x , Q )
9393
9494 def test_pow_non_numeric_exponent (self , scope ):
@@ -97,23 +97,23 @@ def test_pow_non_numeric_exponent(self, scope):
9797 x ** "two"
9898
9999 def test_hstack_empty (self ):
100- with pytest .raises (ValueError , match = "at least one " ):
100+ with pytest .raises (ValueError , match = "empty argument " ):
101101 sp .hstack ([])
102102
103103 def test_vstack_empty (self ):
104- with pytest .raises (ValueError , match = "at least one " ):
104+ with pytest .raises (ValueError , match = "empty argument " ):
105105 sp .vstack ([])
106106
107107 def test_hstack_mismatched_rows (self , scope ):
108108 x = scope .Variable (3 , 1 )
109109 y = scope .Variable (2 , 1 )
110- with pytest .raises (ValueError , match = "same number of rows " ):
110+ with pytest .raises (ValueError , match = "row mismatch " ):
111111 sp .hstack ([x , y ])
112112
113113 def test_vstack_mismatched_cols (self , scope ):
114114 X = scope .Variable (3 , 2 )
115115 Y = scope .Variable (3 , 3 )
116- with pytest .raises (ValueError , match = "same number of columns " ):
116+ with pytest .raises (ValueError , match = "column mismatch " ):
117117 sp .vstack ([X , Y ])
118118
119119 def test_restricted_domain_on_index (self , scope ):
@@ -130,25 +130,24 @@ def test_restricted_domain_on_index(self, scope):
130130 with pytest .raises (ValueError , match = "cannot be applied directly" ):
131131 sp .entr (x [1 :3 ])
132132
133- def test_quad_over_lin_z_must_be_variable (self , scope ):
133+ def test_quad_over_lin_args_must_be_variables (self , scope ):
134134 x = scope .Variable (3 , 1 )
135135 z = scope .Variable (1 , 1 )
136- # This should work — z is a plain variable, not in numerator
136+ # This should work — both are plain variables
137137 sp .quad_over_lin (x , z )
138138
139- # This should fail — z is an expression, not a plain variable
140- with pytest .raises (ValueError , match = "must be a plain Variable" ):
139+ # x is a composition — fails
140+ with pytest .raises (ValueError , match = "x.*must be a plain Variable" ):
141+ sp .quad_over_lin (sp .sin (x ), z )
142+
143+ # z is a composition — fails
144+ with pytest .raises (ValueError , match = "z.*must be a plain" ):
141145 sp .quad_over_lin (x , sp .exp (z ))
142146
143- def test_quad_over_lin_z_not_in_numerator (self , scope ):
144- x = scope .Variable (3 , 1 )
147+ def test_quad_over_lin_z_not_in_x (self , scope ):
145148 z = scope .Variable (1 , 1 )
146- # z appears in numerator via broadcast: x + z
147- with pytest .raises (ValueError , match = "denominator variable z must not appear in the numerator" ):
148- sp .quad_over_lin (x + z , z )
149-
150- # z appears directly as scalar in numerator
151- with pytest .raises (ValueError , match = "denominator variable z must not appear in the numerator" ):
149+ # z used as both args
150+ with pytest .raises (ValueError , match = "z must not appear in x" ):
152151 sp .quad_over_lin (z , z )
153152
154153 def test_prod_must_be_variable (self , scope ):
0 commit comments