python类nanargmin()的实例源码

data.py 文件源码 项目:trappist1 作者: rodluger 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def mouse_drag(self, event):
    '''

    '''

    if event.inaxes == self.ax and event.button == 1:

      # Index of nearest point
      i = np.nanargmin(((event.xdata - self.x) / self.nx) ** 2)
      j = np.nanargmin(((event.ydata - self.y) / self.ny) ** 2)  

      if (i == self.last_i) and (j == self.last_j):
        return
      else:
        self.last_i = i
        self.last_j = j

      # Toggle pixel
      if self.aperture[j,i]:
        self.aperture[j,i] = 0
      else:
        self.aperture[j,i] = 1

      # Update the contour
      self.update()
data.py 文件源码 项目:trappist1 作者: rodluger 项目源码 文件源码 阅读 37 收藏 0 点赞 0 评论 0
def mouse_click(self, event):
    '''

    '''

    if event.mouseevent.inaxes == self.ax:

      # Index of nearest point
      i = np.nanargmin(((event.mouseevent.xdata - self.x) / self.nx) ** 2)
      j = np.nanargmin(((event.mouseevent.ydata - self.y) / self.ny) ** 2)  
      self.last_i = i
      self.last_j = j

      # Toggle pixel
      if self.aperture[j,i]:
        self.aperture[j,i] = 0
      else:
        self.aperture[j,i] = 1

      # Update the contour
      self.update()
optimization_tools.py 文件源码 项目:pycma 作者: CMA-ES 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def update(self, arx, xarchive=None, arf=None, evals=None):
        """checks for better solutions in list ``arx``.

        Based on the smallest corresponding value in ``arf``,
        alternatively, `update` may be called with a `BestSolution`
        instance like ``update(another_best_solution)`` in which case
        the better solution becomes the current best.

        ``xarchive`` is used to retrieve the genotype of a solution.
        """
        if isinstance(arx, BestSolution):
            if self.evalsall is None:
                self.evalsall = arx.evalsall
            elif arx.evalsall is not None:
                self.evalsall = max((self.evalsall, arx.evalsall))
            if arx.f is not None and arx.f < np.inf:
                self.update([arx.x], xarchive, [arx.f], arx.evals)
            return self
        assert arf is not None
        # find failsave minimum
        try:
            minidx = np.nanargmin(arf)
        except ValueError:
            return
        if minidx is np.nan:
            return
        minarf = arf[minidx]
        # minarf = reduce(lambda x, y: y if y and y is not np.nan
        #                   and y < x else x, arf, np.inf)
        if minarf < np.inf and (minarf < self.f or self.f is None):
            self.x, self.f = arx[minidx], arf[minidx]
            if xarchive is not None and xarchive.get(self.x) is not None:
                self.x_geno = xarchive[self.x].get('geno')
            else:
                self.x_geno = None
            self.evals = None if not evals else evals - len(arf) + minidx + 1
            self.evalsall = evals
        elif evals:
            self.evalsall = evals
        self.last.x = arx[minidx]
        self.last.f = minarf
test_nanfunctions.py 文件源码 项目:radar 作者: amoose136 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def test_nanargmin(self):
        tgt = np.argmin(self.mat)
        for mat in self.integer_arrays():
            assert_equal(np.nanargmin(mat), tgt)
cma_es_lib.py 文件源码 项目:third_person_im 作者: bstadie 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def update(self, arx, xarchive=None, arf=None, evals=None):
        """checks for better solutions in list `arx`.

        Based on the smallest corresponding value in `arf`,
        alternatively, `update` may be called with a `BestSolution`
        instance like ``update(another_best_solution)`` in which case
        the better solution becomes the current best.

        `xarchive` is used to retrieve the genotype of a solution.

        """
        if isinstance(arx, BestSolution):
            if self.evalsall is None:
                self.evalsall = arx.evalsall
            elif arx.evalsall is not None:
                self.evalsall = max((self.evalsall, arx.evalsall))
            if arx.f is not None and arx.f < np.inf:
                self.update([arx.x], xarchive, [arx.f], arx.evals)
            return self
        assert arf is not None
        # find failsave minimum
        minidx = np.nanargmin(arf)
        if minidx is np.nan:
            return
        minarf = arf[minidx]
        # minarf = reduce(lambda x, y: y if y and y is not np.nan
        #                   and y < x else x, arf, np.inf)
        if minarf < np.inf and (minarf < self.f or self.f is None):
            self.x, self.f = arx[minidx], arf[minidx]
            if xarchive is not None and xarchive.get(self.x) is not None:
                self.x_geno = xarchive[self.x].get('geno')
            else:
                self.x_geno = None
            self.evals = None if not evals else evals - len(arf) + minidx + 1
            self.evalsall = evals
        elif evals:
            self.evalsall = evals
        self.last.x = arx[minidx]
        self.last.f = minarf
