Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6800075
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:55:30+00:00 2026-05-26T18:55:30+00:00

In my project I have to use evaluate=false at the time when i am

  • 0

In my project I have to use evaluate=false at the time when i am creating any Add or Mul objects. In this case I am facing a problem when I apply equality checks on these objects. The issue is because of the ordering of the arguments.

Please consider the example below:

k2=Mul(*[x,y,2],evaluate=False)
k1=Mul(*[x,2,y],evaluate=False)
print k1==k2 

The result is false as k2.args are (x,y,2) and k1.args are (x,2,y).
So, while the comparison checks for tuple equality it returns false.
Is there any way I can get the wanted result?

Also, if I put some operation on tuples (like reversing the order and then checking), it fails in the cases when k1 and k2 are formed from different Mul objects (like when k1.args = 2*x,y and k2.args = 2*y,x)

I can’t use sorting here , as in this case Add([x+y,z],evaluate=False) and Add([x+z,y],evaluate=False) will be two different expressions. Also if i use evalaute=True, in this case Add([x+y],x]) and Add([2*x+y]) will be the same, which i don’t want.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T18:55:31+00:00Added an answer on May 26, 2026 at 6:55 pm

    Found one work around.

    in Add/Mul classes at the expression formation
    flatten all arguments using below code

       flatten_args = []
                for arg in args:
                    if (arg.__class__==cls):
                        flatten_args.extend(arg.args)
                    else:
                        flatten_args.append(arg)
    
                obj = Expr.__new__(cls, *flatten_args) 
    

    and at the time of equality check ,i am putting one extra check
    sort the args list first arg_list.sort() and than compare two lists

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a project for school and I have to use Java. Recently I
I am interested in using/learning RoR in a project where I have to use
I have a project the requires the use of the exec family. My project
I have a project which exposes object model to use by different types of
I have a project in which I'd like to use some of the .NET
I need to use IBM Informix for my project where I have point coordinates
I use LINQ-SQL as my DAL, I then have a project called DB which
We have a Library Project that we use for all our central reused code
I have an existing project repo which I use for project A, and has
I have a Visual Studio Setup Project that I use to install a fairly

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.