code: def test_lnprob_and_grad_scalar():
      prior = TophatPrior(
          lower_bound=np.exp(-10),
          upper_bound=np.exp(2),
          seed=1,
      )
  
      # Legal scalar
      for val in (-1, 0, 1):
          assert prior.get_log_probability(val) == 0
          assert prior.get_gradient(val) == 0
  
      # Boundary
      for val in (-10, 2):
          assert prior.get_log_probability(val) == 0
          assert prior.get_gradient(val) == 0
  
      # Values outside the boundary
      for val in (
          -10 - VERY_SMALL_NUMBER,
          2 + VERY_SMALL_NUMBER,
          -50,
          50,
      ):
          assert np.isinf(prior.get_log_probability(val))
          assert prior.get_gradient(val) == 0
  
imports: from functools import partial
  import numpy
  import pytest
  import scipy.optimize
  from smac.constants import VERY_SMALL_NUMBER
  from smac.model.gaussian_process.priors import GammaPrior, HorseshoePrior, LogNormalPrior, SoftTopHatPrior, TophatPrior
label_desc: Use image node_id 4 for calling a global function with example usage: test_lnprob_and_grad_scalar() without return types