Describe the maintenance task
pyaptamer/trafos/base/_base.py has three issues that should be addressed together:
1. Abstract methods raise ValueError instead of NotImplementedError
_fit, _transform, and _transform_element are abstract methods that raise
ValueError when called directly. Python's convention — and the convention used
by skbase.BaseEstimator which BaseTransform inherits from — is to raise
NotImplementedError for unimplemented abstract methods.
# Current (wrong):
def _fit(self, X, y=None):
raise ValueError("abstract method _fit called, this should be implemented in the subclass")
# Should be:
def _fit(self, X, y=None):
raise NotImplementedError("abstract method _fit called, this should be implemented in the subclass")
Using ValueError is misleading because it suggests the error is caused by bad
input values rather than a missing implementation. It can also cause issues if any
upstream code has a bare except ValueError clause that would silently swallow it.
The same applies to _transform and _transform_element.
2. Missing __author__ tag
Every other module in pyaptamer has __author__ = [...]. This file has none.
3. Missing __all__ tag
Every other public module in pyaptamer has __all__ = [...]. This file has none.
Files affected
pyaptamer/trafos/base/_base.py
Fix
- Replace 3x
raise ValueError(...) → raise NotImplementedError(...) for the abstract methods
- Add
__author__ = ["nennomp", "fkiraly"] (consistent with _tags["authors"] in GreedyEncoder)
- Add
__all__ = ["BaseTransform"]
Describe the maintenance task
pyaptamer/trafos/base/_base.pyhas three issues that should be addressed together:1. Abstract methods raise
ValueErrorinstead ofNotImplementedError_fit,_transform, and_transform_elementare abstract methods that raiseValueErrorwhen called directly. Python's convention — and the convention usedby
skbase.BaseEstimatorwhichBaseTransforminherits from — is to raiseNotImplementedErrorfor unimplemented abstract methods.Using
ValueErroris misleading because it suggests the error is caused by badinput values rather than a missing implementation. It can also cause issues if any
upstream code has a bare
except ValueErrorclause that would silently swallow it.The same applies to
_transformand_transform_element.2. Missing
__author__tagEvery other module in
pyaptamerhas__author__ = [...]. This file has none.3. Missing
__all__tagEvery other public module in
pyaptamerhas__all__ = [...]. This file has none.Files affected
pyaptamer/trafos/base/_base.pyFix
raise ValueError(...)→raise NotImplementedError(...)for the abstract methods__author__ = ["nennomp", "fkiraly"](consistent with_tags["authors"]inGreedyEncoder)__all__ = ["BaseTransform"]