@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 python
@jamescooke@fosstodon.org avatar

New blog post 🎉

"An Ode to pipx" - some ways in which using has improved my development experience.

https://jamescooke.info/an-ode-to-pipx.html

revk, to random
@revk@toot.me.uk avatar

I have some musings on Highway Code Rule 170.

https://www.revk.uk/2023/12/rule-170.html

jamescooke,
@jamescooke@fosstodon.org avatar

@revk Thanks for sharing these.

I’m primarily a pedestrian and I still get confused between the mixture of driver behaviours I see at junctions in our neighbourhood. There seem to be junctions where it’s ok to Rule 170, and others where it’s ignored - less than 100m from each other. 😬

jamescooke, to random
@jamescooke@fosstodon.org avatar

Thanks to @hugovk 's post here https://dev.to/hugovk/help-test-python-312-beta-1508 I learned two things:

  1. it's easy to do a pre-release Python build on GitHub Actions

and 2. fail-fast: false strategy config flag is what I've been wanting for literally years!

I just assumed that GHA didn't have this feature 😬 .

jamescooke, to random
@jamescooke@fosstodon.org avatar

New post - just something tiny about balance assertions failure messages being nicer than Ledger's : https://jamescooke.info/hledger-failure-messages-are-better-than-ledgers.html

dazfuller, to DuckDuckGo
@dazfuller@mstdn.social avatar

So, with being down, what is everyone using instead (that isn't Google)?

I'm currently looking at which seems okay

jamescooke,
@jamescooke@fosstodon.org avatar

@dazfuller Oh and maybe check a searx instance from this list: https://searx.space/

jamescooke,
@jamescooke@fosstodon.org avatar

@dazfuller Looks like https://www.ecosia.org/ is also failing - probably using DDG index under the hood 🤔

Just fall back to https://search.marginalia.nu/ 😊

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 There's so much stuff in the numpy / scipy / pandas libraries, it's hard to keep up.

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 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.

jamescooke, to python
@jamescooke@fosstodon.org avatar

If I just want fuzzy search of 7,000 JSON documents that span 1.6M of disk... then am I really meant to spin up an Elastic Search instance?

There must be a better way, right?! Isn't there some lib I can use for this?

jamescooke, to random
@jamescooke@fosstodon.org avatar

A question for people who know about old British telecom wiring… I live in an 1880s terraced house in Brighton. There’s an old cable that runs from this "thing" on our northern neighbour’s side of the chimney, over our roof, our neighbour to the south’s roof and to another similar shaped "thing" on the next chimney.

All neighbours are pretty sure it’s not connected to anything in any houses - but can we cut it and be safe?!

Thing B - on our neighbour’s chimney two doors up.

jamescooke, to random
@jamescooke@fosstodon.org avatar

Hello - I’m joining the movement 💪🏻.

If I can get CI sorted, then I’ll move my projects to Codeberg. Otherwise I might only get as far as GitLab.

For those wanting to read up: https://sfconservancy.org/GiveUpGitHub/

jamescooke, to random
@jamescooke@fosstodon.org avatar

Am thinking I’m going to try out @glyph ‘s new Fritter project… My NHL radio recorder needs a rewrite to make it more robust and automated and I think this library will help with lots of that time / scheduling related logic.

https://github.com/glyph/Fritter

Maybe once the Penguins don’t make the playoffs, then I’ll try 😬🤔😭.

dazfuller, to pihole
@dazfuller@mstdn.social avatar

My crashed yesterday. First time in 3 years it’s put a foot wrong! And it’s just made me even more impressed with it, this tiny little Pi Zero W handling all the houses traffic. Especially when I’ve got things like MS Teams that needs killing and reopening several times a day

jamescooke,
@jamescooke@fosstodon.org avatar

@dazfuller They’re so amazing. I’ve been running our house one on a Pi 1B for more than five years. It’s running off the router’s power via USB, which I love… just like a little symbiote attached to its host 🥰

I’ve got a feeling when it fails it’s going to fail hard though. Have got a Pi Zero doing nothing, so maybe I should prepare that as the backup? 🤔

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 😊

bbelderbos, to python
@bbelderbos@fosstodon.org avatar

With error handling in , 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 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.

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 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,
@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, to random
@jamescooke@fosstodon.org avatar

Have been experimenting with pyproject-fmt and it's pretty nice 👌

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

jamescooke,
@jamescooke@fosstodon.org avatar

Even nicer - I'd found an inconsistency with how it was applying formatting to the list of scripts... Calling pyproject-fmt --check on a file that had just been formatted by pyproject-fmt would cause an error.

However, it looks like that bug was already covered and fixed here 🙌

https://github.com/tox-dev/pyproject-fmt/issues/201

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

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