11 items tagged
Motivation Julia is a very fast language. Julia hybrids many features from many sources. Here I’m taking note on its syntax and features by comparing to Python and Matlab. Basic Functions print is like in python BUT, no \n added at the end of each line. println has the \n String formatting is super easy, we can just use values of expressions. "$greet, $whom.\n" "1 + 2 = $(1 + 2)" Operators . operation extend its usage in matlab it means to vectorize sth. or broadcast one operation to all the element of the argument. This is super powerful, extending beyond arithmatics. You can broadcast everything by putting a . there. ... is like * in python, it could de-bundle a tuple or list into lots of variables. Types :: signify the type of sth. <: signify the type is a subtype of X. nothing equiv to None in python Similar to matlab true false not capitalized. Control Flow Control flow syntax is much like matlab if...elseif...end no indentation or :. Loop syntax is a bit like Python for .... in ..., with some caveat But if there are two things being looped, there needs to be a () , not like python. for (i,x) in enumerate(L) Functions Syntax is like
Motivation This is one step forward from Data transport between python and matlab, since sometimes you not only want to transport data, but want to share some code in python or matlab. How can we do so?
Motivation Method Follow the link to install the add-on to blender https://github.com/eliemichel/MapsModelsImporter Install the RenderDoc program on windows, to inject process to Chrome to fetch 3d data from it. Create a shortcut to launch chrome with some additional debug flags Run chrome, record the process number, pause. Inject to that number in RenderDoc program Then start chrome and go to google map to your favorite buildings Capture through RenderDoc. Save to rdc files to disk. Load that rdc through Blender! and you have your 3d models! Post processing Join the patches to a single object. And merge vertices by distance。 Process texture and stuff to retain a single kind of material with the color. See the youtube video for a tutorial.
Motivation Common Formats Some formats are really common, so that python and matlab both have standard way to import, read and write. So these can be a common json, yaml Simple python dictionary could be easily dumped in yaml json formats, which record the hierachical structure and can store small amount of array data. The best part is it’s human readable. So it’s really suitable to store short configuration files.
Motivation Syntax highlighting for codes Procedurally adding lots of figures to slides using the same format (if you don’t want to copy paste in pptx) Adding lots of equations to it from latex format. Technical Choices Source of info
Motivation Matlab and matplotlib in python are plotting packages of daily usage. They share lots of structures but also have minor differences. For beginners using the plotting routines can suffice most daily needs, but for more refined control over layout, fontsize and so on, we need to better understand the object structure in matlab and matplotlib.
Motivation pandas is a great tool for representing structured data in python, similar to Table in matlab and dataframe in R . Using it to interact with table data (like experimental records) on hard drive and process it in python is also great!
Motivation Unlike matlab, plotting dynamics in python is not as easy or straight forward to use. And to interact with the figure is not always as simple as matlab native plotting routines.
TOC {:toc} Python is a script language. Most of the packages are written in python, and they are just a bunch of script files in a folder hierachy. For these packages, it’s just as easy as find the script file and run them.
Just like written languages, different programming languages have different innate styles, which suit different needs. Like Matlab love matrix, love script; python favors tensor, favors subfunction, favors objective-oriented programming; Mathematica are muchly functional; R are better at datatable demonstration.