glh123456/OmniGIRL huggingface dataset:
Repository: jestjs/jest (TypeScript)

Issue:
[Bug]: Another Immutable equals comparison failure
### Version

28.1.0

### Steps to reproduce

```
import Immutable from 'immutable';

it('works with immutable objects', () => {
  const a = Immutable.OrderedMap().set('saving', true);
  const b = Immutable.OrderedMap().merge({ saving: true });
  console.log(a);
  console.log(b);
  expect(Immutable.is(a, b)).toBe(true);
  expect(a).toEqual(b);
});
```

### Expected behavior

The test should pass

### Actual behavior

The `isEqual` test fails. The `Immutable.is(a, b)` assertion passes.

### Additional context

This is possibly the same issue as #12752 that wasn't addressed in that fix. The call to `merge` sets an `ownerID` value on the `_root` property whereas the `set` call does not.

### Environment

```shell
System:
    OS: macOS 12.4
    CPU: (10) x64 Apple M1 Pro
  Binaries:
    Node: 14.18.1 - /var/folders/b4/0jgrn8fx6vn5bd59pmybg6zw0000gn/T/fnm_multishells/4762_1652895535386/bin/node
    Yarn: 1.22.18 - ~/workspace/zenpayroll/node_modules/.bin/yarn
    npm: 8.3.1 - /opt/homebrew/bin/npm
  npmPackages:
    jest: ^28.1.0 => 28.1.0
```



Hints:
PR welcome 😀 

Patch:
diff --git a/packages/expect-utils/src/jasmineUtils.ts b/packages/expect-utils/src/jasmineUtils.ts
--- a/packages/expect-utils/src/jasmineUtils.ts
+++ b/packages/expect-utils/src/jasmineUtils.ts
@@ -266,3 +266,11 @@ export function isImmutableList(maybeList: any) {
     maybeList[IS_LIST_SENTINEL]
   );
 }
+
+export function isImmutableOrderedKeyed(maybeKeyed: any) {
+  return !!(
+    maybeKeyed &&
+    maybeKeyed[IS_KEYED_SENTINEL] &&
+    maybeKeyed[IS_ORDERED_SENTINEL]
+  );
+}
diff --git a/packages/expect-utils/src/utils.ts b/packages/expect-utils/src/utils.ts
--- a/packages/expect-utils/src/utils.ts
+++ b/packages/expect-utils/src/utils.ts
@@ -11,6 +11,7 @@ import {
   equals,
   isA,
   isImmutableList,
+  isImmutableOrderedKeyed,
   isImmutableUnorderedKeyed,
   isImmutableUnorderedSet,
 } from './jasmineUtils';
@@ -255,7 +256,7 @@ export const iterableEquality = (
     return false;
   }
 
