Skip to content

Commit a25a0d2

Browse files
authored
Merge pull request #248 from github/improve-clean-docs
Explain clean vs compare in README
2 parents 0039b70 + dbc99ec commit a25a0d2

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

README.md

+13
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,19 @@ end
241241

242242
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.)_
243243

244+
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:
245+
246+
```ruby
247+
def user_ids
248+
science "user_ids" do
249+
e.use { [1,2,3] }
250+
e.try { [1,3,2] }
251+
e.clean { |value| value.sort }
252+
e.compare { |a, b| a.sort == b.sort }
253+
end
254+
end
255+
```
256+
244257
### Ignoring mismatches
245258

246259
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:

0 commit comments

Comments
 (0)