Skip to content

MAINT: Remove deprecated mode#420

Merged
bashtage merged 2 commits intomainfrom
remove-deprecated-mode
Oct 22, 2025
Merged

MAINT: Remove deprecated mode#420
bashtage merged 2 commits intomainfrom
remove-deprecated-mode

Conversation

@bashtage
Copy link
Copy Markdown
Owner

Remove mode which has been deprecated singe 2.0

Remove mode which has been deprecated singe 2.0
@bashtage bashtage force-pushed the remove-deprecated-mode branch from a71048b to 9aa33dd Compare October 22, 2025 15:23
def setup_bitgenerator(self, seed, mode=None):
kwargs = {} if mode is None else {"mode": mode}
return self.bit_generator(*seed, **kwargs)
def setup_bitgenerator(self, seed):

Check notice

Code scanning / CodeQL

Mismatch between signature and use of an overridden method Note test

Overridden method signature does not match
call
, where it is passed too many arguments. Overriding method
method TestPCG64XSLRR.setup_bitgenerator
matches the call.
Overridden method signature does not match
call
, where it is passed too many arguments. Overriding method
method TestPCG64XSLRR.setup_bitgenerator
matches the call.
Overridden method signature does not match
call
, where it is passed too many arguments. Overriding method
method TestPCG64XSLRR.setup_bitgenerator
matches the call.
Overridden method signature does not match
call
, where it is passed too many arguments. Overriding method
method TestPCG64XSLRR.setup_bitgenerator
matches the call.
Overridden method signature does not match
call
, where it is passed too many arguments. Overriding method
method TestPCG64XSLRR.setup_bitgenerator
matches the call.
Overridden method signature does not match
call
, where it is passed too many arguments. Overriding method
method TestPCG64DXSM.setup_bitgenerator
matches the call.
Overridden method signature does not match
call
, where it is passed too many arguments. Overriding method
method TestSquares.setup_bitgenerator
matches the call.
Overridden method signature does not match
call
, where it is passed an argument named 'inc'. Overriding method
method TestPCG64XSLRR.setup_bitgenerator
matches the call.
Overridden method signature does not match
call
, where it is passed an argument named 'inc'. Overriding method
method TestPCG64XSLRR.setup_bitgenerator
matches the call.
Overridden method signature does not match
call
, where it is passed an argument named 'inc'. Overriding method
method TestPCG64XSLRR.setup_bitgenerator
matches the call.
Overridden method signature does not match
call
, where it is passed an argument named 'inc'. Overriding method
method TestPCG64XSLRR.setup_bitgenerator
matches the call.
Overridden method signature does not match
call
, where it is passed an argument named 'inc'. Overriding method
method TestPCG64XSLRR.setup_bitgenerator
matches the call.
Overridden method signature does not match
call
, where it is passed an argument named 'inc'. Overriding method
method TestPCG64DXSM.setup_bitgenerator
matches the call.
Overridden method signature does not match
call
, where it is passed an argument named 'counter'. Overriding method
method TestSquares.setup_bitgenerator
matches the call.

Copilot Autofix

AI 6 months ago

To fix this issue, the method signature of the base class (or parent test class) setup_bitgenerator must be updated to be compatible with its usage and the subclass override. The best change is to modify the base class signature (at line 222) from accepting only seed to also accept an optional inc argument defaulting to None: def setup_bitgenerator(self, seed, inc: int | None = None):. This matches the overriding subclass method and fixes the call sites where inc is passed. For backward compatibility, in the body of the base method, if inc is not used, it simply passes it (as default) to the bit generator constructor, so there should be no unintended side effects.


Suggested changeset 1
randomgen/tests/test_direct.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/randomgen/tests/test_direct.py b/randomgen/tests/test_direct.py
--- a/randomgen/tests/test_direct.py
+++ b/randomgen/tests/test_direct.py
@@ -219,8 +219,8 @@
             data = [int(line.split(",")[-1].strip(), 0) for line in csv]
             return {"seed": seed, "data": np.array(data, dtype=cls.dtype)}
 
-    def setup_bitgenerator(self, seed):
-        return self.bit_generator(*seed)
+    def setup_bitgenerator(self, seed, inc: int | None = None):
+        return self.bit_generator(*seed) if inc is None else self.bit_generator(*seed, inc=inc)
 
     def test_default(self):
         bg = self.setup_bitgenerator([None])
EOF
@@ -219,8 +219,8 @@
data = [int(line.split(",")[-1].strip(), 0) for line in csv]
return {"seed": seed, "data": np.array(data, dtype=cls.dtype)}

def setup_bitgenerator(self, seed):
return self.bit_generator(*seed)
def setup_bitgenerator(self, seed, inc: int | None = None):
return self.bit_generator(*seed) if inc is None else self.bit_generator(*seed, inc=inc)

def test_default(self):
bg = self.setup_bitgenerator([None])
Copilot is powered by AI and may make mistakes. Always verify output.
cls.large_advance_final = 326675794918500479020985263602132957772

def setup_bitgenerator(self, seed, mode=None, inc=0):
def setup_bitgenerator(self, seed, inc=0):

Check notice

Code scanning / CodeQL

Mismatch between signature and use of an overridden method Note test

Overridden method signature does not match
call
, where it is passed an argument named 'counter'. Overriding method
method TestSquares.setup_bitgenerator
matches the call.

Copilot Autofix

AI 6 months ago

The ideal solution is to update the parent class's method definition for setup_bitgenerator (at line 1915 in TestPCG64DXSM) so that its signature matches that of the overridden method in TestSquares. This involves adding counter=None and key=None arguments (with default values for backwards compatibility), and adjusting the implementation so that these are properly forwarded to self.bit_generator. We avoid changing existing functionality by retaining inc=0 (since the parent class expects it). Any calls to self.setup_bitgenerator in the parent class or subclasses will then consistently accept seed, inc, counter, and key as keyword arguments, preventing TypeErrors and maintaining Liskov substitutability.

To implement:

  • Change the definition at line 1915 in TestPCG64DXSM to:
    def setup_bitgenerator(self, seed, inc=0, counter=None, key=None):
  • Pass counter and key as keyword arguments to self.bit_generator in the return statement, only if they are not None so that existing usages are not broken.

No further changes are needed to the child class or calls. All changes are in randomgen/tests/test_direct.py.

Suggested changeset 1
randomgen/tests/test_direct.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/randomgen/tests/test_direct.py b/randomgen/tests/test_direct.py
--- a/randomgen/tests/test_direct.py
+++ b/randomgen/tests/test_direct.py
@@ -1912,8 +1912,13 @@
         cls.large_advance_initial = 262626489767919729675955844831248137855
         cls.large_advance_final = 326675794918500479020985263602132957772
 
-    def setup_bitgenerator(self, seed, inc=0):
-        return self.bit_generator(*seed, inc=inc)
+    def setup_bitgenerator(self, seed, inc=0, counter=None, key=None):
+        kwargs = {}
+        if counter is not None:
+            kwargs['counter'] = counter
+        if key is not None:
+            kwargs['key'] = key
+        return self.bit_generator(*seed, inc=inc, **kwargs)
 
     def test_large_advance(self):
         bg = self.setup_bitgenerator([0], inc=1)
EOF
@@ -1912,8 +1912,13 @@
cls.large_advance_initial = 262626489767919729675955844831248137855
cls.large_advance_final = 326675794918500479020985263602132957772

def setup_bitgenerator(self, seed, inc=0):
return self.bit_generator(*seed, inc=inc)
def setup_bitgenerator(self, seed, inc=0, counter=None, key=None):
kwargs = {}
if counter is not None:
kwargs['counter'] = counter
if key is not None:
kwargs['key'] = key
return self.bit_generator(*seed, inc=inc, **kwargs)

def test_large_advance(self):
bg = self.setup_bitgenerator([0], inc=1)
Copilot is powered by AI and may make mistakes. Always verify output.
@codecov
Copy link
Copy Markdown

codecov Bot commented Oct 22, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.41%. Comparing base (47c7f49) to head (af3f647).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #420      +/-   ##
==========================================
- Coverage   95.50%   95.41%   -0.09%     
==========================================
  Files          57       56       -1     
  Lines        8835     8750      -85     
  Branches      177      175       -2     
==========================================
- Hits         8438     8349      -89     
- Misses        382      387       +5     
+ Partials       15       14       -1     
Flag Coverage Δ
adder 95.29% <100.00%> (-0.10%) ⬇️
subtractor 95.29% <100.00%> (-0.10%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bashtage bashtage merged commit 6d99306 into main Oct 22, 2025
31 of 32 checks passed
@bashtage bashtage deleted the remove-deprecated-mode branch October 22, 2025 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants