Replies

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

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? 🤔

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

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 Looks like https://www.ecosia.org/ is also failing - probably using DDG index under the hood 🤔

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

jamescooke,
@jamescooke@fosstodon.org avatar

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

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 🤔

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 , 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 😊

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