-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce USet and UInterval classes with withrepr decorator #59
base: main
Are you sure you want to change the base?
Conversation
Reviewer's Guide by SourceryThis PR introduces a new USet class for handling mathematical sets and adds a withrepr decorator for improved function representation. The implementation includes refactoring of the math_op.py module to improve code organization and readability through the introduction of helper functions. Class diagram for the new USet class and withrepr decoratorclassDiagram
class USet {
+USet(*values: T, iterable: Optional<Iterable<T>> = None, auto_update_U: bool = True)
+set: set<T>
+__repr__() str
+__iter__() Iterator<T>
+_or(other: Iterable<OT> | OT) USet<T | OT>
+__or__(other: Iterable<OT> | OT) USet<T | OT>
+__add__(other: Iterable<OT> | OT) USet<T | OT>
+sub(other: Iterable<OT> | OT) USet<T>
+__sub__(other: Iterable<OT> | OT) USet<T>
+__rsub__(other: Iterable<OT> | OT) USet<T>
+__truediv__(other: Iterable<OT> | OT) USet<T>
+_and(other: Iterable<OT> | OT) USet
+__and__(other: Iterable<OT> | OT) USet
+__mul__(other: Iterable<OT> | OT) USet
+_not(s: Optional<USet<OT>> = None) USet<OT>
+__neg__() USet
+implicate(other: Iterable<OT> | OT) USet
+__gt__(other: Iterable<OT> | OT) USet
+__ge__(other: Iterable<OT> | OT) USet
+__lt__(other: Iterable<OT> | OT) USet
+__le__(other: Iterable<OT> | OT) USet
}
class _U {
+_U(*values: T)
}
class __reprwrapper {
+__init__(repr, func)
+__call__(*args, **kw)
+__repr__()
}
class withrepr {
+withrepr(f: Callable[[T], str])
}
USet <|-- _U
withrepr o-- __reprwrapper
File-Level Changes
Assessment against linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
@sourcery-ai review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @bleudev - I've reviewed your changes - here's some feedback:
Overall Comments:
- Using os.environ for storing the universal set U state is problematic - it's not thread-safe and could cause issues in concurrent environments. Consider using a proper singleton pattern or class-level storage instead.
- The USet class is mixing set operations with global U state management. Consider separating these responsibilities into different classes for better maintainability.
Here's what I looked at during the review
- 🟡 General issues: 4 issues found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
ufpy/algebra/sets.py
Outdated
if iterable else | ||
USet(*values, auto_update_U=False))) | ||
|
||
def _convert_type(s: str): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (bug_risk): Type conversion logic is fragile and could lead to incorrect interpretations
The current string-based type guessing could lead to ambiguous or incorrect conversions. Consider implementing a more robust type conversion system with explicit type information.
Sorry, but this is Useful Set, not Universal :) |
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
@sourcery-ai review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @bleudev - I've reviewed your changes - here's some feedback:
Overall Comments:
- Consider adding tests before merging - mathematical set operations need thorough testing to ensure correctness, especially for edge cases.
- Please document the behavior and performance implications of auto_update_U, particularly its effect on the universal set U.
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟡 Complexity: 2 issues found
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
@sourcery-ai summary |
I'm sorry, I don't understand the command Please use |
@sourcery-ai summary |
I'm sorry, I don't understand the command Please use |
Description
(optional)
Added:
utils.withrepr()
decoratorTO-DO list
(optional)
Issue you want to close
(optional)
closes #58
Summary by Sourcery
Introduce the USet class for mathematical set operations and add a withrepr decorator for improved function representation.
New Features:
Enhancements: