Programming Leftovers
-
Are your memory-bound benchmarking timings normally distributed?
When optimizing software, we routinely measure the time that takes a given function or task. The typical assumption is that we get a normal distribution, and so we should therefore report the average time.
-
Dirk Eddelbuettel: RcppArmadillo 0.12.2.0.0 on CRAN: New Upstream Minor
Armadillo is a powerful and expressive C++ template library for linear algebra and scientific computing. It aims towards a good balance between speed and ease of use, has a syntax deliberately close to Matlab, and is useful for algorithm development directly in C++, or quick conversion of research code into production environments. RcppArmadillo integrates this library with the R environment and language–and is widely used by (currently) 1052 other packages on CRAN, downloaded 28.6 million times (per the partial logs from the cloud mirrors of CRAN), and the CSDA paper (preprint / vignette) by Conrad and myself has been cited 522 times according to Google Scholar.
-
Michael Ablassmeier: tracking changes between pypi package releases
I wondered if there is some tracking for differences between packages published on pypi, something that stores this information in a format similar to debdiff..
I failed to find something on the web, so created a little utility which watches the pypi changelog for new releaes and fetches the new and old version.
-
Polars for initial data analysis, Polars for production
In this article we’ll use both two APIs and see how Polars lets you transition from looking at the data to something we can run even more efficiently in production.
-
Python Replace String in File
To replace a string in a file, open the file with open(), read the data with read(), replace the data with replace() and store it back in the file with write().
-
Python Read File Into String
To read a file into a string in Python, use the read() method, the readlines() method with string concatenation and the read_text() method from Path package.
-
Python UnboundLocalError
UnboundLocalError is caused when a local variable is accessed before the assignment of value. Or due to the confusion between local and global scope.
-
Python Generate a Random Boolean Value
To generate random boolean values in Python, first generate random numeric values and then use the bool() method to convert them into a boolean.
-
Python String to a Dict
To convert a Python String into a Dictionary, use the json.loads() method, the ast.literal_eval() method, or generator expressions.
-
Python String Escape Quotes
To use quotes within a string in Python, use a different set of quotes to declare the string and in between a string or use backslash “\” before quotes.
-
Python Print Numpy Array with Precision
To print the values of the Numpy Array with specific precision in Python, use the set_printoptions() method and define the precision argument.
-
Make a web-safe color guide with Bash
When computer displays had a limited color palette, web designers often used a set of web-safe colors to create websites. While modern websites displaying on newer devices can display many more colors than the original web-safe color palette, I sometimes like to refer to the web-safe colors when I create web pages. This way I know my pages look good anywhere.
You can find web-safe color palettes on the web, but I wanted to have my own copy for easy reference. And you can make one too, using the for loop in Bash.