-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Repeated Capabilites documentation improvements #1686
base: master
Are you sure you want to change the base?
Repeated Capabilites documentation improvements #1686
Conversation
There are several issues open against the way we document usage of repeated capabilites in our rep_caps.rst pages. Summary of Issues * We present implementation details that the user doesn't care about - These may be useful to contributors, but to everyone else they're just distracting. * We list all of the possible types that can be passed to the indexing operator but don't make it clear what the recommend or "python" types are. - This information is worth keeping, but we need to provide better guidance. * We use channel_enabled in all of our examples, though it may not actually support the repeated capability in the example code. The approach to fixing this is as follows: * Turn documentation related to implementation details into comments only viewable in the raw source * Explicilty recommend what types to pass to the indexing operator. * Present examples which demonstrate accessing the repeated capability with our recommended types. - Do not present examples using other types. * Add a note that channel_enabled may not actually supported the repeated capability and to check individual property and method documentation.
build/templates/rep_caps.rst.mako
Outdated
passes a string of :python:`'${prefix}0, ${prefix}1, ${prefix}2'` to the set attribute function. | ||
session.${name}[0:2].channel_enabled = True | ||
|
||
sets :py:attr:`channel_enabled` to :python:`True` for ${name} 0, 1, 2. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I add anything to the recommend types above, I should add an example usage, here.
Can one of the admins verify this patch? |
I haven't committed the results of |
No, please commit them before the PR is ready for review so we can see the effects and merge without having to track anything. |
committed the results of tox-e codegen as requested. |
build/templates/rep_caps.rst.mako
Outdated
|
||
Some repeated capabilities use a prefix before the number and this is optional | ||
The recommended way of accessing repeated capabilities is with an integer :python:`[0]` or range :python:`[0:2]`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
range :python:
[0:2]
I don't think this will work since this is not the correct syntax for Python range
. But ['0:2']
will work because of the custom logic we have for handling range-based strings.
Having said that, I don't think any of the ways I've enumerated above can be recommended over others. int
is obviously the go-to for single instances. Basic sequence types and slice
are good to use because they're part of the language, Range-based strings provides syntactic sugar for defining ranges. e.g. ['0:2']
rather than [range(0,2)]
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see @marcoskirsch doesn't like us to recommend the range-based strings. Since I saw we had logic specifically for handling it, I thought it was important. But it sounds like it was ill-conceived. I don't mind not documenting it.
Once we land on recommended ways, we should go over the examples to ensure only recommended types are used.
…nto ni-jfitzger/rep_cap_documentation-overhaul
…nto ni-jfitzger/rep_cap_documentation-overhaul
…nto ni-jfitzger/rep_cap_documentation-overhaul
build/templates/rep_caps.rst.mako
Outdated
|
||
Some repeated capabilities use a prefix before the number and this is optional | ||
The recommended way of accessing multiple repeated capabilites at once is with a tuple (:python:`[0, 1]` or :python:`['Dev1', 'Dev2']`) or slice :python:`[0:2]`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not currently providing slice usage examples. Let me know if you want me to add them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that would be nice.
I wonder if we should change wording to say that it should be an iterable rather than provide examples of iterables. Or at least it should be :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, we already mention supported values above:
Use the indexing operator [] to indicate which repeated capability instance you are trying to access. The parameter can be a single element or an iterable that implements sequence semantics, like list, tuple, range and slice.
I guess it wouldn't hurt, to keep this part more generic, though, especially given our examples below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still undocumented: rep cap chaining.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
different issue/pr?
docs/nidcpower/rep_caps.rst
Outdated
Use the indexing operator :python:`[]` to indicate which repeated capability instance you are trying to access. | ||
The parameter can be a single element or an iterable that implements sequence semantics, like list, tuple, range and slice. | ||
|
||
The recommended way of accessing a single repeated capability is with an integer :python:`[0]` for capabilities that support it and a string :python:`['Dev1']` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think all the repeated capabilities we have in nimi-python, at least at the moment, work with integers with the exception of instruments
.
I wonder if we should remove this sentence, and instead where we list the repeated capabilites we tell you that the index should be an integer or an iterable of integers (or strings).
We can deduce which one it would be programmatically by looking at the metadata, specifically the rep cap prefix.
|
||
passes a string of :python:`'0, 1, 2'` to the set attribute function. | ||
session.channels[0, 2].output_function = nidcpower.OutputFunction.DC_CURRENT | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here is where we could add an example using an iterable, below line 42?
session.channles[range(3)].output_function = nidcpower.OutputFunction.DC_CURRENT
|
||
passes a string of :python:`'0, 1, 2'` to the set attribute function. | ||
print(session.instruments['Dev1', 'Dev2', '3rdDevice'].serial_number) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found 3rdDevice
confusing. Do we even allow aliases that begin with a number?
Consider using values closer to the defaults customers would encounter:
['PXI1Slot3', 'PXI1Slot4', 'PXI1Slot5']
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do allow aliases that begin with a number, yes. They don't have to have letters, at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found 3rdDevice confusing.
I just didn't want users to think it had to start with "Dev". I have the same concern with the examples you gave.
Maybe my blurb about the basic element should specify "device alias string" for instruments?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, just use something that matches defaults. This will be informative enough and not confused anyone.
Maybe my blurb about the basic element should specify "device alias string" for instruments?
I question how familiar customers are with term "device alias". It's certainly not in our APIs. Let's avoid,
#. pattern_opcode_events_ | ||
#. conditional_jump_triggers_ | ||
#. sites_ | ||
#. rio_events_ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about this... are the RIO triggers and events usable from Python at all in an application?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are. We test it:
def test_rio_events_rep_cap(self, single_instrument_session): |
def test_rio_triggers_rep_cap(self, single_instrument_session): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They work. But are they actually useful in an application? Given that there is no LVFPGA support in Python.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, maybe not.
I can create an issue to remove them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They work. But are they actually useful in an application? Given that there is no LVFPGA support in Python.
I think there is support.
https://github.com/ni/nifpga-python
…ype in documentation for each capability.
I've updated CHANGELOG.md if applicable.What does this Pull Request accomplish?
There are several issues open against the way we document usage of repeated capabilities in our rep_caps.rst pages.
Summary of Issues
This PR addresses these by doing the following:
List issues fixed by this Pull Request below, if any.
What testing has been done?
Local code generation with documentation inspection.