cls.random_sample
See original GitHub issueI wanted to add a method to BaseProvider that allows for sampling n unique elements. There are situations in which I want to grab several random things, but I want those results to be unique. I just forked and added this to my own fork, but I wanted to run it by you before making a pull request.
# in faker/provides/__init__.py BaseProvider
@classmethod
def random_sample(cls, array=('a','b','c'), number=2):
""" Returns $number unique elements from $array"""
return random.sample(array, number)
Issue Analytics
- State:
- Created 10 years ago
- Comments:7
Top Results From Across the Web
CLs method (particle physics) - Wikipedia
In particle physics, CLs represents a statistical method for setting upper limits (also called exclusion limits) on model parameters, a particular form of ......
Read more >Sampling Distributions II - StudyLib
An Example of Sampling Distributions: A Comparison of Simple Random Sampling ... Systematic Sampling, and Cluster Sampling (SRS, STS, SYS, and CLS) Consider ......
Read more >Why does random.sample used with multiprocessing.Pool ...
This is an open bug in Python 3.8. It is not related to random , the reason is the cleanup of worker processes...
Read more >sklearn.ensemble.RandomForestClassifier
A random forest is a meta estimator that fits a number of decision tree classifiers on various sub-samples of the dataset and uses...
Read more >Untitled - Math BLogDr. Natalie Hise
CLASINOON. Hybart | 2. Page 2. Choose which sampling technique is used. (R) Random (STR) Stratified (CLS) Cluster (CON) Convenience (SYS) Systematic. STR....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Closed via #358
@fcurella looks nice for me too 👍 But what about unique texts? I can implement it with generating lot of samples and remove duplicates, but it would be nice to have some kind of generator, which always return unique text (address, name, etc.). What do you think about such feature?
I want to use it in my factory for models, which have
unique
constraints.I can try to implement this myself in PR, if you think it can be useful.