-
Notifications
You must be signed in to change notification settings - Fork 1
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
update assign_units
and add kcal_per_h
#89
Conversation
Reviewer's Guide by SourceryThis pull request enhances the Sequence diagram for enhanced assign_units decorator flowsequenceDiagram
participant C as Client Code
participant A as assign_units
participant R as _remove_unit
C->>A: Call with function and units
A->>A: Parse function arguments
loop For each argument
alt Argument has unit specification
A->>R: Remove/convert units
R-->>A: Return processed value
end
end
A->>A: Execute original function
alt Result units specified
A->>A: Validate result structure
A->>A: Assign result units
end
A-->>C: Return result
Class diagram for new unit assignment typesclassDiagram
class CallableAssignUnit {
+without_result_units: Callable
+__call__(*args, **kwargs)
}
class Missing {
}
class Callable
CallableAssignUnit --|> Callable
note for CallableAssignUnit "New class for handling
callable units"
note for Missing "Represents missing
values in assignments"
Class diagram for unit constants updateclassDiagram
class UnitConstants {
+watt: Unit
+horsepower: Unit
+kcal_per_h: Unit
}
note for UnitConstants "Added kcal_per_h
with conversion factor
1.162222 watts"
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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 @chaoming0625 - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 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.
This pull request includes several changes to the
brainunit
library, focusing on improvements to type handling, unit assignment, and documentation corrections.Type Handling and Unit Assignment Improvements:
brainunit/_base.py
: Addedcast
import for type casting and introducedCallableAssignUnit
andMissing
classes to improve the handling of callable units and missing values. Enhanced theassign_units
decorator to support partial assignments and improved error messages for type mismatches. [1] [2] [3] [4]New Unit Constants:
brainunit/_unit_constants.py
: Added a new unit constantkcal_per_h
for kilocalories per hour. [1] [2]Documentation Corrections:
docs/index.rst
: Corrected a typo in the filename fromelinstein_operations.ipynb
toeinstein_operations.ipynb
.docs/mathematical_functions/einstein_operations.ipynb
: Updated the title and links within the notebook to reflect the correct spelling of "Einstein".Summary by Sourcery
Improve the
assign_units
decorator to support partial unit assignments and add a new unit constant for kilocalories per hour (kcal_per_h
). Also fix a typo in the documentation.New Features:
kcal_per_h
unit constant.Tests:
assign_units
decorator.