Skip to content

Commit

Permalink
depend on cython~=3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jfolz committed Oct 22, 2024
1 parent c4ff8c3 commit 38d547f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Unreleased
### Added
- AffineCipher.invert method to obtain the inverse cipher
### Changed
- Depend on cython~=3.0


## [0.0.3] - 2024-10-14
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Issues = "https://github.com/jfolz/shufflish/issues"
Changelog = "https://github.com/jfolz/shufflish/blob/main/CHANGELOG.md"

[build-system]
requires = ["setuptools>=50.0.3", "wheel", "cython~=3.0.0", "setuptools_scm"]
requires = ["setuptools>=50.0.3", "wheel", "cython~=3.0", "setuptools_scm"]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]
Expand Down
20 changes: 10 additions & 10 deletions shufflish/_affine.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,16 @@ cdef class AffineCipher:
self.params.post_offset,
))

def __eq__(self, other):
if not isinstance(other, AffineCipher):
return False
cdef AffineCipher other_ = other
cdef affineCipherParameters oparams = other_.params
return self.params.domain == oparams.domain \
and self.params.prime == oparams.prime \
and self.params.pre_offset == oparams.pre_offset \
and self.params.post_offset == oparams.post_offset

def parameters(self):
"""
Returns the affine parameters as tuple
Expand All @@ -135,16 +145,6 @@ cdef class AffineCipher:
self.params.post_offset,
)

def __eq__(self, other):
if not isinstance(other, AffineCipher):
return False
cdef AffineCipher other_ = other
cdef affineCipherParameters oparams = other_.params
return self.params.domain == oparams.domain \
and self.params.prime == oparams.prime \
and self.params.pre_offset == oparams.pre_offset \
and self.params.post_offset == oparams.post_offset

def invert(self) -> AffineCipher:
"""
Returns the inverse of this affine cipher, i.e.,
Expand Down

0 comments on commit 38d547f

Please sign in to comment.