Any tips to help a scientist become a better programmer?
Turun @ Turun @feddit.de Posts 0Comments 599Joined 2 yr. ago
As a researcher: all the professional software engineers here have no idea about the requirements for code in a research setting.
I recommend you use
- git. It's nice to be able to revert changes without worry.
- descriptive variable names. The meaning of descriptive is highly dependent on your situation. Single letters can have an obvious meaning, but err on the side of longer names if you're unsure. The goal is to be able to look at a variable and instantly know what it represents.
- virtual environments and requirements.txt. when you have your code working you should have pip (or anaconda or whatever) take a snapshot of your current python installation. Then you can install the exact same requirements when you want to revive your code a few months or years down the line. I didn't do that and it's kinda biting me in the ass right now.
No.
I have written rust for my research (one does not simply calculate 4 million data points in python), but just no.
My main code is still python, because it's just so much nicer to write and iterate on.
I use classes to group data together. E.g.
@dataclass.dataclass class Measurement: temperature: int voltage: numpy.ndarray current: numpy.ndarray another_parameter: bool def resistance(self) -> float: ... measurements = parse_measurements() measurements = [m for m in measurements if m.another_parameter] plt.plot( [m.temperature for m in measurements], [m.resistance() for m in measurements] )
This is much nicer to handle than three different lists of temperature, voltage and current. And then a fourth list of resistances. And another list for another_parameter
. Especially if you have more parameters to each measurement and need to group measurements by these parameters.
Yes, those prototypes are the goal here.
You know how changing requirements is the bane of real™ production grade™ software?
In science requirements change all the time. You write some 50-100 lines to plot your results. You realize that the effect is not visible, so you go back to the lab, change 5 variables and run the test again. Some quick code changes and you see the effect. Perfect. Now you do the measurement as a function of temperature. You adapt your script, you indent the data processing code to turn your list of files into a list of characteristics parameters and adapt the plotting. You run the experiment for the three samples you have prepared and compare their plots. Some more experiments tuning and corresponding script tuning is required. You take the characteristic parameters that your code (grew to 200 lines now, but whatever) calculated and write a new script to take that array and plot it nicely.
Now someone wants to repeat the experiment 4 years later. The measurement equipment changed and the data format is slightly different. It's impossible to document the exact state of the hardware in your code anyway. They are actually interested in a different effect and want to plot that as well, but they need the effect/characteristics parameters that are shown by your code as a sanity check. They need to rewrite 125 of the 200 lines.
There never is a finished product that is worth maintaining long term. Everyone using the script has to understand the domain precisely anyway. Is it worth it to reuse the old code when you need to rewrite more than half of it anyway?
Don't get me wrong, code reuse does happen. But it's much more "oh, I wrote that three months ago somewhere else" ctrl-c ctrl-v. "Ok, now I need to change five lines in this function to adapt to the new thing I'm trying to do." It makes absolutely no sense to write that function in a abstracted way. Every time you use it the requirements changed and the abstraction is no longer valid anyway.
Right, and what force is acting on the child to make it deviate from a circular orbit into a spiral one?
Permanently Deleted
Jup, but that was only relevant on iOS, never for MacOS. Also the digital markets act will end even that.
For example you can make and receive calls on your computer instead of your phone when you are working on your PC. That is unmatched by any other ecosystem.
Edit: for the time and effort you need to put in to make it work. Yes, you can do it with anything. Linux and pine phone will for sure be capable - but no normal person will do that. Because it takes a ton of effort. Apple supports that out of the box and because everything is linked to a single ID it just works.
I'd just like to point out that the "we haven't had sex in three months" one technically doesn't specify who did the deed. It could be her excuse for cheating, like "how was I supposed to get off?"
Permanently Deleted
Their integration is the best you can get.
You need to buy an expensive phone, watch, computer (would you like to spend another thousand bucks for a monitorstand?) to take advantage of it, which is why I don't have and don't want anything apple. But if you have that, their software stack is superb.
Permanently Deleted
It does what it says on the tin.
You can toggle it and compare the differences.
It's readable on mobile. You need to unfix that immediately. The font must not appear bigger than 5px. Responsive layout is forbidden.
In English, not in general. The continent is called America in lots of languages, but the country is most often referred to as the USA. Because that's the title the country has chosen for itself.
Yeah, the everyday usage is limited to, well, everyday sizes.
As you pointed out there is no difference in everyday usage. But for anything outside of the most trivial of comparisons, the imperial system breaks down hard.
The advantage of the metric system is the possibility to scale both bigger and smaller when you need it, and always does so with a consistent factor. Sure, not needed when you want to know how many 8 cm strips are needed to cover 50cm. But for 1m? With inches and yards you already have to handle two conversation factors. How many sixteenth of an inch do you need to cover a foot? 192. Possible to calculate, but not nice and you'll approximate with 200 if you need to do some calculations in your head. How many feet are in a mile? 5280. And yards? 1760. Do you really know these conversation factors? Do you want to calculate "there's a street light every 30 yards, the street is 2 miles long, that's xx streetlights? Or "there's a street light every 30 meters, the street is 3.2km long, that's 3200/30 = 107 streetlights"?
Oh, and the weird units do actually get used when it is a convenient size.
Cooking uses lots of in-between units for example. Centiliters (cl) are common in cocktail recipes or for shots, in some cookbooks you will find dekagrams, etc.
Hectare is commonly used to give area measurements (it's origin is hekto-are, and "are" in turn is hekto-square meters, though "are" is not commonly used.). Want to convert hectare to square kilometers? Simply divide the number by 100! 3000hectare of forest burned down? That's 30km^2, so 5kmx6km. Easy to visualize.
The US customary system makes such conversations really really really hard. How many square feet, yards or miles are in an acre? I just looked at the Wikipedia page and there is no way anyone will be able to convert an area given in acre into "well, it's approximately x by z miles". Or "my house have xx square foot of living space, so that's yy acres".
Btw, no one uses kiloliters, because that's equivalent to cubic meters. Easy conversions!
To be fair, mass is weird because the base unit is kg (yes, the name includes a prefactor). I have no idea how they managed to fuck it up that badly.
On sync for reddit I was annoyed by the permanent ad bar at the bottom of the screen, because it is where the android buttons (home, back, app overview) are and sometimes I would accidentally click an ad.
I actually really like the new placement.
- I no longer accidentally click it
- It only shows up when viewing the comments on a post
- it's gone when i scroll down/read long discussions. (And doesn't annoy me for long when there are few comments to read)
Edit: also they don't flicker for me at all (Fairphone 3). And the beta already has redgif support, so I don't understand half of OPs complaints anyway. Darktheme matching would be really nice, but I have never heard of that being a thing supported by ads.
Hold up, I think we have a discrepancy regarding what we are talking about.
I'm not thinking of anything user facing. The ux would be exactly identical to what is publicly observable on reddit already. I'm talking about the possibility to dump any change to comments or posts into a cold data store for later analysis. We don't have to question or think how many users would make use of it, we can count the fraction of comments with an "edited" label on reddit.
Yes, and?
Edit: before this we knew of two groups of alive things that produce milk: mammals and monotremes (egg laying mammals). Finding an amphibian that also does it is very interesting.
"Roger Rodger"
"we've got clearance Clarence"
"What's our vector victor?"
From the movie airplane.
You can jump to definition in any language. In fact, python may be one of the worst ones, because compiled libraries are so common. "Real signature unknown" is all you will get some times. E.g. Numpy is implemented in C not python.