question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add Arb.distinct that will terminate

See original GitHub issue

The current distinct is likely to hang if it cannot generate enough unique values. That is why we deprecated it. But the functionality is still useful. I propose we add an alternative, that makes those caveats crystal.

arb.distinct(maxAttempts = 1000, throwOnLimit = true)

Those parameters would not have defaults so it would be obvious what you’re doing.

@myuwono ?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
myuwonocommented, Jun 8, 2021

@aSemy thank you! Quite honestly i was also thinking along similar lines. Because as you’ve rightly highlighted it’s important to have these arbs stateless. Maybe we can introduce such constraint as an additional parameter to checkall.

In a nutshell…

test("my distinct") {
  val myset: MutableSet<B> = mutableSetOf()
  fun isDistinct(a: A, b: B): Boolean = ...
  checkAll(arbA, arbB, constraint = ::isDistinct) { a, b ->
    ...
    
  }
}

I think @aSemy 's idea makes sense.

We have to think about ergonomics but this actually solves a lot of problems, not only distinct.

Wdyt @sksamuel ?

0reactions
sksamuelcommented, Aug 1, 2021

Any thoughts on the above ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tutorial 2: Sequence alignments using ARB
A message box should pop up telling you that the PT_Server database is built. Click on OK. Close the PT_Server Admin window. The...
Read more >
Angiotensin receptor blockers (ARBs) - Heart Matters magazine
Unfortunately, this is rarely the case: high blood pressure will return once the medication is stopped. It may be necessary to stop taking...
Read more >
TRED Recovery Boards & Accessories - ARB USA
TRED recovery boards are the ultimate off-road recovery device, specially designed to get your 4×4, or ATV out of trouble when traction is...
Read more >
Select All distinct values in a column using LINQ
To have unique Categories: var uniqueCategories = repository.GetAllProducts() .Select(p => p.Category) .Distinct();.
Read more >
ARB/SILVA FAQs
Select your sequences of interest by ticking the box in front of each sequence ( will be shown) or add all sequences to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found