Skip to content

Instantly share code, notes, and snippets.

@evertrol
evertrol / Conda-scipy-mpi4py.txt
Last active March 1, 2023 16:00
Conda installation of SciPy and MPI4py/MPIch
[ER; 2023-03-01]
When using the Conda channel "anaconda" and Python 3.7, the combination of the scipy package and the mpich package can cause problems. The mpich installation is a dependency of mpi4py, so the combination scipy / mpi4py has the same problem. (Note that I've tested and found the issue is the same with Python 3.10, and probably 3.8 and 3.9 as well, since mpich does not depend on Python. 3.11 is still to new (half a year old!) for the scipy package to be properly installed.)
SciPy has a dependency on libgfortran and ligfortran-ng: which one will be used, depends on the SciPy package selected, at least for libgfortran. This is the core of the problem.
When installing SciPy before MPIch, Conda will pick the most recent version. On Linux, this is scipy-1.7.3-py37h6c91a56_2 [*] (try in a new environment).
The related package file on anaconda.org is linux-64/scipy-1.7.3-py37h6c91a56_2.tar.bz2 . This shows, among others, the following dependencies:
libgfortran-ng, libgfortran5 >=11.2.0
@evertrol
evertrol / configuration-file.md
Created February 26, 2023 18:50
Configuration files

Configuration files

Configuration files are a practical, and probably essential, thing to have your code run flexibly. A good configuration can prevent lots of tiny (or large!) errors, and make it easier for other people to use your code (or you yourself if you haven't used the code for a while).

Generally, there will be configuration files, to change things like

  • starting configuration (of a simulation)
  • output file names, directories or formats
  • what to calculate or process (steps to take, steps to skip)
  • what to output (some calculated parameters may not be interesting for most calculations)

Prerequisities:

  • A reasonably new Ubuntu or Ubuntu-derived system. This helps matching the required system packages to be installed, that are used to build Python form source later on.
  • Single user usage of Python packages. That is, you are not the system administrator that installs packages for multiple users.
  1. Don't use sudo to install Python or a Python packages. There is no need for it, and it can only mess up your system. sudo is only to be used to update the system, or install helper packages (libraries, compilers) to build Python or any package (such as NUmPy) from source, through the system package manager (such as apt, dnf or pacman).

That also means there is no need to install (system) packages such as python(3)-numpy or python(3)-scipy, or even python(3)-pip. In fact, these could possibly even be uninstalled, and no harm would come from it. But if they are installed, let them be. They should not interfere with user-installed versions later on.

  1. Virtual environments are onl
# Notes about values in the TOML config file:
# - strings should always be quoted. Multi-line strings are possible
# using triple-quotes, but should not be necessary in this config file
# - floating point values require a decimal dot, or an exponent (or
# both). Otherwise, they are interpreted as integers.
# More information about the TOML config format: https://github.com/toml-lang/toml
# Scenarios to use.
# This defines only the names and epoch.
@evertrol
evertrol / julia_comprehension_generator_examples.txt
Last active February 6, 2020 16:25
Julia array / list comprehension and generator expression examples
julia> VERSION
v"1.3.0"
julia> # Julia documention on array) comprehensions and generator expressions:
julia> # https://docs.julialang.org/en/v1/manual/arrays/#Comprehensions-1
julia> # https://docs.julialang.org/en/v1/manual/arrays/#Generator-Expressions-1
julia> # The code below uses generator expressions
julia> # Double list comprehension for the first fifty-one terms of the power series of the exponential function
julia> sum(prod(1/i for i in 1:n) for n in 1:50) + 1
@evertrol
evertrol / environment.yml
Last active June 24, 2019 13:58
Rhine temperature response
name: base
channels:
- conda-forge
- defaults
dependencies:
- iris=2.2.0=py36_1003
- iris-sample-data=2.1.0=py_0
- cftime=1.0.3.4=py36hd352d35_1001
- numpy=1.16.2=py36_blas_openblash1522bff_0
- pandas=0.23.4=py36h637b7d7_1000
2018-10-16 08:43:28,966 UTC [50059] INFO esmvaltool._main:123
______________________________________________________________________
_____ ____ __ ____ __ _ _____ _
| ____/ ___|| \/ \ \ / /_ _| |_ _|__ ___ | |
| _| \___ \| |\/| |\ \ / / _` | | | |/ _ \ / _ \| |
| |___ ___) | | | | \ V / (_| | | | | (_) | (_) | |
|_____|____/|_| |_| \_/ \__,_|_| |_|\___/ \___/|_|
______________________________________________________________________
ESMValTool - Earth System Model Evaluation Tool
/// Rust Fibonacci one-liner using `fold`
///
/// Not very practical: only for one time use,
/// since it will have to re-calculate all terms again and again
/// if used in a loop to create multiple items.
/// The use of `_` also suggests this is not an ideal solution.
fn main() {
let n = 10;
let x = (0..n).fold((0, 1), |x, _| (x.0+x.1, x.0)).0;
println!("{}: {}", n, x);
This file has been truncated, but you can view the full file.
<!DOCTYPE html>
<html>
<head><meta charset="utf-8" />
<title>Thumbnail classification</title><script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.10/require.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<style type="text/css">
/*!
*
@evertrol
evertrol / Makefiles.md
Last active April 1, 2024 19:11
Makefile cheat sheet

Makefile cheat sheet

Mostly geared towards GNU make

I've used ->| to indicate a tab character, as it's clearer to read than

  • Set a target, its dependencies and the commands to execute in order
target: [dependencies]
-&gt;|