Replies: 3 comments 30 replies
-
Thank you for raising the issue. For more background information: In #718 we discussed the ChannelCreator extensively. Unfortunately many comments are in (hidden) conversations. Especially @msmttchr added the idea of the ChannelCreator. Ideas behind the ChannelCreator (summarized from memory):
In the end, the Your example won't work, as you assign a single Channel instance ( I see your point in understandability of the code, but I think the advantages overweigh the disadvantages. Especially as we talk about understanding the source code. Good instrument documentation should state how the channels are named and accessed such that users do not have to understand how it works. I think your issue is more about documentation than about the working of pymeasure. |
Beta Was this translation helpful? Give feedback.
-
Ok, supposed to be an executive summary so I'll try and keep this short. Commonly, new researchers are handed an experiment setup with opaque control software and left to figure it out. Besides hitting "go", there is no real visibility into what the instruments are doing. Despite often having no background in programming, they are game to try out pymeasure because of the intuitive drivers like So I want to preserve the simplistic pattern for the instrument driver interface as much as possible. The current Across the 14 instruments that use A couple instruments that have more than 16 channels don't use I think if an instrument has fewer than 16 (?), then each channel should be explicitly declared in the instrument driver. This branch is a proof of concept on how this can work: Commit with changes: Current lakeshore331: Updated lakeshore331: Current lakeshore331 docs: Screenshot up new lakeshore331 docs: You can see the "i_ch" is generated with the "factory" mode. "output_1" and "output_2" are explicitly defined in "singular mode". Having "output_1" and "output_2" explicitly defined is much more clean in source code and documentation for the user to know it is a channel interface. The singular channels can have descriptive docstrings that provide more information about the interface. The docstrings for the singular channels get created by using the |
Beta Was this translation helpful? Give feedback.
-
Let's formulate goals of the behaviour:
What do you think, @mcdo0486 , @bilderbuchi ? |
Beta Was this translation helpful? Give feedback.
-
TLDR:
Pymeasure framework has an intuitive layout that is especially useful for new python or Pymeasure users. Most users will be making
Procedures
, not changes to drivers or underlying framework. It is important to favor readability over complexity to keep Pymeasure intuitive.CommonBase.ChannelCreator
breaks this intuitive layout pattern.Channel
s should be explicitly defined as they would be called in aProcedure
.Post:
A strength of Pymeasure is the intuitive layout of parameters, procedures, and drivers. From working with researchers, for a lot of experimentalists Pymeasure is their first python project, and the intuitive at a glance approach that Pymeasure has for procedures and drivers really helps for adoption. Most Pymeasure users will never make driver let alone commit to the upstream Pymeasure repository, but they will be making a lot of procedures and the layout of components in the framework goes a long way for these users.
Just to highlight what I think is the intuitive nature for
Procedure
sThe actual layout of the code in a
Procedure
is intuitive for new users: there are class attributes likeFloatParameter
,DATA_COLUMNS
is important for the results file, thenstartup()
for setting up instruments,execute()
when data is emitted, and finallyshutdown()
to clean things up. And as an additional bonus,FloatParameter
will automatically be integrated as an input, along with data plotting, all into a Pymeasure GUI "for free" which is a huge deal.For instrument drivers the intuitive layout follows for new users with a twist. The explanation that “Instrument.control() is a static method from the CommonBase class that generates a property for getting and setting values to the instrument” is odd for new users of python. But with this approach we can see at a glance the actual VISA commands that are sent, the help docstring describing the property, and validators for the property values. It is easy to make it click, and then
inst.source_voltage = 10
orinst.source_voltage
follows intuitively.It is easy to understand how we got here:
Channel
classChannel
s share a lot of logic withInstrument
CommonBase
can implement this logic for both classesThat all follows, but the current
CommonBase.ChannelCreator
implementation removes the intuitive layout from instrument drivers.It is not obvious that this line is generating
inst.ch_1.current_limit = 1
and that is how you interact with this instrument. Only by going through the codebase can you find the answer to how this line works.Even if it is included in the docstring, I don’t believe that this line makes it obvious that
monitor.input_D5.kelvin
is how things work.Channels should be explicitly defined without a Channel factory to preserve the intuitive approach to instrument drivers (only an example):
Explicitly creating the channels is a better approach for readability even if there are many channels. And besides, most instruments will likely have much fewer channels then this example.
Beta Was this translation helpful? Give feedback.
All reactions