Examples under python.
Ciro Santilli's wife was studying a bit of basic Python for some job interviews, when she noticed:Damn right, girl, damn right.
Wow,in
is so powerful! You can dofor x in list
,for x in dict
andif x in dict
all with that single word!
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???
- this fucking train-wreck cannot come up with a unified documented way of specifying dependencies:So basically
- stackoverflow.com/questions/14399534/reference-requirements-txt-for-the-install-requires-kwarg-in-setuptools-setup-py
- stackoverflow.com/questions/26900328/install-dependencies-from-setup-py
- stackoverflow.com/questions/30797124/how-to-use-setup-py-to-install-dependencies-only/63743115
- stackoverflow.com/questions/6947988/when-to-use-pip-requirements-file-versus-install-requires-in-setup-py
requirements.txt
is thepackage-lock.json
. But how to generate it cleanly? You would need to create a virtualenv? pip search
was disabled in 2020: stackoverflow.com/questions/17373473/how-do-i-search-for-an-available-python-package-using-pip. WTF. If server load is a problem, just create a token system! It is hard to understand how such a popular language can't rais enough money to keep such simple server functionality running.
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:and from then on we can do
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
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.shThe best package ever is: pypi.org/project/china-dictatorship/ see also: cirosantilli.com/china-dictatorship/mirrors
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.
Polymorphism 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.
Some other basic hits due to how bad Jupyter is:
The people who work on this will go straight to heaven, no questions asked.
The output was also uploaded to: commons.wikimedia.org/wiki/File:DFT_2sin(t)_%2B_sin(4t).svg and added to en.wikipedia.org/w/index.php?title=Discrete_Fourier_transform&oldid=1176616763 only to be later removed of course: Deletionism on Wikipedia.
Output:With our understanding of the discrete Fourier transform we see clearly that:
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
- 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 thatrfft
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
React setups:
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:which apparently broke in 3.6: stackoverflow.com/questions/41343263/provide-classcell-example-for-python-3-6-metaclass and
RuntimeError: __class__ not set defining 'AbstractBaseUser' as <class 'django.contrib.auth.base_user.AbstractBaseUser'>. Was __classcell__ propagated to type.__new__?
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
There are currently no matching articles.