My #PiHole 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
@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? 🤔
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 🙌
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
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 😊
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])
@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 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.
@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.