Giter Club home page Giter Club logo

Comments (4)

tBuLi avatar tBuLi commented on May 21, 2024

After thinking about it some more,

x, y = variables()
a, b = parameters()

looks weird to me. As a user I would not understand how this could possibly work. How does it know I want two? At the very least I would expect to have to give an int as argument for the number I want. So I guess in this case the sympy way is better.

Just as an aside, does the following look good?

(x, y), (a, b) = variables('x y'), parameters('a b')

I think it looks rather nice, and greatly reduces the number of lines needed! I'm thinking of adopting this as the official way of defining vars and params in the docs.

from symfit.

tBuLi avatar tBuLi commented on May 21, 2024

Some other cool ideas for the parameter factory, given that you also should have some method of specifying default values and ranges:

# value will be used as initial guess
a, b = parameters(a=1.0, b=2.0)

# Parameter will be initiated from the dict
c, d = parameters(c={'value': 1.0, 'min': 0.0}, d={'value': 2.0, 'fixed': True})

# The range of the param. Must be increasing in size. Does not support fixed kw nicely
a, e = parameters(a=(0.0, 1.0), e=(0.0, 1.1, 5.0))

# Or, taking even more inspiration from django:
c, d = parameters(c=1.0, c__min=0.0, d=2.0, d__fixed=True)

In all of these the name of the keyword argument is used as the name of the parameter.

I like a combination of the first two most: if only a number is supplied use it as an initial guess, if dict then use that instead. The Djangoesque way is also quite nice, but only if you've seen it before I imagine.

# Next level with djangoesque syntax to keep similarity with variables():
c, d = parameters('c d', c__min=0.0, d__value=2.0, d__fixed=True)

from symfit.

Eljee avatar Eljee commented on May 21, 2024

Though some of these might reduce the numbers of lines of code, the main choice in what would be possible is not convenience rather than readability, since the main idea (as it strikes me) is to produce readable fitting,

With that in mind I would say that the Variables object will have to have more input and not use introspection (?) to find the number of variables to be defined. The string added, like sympy, would be the better option, though the formatting bothers me. I would want to see (compulsory?):

x, y = Variables('x, y') 

Note the added comma, which in PEP8 is the best way to represent multiple variables. It might be however, that some fuzziness should be allowed (PEP8 is a style guide) and I'm not sure on the implementation of that.

As for the Django-esque syntax, though it might be beautiful, I would at the very least not introduce it as standard. If it were possible for Django users and not be the norm, I would not object encourage it.

from symfit.

tBuLi avatar tBuLi commented on May 21, 2024

@Eljee, I agree with you that using a space as a separator is not nice. It's my other big annoyance about the way symbols are defined in sympy. (Apart from the violation of DRY)

After talking to a mutual friend of ours I decided that parameter creation shouldn't be done with optional extra's. Instead, if other default guesses or ranges are required, you can always set them separately:

a, b = parameters('a, b')
a.value = 2.0
a.min, a.max = 0.0, 10.0

I got a bit carried away earlier ;).

I still don't like the violation of DRY though... But it is the least surprising to users, which is important.

from symfit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.