cma_es_lib.py 文件源码 项目:rllabplusplus 作者: shaneshixiang 项目源码 文件源码 阅读 39 收藏 0 点赞 0 评论 0
def update(self, arx, xarchive=None, arf=None, evals=None):
        """checks for better solutions in list `arx`.

        Based on the smallest corresponding value in `arf`,
        alternatively, `update` may be called with a `BestSolution`
        instance like ``update(another_best_solution)`` in which case
        the better solution becomes the current best.

        `xarchive` is used to retrieve the genotype of a solution.

        """
        if isinstance(arx, BestSolution):
            if self.evalsall is None:
                self.evalsall = arx.evalsall
            elif arx.evalsall is not None:
                self.evalsall = max((self.evalsall, arx.evalsall))
            if arx.f is not None and arx.f < np.inf:
                self.update([arx.x], xarchive, [arx.f], arx.evals)
            return self
        assert arf is not None
        # find failsave minimum
        minidx = np.nanargmin(arf)
        if minidx is np.nan:
            return
        minarf = arf[minidx]
        # minarf = reduce(lambda x, y: y if y and y is not np.nan
        #                   and y < x else x, arf, np.inf)
        if minarf < np.inf and (minarf < self.f or self.f is None):
            self.x, self.f = arx[minidx], arf[minidx]
            if xarchive is not None and xarchive.get(self.x) is not None:
                self.x_geno = xarchive[self.x].get('geno')
            else:
                self.x_geno = None
            self.evals = None if not evals else evals - len(arf) + minidx + 1
            self.evalsall = evals
        elif evals:
            self.evalsall = evals
        self.last.x = arx[minidx]
        self.last.f = minarf
cma.py 文件源码 项目:cma 作者: hardmaru 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def update(self, arx, xarchive=None, arf=None, evals=None):
        """checks for better solutions in list `arx`.

        Based on the smallest corresponding value in `arf`,
        alternatively, `update` may be called with a `BestSolution`
        instance like ``update(another_best_solution)`` in which case
        the better solution becomes the current best.

        `xarchive` is used to retrieve the genotype of a solution.

        """
        if isinstance(arx, BestSolution):
            if self.evalsall is None:
                self.evalsall = arx.evalsall
            elif arx.evalsall is not None:
                self.evalsall = max((self.evalsall, arx.evalsall))
            if arx.f is not None and arx.f < np.inf:
                self.update([arx.x], xarchive, [arx.f], arx.evals)
            return self
        assert arf is not None
        # find failsave minimum
        minidx = np.nanargmin(arf)
        if minidx is np.nan:
            return
        minarf = arf[minidx]
        # minarf = reduce(lambda x, y: y if y and y is not np.nan
        #                   and y < x else x, arf, np.inf)
        if minarf < np.inf and (minarf < self.f or self.f is None):
            self.x, self.f = arx[minidx], arf[minidx]
            if xarchive is not None and xarchive.get(self.x) is not None:
                self.x_geno = xarchive[self.x].get('geno')
            else:
                self.x_geno = None
            self.evals = None if not evals else evals - len(arf) + minidx + 1
            self.evalsall = evals
        elif evals:
            self.evalsall = evals
        self.last.x = arx[minidx]
        self.last.f = minarf
test_nanfunctions.py 文件源码 项目:krpcScripts 作者: jwvanderbeck 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def test_nanargmin(self):
        tgt = np.argmin(self.mat)
        for mat in self.integer_arrays():
            assert_equal(np.nanargmin(mat), tgt)
stellar_parameters.py 文件源码 项目:smhr 作者: andycasey 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def figure_mouse_pick(self, event):
        """
        Trigger for when the mouse is used to select an item in the figure.

        :param event:
            The matplotlib event.
        """

        ycol = "abundance"
        xcol = {
            self.ax_excitation_twin: "expot",
            self.ax_line_strength_twin: "reduced_equivalent_width"
        }[event.inaxes]

        xscale = np.ptp(event.inaxes.get_xlim())
        yscale = np.ptp(event.inaxes.get_ylim())
        try:
            distance = np.sqrt(
                    ((self._state_transitions[ycol] - event.ydata)/yscale)**2 \
                +   ((self._state_transitions[xcol] - event.xdata)/xscale)**2)
        except AttributeError:
            # Stellar parameters have not been measured yet
            return None

        index = np.nanargmin(distance)

        # Because the state transitions are linked to the parent source model of
        # the table view, we will have to get the proxy index.
        proxy_index = self.table_view.model().mapFromSource(
            self.proxy_spectral_models.sourceModel().createIndex(index, 0)).row()

        self.table_view.selectRow(proxy_index)
        return None
detect_stages_tph1.py 文件源码 项目:CElegansBehaviour 作者: ChristophKirst 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def find_min(x, bin_width = 10):
  xm = binned_average(x, bin_width=bin_width);
  imin = np.nanargmin(xm);
  return int((imin + 0.5) * bin_width);
detect_stages_n2.py 文件源码 项目:CElegansBehaviour 作者: ChristophKirst 项目源码 文件源码 阅读 37 收藏 0 点赞 0 评论 0
def find_min(x, bin_width = 10):
  xm = binned_average(x, bin_width=bin_width);
  imin = np.nanargmin(xm);
  return int((imin + 0.5) * bin_width);
detect_stages_cat2.py 文件源码 项目:CElegansBehaviour 作者: ChristophKirst 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def find_min(x, bin_width = 10):
  xm = binned_average(x, bin_width=bin_width);
  imin = np.nanargmin(xm);
  return int((imin + 0.5) * bin_width);
detect_stages_npr1.py 文件源码 项目:CElegansBehaviour 作者: ChristophKirst 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def find_min(x, bin_width = 10):
  xm = binned_average(x, bin_width=bin_width);
  imin = np.nanargmin(xm);
  return int((imin + 0.5) * bin_width);
detect_stages_daf7.py 文件源码 项目:CElegansBehaviour 作者: ChristophKirst 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
def find_min(x, bin_width = 10):
  xm = binned_average(x, bin_width=bin_width);
  imin = np.nanargmin(xm);
  return int((imin + 0.5) * bin_width);
optimize.py 文件源码 项目:scikit-gstat 作者: mmaelicke 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def Variogram(self):
        """

        :return:
        """
        self.run()

        # find the best Variogram
        idx = np.nanargmin(self.e)

        return self.V[idx]
evaluate_new.py 文件源码 项目:motion-classification 作者: matthiasplappert 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def _select_best_measure_index(curr_measures, args):
    idx = None
    try:
        if args.measure == 'aicc':
            # The best score for AICc is the minimum.
            idx = np.nanargmin(curr_measures)
        elif args.measure in ['hmm-distance', 'wasserstein', 'mahalanobis']:
            # The best score for the l-d measure is the maximum.
            idx = np.nanargmax(curr_measures)
    except:
        idx = random.choice(range(len(curr_measures)))
    assert idx is not None
    return idx
bench_classify_online.py 文件源码 项目:DeepRepICCV2015 作者: tomrunia 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def initial_count(classify, test_set_x, data, valid):

    (valid_st2,valid_st5,valid_st8) = valid
    (ns_test_set_x_st2,ns_test_set_x_st5,ns_test_set_x_st8) = data

    # classify st_2 it is always valid
    (st2_count, st2_res, st2_entropy) = count_in_interval(classify, test_set_x, ns_test_set_x_st2, 0, 0, 81)  #100 - 19 etc.

    # check if st5 is valid. if not return st2 count
    if (valid_st5 == 1):
        (st5_count, st5_res, st5_entropy) = count_in_interval(classify, test_set_x, ns_test_set_x_st5, 0, 0, 21)
    else:
        st8_entropy = numpy.inf

    if (valid_st8 == 1):
        (st8_count, st8_res, st8_entropy) = count_in_interval(classify, test_set_x, ns_test_set_x_st8, 0, 0, 6)
    else:
        st8_entropy = numpy.inf


    winner = numpy.nanargmin(numpy.array([st2_entropy, st5_entropy, st8_entropy]))

    if (winner == 0):
        # winner is stride 2
        return (st2_count, (st2_res*2/2,st2_res*2/5, st2_res*2/8))
    if (winner == 1):
        # winner is stride 5
        return (st5_count, (st5_res*5/2,st5_res*5/5, st5_res*5/8))
    if (winner == 2):
        # winner is stride 8
        return (st8_count, (st8_res*8/2,st8_res*8/5, st8_res*8/8))
bench_classify_online.py 文件源码 项目:DeepRepICCV2015 作者: tomrunia 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def get_next_count(classify, test_set_x, data, valid, global_count, curr_residue, start_frame):

    (valid_st2,valid_st5,valid_st8) = valid
    (ns_test_set_x_st2,ns_test_set_x_st5,ns_test_set_x_st8) = data
    (curr_residue_st2, curr_residue_st5, curr_residue_st8) = curr_residue

    # classify st_2 it is always valid
    (st2_count, st2_res, st2_entropy) = count_in_interval(classify, test_set_x, ns_test_set_x_st2, curr_residue_st2, (start_frame/2-19), (start_frame/2-19)+20)
    # check if st5 is valid. if not return st2 count
    if (valid_st5 == 1):
        (st5_count, st5_res, st5_entropy) = count_in_interval(classify, test_set_x, ns_test_set_x_st5, curr_residue_st5, (start_frame/5-19), (start_frame/5-19)+8)
    else:
        st5_entropy = numpy.inf

    if (valid_st8 == 1):
        (st8_count, st8_res, st8_entropy) = count_in_interval(classify, test_set_x, ns_test_set_x_st8, curr_residue_st8, (start_frame/8-19), (start_frame/8-19)+5)
    else:
        st8_entropy = numpy.inf

    winner = numpy.nanargmin(numpy.array([st2_entropy, st5_entropy, st8_entropy]))

    if (winner == 0):
        # winner is stride 2
        return (global_count + st2_count, (st2_res*2/2,st2_res*2/5, st2_res*2/8))
    if (winner == 1):
        # winner is stride 5
        return (global_count + st5_count, (st5_res*5/2,st5_res*5/5, st5_res*5/8))
    if (winner == 2):
        # winner is stride 8
        return (global_count + st8_count, (st8_res*8/2,st8_res*8/5, st8_res*8/8))
bench_classify_online.py 文件源码 项目:DeepRepICCV2015 作者: tomrunia 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def get_remain_count(classify, test_set_x, data, valid, global_count, curr_residue, start_frame):

    (valid_st2,valid_st5,valid_st8) = valid
    (ns_test_set_x_st2,ns_test_set_x_st5,ns_test_set_x_st8) = data
    (curr_residue_st2, curr_residue_st5, curr_residue_st8) = curr_residue

    # classify st_2 it is always valid
    (st2_count, st2_res, st2_entropy) = count_in_interval(classify, test_set_x, ns_test_set_x_st2, curr_residue_st2, (start_frame/2-19), ns_test_set_x_st2.shape[0])
    # check if st5 is valid. if not return st2 count
    if (valid_st5 == 1):
        (st5_count, st5_res, st5_entropy) = count_in_interval(classify, test_set_x, ns_test_set_x_st5, curr_residue_st5, (start_frame/5-19), ns_test_set_x_st5.shape[0])
    else:
        st5_entropy = numpy.inf

    if (valid_st8 == 1):
        (st8_count, st8_res, st8_entropy) = count_in_interval(classify, test_set_x, ns_test_set_x_st8, curr_residue_st8, (start_frame/8-19), ns_test_set_x_st8.shape[0])
    else:
        st8_entropy = numpy.inf


    winner = numpy.nanargmin(numpy.array([st2_entropy, st5_entropy, st8_entropy]))

    if (winner == 0):
        # winner is stride 2
        return (global_count + st2_count)
    if (winner == 1):
        # winner is stride 5
        return (global_count + st5_count)
    if (winner == 2):
        # winner is stride 8
        return (global_count + st8_count)
bench_classify_online.py 文件源码 项目:DeepRepICCV2015 作者: tomrunia 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def count_entire_movie(classify, test_set_x, data, valid, global_count, curr_residue, start_frame):

    (valid_st2,valid_st5,valid_st8) = valid
    (ns_test_set_x_st2,ns_test_set_x_st5,ns_test_set_x_st8) = data
    (curr_residue_st2, curr_residue_st5, curr_residue_st8) = curr_residue

    # classify st_2 it is always valid
    (st2_count, st2_res, st2_entropy) = count_in_interval(classify, test_set_x, ns_test_set_x_st2, curr_residue_st2, 0, ns_test_set_x_st2.shape[0])
    # check if st5 is valid. if not return st2 count
    if (valid_st5 == 1):
        (st5_count, st5_res, st5_entropy) = count_in_interval(classify, test_set_x, ns_test_set_x_st5, curr_residue_st5, 0, ns_test_set_x_st5.shape[0])
    else:
        st5_entropy = numpy.inf

    if (valid_st8 == 1):
        (st8_count, st8_res, st8_entropy) = count_in_interval(classify, test_set_x, ns_test_set_x_st8, curr_residue_st8, 0, ns_test_set_x_st8.shape[0])
    else:
        st8_entropy = numpy.inf

    winner = numpy.nanargmin(numpy.array([st2_entropy, st5_entropy, st8_entropy]))

    if (winner == 0):
        # winner is stride 2
        return (global_count + st2_count)
    if (winner == 1):
        # winner is stride 5
        return (global_count + st5_count)
    if (winner == 2):
        # winner is stride 8
        return (global_count + st8_count)
test_nanfunctions.py 文件源码 项目:aws-lambda-numpy 作者: vitolimandibhrata 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def test_nanargmin(self):
        tgt = np.argmin(self.mat)
        for mat in self.integer_arrays():
            assert_equal(np.nanargmin(mat), tgt)
soinn.py 文件源码 项目:soinn 作者: fukatani 项目源码 文件源码 阅读 36 收藏 0 点赞 0 评论 0
def __find_nearest_nodes(self, num, signal, mahar=True):
        #if mahar: return self.__find_nearest_nodes_by_mahar(num, signal)
        n = self.nodes.shape[0]
        indexes = [0.0] * num
        sq_dists = [0.0] * num
        D = util.calc_distance(self.nodes, np.asarray([signal] * n))
        for i in range(num):
            indexes[i] = np.nanargmin(D)
            sq_dists[i] = D[indexes[i]]
            D[indexes[i]] = float('nan')
        return indexes, sq_dists
cma_es_lib.py 文件源码 项目:gail-driver 作者: sisl 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
def update(self, arx, xarchive=None, arf=None, evals=None):
        """checks for better solutions in list `arx`.

        Based on the smallest corresponding value in `arf`,
        alternatively, `update` may be called with a `BestSolution`
        instance like ``update(another_best_solution)`` in which case
        the better solution becomes the current best.

        `xarchive` is used to retrieve the genotype of a solution.

        """
        if isinstance(arx, BestSolution):
            if self.evalsall is None:
                self.evalsall = arx.evalsall
            elif arx.evalsall is not None:
                self.evalsall = max((self.evalsall, arx.evalsall))
            if arx.f is not None and arx.f < np.inf:
                self.update([arx.x], xarchive, [arx.f], arx.evals)
            return self
        assert arf is not None
        # find failsave minimum
        minidx = np.nanargmin(arf)
        if minidx is np.nan:
            return
        minarf = arf[minidx]
        # minarf = reduce(lambda x, y: y if y and y is not np.nan
        #                   and y < x else x, arf, np.inf)
        if minarf < np.inf and (minarf < self.f or self.f is None):
            self.x, self.f = arx[minidx], arf[minidx]
            if xarchive is not None and xarchive.get(self.x) is not None:
                self.x_geno = xarchive[self.x].get('geno')
            else:
                self.x_geno = None
            self.evals = None if not evals else evals - len(arf) + minidx + 1
            self.evalsall = evals
        elif evals:
            self.evalsall = evals
        self.last.x = arx[minidx]
        self.last.f = minarf
test_nanfunctions.py 文件源码 项目:lambda-numba 作者: rlhotovy 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def test_nanargmin(self):
        tgt = np.argmin(self.mat)
        for mat in self.integer_arrays():
            assert_equal(np.nanargmin(mat), tgt)
test_nanfunctions.py 文件源码 项目:deliver 作者: orchestor 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def test_nanargmin(self):
        tgt = np.argmin(self.mat)
        for mat in self.integer_arrays():
            assert_equal(np.nanargmin(mat), tgt)
delay_estimator.py 文件源码 项目:pactools 作者: pactools 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def plot(self, ax=None, write_tau=True):
        """
        Returns
        -------
        fig : matplotlib.figure.Figure
            Figure instance containing the plot.
        """
        check_is_fitted(self, 'neg_log_likelihood_')
        if ax is None:
            fig = plt.figure()
            ax = fig.gca()
        else:
            fig = ax.figure

        blue, green, red, purple, yellow, cyan = SEABORN_PALETTES['deep']

        i_best = np.nanargmin(self.neg_log_likelihood_)
        ax.plot(self.delays_ms_, self.neg_log_likelihood_, color=purple)
        ax.plot(self.delays_ms_[i_best], self.neg_log_likelihood_[i_best], 'D',
                color=red)
        ax.set_xlabel('Delay (ms)')
        ax.set_ylabel('Neg. log likelihood / T')
        ax.grid('on')

        if write_tau:
            ax.text(0.5, 0.80, r'$\mathrm{Estimated}$',
                    horizontalalignment='center', transform=ax.transAxes)
            ax.text(0.5, 0.66, r'$\tau_0 = %.0f \;\mathrm{ms}$' %
                    (self.delays_ms_[i_best], ), horizontalalignment='center',
                    transform=ax.transAxes)

        return fig
test_delay_estimator.py 文件源码 项目:pactools 作者: pactools 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def test_delay_shape():
    est = fast_delay()
    assert_equal(est.neg_log_likelihood_.shape, est.delays_ms_.shape)
    assert_greater(est.neg_log_likelihood_.shape[0], 1)
    i_best = np.nanargmin(est.neg_log_likelihood_)
    assert_equal(est.best_delay_ms_, est.delays_ms_[i_best])
cma_es_lib.py 文件源码 项目:rllab 作者: rll 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def update(self, arx, xarchive=None, arf=None, evals=None):
        """checks for better solutions in list `arx`.

        Based on the smallest corresponding value in `arf`,
        alternatively, `update` may be called with a `BestSolution`
        instance like ``update(another_best_solution)`` in which case
        the better solution becomes the current best.

        `xarchive` is used to retrieve the genotype of a solution.

        """
        if isinstance(arx, BestSolution):
            if self.evalsall is None:
                self.evalsall = arx.evalsall
            elif arx.evalsall is not None:
                self.evalsall = max((self.evalsall, arx.evalsall))
            if arx.f is not None and arx.f < np.inf:
                self.update([arx.x], xarchive, [arx.f], arx.evals)
            return self
        assert arf is not None
        # find failsave minimum
        minidx = np.nanargmin(arf)
        if minidx is np.nan:
            return
        minarf = arf[minidx]
        # minarf = reduce(lambda x, y: y if y and y is not np.nan
        #                   and y < x else x, arf, np.inf)
        if minarf < np.inf and (minarf < self.f or self.f is None):
            self.x, self.f = arx[minidx], arf[minidx]
            if xarchive is not None and xarchive.get(self.x) is not None:
                self.x_geno = xarchive[self.x].get('geno')
            else:
                self.x_geno = None
            self.evals = None if not evals else evals - len(arf) + minidx + 1
            self.evalsall = evals
        elif evals:
            self.evalsall = evals
        self.last.x = arx[minidx]
        self.last.f = minarf
evaluation.py 文件源码 项目:single-cell-classification 作者: whuTommy 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def optimize_threshold_with_f1(f1c, thresholds, criterion='max'):
    #f1c[np.isnan(f1c)] = 0
    if criterion == 'max':
        ti = np.nanargmax(f1c)
    else:
        ti = np.nanargmin(np.abs(thresholds-0.5*f1c))
        #assert(np.all(thresholds>=0))
        #idx = (thresholds>=f1c*0.5-mp) & (thresholds<=f1c*0.5+mp)
        #assert(np.any(idx))
        #ti = np.where(idx)[0][f1c[idx].argmax()]
    return thresholds[ti], ti
_pick_info.py 文件源码 项目:mplcursors 作者: anntzer 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def _(artist, event):
    offsets = artist.get_offsets()
    ds = np.hypot(
        *(artist.axes.transData.transform(offsets) - [event.x, event.y]).T)
    argmin = np.nanargmin(ds)
    if ds[argmin] < artist.get_pickradius():
        target = with_attrs(offsets[argmin], index=argmin)
        return Selection(artist, target, ds[argmin], None, None)
    else:
        return None


问题


面经


文章

微信
公众号

扫码关注公众号