probability theory – Convexity in function argument of Donsker and Varadhan inequality (for KL divergence)

Let $mu$ and $lambda$ be probability measures on a measurable space $(X, Sigma)$. According to Donsker and Varadhan the KL divergence can be expressed as
operatorname{KL}(mu | lambda)
= sup_{Phi in mathcal{C}} left(int_X Phi , dmu – logint_X exp(Phi) , dlambdaright),

where the supremum is taken over the set $mathcal{C}$ of all bounded and measurable functions $Xto mathbb{R}$. Consider the functional
J(Phi) = int_X Phi , dmu – logint_X exp(Phi) , dlambda.

Question: Is $J(Phi)$ a convex function in $Phi$?

Why does the time hierarchy theorem uses a rather intricate diagonal argument?

Isn’t it possible to prove it by defining some problem that can be solved in $f(n)^2$ in worst case due to its output being always $f(n)^2$ characters so that I won’t be solvable in $f(n)$?
Where am I wrong?

Argument 2 passed to DrupalConsoleCommandTestRunCommand::__construct() must be an instance of DrupalsimpletestTestDiscovery

I’m trying to install drupal console with Drupal 9.0.5, so I ran this command:

composer require drupal/console:~1.0

However when I try run the drupal command with any arguments I get this error:

root@6dc17ce2d4bf:/opt/drupal# drupal --version
TypeError: Argument 2 passed to DrupalConsoleCommandTestRunCommand::__construct() must be an instance of DrupalsimpletestTestDiscovery, null given in /opt/drupal/vendor/drupal/console/src/Command/Test/RunCommand.php on line 58 #0 (internal function): DrupalConsoleCommandTestRunCommand->__construct('/opt/drupal/web', NULL, Object(DrupalCoreExtensionModuleHandler), Object(DrupalCoreDatetimeDateFormatter))
#1 /opt/drupal/vendor/symfony/dependency-injection/ContainerBuilder.php(1144): ReflectionClass->newInstanceArgs(Array)
#2 /opt/drupal/vendor/symfony/dependency-injection/ContainerBuilder.php(618): SymfonyComponentDependencyInjectionContainerBuilder->createService(Object(SymfonyComponentDependencyInjectionDefinition), Array, true, 'console.test_ru...')
#3 /opt/drupal/vendor/symfony/dependency-injection/ContainerBuilder.php(558): SymfonyComponentDependencyInjectionContainerBuilder->doGet('console.test_ru...', 1)
#4 /opt/drupal/vendor/drupal/console-core/src/Application.php(468): SymfonyComponentDependencyInjectionContainerBuilder->get('console.test_ru...')
#5 /opt/drupal/vendor/drupal/console-core/src/Application.php(214): DrupalConsoleCoreApplication->registerCommands()
#6 /opt/drupal/vendor/drupal/console-core/src/Application.php(119): DrupalConsoleCoreApplication->loadCommands()
#7 /opt/drupal/vendor/drupal/console/src/Application.php(64): DrupalConsoleCoreApplication->doRun(Object(SymfonyComponentConsoleInputArgvInput), Object(SymfonyComponentConsoleOutputConsoleOutput))
#8 /opt/drupal/vendor/symfony/console/Application.php(147): DrupalConsoleApplication->doRun(Object(SymfonyComponentConsoleInputArgvInput), Object(SymfonyComponentConsoleOutputConsoleOutput))
#9 /opt/drupal/vendor/drupal/console/bin/drupal.php(89): SymfonyComponentConsoleApplication->run()
#10 /opt/drupal/vendor/drupal/console/bin/drupal(4): require('/opt/drupal/ven...')
#11 {main}
TypeError: Argument 2 passed to DrupalConsoleCommandTestRunCommand::__construct() must be an instance of DrupalsimpletestTestDiscovery, null given in DrupalConsoleCommandTestRunCommand->__construct() (line 58 of /opt/drupal/vendor/drupal/console/src/Command/Test/RunCommand.php).

I don’t really understand this error. Any ideas what might cause this?

magento2 – Magento 2.4 : Missing required argument $engines of MagentoSearchModelEngineResolver

I’ve a fresh install of Magento 2.4.0 on ubuntu 20.04 installed from CLI, downloaded with Composer.

I get this error while trying to reindex the catalog_search index :

Catalog Search index process unknown error:
Missing required argument $engines of MagentoSearchModelEngineResolver.

Also, my catalog/catalog tab in admin panel is empty for the scope default config so I can’t set the elasticsearch engine from the UI. In the core_config_data, there was no catalog/search/engine, so I tried to set a new one with elasticsearch7 or mysql but neither worked.

I precise that I’ve a working elasticsearch 7.x on this new server, with no credentials.

It seems that the elasticsearch related config are not set properly, and I can’t figure out why no option are visible in the default scope admin panel for the catalog/catalog tab…

An idea ?

design – When should an argument be set to None in Python?

The focus of my question is on design.

If I have an argument that can be None and it is passed between several functions until finally being used, which function should treat it as a default argument?

For example, suppose the following code block:

def foo(a):
 b = # some code block to assign b
 return bar(a, b)

def bar(a, b):
 c = # some code block to assign c
 return baz(a, b, c)

def baz(a, b, c):
 return a + b + c

The default value should be set only in foo and all the other functions must expect the argument as mandatory (e.g., foo(a=None); bar(a, b); baz(a, b, c))? Or is there a better design?

And if type verification was needed, what is the most suitable function for this?

c++ template – More than one instance of overloaded function matches the argument list

Why did only the last invocation of max raise error?

error C2668: ‘max’: ambiguous call to overloaded function

#include <iostream>
#include <type_traits>

template<typename T1, typename T2>
auto max(T1 t1, T2 t2)
    return t1 < t2 ? t2 : t1;

template<typename RT, typename T1, typename T2>
RT max (T1 a, T2 b)
return b < a ? a : b;

int main()

    max<long double>(4.5, 4);
    max<double>(4.5, 4);
    return 0;

8 – Warning: Invalid argument supplied for foreach() in DrupalCoreAssetLibraryDiscoveryParser->buildByExtension()

I get the error :

