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 6219073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T07:43:00+00:00 2026-05-24T07:43:00+00:00

I am trying to setup a system where users can submit an equation to

  • 0

I am trying to setup a system where users can submit an equation to be solved. I have a class, DP, which represents the full parameterization of the problem. A different class, dpsolver, takes a dp object, constructs the matrices, and will solve the problem.

When creating the DP object, one of the attributes is a function reference where the function is like this:

def equation1(r, tx, p, p_prime, k, k_prime, z, z_prime ):
    """ it is assumed all arguments are same sized ndarray or scalar"""
    inv = k_prime - 0.8 * k
    v = np.power(z_prime * inv, 0.75) * (1-tx) - p*tx + p_prime
    return(v)

r and tx are scalars defined in the DP object. p, p_prime, k, k_prime, z, z_prime are all numpy matrices which are constructed based on other information contained in the instantiation of the DP class. The DP class contains an OrderedDict which has p,k, and z as keys (in that order). p_prime, k_prime, and z_prime are all inferred by solver. My question is, what is the right way to call the equation1 function from solver. I want to that function as simple as possible, so other people can submit equations which can be easily integrated into this system.

I was thinking that using eval could work, or alternatively using lists and then using eval to unpack the list within equation1. What is the best way to do this without using eval? Or will eval be okay in terms of performance?

  • 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-24T07:43:02+00:00Added an answer on May 24, 2026 at 7:43 am

    From your question:

    alternatively using lists and then using eval to unpack the list
    within equation1

    You may very well already be aware of this, but in case you’re not, calling:

    equation1(*list_of_parameters)
    

    Does just this.

    Similarly, doing

    equation1(**dict_of_parameters)
    

    Will expand a dict to keyword arguments.

    Eval is there for a reason, but using it for metaprogramming is often a bad idea.

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

Sidebar

Related Questions

So I am trying to setup an entry posting system, where the user can
i have a private section where specific users can login on my system (restricted
I am trying to setup a shared authentication system on a build server. We
I am trying to build a reporting system that allows users to customize reports
I'm trying to setup a 'Click to Chat' system for my company. It requires
I am trying to build a voting system where user can vote without signing
I am trying to set up a system in which user uploaded files will
Say I have a system with Products that can have various decoration (or printing)
I'm trying to set up a system that displays calendar items from a resource
I'll try my best to explain how I'm trying to set up this system.

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.