Re: customer compare in assertEqual
Stone Zhong wrote: > Hi There, > > Now I want to make sure my code calls a function foo with an object t, > however, foo.assert_called_once_with(t) does not work, since t is a model > object and the code may load a different copy of t, so what I really want > to test is "It calls foo with t where t.id equals real_t.id, is there a > way to do that in python unit test? If you don't find any mock-specific solution you can provide a t with a custom equality operator: class U: def __init__(self, id): self.id = id def __eq__(self, other): return self.id == other.id foo.assert_called_once_with(U(42)) This should ensure that real_t.id == 42. -- https://mail.python.org/mailman/listinfo/python-list
Getting Pandas NaT to propagate like NaN
I'm trying to take the min and max of a couple Pandas Series objects in the face of NaT. np.minimum and np.maximum work the way I want if the elements are floats. For example: >>> s1 00.0 11.8 23.6 35.4 dtype: float64 >>> s2 010.0 117.0 2 NaN 314.0 dtype: float64 >>> np.maximum(s1, s2) 010.0 117.0 2 NaN 314.0 dtype: float64 >>> np.minimum(s1, s2) 00.0 11.8 2NaN 35.4 dtype: float64 This doesn't work if s1 and s2 are datetime64[ns] objects: >>> s1 0 2199-12-31 1 2199-12-31 2 2199-12-31 3 2199-12-31 dtype: datetime64[ns] >>> s2 0 NaT 1 2018-10-30 2 NaT 3 NaT dtype: datetime64[ns] >>> np.maximum(s1, s2) 0 2199-12-31 1 2199-12-31 2 2199-12-31 3 2199-12-31 dtype: datetime64[ns] >>> np.minimum(s1, s2) 0 2199-12-31 1 2018-10-30 2 2199-12-31 3 2199-12-31 dtype: datetime64[ns] After doing a bit of reading, I came to realize NaT is only approximately NaN, the latter having a proper floating point representation. Further reading suggested no simple way to have NaT "pollute" these comparisons. What's the correct way to get NaT to propagate in min/max comparisons the way NaN does in a floating point context? Thanks, Skip -- https://mail.python.org/mailman/listinfo/python-list
[ANN] maildog, Re: email automation
On Tue, 2018-10-23 at 13:58 +0200, Brian J. Oney wrote: > On Tue, 2018-10-23 at 10:31 +0100, Ali Rıza KELEŞ wrote: > > On Tue, 23 Oct 2018 at 09:07, Thomas Jollans wrote: > Now that it seems that I will be writing this. So I have gotten so far as to have a little package called 'maildog' working for me. It reads emails and sends customized replies on my behalf. Currently, I have it working for two languages. If you also have to reply to the same email ofter for whatever reason this little puppy may help you write fewer repetive email replies. That's what it does for me. If I have piqued your interest, have a look at https://github.com/oneyb/maildog/ Thank you for the tips. Kind regards Brian -- https://mail.python.org/mailman/listinfo/python-list
