From dbc99ecf31834c979ca35a20edd9ccbd64dc0d57 Mon Sep 17 00:00:00 2001 From: Erwin Kroon <123574+ekroon@users.noreply.github.com> Date: Thu, 23 Nov 2023 09:02:24 +0000 Subject: [PATCH] Explain clean vs compare in README --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index b64675e..7d15a20 100644 --- a/README.md +++ b/README.md @@ -241,6 +241,19 @@ end Note that the `#clean` method will discard the previous cleaner block if you call it again. If for some reason you need to access the currently configured cleaner block, `Scientist::Experiment#cleaner` will return the block without further ado. _(This probably won't come up in normal usage, but comes in handy if you're writing, say, a custom experiment runner that provides default cleaners.)_ +The `#clean` method will not be used for comparison of the results, so in the following example it is not possible to remove the `#compare` method without the experiment failing: + +```ruby +def user_ids + science "user_ids" do + e.use { [1,2,3] } + e.try { [1,3,2] } + e.clean { |value| value.sort } + e.compare { |a, b| a.sort == b.sort } + end +end +``` + ### Ignoring mismatches During the early stages of an experiment, it's possible that some of your code will always generate a mismatch for reasons you know and understand but haven't yet fixed. Instead of these known cases always showing up as mismatches in your metrics or analysis, you can tell an experiment whether or not to ignore a mismatch using the `ignore` method. You may include more than one block if needed: