Short solutions of 2017

Back to Blog

In this section I will collect short things that have taken me some time to figure out. The intent is that I would be able to avoid wasting time in the future after I have forgotten about them.

Biber in LatexTools in Sublime Text

11.12.2017

Problem

When using Biber in LatexTools in Sublime Text, bibliography is not shown.

Solution

From the settings of LatexTools, set use_biblatex to true, and set builder to basic. In the Latex source, use \addbibresource{bibliography.bib} to add bibliographies, and \printbibliography to include the bibliography.

Change CMake compiler

06.12.2017

Problem

CMake does not recognize the change in compiler, say from Clang to gcc.

Solution

You need to delete both of CMakeCache.txt and CMakeFiles, and then run CMake again.

Compilation issues

06.12.2017

Problem

Pastel does not compile with gcc-7.2, hitting an internal compiler error in PASTEL_ARG_SC.

Solution

Revert to an earlier compiler; gcc-5.4 works.

Bitbucket draft status

26.06.2017

Problem

After pushing to a Bitbucket repository, Mercurial shows the commits in draft status.

Solution

Go to Bitbucket’s repository settings, and uncheck “This is a non-publishing repository”.

Matlab and Armadillo segmentation fault

15.06.2016

Problem

When using the Armadillo linear algebra library in a Matlab mex-file in Linux Mint 18, running the file gives a segmentation fault in Matlab.

Solution

Under Linux, the system’s BLAS library is confused with Matlab’s BLAS library. The segmentation fault occurs because of using different bit-widths for integers. A solution that worked for me is to define ARMA_BLAS_LONG_LONG in the C++ compiler flags. See more here

libc++ exception specification bug

15.06.2017

Problem

When compiling against an older version of libc++, you get an error like this:

error: 'basic_string<_CharT, _Traits, _Allocator>' is missing exception specification
      'noexcept(is_nothrow_copy_constructible<allocator_type>::value)'
basic_string<_CharT, _Traits, _Allocator>::basic_string(const allocator_type& __a)

Solution

This is a bug in libc++ that has since been fixed; see here. Either find a newer version of libc++, or use GNU’s libstdc++ instead.

Matlab segmentation fault in Linux Mint 18

15.06.2017

Problem

When running Matlab 2015a in Linux Mint 18, you get a segmentation fault with just basic use.

Solution

Matlab contains conflicting versions for the C++ Standard Library. There is a package to fix this:

sudo apt install matlab-support

The package replaces files in the Matlab installation with proper ones. This is from here.

Linux Mint shared folder in VirtualBox

15.06.2017

Problem

After installing Linux Mint in VirtualBox, you cannot share folders with the host, because you don’t have permissions.

Solution

Add yourself to the vboxsf group:

sudo gpasswd -a username vboxsf

Visual Studio Html+Javascript+Css

01.06.2017

Problem

You want to create a pure Html+Javascript+Css project in Visual Studio 2017.

Solution

Choose the New Web Site command from the File menu, and select ASP .NET Empty Web Site. This project type is missing from New Project.

Erroneous proofs in estimation paper

26.04.2017

Problem

Concerning the paper “Estimation of Information Theoretic Measures for Continuous Random Variables”, Fernando PĂ©rez-Cruz, Advances in Neural Information Processing Systems 21, Proceedings of the Twenty-Second Annual Conference on Neural Information Processing Systems, Vancouver, British Columbia, Canada, December 8-11, 2008.

The proofs in this paper are flawed. The proofs appeal to the (classical) strong law of large numbers, which is not applicable since the averaged random variables are not independent. The probabilities under the k-neighbor balls are dependent on each other, and in particular the probability in a k-neighbor ball depends on the whole sample set, not just the center point of the search as is suggested by the notation. This dependency is the exact source of difficulty when analysing algorithms based on k-nearest neighbors.

Solution

As far as I know, the result claimed in the paper, almost-sure convergence, has not yet been proved for all distributions. A very general result for almost-sure convergence, under certain assumptions on the distribution, is “A law of large numbers for nearest neighbour statistics”, Dafydd Evans, Proc. R. Soc. A 2008 464 3175-3192, 2008.

Latest gcc on Linux Mint

14.03.2017

Problem

You want to use the latest gcc on Linux Mint.

Solution

See here.

Linux Mint installation

14.03.2017

Problem

After installing Linux Mint in VirtualBox, Mint warns about reverting to software rendering.

Solution

See here.

Live account requires last name

14.03.2017

Problem

Live account requires to give a non-empty last name, which you don’t want to give.

Solution

Use an invisible Unicode character, such as U+202A Left to Right Embedding. This is from here.

User name on Visual Studio

14.03.2017

Problem

Visual Studio Feedback tool shows your real name in feedback.

Solution

There is a separate account for Visual Studio, which contains its own information in addition to the main Live-account. This accout is required to use Visual Studio Community. Change the name in the Visual Studio account.

LatexTools label trigger

10.03.2017

Problem

