-
Notifications
You must be signed in to change notification settings - Fork 4
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
Add plain text input param and calc length estimate improvement #30
Conversation
Improve calculation length estimate for negative constants Update docs and add new release version
Reviewer's Guide by SourceryThis pull request implements two main features: adds a plain text display option for select input fields and improves the calculation length estimation for negative constants. The changes also include documentation updates and a version bump from 1.2.4 to 1.2.6. Updated class diagram for the Input classclassDiagram
class Input {
- str variable_name
- int|float|str default_value = 0
- str unit = None
- str description = None
- str reference = None
- Literal['number', 'text', 'select'] input_type = 'number'
- list select_options = None
- int|float min_value = None
- int|float max_value = None
- int|float|str num_step = 'any'
- bool plain_text_value = False
}
Updated class diagram for the Calculation classclassDiagram
class Calculation {
+ _get_symbolic_string() str
+ _get_result_string() str
+ estimate_display_length() CalculationLength
}
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 @youandvern - 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: 1 issue found
- 🟢 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.
def test_input_plain_text(common_setup_teardown): | ||
a = Input("calc", "No & no", plain_text_value=True) | ||
result = generate_html_for_calc_items([a]) | ||
assert a.name in result | ||
assert r"\text{No & no}" in result |
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.
suggestion (testing): Test for plain text input should verify HTML escaping more thoroughly
Consider adding more test cases with different special characters that need HTML escaping (e.g. <, >, ", etc) to ensure the plain text input handles all HTML special characters correctly.
def test_input_plain_text(common_setup_teardown):
test_cases = [
("No & no", r"\text{No & no}"),
("a < b > c", r"\text{a < b > c}"),
('Text "quoted"', r'\text{Text "quoted"}'),
]
for input_text, expected in test_cases:
a = Input("calc", input_text, plain_text_value=True)
result = generate_html_for_calc_items([a])
assert a.name in result
assert expected in result
if self._get_display_type() != InputDisplayType.NUMBER: | ||
return rf"\mathrm{{{self.name}}} = \mathrm{{{self.value}}} \ {self.unit}" | ||
text_value = ( | ||
rf"\text{{{self.value}}}" if self.plain_text_value else self.value | ||
) | ||
return rf"\mathrm{{{self.name}}} = \mathrm{{{text_value}}} \ {self.unit}" | ||
else: | ||
return super().__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 (code-quality): We've found these issues:
- Swap if/else branches (
swap-if-else-branches
) - Remove unnecessary else after guard condition (
remove-unnecessary-else
)
Add plain text option for select input fields
Improve calculation length estimate for negative constants
Update docs and add new release version
Summary by Sourcery
Introduce a plain text option for input fields and enhance the calculation length estimation for negative constants. Update the documentation to version 1.2.6 and add tests for the new features.
New Features:
Enhancements:
Documentation:
Tests: