@jamescooke@fosstodon.org
@jamescooke@fosstodon.org avatar

jamescooke

@jamescooke@fosstodon.org

Python developer working with data and royalties at Mixcloud.

Lover of testing and linting. User of Linux.

Author of https://github.com/jamescooke/flake8-aaa

This profile is from a federated server and may be incomplete. Browse more on the original instance.

jamescooke, to random
@jamescooke@fosstodon.org avatar

When I was a kid I read the entire MSDOS manual that came with my dad's Amstrad PC1512.

These days I don't even get to the bottom of a single man page 😬

jamescooke,
@jamescooke@fosstodon.org avatar

@deshipu Alas nothing so fancy - I remember it being plain black and white and just a man-page-like entry for each command: cd, dir, etc

jamescooke,
@jamescooke@fosstodon.org avatar

@deshipu Wow!

Ok now I’m confused. I never read (or maybe even saw) that manual 😲

Now I’m wondering if that MSDOS manual came with my dad’s Tandon laptop 🤔🤔🤔

jamescooke,
@jamescooke@fosstodon.org avatar

@deshipu Yeah that’s totally possible.

I’m remembering helping my dad fit a maths coprocessor to the PC 1512 - maybe he upgraded to MSDOS 4 at that stage 🤔

jamescooke, to random
@jamescooke@fosstodon.org avatar

In my efforts to stay at least 5 years behind the curve, I've just installed fd as a replacement to find and it's amazingly fast.

As a result of it automatically ignoring ".gitignored" directories, search is now much quicker and condensed - plus I've wired it all into , which has made that even faster 😍

https://github.com/sharkdp/fd

arildsen, to python
@arildsen@fosstodon.org avatar

I have used numpy.allclose to test for approximate equality in Python for years, but I recently found pytest.approx better, because it lets Pytest interpret the result. For example, with numpy.allclose:

> assert np.allclose(result, 3.061, atol=1e-3, rtol=1e-3)
E assert False
E + where False = <function allclose at 0x7f8fea7efa60>(1.4872, 3.061, atol=0.001, rtol=0.001)
E + where <function allclose at 0x7f8fea7efa60> = np.allclose

jamescooke,
@jamescooke@fosstodon.org avatar

@arildsen Ahh I never use np.allclose() ...

Interested to know if you've tried out any of np.testing? Array almost equal is in there: https://numpy.org/doc/stable/reference/generated/numpy.testing.assert_array_almost_equal.html

Asking because I've got into using np.testing.assert_array_equal() to check columns in Pandas DataFrames match what I'm expecting at test time - and the output doesn't look too grim 😊

jamescooke,
@jamescooke@fosstodon.org avatar

@arildsen assert_array_almost_equal() gives this kind of output on my first try:

np.testing.assert_array_almost_equal(result['score_fuzzy'], [expected_score_fuzzy + 0.12])  

Gives

AssertionError:  
Arrays are not almost equal to 6 decimals

Mismatched elements: 1 / 1 (100%)  
Max absolute difference: 0.12  
Max relative difference: 0.00477707  
 x: array([25])  
 y: array([25.12])  
jamescooke,
@jamescooke@fosstodon.org avatar

@arildsen There's so much stuff in the numpy / scipy / pandas libraries, it's hard to keep up.

jamescooke,
@jamescooke@fosstodon.org avatar

@arildsen I think if the code being tested uses numpy, then the dependency is already there and is already loaded at test time (because the test ran and the numpy thing got used / created).

So the only overhead in the test is the single "import numpy as np" - which I think is basically a NOOP because Python already knows numpy is loaded and doesn't reload.

bbelderbos, to python
@bbelderbos@fosstodon.org avatar

With error handling in #Python, handle specific exceptions (known issues) first.

Reserve a general Exception catch-all for the end — and only use it if you're unsure of more specific exceptions that may arise. 💡

Remember, explicit is better than implicit! 🐍 😍

jamescooke,
@jamescooke@fosstodon.org avatar

@bbelderbos Could you share any benefits to using the general except Exception handler at all?

I’ve always advised against it, and heard it called "the Pokémon handler" (got to catch them all). I’d never allow it in production projects, and have some horror stories from its use.

jamescooke,
@jamescooke@fosstodon.org avatar

@bbelderbos My main and most recent horror story is detailed and involves multiple moving pieces. Code changes to the function being called inside the catch all handler caused new exceptions to be a raised, object creation to retry() and the database to burn through 2B integer IDs in days, where previously the max ID was 500K after 10 years.

This caused the DB to run out of IDs and new uploads to stop.

jamescooke,
@jamescooke@fosstodon.org avatar

@bbelderbos Meanwhile, I don't have much on risks, but here's some "best practice":

Quotes from this Python thread: https://discuss.python.org/t/extend-type-hints-to-cover-exceptions/23788

> Code should be written to catch what it understands, and ignore everything else.

> Anything which encourages the proliferation of the catch everything anti-pattern into every method and function should be resisted.

And that second comment links to https://realpython.com/the-most-diabolical-python-antipattern/ 👈 which says it far better than I could.

Hope that's helpful.

