Earlier quoted context omitted.
I'm not versed in C#, what should you use otherwise?
It's not a C# thing, it's a floating-point thing. Two numbers which mathematically "should" be equal, might not be due to rounding errors. (In python, 0.15 + 0.15 != 0.1 + 0.2.) So it's risky to compare them with ==, sometimes you'll get the result you expect (and sometimes you can be confident of that) but sometimes you won't. If you can't be sure, you should compare that they're the same within some threshold, but…
Diagnosing a Linux-only unit test failure
21–25 of 25 posts
Re: Diagnosing a Linux-only unit test failure
#22Well, you know exactly how to reproduce the issue, so git bisect it to find the exact commit that fixed it and how. Granted, it may take a very long time, given the size of .Net Core.
Re: Diagnosing a Linux-only unit test failure
#23Earlier quoted context omitted.
Python added "f strings" recently (read: in 2015)[1], which look like f"{some_var}" which evaluates "some_var" in the local scope. Sort of like Ruby's "#{...}" (if I'm remembering that syntax correctly). Rust supports named parameters in format strings[2] but that's not quite the same. [1]: https://www.python.org/dev/peps/pep-0498/ [2]: https://doc.rust-lang.org/std/fmt/#named-parameters
Note that you can do this in old version of Python, too, using the "format-locals" idiom: some_var = ... "{some_var}".format(**locals()) Although this does have some limitations regarding variables to strictly being in the local scope, this is a fine idiom if you need to be compatible with older Python versions.
some_var = ...
"%(some_var)s" % locals()
If you want to do both locals and globals you can do: some_var = ...
"%(some_var)s" % dict(globals(), **locals())
New Python versions (>=3.5) have this syntax: "%(some_var)s" % {**globals(), **locals()}
But those versions also have f-strings so that's sort of moot.Re: Diagnosing a Linux-only unit test failure
#24Earlier quoted context omitted.
It's not a C# thing, it's a floating-point thing. Two numbers which mathematically "should" be equal, might not be due to rounding errors. (In python, 0.15 + 0.15 != 0.1 + 0.2.) So it's risky to compare them with ==, sometimes you'll get the result you expect (and sometimes you can be confident of that) but sometimes you won't. If you can't be sure, you should compare that they're the same within some threshold, but…
`0.1 + 0.2 != 0.3` is a property of all (base-2) floating-point arithmetic, no matter the precision or programming language.
Re: Diagnosing a Linux-only unit test failure
#25Earlier quoted context omitted.
`0.1 + 0.2 != 0.3` is a property of all (base-2) floating-point arithmetic, no matter the precision or programming language.
Well yeah, but this was 0.1 + 0.2 != 0.15 + 0.15, and there's no obvious reason why 0.15 + 0.15 = 0.3 imo.