@@ -182,7 +182,7 @@ def {sig}:{doc}
182
182
# (?|...) is a branch reset (regex module only feature). It works like (?:...)
183
183
# except only the matched alternative is assigned group numbers, so \1, \2, and
184
184
# so on will always refer to a single match from _value.
185
- _value = r"(?|`([^`]*)`|a (finite) number|a (positive \(i\.e\., greater than `0`\) finite) number|a (negative \(i\.e\., less than `0`\) finite) number|(finite)|(positive)|(negative)|(nonzero)|(?:a )?(nonzero finite) numbers?|an (integer) value|already (integer)-valued|an (odd integer) value|an implementation-dependent approximation to `([^`]*)`(?: \(rounded\))?|a (signed (?:infinity|zero)) with the mathematical sign determined by the rule already stated above|(positive) mathematical sign|(negative) mathematical sign)"
185
+ _value = r"(?|`([^`]*)`|a (finite) number|a (positive \(i\.e\., greater than `0`\) finite) number|a (negative \(i\.e\., less than `0`\) finite) number|(finite)|(positive)|(negative)|(nonzero)|(?:a )?(nonzero finite) numbers?|an (integer) value|already (integer)-valued|an (odd integer) value|an implementation-dependent approximation to `([^`]*)`(?: \(rounded\))?|a (signed (?:infinity|zero)) with the mathematical sign determined by the rule already stated above|(positive mathematical sign) |(negative mathematical sign) )"
186
186
SPECIAL_CASE_REGEXS = dict (
187
187
ONE_ARG_EQUAL = regex .compile (rf'^- +If `x_i` is { _value } , the result is { _value } \.$' ),
188
188
ONE_ARG_GREATER = regex .compile (rf'^- +If `x_i` is greater than { _value } , the result is { _value } \.$' ),
@@ -248,7 +248,8 @@ def parse_value(value, arg):
248
248
return value
249
249
elif value in ['finite' , 'nonzero' , 'nonzero finite' ,
250
250
"integer" , "odd integer" , "positive" ,
251
- "negative" ]:
251
+ "negative" , "positive mathematical sign" ,
252
+ "negative mathematical sign" ]:
252
253
return value
253
254
# There's no way to remove the parenthetical from the matching group in
254
255
# the regular expression.
@@ -287,9 +288,15 @@ def get_mask(typ, arg, value):
287
288
elif value == 'positive' :
288
289
_check_exactly_equal (typ , value )
289
290
return f"ispositive({ arg } )"
291
+ elif value == 'positive mathematical sign' :
292
+ _check_exactly_equal (typ , value )
293
+ return f"positive_mathematical_sign({ arg } )"
290
294
elif value == 'negative' :
291
295
_check_exactly_equal (typ , value )
292
296
return f"isnegative({ arg } )"
297
+ elif value == 'negative mathematical sign' :
298
+ _check_exactly_equal (typ , value )
299
+ return f"negative_mathematical_sign({ arg } )"
293
300
elif value == 'integer' :
294
301
_check_exactly_equal (typ , value )
295
302
return f"isintegral({ arg } )"
@@ -311,9 +318,15 @@ def get_assert(typ, result):
311
318
elif result == "positive" :
312
319
_check_exactly_equal (typ , result )
313
320
return "assert_positive(res[mask])"
321
+ elif result == "positive mathematical sign" :
322
+ _check_exactly_equal (typ , result )
323
+ return "assert_positive_mathematical_sign(res[mask])"
314
324
elif result == "negative" :
315
325
_check_exactly_equal (typ , result )
316
326
return "assert_negative(res[mask])"
327
+ elif result == "negative mathematical sign" :
328
+ _check_exactly_equal (typ , result )
329
+ return "assert_negative_mathematical_sign(res[mask])"
317
330
elif 'x_i' in result :
318
331
return f"assert_{ typ } (res[mask], { result .replace ('x_i' , 'arg1' )} [mask])"
319
332
elif 'x1_i' in result :
0 commit comments