You want to use a generalized trigger ref{ for label-searching in LatexTools, while currently it is triggered by \ref{.

Solution

Add the following into Sublime Text’s key bindings:

{
    "keys": ["{"],
    "command": "latex_fill_all",
    "args": {
        "completion_type": "ref",
        "insert_char": "{"
    },
    "context":
    [
        { "key": "selector", "operator": "equal", "operand": "text.tex.latex - comment" },
        { "key": "preceding_text", "operator": "regex_contains", "operand": "ref$" },
    ],
},

This is from here.

Latexing

10.03.2017

Problem

With a recent update, Latexing plug-in for Sublime Text stopped working, meaning that the default syntax cleans the files instead of building them. I tried to work around this bug by selecting another syntax, but then I was hit by other bugs, which made inverse search fail. Unfortunately, Sublime Text does not allow to downgrade packages, and so I was stuck.

Solution

Switch to the LatexTools package instead, which is better supported, and has a larger community.

Atom

10.03.2017

I tried the Atom text editor on Windows today. It is a nice editor when looking at features and extensibility. The problem is that it has noticeable lag in almost every action, from selecting text to inverse-searching pdfs when building Latex files. This is something I cannot get over.

Python 2 and 3 confusing each other

09.03.2017

Problem

You have both Python 2 and Python 3 installed on Windows. You have a Python script foo.py installed using pip3, which works on both Python 2 and Python 3. The foo.py is on the path. Running foo.py launches Python 2, which then states being unable to find a module related to foo.py, since those modules are stored with Python 3.

Solution

Make sure that only one of the Python script directories on the path, and make it the same as the default Python interpreter.

Empty file in Windows

09.03.2017

Problem

You want to create an empty file.

Solution

On the command-line, write

copy NUL empty.txt

PyPi duplicate file

09.03.2017

Problem

You would like to upload a new version into PyPi, with two different formats such as .zip and .gztar. However, upload fails with

error: Upload failed (400): Duplicate file upload detected.

Solution

Only upload the .zip file. Somewhere along the way, PyPi was changed so that the extensionless names of the files must be unique.

Windows Subsystem for Linux: Weird behaviour

09.03.2017

Problem

While WSL was running, I tried to change a directory in Windows command-line, and then dir that. Command-line automatically changed the directory to the `C:\Users\Kaba" directory and listed the contents of that.

Solution

Close the Windows Subsystem for Linux. Perhaps restart the computer.

Windows Subsystem for Linux: Language

09.03.2017

Problem

The language is not english, although my Windows is.

Solution

To change the language:

sudo update-locale LANG=en_US.UTF8

Windows Subsystem for Linux: sudo

09.03.2017

Problem

After installing Windows Subsystem for Linux, running sudo says

sudo: unable to resolve host (none)

Solution

Add the name of the PC to /etc/hosts:

127.0.0.1 KABA-PC

Latexing fails to build

12.11.2017

Problem

On Latexing 1.2.20 on Sublime Text on Windows, choosing the syntax as “Latexing” fails to build the document when pressing Ctrl+B. Instead, Latexing runs a clean-up, deleting all temporary files.

Solution

A workaround is to choose another syntax, such as “Latexing (Tikz)” as the default for .tex files. Another solution is to press Ctrl+L+B to get to a menu and explicitly choosing to build. I have reported this bug here.

Mathematica animation

11.02.2017

Problem

When trying to animate a plot as in

Animate[Plot[PDF[BetaDistribution[3, n], x], {x, 0, 1}, PlotRange -> {0, 40}], {n, 1, 100}]

Mathematica 11 fails to show the animation, providing an error about being unable to show dynamic content.

Solution

Turning of the suggestion bar from the preferences removes the problem. This is from here.

Pillow installation

31.01.2017

Problem

When trying to install Pillow 3.4.2 on Linux, installation fails because the developer libraries of zlib and libjpeg are missing.

Solution

Install both libraries:

sudo apt-get install libjpeg-dev zlib1g-dev

Numerical issues with numpy eigenvalue-decomposition

16.01.2017

Problem

In numpy, the eigenvalue-decomposition of an almost-diagonal matrix will not produce an orthogonal matrix of eigenvectors:

import numpy
a = 7599.9393278410407
b = 7.198527976045102e-13
c = 7599.9393278410489
A = [[a, b], [b, c]]
s, u = numpy.linalg.eig(A)
print(u.T.dot(u))

The same problem was present in at least the following builds:

numpy-1.11.3+mkl-cp35-cp35m-win32.whl
numpy-1.12.0+mkl-cp35-cp35m-win32.whl

Solution

Since my matrix was symmetric, I could use the specific symmetric version eigh instead. This fixed the problem. My guess is that the non-symmetric eigenvalue-decomposition is badly conditioned, with the condition number being related to the minimum distance between eigenvalues. But perhaps that is not the case, and the problem is in the algorithm. Both numpy and Matlab use LAPACK for computations. Matlab does not have the problem, because it automatically selects the symmetric version based on the matrix. I reported the issue for numpy here and then to the LAPACK bulletin board.