Examples under python.
Ciro Santilli's wife was studying a bit of basic Python for some job interviews, when she noticed:
Wow, in is so powerful! You can do for x in list, for x in dict and if x in dict all with that single word!
Damn right, girl, damn right.
Ciro remembers hearing about Python online briefly. It seemed like a distant thing from the Java/C dominated (and outdated) university courses. Then some teaching assistant mentioned during some course when Ciro was at École Polytechnique that Python was a great integration tool. That sounded cool.
Then finally, when the École Polytechnique mathematics department didn't let Ciro Santilli do his internship of choice due to grades and Ciro was at an useless last moment backup internship, he learned more Python instead of doing his internship job, and was hooked.
Examples under python/typing_cheat.
The hello world!
How many stupid bugs. How many stupid bugs do we need to face???
Conda is like pip, except that it also manages shared library dependencies, including providing prebuilts.
This has made Conda very popular in the deep learning community around 2020, where using Python frontends like PyTorch to configure faster precompiled backends was extremelly common.
Tested on Ubuntu 20.04:
mkdir -p ~/miniconda3
wget https://repo.anaconda.com/miniconda/Miniconda3-py311_23.11.0-2-Linux-x86_64.sh -O ~/miniconda3/miniconda.sh
bash ~/miniconda3/miniconda.sh -b -u -p ~/miniconda3
rm -rf ~/miniconda3/miniconda.sh
~/miniconda3/bin/conda init bash
. ~/.bashrc
and from then on we can do conda commands normally.
At that time, the exact installer under latest appears to have been: repo.anaconda.com/miniconda/Miniconda3-py311_23.11.0-2-Linux-x86_64.sh
python3 -m pip install --user virtualenv
virtualenv .venv
. .venv/bin/activate
pip install -r requirements.txt
To run each example and see the output run:
./build.sh
xdg-open out/index.html
Minimal example. Gives a hint at how boilerplate heavy Sphinx can be!
Basic class example.
A waste of time. Output in my source files pollutes git and prevents me from editing it in Vim. Just let me run the freacking code and render images as standalone PNGs which I can include from Markdown.
The people who work on this will go straight to heaven, no questions asked.
Generates numpy/fft_plot.svg, the plot of with 25 points and its DFT.
Figure 1.
DFT of with 25 points
. Source code at: numpy/fft_plot.py.
Output:
sin(t)
fft
real 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
imag 0 -10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10
rfft
real 0 0 0 0 0 0 0 0 0 0 0
imag 0 -10 0 0 0 0 0 0 0 0 0

sin(t) + sin(4t)
fft
real 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
imag 0 -10 0 0 -10 0 0 0 0 0 0 0 0 0 0 0 10 0 0 10
rfft
real 0 0 0 0 0 0 0 0 0 0 0
imag 0 -10 0 0 -10 0 0 0 0 0 0
With our understanding of the discrete Fourier transform we see clearly that:
  • the signal is being decomposed into sinusoidal components
  • because we are doing the Discrete Fourier transform of a real signal, for the fft, so there is redundancy in the. We also understand that rfft simply cuts off and only keeps half of the coefficients
A Python wrapper over a bunch of numeric and computer algebra system packages to try and fully replace MATLAB et. al.
Quickstart tutorial at: www.sagemath.org/tour-quickstart.html From this we see that they are very opinionated, you don't need to import anything, everything has a pre-defined global name, which is convenient, e.g.:
is the 3D vector space over the rationals. This also suggests that they are quite focused on computer algebra as opposed to numerical.
Examples under python/sklearn
. .venv/bin/activate
pip install sklearn matplotlib seaborn
One problem with Django is that it does not expose its ORM as an external library: stackoverflow.com/questions/33170016/how-to-use-django-1-8-5-orm-without-creating-a-django-project which is wasteful of development time.
As of 2021, last updated 2016, and python 3.5 appears to be mandatory or else:
RuntimeError: __class__ not set defining 'AbstractBaseUser' as <class 'django.contrib.auth.base_user.AbstractBaseUser'>. Was __classcell__ propagated to type.__new__?
which apparently broke in 3.6: stackoverflow.com/questions/41343263/provide-classcell-example-for-python-3-6-metaclass and pyenv install fails on Ubuntu 20.10, so... fuck. Workarounds at:but am I in the mood considering that the ancient Django version would require an immediate port anyways? Repo is at Django 1.0, while newest is now already Django 3. The Rails one is broken for the same reason. Fuck 2.

Articles by others on the same topic (0)

There are currently no matching articles.