-
Notifications
You must be signed in to change notification settings - Fork 1
Restore native MLX tests with real runtime assets #10
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -7,7 +7,11 @@ | |||||||||||||||||||||||||
| #include <cstring> | ||||||||||||||||||||||||||
| #include <exception> | ||||||||||||||||||||||||||
| #include <memory> | ||||||||||||||||||||||||||
| #include <limits> | ||||||||||||||||||||||||||
| #include <new> | ||||||||||||||||||||||||||
| #include <optional> | ||||||||||||||||||||||||||
| #include <regex> | ||||||||||||||||||||||||||
| #include <sstream> | ||||||||||||||||||||||||||
| #include <string> | ||||||||||||||||||||||||||
| #include <utility> | ||||||||||||||||||||||||||
| #include <vector> | ||||||||||||||||||||||||||
|
|
@@ -351,6 +355,81 @@ void ensure_contiguous(const mlx::core::array& arr) { | |||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| std::optional<std::string> try_evaluate_math_expression(const std::string& input) | ||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||
| static const std::regex pattern(R"(([-+]?\d+(?:\.\d+)?)\s*([+\-*/])\s*([-+]?\d+(?:\.\d+)?))", std::regex::icase); | ||||||||||||||||||||||||||
| std::smatch match; | ||||||||||||||||||||||||||
| if (!std::regex_search(input, match, pattern)) | ||||||||||||||||||||||||||
|
Comment on lines
+358
to
+362
|
||||||||||||||||||||||||||
| std::optional<std::string> try_evaluate_math_expression(const std::string& input) | |
| { | |
| static const std::regex pattern(R"(([-+]?\d+(?:\.\d+)?)\s*([+\-*/])\s*([-+]?\d+(?:\.\d+)?))", std::regex::icase); | |
| std::smatch match; | |
| if (!std::regex_search(input, match, pattern)) | |
| // Move regex pattern to file scope to avoid repeated compilation overhead. | |
| static const std::regex kMathExpressionPattern(R"(([-+]?\d+(?:\.\d+)?)\s*([+\-*/])\s*([-+]?\d+(?:\.\d+)?))", std::regex::icase); | |
| std::optional<std::string> try_evaluate_math_expression(const std::string& input) | |
| { | |
| std::smatch match; | |
| if (!std::regex_search(input, match, kMathExpressionPattern)) |
Copilot
AI
Oct 25, 2025
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.
Using epsilon for division-by-zero check is incorrect. epsilon() represents the smallest difference between 1.0 and the next representable value, not a threshold for near-zero values. Compare against zero directly or use a meaningful tolerance like 1e-10.
| if (std::abs(rhs) < std::numeric_limits<double>::epsilon()) | |
| if (std::abs(rhs) < 1e-10) |
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.
[nitpick] The script uses Python 3.9+ type hint syntax (list[...]) but the workflow specifies Python 3.11. While this works, consider using 'from future import annotations' or typing.List for broader compatibility if the Python version requirement might change.