-  if (!isImmutableList(a)) {
+  if (!isImmutableList(a) && !isImmutableOrderedKeyed(a)) {
     const aEntries = Object.entries(a);
     const bEntries = Object.entries(b);
     if (!equals(aEntries, bEntries)) {


Test patch:
diff --git a/packages/expect-utils/src/__tests__/utils.test.ts b/packages/expect-utils/src/__tests__/utils.test.ts
--- a/packages/expect-utils/src/__tests__/utils.test.ts
+++ b/packages/expect-utils/src/__tests__/utils.test.ts
@@ -6,7 +6,7 @@
  *
  */
 
-import {List} from 'immutable';
+import {List, OrderedMap} from 'immutable';
 import {stringify} from 'jest-matcher-utils';
 import {
   arrayBufferEquality,
@@ -525,6 +525,12 @@ describe('iterableEquality', () => {
 
     expect(iterableEquality(a, b)).toBe(true);
   });
+
+  test('returns true when given Immutable OrderedMaps without an OwnerID', () => {
+    const a = OrderedMap().set('saving', true);
+    const b = OrderedMap().merge({saving: true});
+    expect(iterableEquality(a, b)).toBe(true);
+  });
 });
 
 describe('arrayBufferEquality', () => {
Repository: jestjs/jest (TypeScript)

Issue:
[Bug]: Immutable.OrderedSet equality comparison failure
### Version

28.1.2

### Steps to reproduce

```
import { OrderedSet, List } from 'immutable';

it('works with immutable objects', () => {
  const a = OrderedSet().add('newValue');
  const b = List(['newValue']).toOrderedSet();
  expect(Immutable.is(a, b)).toBe(true); // passes
  expect(a).toEqual(b); // fails
});
```

### Expected behavior

The test should pass

### Actual behavior

The `isEqual` test fails. The `Immutable.is(a, b)` assertion passes.

### Additional context

This is the same issue as #12860, but needs its own condition.

### Environment

```shell
System:
    OS: macOS 12.4
    CPU: (10) x64 Apple M1 Pro
  Binaries:
    Node: 14.18.1 - /var/folders/b4/0jgrn8fx6vn5bd59pmybg6zw0000gn/T/fnm_multishells/4762_1652895535386/bin/node
    Yarn: 1.22.18 - ~/workspace/zenpayroll/node_modules/.bin/yarn
    npm: 8.3.1 - /opt/homebrew/bin/npm
  npmPackages:
    jest: ^28.1.2 => 28.1.2
```



Hints:

Patch:
diff --git a/packages/expect-utils/src/jasmineUtils.ts b/packages/expect-utils/src/jasmineUtils.ts
--- a/packages/expect-utils/src/jasmineUtils.ts
+++ b/packages/expect-utils/src/jasmineUtils.ts
@@ -274,3 +274,12 @@ export function isImmutableOrderedKeyed(maybeKeyed: any) {
     maybeKeyed[IS_ORDERED_SENTINEL]
   );
 }
+
+
+export function isImmutableOrderedSet(maybeSet: any) {
+  return !!(
+    maybeSet &&
+    maybeSet[IS_SET_SENTINEL] &&
+    maybeSet[IS_ORDERED_SENTINEL]
+  );
+}
diff --git a/packages/expect-utils/src/utils.ts b/packages/expect-utils/src/utils.ts
--- a/packages/expect-utils/src/utils.ts
+++ b/packages/expect-utils/src/utils.ts
@@ -12,6 +12,7 @@ import {
   isA,
   isImmutableList,
   isImmutableOrderedKeyed,
+  isImmutableOrderedSet,
   isImmutableUnorderedKeyed,
   isImmutableUnorderedSet,
 } from './jasmineUtils';
@@ -256,7 +257,11 @@ export const iterableEquality = (
     return false;
   }
 
-  if (!isImmutableList(a) && !isImmutableOrderedKeyed(a)) {
+  if (
+    !isImmutableList(a) &&
+    !isImmutableOrderedKeyed(a) &&
+    !isImmutableOrderedSet(a)
+  ) {
     const aEntries = Object.entries(a);
     const bEntries = Object.entries(b);
     if (!equals(aEntries, bEntries)) {


Test patch:
diff --git a/packages/expect-utils/src/__tests__/utils.test.ts b/packages/expect-utils/src/__tests__/utils.test.ts
--- a/packages/expect-utils/src/__tests__/utils.test.ts
+++ b/packages/expect-utils/src/__tests__/utils.test.ts
@@ -6,7 +6,7 @@
  *
  */
 
-import {List, OrderedMap} from 'immutable';
+import {List, OrderedMap, OrderedSet} from 'immutable';
 import {stringify} from 'jest-matcher-utils';
 import {
   arrayBufferEquality,
@@ -531,6 +531,12 @@ describe('iterableEquality', () => {
     const b = OrderedMap().merge({saving: true});
     expect(iterableEquality(a, b)).toBe(true);
   });
+
+  test('returns true when given Immutable OrderedSets without an OwnerID', () => {
+    const a = OrderedSet().add('newValue');
+    const b = List(['newValue']).toOrderedSet();
+    expect(iterableEquality(a, b)).toBe(true);
+  });
 });
 
 describe('arrayBufferEquality', () => {
Repository: statsmodels/statsmodels (Python)

Issue:
BUG: acorr_breusch_godfrey error in regressions without const or exogs
In ARMA models without constant (or ARMAX without constant and without exogs) the acorr_breusch_godfrey method don't check if res.model.exog is None and try to use exogs returning a ValueError.

#### Code Sample, a copy-pastable example if possible


```python
from statsmodels.tsa.arima_model import ARMA
import pandas as pd
from statsmodels.datasets import sunspots

data = sunspots.load_pandas().data['SUNACTIVITY']

res = ARMA(data, (1,0)).fit(disp=False, trend = 'nc')

from statsmodels.stats.diagnostic import acorr_breusch_godfrey

acorr_breusch_godfrey(res, nlags=1)
```

#### Expected Output

N/A

#### Output of ``import statsmodels.api as sm; sm.show_versions()``

0.11.0 


Hints:

Patch:
diff --git a/statsmodels/stats/diagnostic.py b/statsmodels/stats/diagnostic.py
--- a/statsmodels/stats/diagnostic.py
+++ b/statsmodels/stats/diagnostic.py
@@ -802,7 +802,10 @@ def acorr_breusch_godfrey(res, nlags=None, store=False):
     nobs = xdall.shape[0]
     xdall = np.c_[np.ones((nobs, 1)), xdall]
     xshort = x[-nobs:]
-    exog = np.column_stack((exog_old, xdall))
+    if exog_old is None:
+        exog = xdall
+    else:
+        exog = np.column_stack((exog_old, xdall))
     k_vars = exog.shape[1]
 
     resols = OLS(xshort, exog).fit()


Test patch:
diff --git a/statsmodels/stats/tests/test_diagnostic.py b/statsmodels/stats/tests/test_diagnostic.py
--- a/statsmodels/stats/tests/test_diagnostic.py
+++ b/statsmodels/stats/tests/test_diagnostic.py
@@ -28,6 +28,7 @@
 from statsmodels.tools.tools import Bunch
 from statsmodels.tools.tools import add_constant
 from statsmodels.tsa.ar_model import AutoReg
+from statsmodels.tsa.arima_model import ARMA
 
 cur_dir = os.path.abspath(os.path.dirname(__file__))
 
@@ -287,6 +288,11 @@ def test_acorr_breusch_godfrey_multidim(self):
         with pytest.raises(ValueError, match='Model resid must be a 1d array'):
             smsdia.acorr_breusch_godfrey(res)
 
+    def test_acorr_breusch_godfrey_exogs(self):
+        data = sunspots.load_pandas().data['SUNACTIVITY']
+        res = ARMA(data, (1, 0)).fit(disp=False, trend='nc')
+        smsdia.acorr_breusch_godfrey(res, nlags=1)
+
     def test_acorr_ljung_box(self):
 
         # unit-test which may be useful later
Repository: statsmodels/statsmodels (Python)

Issue:
BUG: fix percentiles being dropped in Description frame.
- [x] closes #7316
- [x] tests added / passed. 
- [x] code/documentation is well formatted.  
- [x] properly formatted commit message

@bashtage I am not very familiar with this function, so if you have a moment to check if I did something sensible, that would be great!


Hints:

Patch:
diff --git a/statsmodels/stats/descriptivestats.py b/statsmodels/stats/descriptivestats.py
--- a/statsmodels/stats/descriptivestats.py
+++ b/statsmodels/stats/descriptivestats.py
@@ -525,6 +525,9 @@ def _safe_jarque_bera(c):
             output = f"{{0:{fmt}}}%"
             perc.index = [output.format(val) for val in index]
 
+        # Add in the names of the percentiles to the output
+        self._stats = self._stats + perc.index.tolist()
+
         return self._reorder(pd.concat([results_df, perc], axis=0))
 
     @cache_readonly


Test patch:
diff --git a/statsmodels/stats/tests/test_descriptivestats.py b/statsmodels/stats/tests/test_descriptivestats.py
--- a/statsmodels/stats/tests/test_descriptivestats.py
+++ b/statsmodels/stats/tests/test_descriptivestats.py
@@ -164,7 +164,15 @@ def test_description_basic(df):
 def test_odd_percentiles(df):
     percentiles = np.linspace(7.0, 93.0, 13)
     res = Description(df, percentiles=percentiles)
-    print(res.frame.index)
+    stats = [
+        'nobs', 'missing', 'mean', 'std_err', 'upper_ci', 'lower_ci', 'std',
+        'iqr', 'iqr_normal', 'mad', 'mad_normal', 'coef_var', 'range', 'max',
+        'min', 'skew', 'kurtosis', 'jarque_bera', 'jarque_bera_pval', 'mode',
+        'mode_freq', 'median', 'distinct', 'top_1', 'top_2', 'top_3', 'top_4',
+        'top_5', 'freq_1', 'freq_2', 'freq_3', 'freq_4', 'freq_5', '7.0%',
+        '14.1%', '21.3%', '28.5%', '35.6%', '42.8%', '50.0%', '57.1%', '64.3%',
+        '71.5%', '78.6%', '85.8%', '93.0%']
+    assert_equal(res.frame.index.tolist(), stats)
 
 
 def test_large_ntop(df):
Repository: statsmodels/statsmodels (Python)

Issue:
ENH: GLM add warning if negbin parameter is default
I have seen several examples, e.g. on stackoverflow, where users do not set the GLM-negbin parameter.
I guess users often assume that the extra parameter is estimated.

A warning if the default parameter is used would be useful to reduce the risk that user misunderstand the model.




Hints:

Patch:
diff --git a/statsmodels/genmod/families/family.py b/statsmodels/genmod/families/family.py
--- a/statsmodels/genmod/families/family.py
+++ b/statsmodels/genmod/families/family.py
@@ -8,6 +8,7 @@
 
 
 import inspect
+import warnings
 
 import numpy as np
 from scipy import special, stats
@@ -1310,6 +1311,9 @@ class NegativeBinomial(Family):
 
     def __init__(self, link=None, alpha=1.):
         self.alpha = 1. * alpha  # make it at least float
+        if alpha is self.__init__.__defaults__[1]:
+            warnings.warn("Negative binomial dispersion parameter alpha not "
+                          f"set. Using default value alpha={alpha}.")
         if link is None:
             link = L.Log()
         super(NegativeBinomial, self).__init__(


Test patch:
diff --git a/statsmodels/discrete/tests/test_discrete.py b/statsmodels/discrete/tests/test_discrete.py
--- a/statsmodels/discrete/tests/test_discrete.py
+++ b/statsmodels/discrete/tests/test_discrete.py
@@ -1636,6 +1636,22 @@ def test_issue_341():
     np.testing.assert_equal(res1.predict(x[None]).shape, (1,7))
 
 
+def test_negative_binomial_default_alpha_param():
+    with pytest.warns(UserWarning, match='Negative binomial'
+                      ' dispersion parameter alpha not set'):
+        sm.families.NegativeBinomial()
+    with pytest.warns(UserWarning, match='Negative binomial'
+                      ' dispersion parameter alpha not set'):
+        sm.families.NegativeBinomial(link=sm.families.links.nbinom(alpha=1.0))
+    with warnings.catch_warnings():
+        warnings.simplefilter("error")
+        sm.families.NegativeBinomial(alpha=1.0)
+    with warnings.catch_warnings():
+        warnings.simplefilter("error")
+        sm.families.NegativeBinomial(link=sm.families.links.nbinom(alpha=1.0),
+                                     alpha=1.0)
+
+
 def test_iscount():
     X = np.random.random((50, 10))
     X[:,2] = np.random.randint(1, 10, size=50)
Repository: statsmodels/statsmodels (Python)

Issue:
DIckey Fuller test breaks on constant values
#### Describe the bug

Dickey-Fuller test gives error when testing with constant values.

#### Code Sample, a copy-pastable example if possible


```python
adfuller(np.full(8, 5.0))
```
`RuntimeWarning: divide by zero encountered in log
  llf = -nobs2*np.log(2*np.pi) - nobs2*np.log(ssr / nobs) - nobs2`

#### Expected Output

I have expected that this series is stationary

#### Output of ``import statsmodels.api as sm; sm.show_versions()``

<details>

INSTALLED VERSIONS
------------------
Python: 3.10.6.final.0
OS: Linux 5.15.0-50-generic #56-Ubuntu SMP Tue Sep 20 13:23:26 UTC 2022 x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8

statsmodels
===========

Installed: 0.13.2 (/home/michael/.local/lib/python3.10/site-packages/statsmodels)

Required Dependencies
=====================

cython: Not installed
numpy: 1.23.3 (/home/michael/.local/lib/python3.10/site-packages/numpy)
scipy: 1.9.2 (/home/michael/.local/lib/python3.10/site-packages/scipy)
pandas: 1.5.0 (/home/michael/.local/lib/python3.10/site-packages/pandas)
    dateutil: 2.8.2 (/home/michael/.local/lib/python3.10/site-packages/dateutil)
patsy: 0.5.3 (/home/michael/.local/lib/python3.10/site-packages/patsy)

Optional Dependencies
=====================

matplotlib: 3.6.1 (/home/michael/.local/lib/python3.10/site-packages/matplotlib)
    backend: module://matplotlib_inline.backend_inline 
cvxopt: Not installed
joblib: Not installed

Developer Tools
================

IPython: 8.5.0 (/home/michael/.local/lib/python3.10/site-packages/IPython)
    jinja2: 3.1.2 (/home/michael/.local/lib/python3.10/site-packages/jinja2)
sphinx: Not installed
    pygments: 2.13.0 (/home/michael/.local/lib/python3.10/site-packages/pygments)
pytest: Not installed
virtualenv: 20.16.5 (/home/michael/.local/lib/python3.10/site-packages/virtualenv)

</details>



Hints:
The test isn't well defined if the residual variance is 0. Ideally this would be caught and a meaningful exception raised. 

Patch:
diff --git a/statsmodels/tsa/stattools.py b/statsmodels/tsa/stattools.py
--- a/statsmodels/tsa/stattools.py
+++ b/statsmodels/tsa/stattools.py
@@ -268,6 +268,9 @@ def adfuller(
     store = bool_like(store, "store")
     regresults = bool_like(regresults, "regresults")
 
+    if x.max() == x.min():
+        raise ValueError("Invalid input, x is constant")
+
     if regresults:
         store = True
 


Test patch:
diff --git a/statsmodels/tsa/tests/test_stattools.py b/statsmodels/tsa/tests/test_stattools.py
--- a/statsmodels/tsa/tests/test_stattools.py
+++ b/statsmodels/tsa/tests/test_stattools.py
@@ -188,6 +188,12 @@ def test_store_str(self):
         )
 
 
+@pytest.mark.parametrize("x", [np.full(8, 5.0)])
+def test_adfuller_resid_variance_zero(x):
+    with pytest.raises(ValueError):
+        adfuller(x)
+
+
 class CheckCorrGram:
     """
     Set up for ACF, PACF tests.
Repository: redis/redis-py (Python)

Issue:
Add support for SORT_RO



Hints:

Patch:
diff --git a/redis/commands/core.py b/redis/commands/core.py
--- a/redis/commands/core.py
+++ b/redis/commands/core.py
@@ -2224,6 +2224,39 @@ def sort(
         options = {"groups": len(get) if groups else None}
         return self.execute_command("SORT", *pieces, **options)
 
+    def sort_ro(
+        self,
+        key: str,
+        start: Optional[int] = None,
+        num: Optional[int] = None,
+        by: Optional[str] = None,
+        get: Optional[List[str]] = None,
+        desc: bool = False,
+        alpha: bool = False,
+    ) -> list:
+        """
+        Returns the elements contained in the list, set or sorted set at key.
+        (read-only variant of the SORT command)
+
+        ``start`` and ``num`` allow for paging through the sorted data
+
+        ``by`` allows using an external key to weight and sort the items.
+            Use an "*" to indicate where in the key the item value is located
+
+        ``get`` allows for returning items from external keys rather than the
+            sorted data itself.  Use an "*" to indicate where in the key
+            the item value is located
+
+        ``desc`` allows for reversing the sort
+
+        ``alpha`` allows for sorting lexicographically rather than numerically
+
+        For more information check https://redis.io/commands/sort_ro
+        """
+        return self.sort(
+            key, start=start, num=num, by=by, get=get, desc=desc, alpha=alpha
+        )
+
 
 class ScanCommands:
     """


Test patch:
diff --git a/tests/test_commands.py b/tests/test_commands.py
--- a/tests/test_commands.py
+++ b/tests/test_commands.py
@@ -2700,6 +2700,16 @@ def test_sort_all_options(self, r):
         assert num == 4
         assert r.lrange("sorted", 0, 10) == [b"vodka", b"milk", b"gin", b"apple juice"]
 
+    @skip_if_server_version_lt("7.0.0")
+    def test_sort_ro(self, r):
+        r["score:1"] = 8
+        r["score:2"] = 3
+        r["score:3"] = 5
+        r.rpush("a", "3", "2", "1")
+        assert r.sort_ro("a", by="score:*") == [b"2", b"3", b"1"]
+        r.rpush("b", "2", "3", "1")
+        assert r.sort_ro("b", desc=True) == [b"3", b"2", b"1"]
+
     def test_sort_issue_924(self, r):
         # Tests for issue https://github.com/andymccurdy/redis-py/issues/924
         r.execute_command("SADD", "issue#924", 1)
Repository: redis/redis-py (Python)

Issue:
Add support for EXPIRETIME



Hints:

Patch:
diff --git a/redis/commands/core.py b/redis/commands/core.py
--- a/redis/commands/core.py
+++ b/redis/commands/core.py
@@ -1514,6 +1514,15 @@ def expireat(self, name: KeyT, when: AbsExpiryT) -> ResponseT:
             when = int(time.mktime(when.timetuple()))
         return self.execute_command("EXPIREAT", name, when)
 
+    def expiretime(self, key: str) -> int:
+        """
+        Returns the absolute Unix timestamp (since January 1, 1970) in seconds
+        at which the given key will expire.
+
+        For more information check https://redis.io/commands/expiretime
+        """
+        return self.execute_command("EXPIRETIME", key)
+
     def get(self, name: KeyT) -> ResponseT:
         """
         Return the value at key ``name``, or None if the key doesn't exist


Test patch:
diff --git a/tests/test_commands.py b/tests/test_commands.py
--- a/tests/test_commands.py
+++ b/tests/test_commands.py
@@ -1075,6 +1075,12 @@ def test_expireat_unixtime(self, r):
         assert r.expireat("a", expire_at_seconds) is True
         assert 0 < r.ttl("a") <= 61
 
+    @skip_if_server_version_lt("7.0.0")
+    def test_expiretime(self, r):
+        r.set("a", "foo")
+        r.expireat("a", 33177117420)
+        assert r.expiretime("a") == 33177117420
+
     def test_get_and_set(self, r):
         # get and set can't be tested independently of each other
         assert r.get("a") is None
Repository: redis/redis-py (Python)

Issue:
Add support for PEXPIRETIME



Hints:

Patch:
diff --git a/redis/commands/core.py b/redis/commands/core.py
--- a/redis/commands/core.py
+++ b/redis/commands/core.py
@@ -1782,6 +1782,15 @@ def pexpireat(self, name: KeyT, when: AbsExpiryT) -> ResponseT:
             when = int(time.mktime(when.timetuple())) * 1000 + ms
         return self.execute_command("PEXPIREAT", name, when)
 
+    def pexpiretime(self, key: str) -> int:
+        """
+        Returns the absolute Unix timestamp (since January 1, 1970) in milliseconds
+        at which the given key will expire.
+
+        For more information check https://redis.io/commands/pexpiretime
+        """
+        return self.execute_command("PEXPIRETIME", key)
+
     def psetex(
         self,
         name: KeyT,


Test patch:
diff --git a/tests/test_commands.py b/tests/test_commands.py
--- a/tests/test_commands.py
+++ b/tests/test_commands.py
@@ -1248,6 +1248,12 @@ def test_pexpireat_unixtime(self, r):
         assert r.pexpireat("a", expire_at_seconds) is True
         assert 0 < r.pttl("a") <= 61000
 
+    @skip_if_server_version_lt("7.0.0")
+    def test_pexpiretime(self, r):
+        r.set("a", "foo")
+        r.pexpireat("a", 33177117420000)
+        assert r.pexpiretime("a") == 33177117420000
+
     @skip_if_server_version_lt("2.6.0")
     def test_psetex(self, r):
         assert r.psetex("a", 1000, "value")
Repository: redis/redis-py (Python)

Issue:
Add support for missing command BITPOS - [BYTE|BIT] field



Hints:

Patch:
diff --git a/redis/commands/core.py b/redis/commands/core.py
--- a/redis/commands/core.py
+++ b/redis/commands/core.py
@@ -1363,6 +1363,7 @@ def bitcount(
         key: KeyT,
         start: Union[int, None] = None,
         end: Union[int, None] = None,
+        mode: Optional[str] = None,
     ) -> ResponseT:
         """
         Returns the count of set bits in the value of ``key``.  Optional
@@ -1376,6 +1377,8 @@ def bitcount(
             params.append(end)
         elif (start is not None and end is None) or (end is not None and start is None):
             raise DataError("Both start and end must be specified")
+        if mode is not None:
+            params.append(mode)
         return self.execute_command("BITCOUNT", *params)
 
     def bitfield(
@@ -1411,6 +1414,7 @@ def bitpos(
         bit: int,
         start: Union[int, None] = None,
         end: Union[int, None] = None,
+        mode: Optional[str] = None,
     ) -> ResponseT:
         """
         Return the position of the first bit set to 1 or 0 in a string.
@@ -1430,6 +1434,9 @@ def bitpos(
             params.append(end)
         elif start is None and end is not None:
             raise DataError("start argument is not set, " "when end is specified")
+
+        if mode is not None:
+            params.append(mode)
         return self.execute_command("BITPOS", *params)
 
     def copy(


Test patch:
diff --git a/tests/test_commands.py b/tests/test_commands.py
--- a/tests/test_commands.py
+++ b/tests/test_commands.py
@@ -854,6 +854,15 @@ def test_bitcount(self, r):
         assert r.bitcount("a", -2, -1) == 2
         assert r.bitcount("a", 1, 1) == 1
 
+    @skip_if_server_version_lt("7.0.0")
+    def test_bitcount_mode(self, r):
+        r.set("mykey", "foobar")
+        assert r.bitcount("mykey") == 26
+        assert r.bitcount("mykey", 1, 1, "byte") == 6
+        assert r.bitcount("mykey", 5, 30, "bit") == 17
+        with pytest.raises(redis.ResponseError):
+            assert r.bitcount("mykey", 5, 30, "but")
+
     @pytest.mark.onlynoncluster
     @skip_if_server_version_lt("2.6.0")
     def test_bitop_not_empty_string(self, r):
@@ -926,6 +935,15 @@ def test_bitpos_wrong_arguments(self, r):
         with pytest.raises(exceptions.RedisError):
             r.bitpos(key, 7) == 12
 
+    @skip_if_server_version_lt("7.0.0")
+    def test_bitpos_mode(self, r):
+        r.set("mykey", b"\x00\xff\xf0")
+        assert r.bitpos("mykey", 1, 0) == 8
+        assert r.bitpos("mykey", 1, 2, -1, "byte") == 16
+        assert r.bitpos("mykey", 0, 7, 15, "bit") == 7
+        with pytest.raises(redis.ResponseError):
+            r.bitpos("mykey", 1, 7, 15, "bite")
+
     @pytest.mark.onlynoncluster
     @skip_if_server_version_lt("6.2.0")
     def test_copy(self, r):