# Buggy code
def recalculate_overall_sensitivity(self, frequency=None):
    """
    Recalculates the overall sensitivity.

    :param frequency: Choose frequency at which to calculate the
        sensitivity. If not given it will be chosen automatically.
    """
    if not hasattr(self, "instrument_sensitivity"):
        msg = (
            "Could not find an instrument sensitivity - will not "
            "recalculate the overall sensitivity."
        )
        raise ValueError(msg)

    if not self.instrument_sensitivity.input_units:
        msg = (
            "Could not determine input units - will not "
            "recalculate the overall sensitivity."
        )
        raise ValueError(msg)

    i_u = self.instrument_sensitivity.input_units

    unit_map = {
        "DISP": ["M"],
        "VEL": ["M/S", "M/SEC"],
        "ACC": ["M/S**2", "M/(S**2)", "M/SEC**2", "M/(SEC**2)", "M/S/S"],
    }
    unit = None
    for key, value in unit_map.items():
        if i_u and i_u.upper() in value:
            unit = key
    if not unit:
        msg = (
            "ObsPy does not know how to map unit '%s' to "
            "displacement, velocity, or acceleration - overall "
            "sensitivity will not be recalculated."
        ) % i_u
        raise ValueError(msg)

    # Determine frequency if not given.
    if frequency is None:
        # lookup normalization frequency of sensor's first stage it should
        # be in the flat part of the response
        stage_one = self.response_stages[0]
        try:
            frequency = stage_one.normalization_frequency
        except AttributeError:
            pass
        for stage in self.response_stages[::-1]:
            # determine sampling rate
            try:
                sampling_rate = (
                    stage.decimation_input_sample_rate / stage.decimation_factor
                )
                break
            except Exception:
                continue
        else:
            sampling_rate = None
        if sampling_rate:
            # if sensor's normalization frequency is above 0.5 * nyquist,
            # use that instead (e.g. to avoid computing an overall
            # sensitivity above nyquist)
            nyquist = sampling_rate / 2.0
            if frequency:
                frequency = min(frequency, nyquist / 2.0)
            else:
                frequency = nyquist / 2.0

    if frequency is None:
        msg = (
            "Could not automatically determine a suitable frequency "
            "at which to calculate the sensitivity. The overall "
            "sensitivity will not be recalculated."
        )
        raise ValueError(msg)

    freq, gain = self._get_overall_sensitivity_and_gain(
        output=unit, frequency=frequency
    )

    self.instrument_sensitivity.value = gain
    self.instrument_sensitivity.frequency = freq


# Traceback (ArgumentError)
In [0]: from obspy import read_inventory, UTCDateTime as UTC
In [1]: inv = read_inventory()
In [4]: rsp = inv.get_response('BW.RJOB..EHZ', UTC())
In [5]: rsp.recalculate_overall_sensitivity(5)
---------------------------------------------------------------------------
ArgumentError                             Traceback (most recent call last)
<ipython-input-5-9892716a93fe> in <module>()
----> 1 rsp.recalculate_overall_sensitivity(5)

~/dev/obspy/obspy/core/inventory/response.py in recalculate_overall_sensitivity(self, frequency)
1029
1030         freq, gain = self._get_overall_sensitivity_and_gain(
-> 1031             output=unit, frequency=frequency)
1032
1033         self.instrument_sensitivity.value = gain

~/dev/obspy/obspy/core/inventory/response.py in _get_overall_sensitivity_and_gain(self, frequency, output)
1064         response_at_frequency = self._call_eval_resp_for_frequencies(
1065             frequencies=[frequency], output=output,
-> 1066             hide_sensitivity_mismatch_warning=True)[0][0]
1067         overall_sensitivity = abs(response_at_frequency)
1068         return frequency, overall_sensitivity

~/dev/obspy/obspy/core/inventory/response.py in _call_eval_resp_for_frequencies(self, frequencies, output, start_stage, end_stage, hide_sensitivity_mismatch_warning)
1574             rc = clibevresp._obspy_calc_resp(C.byref(chan), frequencies,
1575                                              len(frequencies),
-> 1576                                              output, out_units, -1, 0, 0)
1577             if rc:
1578                 e, m = ew.ENUM_ERROR_CODES[rc]

ArgumentError: argument 2: <class 'TypeError'>: array must have data type float64

# Fixed code
def recalculate_overall_sensitivity(self, frequency=None):
    """
    Recalculates the overall sensitivity.

    :param frequency: Choose frequency at which to calculate the
        sensitivity. If not given it will be chosen automatically.
    """
    if not hasattr(self, "instrument_sensitivity"):
        msg = (
            "Could not find an instrument sensitivity - will not "
            "recalculate the overall sensitivity."
        )
        raise ValueError(msg)

    if not self.instrument_sensitivity.input_units:
        msg = (
            "Could not determine input units - will not "
            "recalculate the overall sensitivity."
        )
        raise ValueError(msg)

    i_u = self.instrument_sensitivity.input_units

    unit_map = {
        "DISP": ["M"],
        "VEL": ["M/S", "M/SEC"],
        "ACC": ["M/S**2", "M/(S**2)", "M/SEC**2", "M/(SEC**2)", "M/S/S"],
    }
    unit = None
    for key, value in unit_map.items():
        if i_u and i_u.upper() in value:
            unit = key
    if not unit:
        msg = (
            "ObsPy does not know how to map unit '%s' to "
            "displacement, velocity, or acceleration - overall "
            "sensitivity will not be recalculated."
        ) % i_u
        raise ValueError(msg)

    # Determine frequency if not given.
    if frequency is None:
        # lookup normalization frequency of sensor's first stage it should
        # be in the flat part of the response
        stage_one = self.response_stages[0]
        try:
            frequency = stage_one.normalization_frequency
        except AttributeError:
            pass
        for stage in self.response_stages[::-1]:
            # determine sampling rate
            try:
                sampling_rate = (
                    stage.decimation_input_sample_rate / stage.decimation_factor
                )
                break
            except Exception:
                continue
        else:
            sampling_rate = None
        if sampling_rate:
            # if sensor's normalization frequency is above 0.5 * nyquist,
            # use that instead (e.g. to avoid computing an overall
            # sensitivity above nyquist)
            nyquist = sampling_rate / 2.0
            if frequency:
                frequency = min(frequency, nyquist / 2.0)
            else:
                frequency = nyquist / 2.0

    if frequency is None:
        msg = (
            "Could not automatically determine a suitable frequency "
            "at which to calculate the sensitivity. The overall "
            "sensitivity will not be recalculated."
        )
        raise ValueError(msg)

    freq, gain = self._get_overall_sensitivity_and_gain(
        output=unit, frequency=float(frequency)
    )

    self.instrument_sensitivity.value = gain
    self.instrument_sensitivity.frequency = freq