Giter Club home page Giter Club logo

Comments (8)

alexcjohnson avatar alexcjohnson commented on August 16, 2024

My main concern here is that users know when they're asking for a soft_get instead of a real reading, even if they're not the driver authors.

When do you think this functionality will be useful?

  • just as a one-off "remind me what I set this to"
    • then we could make a method like .latest() or something, that as you say just returns self._last_value
  • or can you see cases for using this in a Loop? I guess here's one: if you've got some other high-level parameter that includes a feedback loop, and elsewhere in the loop you want to store the feedback setting...
    • we can make a really simple object that wraps any parameter, just overriding get, so that it can be used in a Loop.

Actually, I bet the only thing a user has to see is .latest, used as a function as in the first case, or without calling it you have an object that can be a Loop action:

class StandardParameter(...):
    def __init__(self):
        ...
        self.latest = GetLatest(self)
        ...

class GetLatest(DelegateAttributes):
    delegate_attr_objects = ['parameter']

    def __init__(self, parameter):
        self.parameter = parameter

    def get(self):
        return self.parameter._last_value

    def __call__(self):
        return self.get()

Seem reasonable? Any other ideas what to call this thing?

from qcodes.

alexcjohnson avatar alexcjohnson commented on August 16, 2024

Small change, if I first standardize the names of stored values between StandardParameter and ManualParameter as discussed in #38 and #41 then we can plug this into Parameter rather than StandardParameter - of course in ManualParameter you wouldn't need this (it wouldn't hurt, it's doing exactly what .get() does there anyway...) but it would be nice to allow in other Parameter subclasses people might make.

from qcodes.

AdriaanRol avatar AdriaanRol commented on August 16, 2024

@alexcjohnson .

I definately like the idea of .latest() or .get_latest(). I think that would be a good addition.

However having .latest does not solve the problem I am having which relates to instruments that have a lacking communications protocol (and there are surprisingly many of them) In that case I would like it to be able to use the standard .get() function.

For the specific problem I am having now it is a VISA instrument so I would like my parameter to still be a visa instrument and just rerout parameter.get() to the proposed parameter.latest().

If we add this feature we should add a note on when to and when not to use this feature in the docstring that explains it, unless you see a better solution. (Maybe .latest() for every parameter?)

from qcodes.

alexcjohnson avatar alexcjohnson commented on August 16, 2024

However having .latest does not solve the problem I am having which relates to instruments that have a lacking communications protocol on (and there are surprisingly many of them) In that case I would like it to be able to use the standard .get() function.

I'm still not sure I get your point - you want to be able to use .get() exactly, or you just want to make sure there's always something available?

Maybe .latest() for every parameter?

That's what I was proposing above - if you just want to read this value out, you do:

myparam.latest()

and to put this as data into a loop:

Loop(...).each(myparam.latest)

from qcodes.

AdriaanRol avatar AdriaanRol commented on August 16, 2024

I'm still not sure I get your point - you want to be able to use .get() exactly, or you just want to make sure there's always something available?

Yes, I want to rerout .get() to .latest() in some very specific cased (i.e. if the hardware does not support get-functionality). In all other cases I am very happy with the addition of the .latest() method.

from qcodes.

AdriaanRol avatar AdriaanRol commented on August 16, 2024

@alexcjohnson
Actually on second thought, let's stick with having only the .latest() and no .get() in the case of soft-parameters. The only addition I propose is to have the NotImplementedError in the .get() refer to the .latest() explicitly so that the user will know immediately how to solve this.

from qcodes.

alexcjohnson avatar alexcjohnson commented on August 16, 2024

The only addition I propose is to have the NotImplementedError in the .get() refer to the .latest() explicitly so that the user will know immediately how to solve this.

Haha I was about to propose exactly that. Sold, I'll add it to #48

from qcodes.

alexcjohnson avatar alexcjohnson commented on August 16, 2024

closed by #48

from qcodes.

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.