Warning: Invalid argument supplied for foreach() in
DrupalCoreAssetLibraryDiscoveryParser->buildByExtension() (line 150
of core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php

custom_changes.module >> hook_form_alter

if ($form_id =='user_form') {
        $form('#attached')('library')() = 'custom_changes/user_library';


  version: VERSION
      css/user.css: {}
  version: VERSION
    css/hr.css: {}

8 – Pretty-printing JSON as preformatted text in translatable string passed as argument to method?


In a Service class, I’d like to display onscreen debug info for users with a specific permission.

In my_custom_module.permissions.yml:

'view debug info':
  title: 'View debug info'
  description: 'Allow user to view DataPartner API debugging messages.'
  restrict access: true

In src/Api/DataPartner.php:


namespace Drupalmy_custom_moduleApi;

 * @file
 * Contains Drupalmy_custom_moduleApiDataPartner.

use DrupalCoreSessionAccountInterface;
use DrupalCoreMessengerMessengerInterface;
use DrupalCoreStringTranslationStringTranslationTrait;

 * Provides API integration methods.
class DataPartner {

  use StringTranslationTrait;

   * Private function to determine whether displaying debug info is permitted.
   * @return bool
   *   TRUE if debugging is permitted for current user in current environment.
  private function hasDebugPermission() {
    return MY_CUSTOM_MODULE_DEBUG_FLAG && $this->account->hasPermission('view debug info');

There’s a bit more to it.

I have left out the dependency injection stuff in *.services.yml and in the Service class, which I’m using to provide methods to deal with checking user account permission, writing Drupal messages to the screen, and other stuff. (I included just enough to show what services I’m injecting, and to show that I’m using the StringTranslationTrait in the Service class rather than injecting that dependency, in case that is relevant to my question.)

I have also defined the constant MY_CUSTOM_MODULE_DEBUG_FLAG to disable the debugging in the production environment and toggle it based on a checkbox in a ConfigForm, but that won’t have any effect on my actual question.

Anyway, now I can display the API debugging messages like this:

if ($this->hasDebugPermission()) {
  $this->messenger->addMessage($this->t('Step 2: $response = <br><pre>@value</pre>', (
    '@value' => print_r(json_encode($this->response_decode, JSON_PRETTY_PRINT), TRUE),

This is fine, as far as it goes, but I wanted better encapsulation. I tried this:

   * Private function to display debug info if permitted.
   * @param string $message
   *   Translatable message string to be displayed, if permitted.
   * @param array $variables
   *   Values for substitution in translatable string.
  private function displayDebugInfo(string $message, array $variables = ()) {
    if ($this->account->hasPermission('view debug info')) {
      $this->messenger->addMessage($this->t($message, $variables));

However, this violates Drupal coding standards because:

WARNING | Only string literals should be passed to t() where possible

There’s an interesting discussion of this here.

The linked issue queue mentions that you can mark the string for translation before passing it as an argument to your method, so I tried that:

   * Private function to display debug info if permitted.
   * @param string $message
   *   Translatable message string to be displayed, if permitted.
  private function displayDebugInfo(string $message, array $variables = ()) {
    if ($this->account->hasPermission('view debug info')) {

If I do that, I need to display the API debugging messages like this:

this->displayDebugInfo($this->t('Step 2: $response = <br><pre>@value</pre>', (
  '@value' => print_r(json_encode($this->response_decode, JSON_PRETTY_PRINT), TRUE),

This lengthy preamble brings me to my question.


Passing the translatable string to the method in this way causes the HTML markup to be printed to the screen, so that instead of seeing pretty-printed JSON as preformatted text, the user sees a brick of ugly text and markup.

When I examine the markup in the DOM inspector of the browser’s Dev Tools, it looks like regular markup, not escaped HTML entities like &lt;pre&gt;.

  • Why is the markup not being interpreted by the browser? (I’m assuming there is a security reason.)
  • If I want to have my cake (preformatted pretty-printed JSON in $this->messenger->addMessage()) and eat it too (with better object-oriented encapsulation), is there any way for me to get what I want?

numerical integration – NIntegrate argument is not numeric with __?NumericQ function

I have the following dummy Code

f[arg : {__?NumericQ}] := 2*arg;;
g := f[{x, y}]
NIntegrate[g, {x, 0, 1}, {y, 0, 1}]
NIntegrate[f[{x, y}], {x, 0, 1}, {y, 0, 1}]

Both tries yield

NIntegrate::inum: Integrand f[{x,y}] is not numerical at {x,y} = {0.5,0.5}.


f[{x, y}] /. x -> 0.5 /. y -> 0.5
f[{0.5, 0.5}]

How to solve this? I can not remove the requirement that f[] is only evaluated for numeric lists.

In response to a comment:

NIntegrate[2*{x, y}, {x, 0, 1}, {y, 0, 1}]

This evaluates just fine.

Fortran errors – Complex argument bessel function

I have been having some trouble getting some fortran code I was given working. This code uses an external library, NUMERICAL_LIBRARIES, by Rogue Wave in order to implement a bessel function with complex argument. I have attempted to contact Rogue Wave but they have ignored my emails so far.

I downloaded a bessel function library from, (, in an attempt to get an open source version working. However, I have not been able to get this code integrated with the code given to me.

Compiling the code with this statement in cygwin:

gfortran "pulse9_sili_oneTube - Copy.f90" -o "CBESSEL.F90" -o pressureWaveModel

gives me this error statement:

/usr/lib/gcc/x86_64-pc-cygwin/9.3.0/../../../../x86_64-pc-cygwin/bin/ld: /tmp/cc0Rqf3a.o:pulse9_sili_oneTube - Copy.f90:(.text+0x29d80): undefined reference to `cbesj_'
/tmp/cc0Rqf3a.o:pulse9_sili_oneTube - Copy.f90:(.text+0x29d80): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `cbesj_'
collect2: error: ld returned 1 exit status

I have linked the CBESSEL.F90 file to my main file:


USE Complex_Bessel

However, I cant even get the testing code running so perhaps my compiler is set up wrong? Compiling the test code gives me error saying it cant open the module file, do I need to somehow create a module file? There were no useful instructions included with this code.

Any help you can provide would be super useful!!