-
Notifications
You must be signed in to change notification settings - Fork 23
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
mef.get_transform_fxn() outputs should be OrderedDict instead of lists to carry around channel ID #232
Comments
There are two separate issues here. I'll tackle the one about In [1]: import collections
In [2]: d = collections.OrderedDict()
In [3]: d['k1'] = 1
In [4]: d['k2'] = 2
In [5]: for di in d:
...: print di
...:
k1
k2 In addition, I think the main problem is that The other issue that you present is the output of
I would prefer the first option. It seems to me that this is not a problem of poor design in In general, I have some inertia towards changing things to OrderedDicts because I prefer to use native types when possible, and because user's code will break. |
Also, the description of |
Agreed. Issue 1 -
|
Ditto "Issue 1" for |
So issue 2 is not an issue anymore, besides documentation? I'm becoming more convinced that making |
Yeah, I think so.
I agree this should probably be a 2nd digit version change. As mentioned above, possibly appropriate to roll out with Compensation (but generally, whenever the issue has been sufficiently fixed and can be bundled with other more important changes that warrant a 2nd digit version change). Are you omitting I am not currently working on this, but I think the foundational change should be pretty straightforward. Specifically, updating the accumulator data structure update statements: # If no errors were found, store results
beads_samples.append(beads_sample_gated)
mef_transform_fxns[beads_id] = mef_transform_fxn
if full_output:
mef_outputs.append(mef_output) and propagating those changes to any code that uses those structures (I haven't looked recently at how far-reaching those propagations would be). If you're on board with updating |
No, I forgot about it.
Yes. I'll open another issue for the documentation and work on it. |
mef.get_transform_fxn()
loops through specified MEF channels and builds afunctools.partial
function which transforms RFI values to MEF values based on specified bead data. If you ask forfull_output
, this function accumulates useful intermediate data structures and information for each specified MEF channel (specified viamef_channels
input) in a series of lists and returns these lists to the user. E.g. from themef.get_transform_fxn()
documentation -I think it would be more useful if these accumulation data structures were
OrderedDict
s keyed on themef_channels
values. This seems like a natural way to carry around the channel ID for use in subsequent computations, and I believe the original list can be recovered easily viaOrderedDict.values()
.My use case is that I'm using the
excel_ui.process_beads_table()
function from the Python API, and I want to print the detector voltages of the channels I've chosen to MEF.excel_ui.process_beads_table()
returns:so I can extract useful information (e.g. the bead fitting parameters) by accessing
mef_outputs
via the numerical list index which corresponds to the Beads table entry I am interested in. (I will note here thatmef_outputs
andbeads_samples
should also maybe be an OrderedDict to be consistent withmef_transform_fxns
. In general, I've found it very useful to loop through the Beads Table UIDs (DataFrame index) and access these structures via the UID instead of having to additionally carry around the list index (e.g. viaenumerate
) to access a bunch of lists).From this context, though, I don't have access to the
mef_channels
thatexcel_ui.process_beads_table()
calledmef.get_transform_fxn()
with without going back to the Excel file and re-parsing/extracting them myself, which seems woefully inelegant. I don't think it's possible in the general case with the current implementation to determine the channel ID without consulting the Excel file because the user can specify any combination of valid channels to MEF.Problematic example code:
I would prefer:
The text was updated successfully, but these errors were encountered: