Create BitVectorProtocol#67
Conversation
Creates a new file `BitVector/protocol.py` that defines a `BitVectorProtocol` class using `typing.Protocol`. The protocol contains the core operations of a BitVector, omitting domain-specific methods (such as GF(2^n) math, primality testing, and cryptography functions). The protocol is exported in `BitVector/__init__.py`.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
Creates a new file `BitVector/protocol.py` that defines a `BitVectorProtocol` class using `typing.Protocol`. The protocol contains the core operations of a BitVector, omitting domain-specific methods (such as GF(2^n) math, primality testing, and cryptography functions). The protocol is exported in `BitVector/__init__.py`.
|
|
||
| class BitVectorProtocol(Protocol): | ||
| size: int | ||
| FILEIN: BinaryIO | None |
There was a problem hiding this comment.
Remove and remove the file io calls from the protocol
There was a problem hiding this comment.
I have removed the file I/O calls (FILEIN, FILEOUT, filename, more_to_read) as requested.
| class BitVectorProtocol(Protocol): | ||
| size: int | ||
| FILEIN: BinaryIO | None | ||
| FILEOUT: BinaryIO | None |
There was a problem hiding this comment.
Removed.
| filename: str | None | ||
| more_to_read: bool | ||
|
|
||
| def __init__( |
There was a problem hiding this comment.
Can the protocol leave out the init?
There was a problem hiding this comment.
Yes, I have removed __init__ from the protocol.
| def __add__(self, other: Self) -> Self: ... | ||
| def __iadd__(self, other: Self) -> Self: ... | ||
| def _getsize(self) -> int: ... | ||
| def read_bits_from_file(self, blocksize: int) -> Self: ... |
There was a problem hiding this comment.
Removed.
| def __contains__(self, otherBitVec: Self) -> bool: ... | ||
| def reset(self, val: int | Any) -> Self: ... | ||
| def count_bits(self) -> int: ... | ||
| def set_value( |
There was a problem hiding this comment.
Removed.
| def __iadd__(self, other: Self) -> Self: ... | ||
| def _getsize(self) -> int: ... | ||
| def read_bits_from_file(self, blocksize: int) -> Self: ... | ||
| def read_bits_from_fileobject(self, fp: Any) -> Any: ... |
There was a problem hiding this comment.
Removed.
| def _getsize(self) -> int: ... | ||
| def read_bits_from_file(self, blocksize: int) -> Self: ... | ||
| def read_bits_from_fileobject(self, fp: Any) -> Any: ... | ||
| def write_bits_to_stream_object(self, fp: Any) -> None: ... |
There was a problem hiding this comment.
Removed.
| def divide_into_two(self) -> list[Self]: ... | ||
| def permute(self, permute_list: Sequence[int] | Any) -> Self: ... | ||
| def unpermute(self, permute_list: Sequence[int] | Any) -> Self: ... | ||
| def write_to_file(self, file_out: BinaryIO | Any) -> None: ... |
There was a problem hiding this comment.
Removed.
Removes the `__init__` and all file I/O operations (e.g. `read_bits_from_file`, `write_to_file`) from `BitVectorProtocol` as per PR review comments.
|
|
||
| class BitVectorProtocol(Protocol): | ||
| size: int | ||
| filename: str | None |
There was a problem hiding this comment.
Removed.
| class BitVectorProtocol(Protocol): | ||
| size: int | ||
| filename: str | None | ||
| more_to_read: bool |
There was a problem hiding this comment.
Removed.
| def __le__(self, other: object) -> bool: ... | ||
| def __gt__(self, other: object) -> bool: ... | ||
| def __ge__(self, other: object) -> bool: ... | ||
| def __deepcopy__(self, memo: dict[int, Any] | None = None) -> Self: ... |
There was a problem hiding this comment.
Remove deepcopy from the protocol.
There was a problem hiding this comment.
Removed.
There was a problem hiding this comment.
Removed.
| def unpermute(self, permute_list: Sequence[int] | Any) -> Self: ... | ||
| def int_val(self) -> int: ... | ||
| def get_bitvector_in_ascii(self) -> str: ... | ||
| def get_bitvector_in_hex(self) -> str: ... |
There was a problem hiding this comment.
Removed.
| def __iadd__(self, other: Self) -> Self: ... | ||
| def _getsize(self) -> int: ... | ||
| def divide_into_two(self) -> list[Self]: ... | ||
| def permute(self, permute_list: Sequence[int] | Any) -> Self: ... |
There was a problem hiding this comment.
Removed.
| def is_power_of_2(self) -> bool: ... | ||
| def is_power_of_2_sparse(self) -> bool: ... | ||
| def reverse(self) -> Self: ... | ||
| def length(self) -> int: ... |
There was a problem hiding this comment.
Removed.
| def reverse(self) -> Self: ... | ||
| def length(self) -> int: ... | ||
| def runs(self) -> list[str]: ... | ||
| def gen_random_bits(self, width: int) -> Self: ... |
There was a problem hiding this comment.
Removed.
| def length(self) -> int: ... | ||
| def runs(self) -> list[str]: ... | ||
| def gen_random_bits(self, width: int) -> Self: ... | ||
| def min_canonical(self) -> Self: ... |
There was a problem hiding this comment.
Removed.
| def rank_of_bit_set_at_index(self, position: int) -> int: ... | ||
| def is_power_of_2(self) -> bool: ... | ||
| def is_power_of_2_sparse(self) -> bool: ... | ||
| def reverse(self) -> Self: ... |
There was a problem hiding this comment.
Removed.
| def __gt__(self, other: object) -> bool: ... | ||
| def __ge__(self, other: object) -> bool: ... | ||
| def __deepcopy__(self, memo: dict[int, Any] | None = None) -> Self: ... | ||
| def _resize_pad_from_left(self, n: int) -> Self: ... |
There was a problem hiding this comment.
Removed.
This adds tests in `tests/test_protocol.py` that imports `BitVectorProtocol` and verifies properties like `int_val()`. It also properly sets `\\.\\.\\.` to be ignored from pytest coverage in `pyproject.toml` so our coverage reaches 100% and tests pass.
Fixes pre-commit lint issues like trailing spaces. Applies ruff format.
Removes the requested methods from the BitVectorProtocol as per PR comments. The protocol now only includes basic types, magic methods (`__and__`, `__len__`, etc), and a few public basic properties like `length` and `count_bits`.
This commit removes all the specified methods (e.g. `_setbit`, `_getbit`, `divide_into_two`, `permute`, `unpermute`, `get_bitvector_in_ascii`, `get_bitvector_in_hex`, `circular_rotate_left_by_one`, `shift_left_by_one`, `__deepcopy__`, `pad_from_left`, `pad_from_right`, `set_value`, `runs`, etc) from the `BitVectorProtocol` according to pull request review comments.
Removed `length()` from the protocol as requested by PR comments.
Creates a new
BitVectorProtocolclass inBitVector/protocol.pywhich specifies the structural type for aBitVectorimplementation without any domain specific methods. Exports it inBitVector/__init__.py. Fixes #66.PR created automatically by Jules for task 730924944874791392 started by @schwehr