Skip to content
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

Indexing Error on Last Bin #20

Open
magsreed opened this issue Dec 11, 2024 · 0 comments · May be fixed by #21
Open

Indexing Error on Last Bin #20

magsreed opened this issue Dec 11, 2024 · 0 comments · May be fixed by #21
Assignees
Labels
bug Something isn't working

Comments

@magsreed
Copy link
Contributor

current_mask = self._get_cut_mask(ofamp_lims=ofamp_lims_arr, cut_pars=current_exception_pars,
lgcdiagnostics=lgcdiagnostics,
include_previous_cuts=include_previous_cuts,
on_cut_bin =i + 1)

There appears to be an indexing error on the last bin for amplitude cuts.

Diagnosis:

Adding the following print statements before lines

self.values_upper[on_cut_bin] = cut_pars['val_upper']

-> print(f'on_cut_bin', on_cut_bin)
-> print(f'values_upper size: ', len(self.values_upper))

Input code:

ofamp_limits = [-1e-8,-0.5e-8, 0.0, 1e-8]
cut_exception_pars = {'val_upper': 2.8e3, 'val_lower': 0.}
exceptions_dict = {0: cut_exception_pars, 1: cut_exception_pars, 2: cut_exception_pars, 3: cut_exception_pars}
chi2_cut = Semiautocut(myanalyzer_feature.df, cut_rq = 'lowchi2_of1x1_nodelay', channel_name='IrPtTES100x25',
                               cut_pars=cut_pars_chi2, ofamp_bins = ofamp_limits,
                      exceptions_dict=exceptions_dict)

Results:

on_cut_bin: 0
val_upper size: 4
on_cut_bin: 1
val_upper size: 4
on_cut_bin: 2
val_upper size: 4
on_cut_bin: 4
val_upper size: 4

Results above indicate over indexing on the last bin only. Simple fix is to remove the extraneous +=1 on

current_mask = self._get_cut_mask(ofamp_lims=ofamp_lims_arr, cut_pars=current_exception_pars,
lgcdiagnostics=lgcdiagnostics,
include_previous_cuts=include_previous_cuts,
on_cut_bin =i + 1)

Above appears to index i twice on the last bin, thus overshooting. I am submitting the issue and then immediately fixing with a PR request as I just tested if removing the extra indexing on the last bin fixes the issue totally, and had success.

@magsreed magsreed added the bug Something isn't working label Dec 11, 2024
@magsreed magsreed self-assigned this Dec 11, 2024
@magsreed magsreed linked a pull request Dec 11, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant