diff options
author | Alibi <aliby.bbb@gmail.com> | 2022-08-04 19:00:51 +0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-04 16:00:51 +0300 |
commit | 34f07a716f1029a38cc000177c931a7ea8bd712e (patch) | |
tree | fe50a0d29ccf5bea52a3907db2d416355bbde909 /redis | |
parent | aca005084a95110796cfd59b20c87ce7baaf94c0 (diff) | |
download | redis-py-34f07a716f1029a38cc000177c931a7ea8bd712e.tar.gz |
Add TDIGEST.TRIMMED_MEAN (#2300)
* Add tdigest trimmed mean command with test
* Add skip version for test
* add to module callbacks
Co-authored-by: Alibi Shalgymbay <a.shalgymbay@mycar.kz>
Co-authored-by: dvora-h <67596500+dvora-h@users.noreply.github.com>
Co-authored-by: dvora-h <dvora.heller@redis.com>
Diffstat (limited to 'redis')
-rw-r--r-- | redis/commands/bf/__init__.py | 1 | ||||
-rw-r--r-- | redis/commands/bf/commands.py | 11 |
2 files changed, 12 insertions, 0 deletions
diff --git a/redis/commands/bf/__init__.py b/redis/commands/bf/__init__.py index 3169ba2..e41354b 100644 --- a/redis/commands/bf/__init__.py +++ b/redis/commands/bf/__init__.py @@ -170,6 +170,7 @@ class TDigestBloom(TDigestCommands, AbstractBloom): TDIGEST_QUANTILE: parse_tdigest_quantile, TDIGEST_MIN: float, TDIGEST_MAX: float, + TDIGEST_TRIMMED_MEAN: float, TDIGEST_INFO: TDigestInfo, } diff --git a/redis/commands/bf/commands.py b/redis/commands/bf/commands.py index 84a6b5f..0fe065d 100644 --- a/redis/commands/bf/commands.py +++ b/redis/commands/bf/commands.py @@ -49,6 +49,7 @@ TDIGEST_QUANTILE = "TDIGEST.QUANTILE" TDIGEST_MIN = "TDIGEST.MIN" TDIGEST_MAX = "TDIGEST.MAX" TDIGEST_INFO = "TDIGEST.INFO" +TDIGEST_TRIMMED_MEAN = "TDIGEST.TRIMMED_MEAN" TDIGEST_MERGESTORE = "TDIGEST.MERGESTORE" @@ -418,6 +419,16 @@ class TDigestCommands: """ # noqa return self.execute_command(TDIGEST_INFO, key) + def trimmed_mean(self, key, low_cut_quantile, high_cut_quantile): + """ + Return mean value from the sketch, excluding observation values outside + the low and high cutoff quantiles. + For more information see `TDIGEST.TRIMMED_MEAN <https://redis.io/commands/tdigest.trimmed_mean>`_. + """ # noqa + return self.execute_command( + TDIGEST_TRIMMED_MEAN, key, low_cut_quantile, high_cut_quantile + ) + def mergestore(self, dest_key, numkeys, *sourcekeys, compression=False): """ Merges all of the values from `sourcekeys` keys to `dest_key` sketch. |