Export to GitHub

sympy - issue #4081

Equivalent doesn't sort args


Posted on Oct 29, 2013 by Happy Elephant

Equivalent(x, y) sometimes prints as Equivalent(x, y) and sometimes as Equivalent(y, x). I haven't checked if it's not sorting the .args or if the issue is just with the printer.

Comment #1

Posted on Oct 31, 2013 by Happy Giraffe

Looks like a printer issue: the string printing of Equivalent falls back to the _print_Basic method, while other BooleanFunction subclasses such as And, Or have their own _print_And and _print_Or methods that sort the args.

Comment #2

Posted on Nov 3, 2013 by Happy Elephant

Doesn't that mean it's an args ordering issue then?

Comment #3

Posted on Nov 3, 2013 by Happy Giraffe

I assume it's a design decision to have BooleanFunction not sort their args.

Comment #4

Posted on Nov 4, 2013 by Happy Elephant

OK, looking at the code, it has nothing to do with BooleanFunction. BooleanFunction is just a Boolean Function, so it does sort its args (as it should). And and Or are lattice operations, but LatticeOp also sorts the args (it internally uses _argset in case .args is never used). It's Equivalent.new directly that does this, when it calls *set(args). It should use the same methodology as LatticeOp with _argset.

Comment #5

Posted on Nov 4, 2013 by Happy Elephant

See https://github.com/sympy/sympy/pull/2560.

Comment #6

Posted on Nov 5, 2013 by Happy Giraffe

So can we remove the sorting from the _print_And and _print_Or methods?

Comment #7

Posted on Nov 5, 2013 by Happy Elephant

Printing sorting and arg sorting aren't always the same. So we'd have to check.

Comment #8

Posted on Mar 5, 2014 by Happy Elephant

We have moved issues to GitHub https://github.com/sympy/sympy/issues.

Comment #9

Posted on Apr 6, 2014 by Happy Rabbit

Migrated to http://github.com/sympy/sympy/issues/7180

Status: Started

Labels:
Type-Defect Priority-Medium Logic Printing Restrict-AddIssueComment-Commit