Giter Club home page Giter Club logo

Comments (15)

adler-j avatar adler-j commented on May 14, 2024

This is a very nice idea. I think it would go into _OperatorMeta.__new__.

Quite honestly this is also the last chance we have to somehow unify _apply and _call, it would be very much preferable imo, and would greatly simplify this.

from odl.

kohr-h avatar kohr-h commented on May 14, 2024

This is a very nice idea. I think it would go into _OperatorMeta.__new__.

Rather into _OperatorMeta.__call__. Some research necessary here.

Quite honestly this is also the last chance we have to somehow unify _apply and _call, it would be very much preferable imo, and would greatly simplify this.

I agree. So I suppose that would be a _call() method, either without out argument (old _call()) or with (an optional) out argument (old _apply()) and use inspect to check what it is.

Actually, we could get rid of the metaclass altogether by that if I remember correctly.

from odl.

adler-j avatar adler-j commented on May 14, 2024

We have three cases of operators

  • inplace
  • out of place
  • inplace + out of place

This if we have a _call(x, out) for example, this does not imply the existence of a inplace operation. Some thought needed.

from odl.

kohr-h avatar kohr-h commented on May 14, 2024

These could be reflected in the arguments to _call()

  • one positional argument (x) --> in-place
  • two positional arguments (x, out) --> out-of-place
  • two positional arguments, second optional (x, out=None) --> either way, depending on out

kwargs would be passed through from __call__().

from odl.

adler-j avatar adler-j commented on May 14, 2024

Nice idea, we would need to be VERY explicit about this then. Would we enforce the naming? If so preferably only on out.

from odl.

kohr-h avatar kohr-h commented on May 14, 2024

If so, definitely only on out. I'll try an implementation today so we get this done.

from odl.

kohr-h avatar kohr-h commented on May 14, 2024

And agreed, this would be super-explicit in the docstring, and we should add a section "How to implement and operator" in the online doc.

from odl.

kohr-h avatar kohr-h commented on May 14, 2024

I'll make a new issue for the _call() change.

from odl.

adler-j avatar adler-j commented on May 14, 2024

This is ancient, do we work on it?

from odl.

kohr-h avatar kohr-h commented on May 14, 2024

There's still an ancient branch, but I'm not so sure how to do this reliably. I started some coding and found myself writing a docstring parser. Then I realized that it was no easy fix. Maybe it's better to just always document Operator._call officially so the documentation is exposed. We could simply add a hint in Operator.__call__ so users look up at the right place in the docs.

from odl.

adler-j avatar adler-j commented on May 14, 2024

What happens to a See Also placed inside Operator.__call__? Ill do a test.

from odl.

adler-j avatar adler-j commented on May 14, 2024

Seems it links to Operator._call, damnit.

from odl.

kohr-h avatar kohr-h commented on May 14, 2024

That was my first thought, too, but having it point to the overridden _call automatically is not so easy I guess.

from odl.

kohr-h avatar kohr-h commented on May 14, 2024

Any more thoughts here? I say we close this and instead encourage users to write a short description of the operator, roughly what it does, in the class docstring. Extensive explanations in the _call docstring are of limited use anyway.

from odl.

adler-j avatar adler-j commented on May 14, 2024

I agree.

from odl.

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.