Skip to content

Dead and stale code: dead duplicates, removed mpl API, test fixture typo #233

@bdestombe

Description

@bdestombe

Three small standalone hygiene fixes bundled together to reduce issue noise. Each is independently trivial.

1. AP Sensing CH2 test fixture path typo

tests/test_datastore.py:54:

data_dir_ap_sensing_2_CH1 = os.path.join(wd, \"data\", \"ap_sensing_2\", \"CH1_SE\")
data_dir_ap_sensing_2_CH2 = os.path.join(wd, \"data\", \"ap_sensing_2\", \"CH1_SE\")  # <-- should be CH2_SE

Both CH1 and CH2 constants point at CH1_SE. The double-ended AP Sensing test (test_read_apsensing_files_double_ended) is therefore building its DE dataset out of two copies of CH1, not CH1+CH2. The current tmpw == 49.86 check passes only by coincidence — the test does not verify that forward and backward Stokes actually differ.

Fix: change to \"CH2_SE\". Add an assertion that ds_fw.st.values != ds_bw.st.values to prevent regression.

2. matching_section_location_indices has duplicate unreachable body

src/dtscalibration/calibrate_utils.py:1588-1609:

def matching_section_location_indices(...):
    ix_cal_match = np.unique(np.concatenate((ix_sec, hix, tix)))
    nx_cal_match = ix_cal_match.size
    ix_sec2 = np.searchsorted(ix_cal_match, ix_sec)
    ix_E0_mask = np.array([ix for ix in range(nx_cal_match) if ix != ix_sec2[0]])
    ix_from_cal_match_to_glob = ix_cal_match[ix_E0_mask]
    return ix_from_cal_match_to_glob          # <-- returns here
    # contains all indices of the entire fiber that either are used for
    # calibrating to reference temperature or for matching sections. Is sorted.
    ix_cal_match = np.unique(np.concatenate((ix_sec, hix, tix)))
    ...                                        # <-- 16 lines of unreachable copy
    return ix_from_cal_match_to_glob

Lines 1594-1609 are an exact verbatim copy of lines 1588-1593, unreachable after the first return. Suggests an abandoned mid-refactor.

Fix: delete lines 1594-1609.

3. plot_residuals_reference_sections uses removed matplotlib API

src/dtscalibration/plot.py:137, 142, 149, 153:

section_axes[-1].get_shared_x_axes().join(section_axes[-1], section_ax)

Axes.get_shared_x_axes().join(...) was deprecated in matplotlib 3.6 and removed in 3.8. The replacement is Axes.sharex(...) (and Axes.sharey(...) for the y-axis variant at :142). On any matplotlib ≥ 3.8 install, calling this plot raises AttributeError.

Fix: replace with the modern sharex / sharey API. Add a smoke test for plot_residuals_reference_sections (currently entirely uncovered) so future deprecations surface immediately.

Suggested tests

  • Single test asserting ds_fw.st.values != ds_bw.st.values after the AP Sensing CH2 fixture is corrected.
  • Smoke test calling plot_residuals_reference_sections end-to-end on a small calibrated synthetic Dataset (with matplotlib.use(\"Agg\")).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions