class_docstr: Abstract class :class:`Optimiser` for all optimisers.
  
  It must be implemented by all subclasses in this package.
  
  Every :class:`Optimiser` instance can be run for one single step using the
  :py:meth:`run_step` method. The :class:`Optimiser` does not perform the
  evaluation of the objective function but only proposes values from its
  domain. Therefore an evaluation history must be supplied via the
  :py:meth`update` method. The history can be erased and the
  :class:`Optimiser` brought to the initial state via the :py:meth:`reset`
  method.
class_docstr_tok: ["Abstract","class",":","class",":","`","Optimiser","`","for","all","optimisers",".","It","must","be","implemented","by","all","subclasses","in","this","package",".","Every",":","class",":","`","Optimiser","`","instance","can","be","run","for","one","single","step","using","the",":","py",":","meth",":","`","run_step","`","method",".","The",":","class",":","`","Optimiser","`","does","not","perform","the","evaluation","of","the","objective","function","but","only","proposes","values","from","its","domain",".","Therefore","an","evaluation","history","must","be","supplied","via","the",":","py",":","meth","`","update","`","method",".","The","history","can","be","erased","and","the",":","class",":","`","Optimiser","`","brought","to","the","initial","state","via","the",":","py",":","meth",":","`","reset","`","method","."]
code: def _update_history(self, x, fx):
      if isinstance(fx, (float, int)):
          history_point = HistoryPoint(
              sample=x,
              metrics={self.DEFAULT_METRIC_NAME: EvaluationScore(fx)},
          )
      elif isinstance(fx, EvaluationScore):
          history_point = HistoryPoint(
              sample=x, metrics={self.DEFAULT_METRIC_NAME: fx}
          )
      elif isinstance(fx, Dict):
          metrics = {}
          for key, val in fx.items():
              if isinstance(val, (float, int)):
                  metrics[key] = EvaluationScore(val)
              else:
                  metrics[key] = val
          history_point = HistoryPoint(sample=x, metrics=metrics)
      else:
          raise TypeError(
              "Cannot update history for one sample and multiple evaluations."
              " Use batched update instead and provide a list of samples and "
              "a list of evaluation metrics."
          )
      self.history.append(history_point)
  
file_path: hypertunity/hypertunity/optimisation/base.py
imports: import abc
  import math
  from dataclasses import dataclass
  from typing import Any, Dict, List, Sequence
  from hypertunity.domain import Domain, Sample
label_desc: Use image node_id 6 for calling the Optimiser obj's underlying member method code with example usage: obj._update_history(x, fx) without return types