-
Notifications
You must be signed in to change notification settings - Fork 2
fixing typing as string issue #6
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
Conversation
@djarecka ah interesting, I put the ExtractROI into the |
Yes, I think there was an issue with |
While still a bit brittle maybe the regex could be TYPE_REPLACE = [
(r"(?<= )'(bool|str)'(?=,$)", r"\1"),
(r"(?<= )'(File|Multi.*put.*)'(?=,$)", r"specs.\1"),
] and then use |
Hi @tclose sorry for this late reply. @djarecka and I discussed the issue today, and we found out why
If we comment out those two lines, this line from nipype will be converted to
If we uncomment those two lines, it will be converted to
now Now I understand what you mean by using regex to specify the replacement. |
@djarecka I found out why the
which is like
But I can add it once we think this is the best solution. |
Yes, that was it. Seeing that example, the regex I suggested still wouldn't work, maybe this one would though TYPE_REPLACE = [
(r"(?<= )'(bool|str)'(?=,\n {)", r"\1"),
(r"(?<= )'(File|Multi.*put.*)'(?=,\n {)", r"specs.\1"),
] |
hi!! I fixed the typing problem with your regex logic, but I wrote something differently (I mean I asked chatgpt to write it).
we still failed the test but only |
That's good that it works but I don't get the point of the ChatGPT code, if you want your regex to only match the end of lines you can just use the $ symbol |
so the code does the replacement only when the strings are followed by a comma and a newline |
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #6 +/- ##
==========================================
+ Coverage 79.55% 80.92% +1.36%
==========================================
Files 4 4
Lines 362 367 +5
==========================================
+ Hits 288 297 +9
+ Misses 74 70 -4
☔ View full report in Codecov by Sentry. |
I just tested, adding Also I removed the test input here because we don't have any test data. |
But isn't float followed by comma and a newline in the ANTs registration case
|
I was thinking that including the following line up until the open brace '{' would differentiate between the two |
yes, in this case, we want to convert |
Yes, this is what I was thinking, maybe explicitly typing out the full indentation so it is guaranteed to be at the top level |
we probably don't want to use
|
It might be better to target the |
Or you could do a negative look-behind for
|
sorry, not very familiar with this. what do you mean by "target the a negative look-behind for |
Otherwise written as |
ah, make sense. okay, let's choose one. |
I'm thinking a better way to handle this would be to escape the types in a pair of "#", e.g. "#float#", which we can be confident of stripping out after the code is generated, rather than messing around with regexes |
ah! hello!! and sorry for not getting back to this issue earlier. I was
traveling and moving for the past few weeks. I'll work on it the coming
week!!
…On Thu, Jul 13, 2023 at 12:23 AM Tom Close ***@***.***> wrote:
I'm thinking a better way to handle this would be to escape the types in a
pair of "#", e.g. "#float#", which we can be confident of stripping out
after the code is generated, rather than messing around with regexes
—
Reply to this email directly, view it on GitHub
<#6 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AE3VE4AWPXRXIWULUFPE3NLXP5Z5VANCNFSM6AAAAAAYIBODSY>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
hello! (after another week...) okay, your idea inspired me, but I didn't add a pair of |
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.
Nice idea with the "TYPE_" prefix it is much more explicit. All looks good to me :)
Dorota and I tested the converter with
ExtractROI
fromfsl.utils
and found that typing in the input specs was a string, such as"File"
and"str"
.By uncommenting the following in the
write_task()
function, we get the correct typingCorrect typing
specs.File
andstr
as the following