Skip to content

Commit 2c057bb

Browse files
authored
Merge pull request #1390 from mathics/go-over-inequality-doc
Go over comparision doctests and text
2 parents 7799d7a + 818ccb6 commit 2c057bb

1 file changed

Lines changed: 43 additions & 34 deletions

File tree

mathics/builtin/comparison.py

Lines changed: 43 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -652,10 +652,9 @@ def _op(x):
652652

653653

654654
class Unequal(_EqualityOperator, SympyComparison):
655-
"""
655+
u"""
656656
<dl>
657-
<dt>'Unequal[$x$, $y$]'
658-
<dt>'$x$ != $y$'
657+
<dt>'Unequal[$x$, $y$]' or $x$ != $y$ or $x$ \u2260 $y$
659658
<dd>is 'False' if $x$ and $y$ are known to be equal, or
660659
'True' if $x$ and $y$ are known to be unequal.
661660
Commutative properties apply so if $x$ != $y$ then
@@ -667,15 +666,19 @@ class Unequal(_EqualityOperator, SympyComparison):
667666
>> 1 != 1.
668667
= False
669668
669+
Comparsion can be chained:
670+
>> 1 != 2 != 3
671+
= True
672+
673+
>> 1 != 2 != x
674+
= 1 != 2 != x
675+
670676
Strings are allowed:
671677
Unequal["11", "11"]
672678
= False
673679
674-
Equal["121", "11"]
675-
= True
676-
677680
Comparision to mismatched types is True:
678-
Equal[11, "11"]
681+
Unequal[11, "11"]
679682
= True
680683
681684
Lists are compared based on their elements:
@@ -723,49 +726,57 @@ def _op(x):
723726
class Less(_ComparisonOperator, SympyComparison):
724727
"""
725728
<dl>
726-
<dt>'Less[$x$, $y$]'
727-
<dt>'$x$ < $y$'
728-
<dd>yields 'True' if $x$ is known to be less than $y$.
729-
<dt>'$lhs$ < $rhs$'
730-
<dd>represents the inequality $lhs$ < $rhs$.
729+
<dt>'Less[$x$, $y$]' or $x$ < $y$
730+
<dd>yields 'True' if $x$ is known to be less than $y$.
731731
</dl>
732732
733-
#> {Less[], Less[x], Less[1]}
734-
= {True, True, True}
733+
LessEqual operator can be chained:
734+
>> LessEqual[1, 3, 3, 2]
735+
= False
736+
737+
>> 1 < 3 < 3
738+
= False
735739
740+
>> 1 < 3 < x < 2
741+
= 1 < 3 < x < 2
736742
"""
737743

738744
operator = "<"
739745
sympy_name = "StrictLessThan"
740746

741747

742748
class LessEqual(_ComparisonOperator, SympyComparison):
743-
"""
744-
<dl>
745-
<dt>'LessEqual[$x$, $y$]'
746-
<dt>'$x$ <= $y$'
747-
<dd>yields 'True' if $x$ is known to be less than or equal to $y$.
748-
<dt>'$lhs$ <= $rhs$'
749-
<dd>represents the inequality $lhs$ $rhs$.
750-
</dl>
749+
u"""
750+
<dl>
751+
<dt>'LessEqual[$x$, $y$, ...]' or $x$ <= $y$ or $x$ \u2264 $y$
752+
<dd>yields 'True' if $x$ is known to be less than or equal to $y$.
753+
</dl>
754+
755+
LessEqual operator can be chained:
756+
>> LessEqual[1, 3, 3, 2]
757+
= False
758+
759+
>> 1 <= 3 <= 3
760+
= True
761+
751762
"""
752763

753764
operator = "<="
754-
sympy_name = "LessThan"
765+
sympy_name = "LessThan" # in contrast to StrictLessThan
755766

756767

757768
class Greater(_ComparisonOperator, SympyComparison):
758769
"""
759770
<dl>
760-
<dt>'Greater[$x$, $y$]'
761-
<dt>'$x$ > $y$'
762-
<dd>yields 'True' if $x$ is known to be greater than $y$.
763-
<dt>'$lhs$ > $rhs$'
764-
<dd>represents the inequality $lhs$ > $rhs$.
771+
<dt>'Greater[$x$, $y$]' or '$x$ > $y$'
772+
<dd>yields 'True' if $x$ is known to be greater than $y$.
765773
</dl>
774+
775+
Greater operator can be chained:
766776
>> a > b > c //FullForm
767777
= Greater[a, b, c]
768-
>> Greater[3, 2, 1]
778+
779+
>> 3 > 2 > 1
769780
= True
770781
"""
771782

@@ -776,12 +787,10 @@ class Greater(_ComparisonOperator, SympyComparison):
776787
class GreaterEqual(_ComparisonOperator, SympyComparison):
777788
"""
778789
<dl>
779-
<dt>'GreaterEqual[$x$, $y$]'
780-
<dt>'$x$ >= $y$'
781-
<dd>yields 'True' if $x$ is known to be greater than or equal
790+
<dt>'GreaterEqual[$x$, $y$]'
791+
<dt>$x$ \u2256 $y$ or '$x$ >= $y$'
792+
<dd>yields 'True' if $x$ is known to be greater than or equal
782793
to $y$.
783-
<dt>'$lhs$ >= $rhs$'
784-
<dd>represents the inequality $lhs$ $rhs$.
785794
</dl>
786795
"""
787796

0 commit comments

Comments
 (0)