jonty, to random
@jonty@chaos.social avatar

Exactly 12 years ago I made a terrible mistake

https://social.emfcamp.org/@emf/statuses/01HXRZ1PRXCPNPDSFQSCMED9TB

jamescooke,
@jamescooke@fosstodon.org avatar

@jonty And yet an ex EMF rpi has been my home DNS server for nearly five years 😊

hamatti, to blogging
@hamatti@mastodon.world avatar

Combining hockey and development? Yes please.

I love building small projects to enhance community projects and this spring the NHL playoffs and IIHF World Championships have been keeping me busy with building two web projects between the games.

https://hamatti.org/posts/two-small-hockey-web-projects/

jamescooke,
@jamescooke@fosstodon.org avatar

@hamatti Obligatory ice hockey code project boost 👌🏻

jamescooke, to random
@jamescooke@fosstodon.org avatar

Kids sleeping - time for some catch up "work work" so that the team can run monthly reports tomorrow.

jamescooke, to random
@jamescooke@fosstodon.org avatar

Currently wiring pyproject-fmt into my hledger-adjacent bank statement loader project while child[1] naps... So nice to enforce a format on what's usually a file of TOtal Mess 👌

https://pyproject-fmt.readthedocs.io/en/latest/

jamescooke, to random
@jamescooke@fosstodon.org avatar

Definitely feeling like I'm doing a lot of "glue work" at the moment.

https://noidea.dog/glue

jamescooke,
@jamescooke@fosstodon.org avatar

And I re-found that phrase and talk using Marginalia search, which I'm loving at the moment.

https://search.marginalia.nu/search

jamescooke, to random
@jamescooke@fosstodon.org avatar

Three weeks ago I tooted complaining about Linear and saying that Shortcut's epics were better than anything Linear had.

https://fosstodon.org/@jamescooke/112252208841040074

Today, I log into Linear and find they've released a Project Overview pane which, basically, creates a space where we can create Shortcut-like epics. An entire space in Linear to contain the "why" of how the tickets in a project have been structured 🙏

https://linear.app/changelog/2024-05-02-the-next-generation-of-linear-projects

This is good 😊

#linearapp

jamescooke, to random
@jamescooke@fosstodon.org avatar

Note to self: probably not a good idea to try and explain a data processing race condition using an animated gdocs presentation slide 😬

faithlierheimer, to random
@faithlierheimer@data-folks.masto.host avatar

anyways if you're wondering what grief looks like about 6 months on i am swinging wildly between productivity and killing it at my job and wondering why i bother working at all when rare disease could take me any moment and destroy my mind and body like it did my mom.

so anyways at least the Avs are winning

jamescooke,
@jamescooke@fosstodon.org avatar

@faithlierheimer Avs good and Leafs turmoil is amazing. Helpful distractions are helpful 🙏🏻

jamescooke,
@jamescooke@fosstodon.org avatar

@faithlierheimer I’m going to record the game tonight and listen to it in the morning.

I’m guessing they’ll get close to winning - and then fall at the end. Then get to consume the Toronto post-failure carnage via podcasts (which is how I get most of my hockey news).

jamescooke,
@jamescooke@fosstodon.org avatar

@faithlierheimer Avs made it through too 👌🏻

Daojoan, to random
@Daojoan@mastodon.social avatar

Conservatives would celebrate shutting hospitals just to have the privilege of laughing at their neighbours for being sick.

jamescooke,
@jamescooke@fosstodon.org avatar

@Daojoan Also, prevent those sick people from being signed off work because being too sick to work is "a lifestyle choice".

https://www.bbc.co.uk/news/uk-politics-68853166

jamescooke, to random
@jamescooke@fosstodon.org avatar

Seems a shame to turn off fzf-tmux in bash, but I can't get into building a new tmux to get to some version >= 3.2 (I'm "stuck" on version 3.0a which ships with Ubuntu).

In exchange, I can fully upgrade past version 0.46.0 and get new, faster shiny stuff 🤩

Here's the related issue: https://github.com/junegunn/fzf/issues/3635

jamescooke,
@jamescooke@fosstodon.org avatar

@adamchainz I did so little to set them up I had to redocument them for myself yesterday 😬

Given I've got fzf set up as both a package and a vim plugin: https://github.com/jamescooke/dotfiles/blob/master/store/.vimrc#L9

Then installing the fzf package from vim does ~/.fzf/install --all which "Just Works ™️ " - vim installs fzf for bash and makes the keybindings work 🙈

  • All
  • Subscribed
  • Moderated
  • Favorites
  • anitta
  • khanakhh
  • mdbf
  • InstantRegret
  • Durango
  • Youngstown
  • rosin
  • slotface
  • thenastyranch
  • osvaldo12
  • ngwrru68w68
  • kavyap
  • cisconetworking
  • DreamBathrooms
  • megavids
  • magazineikmin
  • cubers
  • vwfavf
  • modclub
  • everett
  • ethstaker
  • normalnudes
  • tacticalgear
  • tester
  • provamag3
  • GTA5RPClips
  • Leos
  • JUstTest
  • All magazines