changing order of unit tests in Python

You can change the default sorting behavior by setting a custom comparison function. In unittest.py you can find the class variable unittest.TestLoader.sortTestMethodsUsing which is set to the builtin function cmp by default. For example you can revert the execution order of your tests with doing this: import unittest unittest.TestLoader.sortTestMethodsUsing = lambda _, x, y: cmp(y, … Read more

Datagrid binding in WPF

PLEASE do not use object as a class name: public class MyObject //better to choose an appropriate name { string id; DateTime date; public string ID { get { return id; } set { id = value; } } public DateTime Date { get { return date; } set { date = value; } } … Read more

How to include SQLite database in executable Jar?

What library are you using for SQLite? I did a search based on the connection URI you indicated and found this one. In the documentation it says: 2009 May 19th: sqlite-jdbc-3.6.14.1 released. This version supports “jdbc:sqlite::resource:” syntax to access read-only DB files contained in JAR archives, or external resources specified via URL, local files address … Read more

Replace negative values by zero

Thanks for the reproducible example. This is pretty basic R stuff. You can assign to selected elements of a vector (note an array has dimensions, and what you’ve given is a vector not an array): > pred_precipitation[pred_precipitation<0] <- 0 > pred_precipitation [1] 1.2091281 0.0000000 7.7665555 0.0000000 0.0000000 0.0000000 0.5151504 0.0000000 1.8281251 [10] 0.5098688 2.8370263 0.4895606 … Read more

Creating WPF BitmapImage from MemoryStream png, gif

Add bi.CacheOption = BitmapCacheOption.OnLoad directly after your .BeginInit(): BitmapImage bi = new BitmapImage(); bi.BeginInit(); bi.CacheOption = BitmapCacheOption.OnLoad; … Without this, BitmapImage uses lazy initialization by default and stream will be closed by then. In first example you try to read image from possibly garbage-collected closed or even disposed MemoryStream. Second example uses file, which is … Read more