-
-
Notifications
You must be signed in to change notification settings - Fork 5
Conversation
despite Matlab not being strongly typed, i still think that separating e.g. float, int, str, function, struct, would be extremely helpful. I understand that "imposing" a type might be restrictive (where other types would also work), but it would provide a better understanding of what is expected, from a user standpoint. |
@jcohenadad for the example at hand, what about
|
great start. i would still like to find a way to explicit when it's an array or a scalar (i see how confusing this could cause undesired bugs down the line). suggestions:
i'm not in love with any of my suggestions above though... so any feedback welcome EDIT: one advantage of encoding this information (about the scalar vs. n-dim array) is that at some point, we will be able to test it |
We could just copy (or copy an edited form) of the
^ which indicates no more than 3-dims for
|
this: shimming-toolbox/shimming-toolbox#145 (comment) (or a variant) is definitely something we should do. I would suggest the "type" indications to be more user-friendly though. e.g.:
p.s. this discussion is a good illustration of the need for such information, because i originally thought that "orders" was a single scalar (not a vector) indicating maximum order, and "X" also a scalar 😬 p.p.s not a big fan of "{}" because it takes longer to write, but i see the need in the example above, to prevent confusion with (:, :, ...) |
It's not exactly the most readable thing however, just copying lines from the arguments block has the advantage of being
Note that actual format isn't quite that of the above comments: There are some annoying things about the order MATLAB deals with these things though: Notably, MATLAB uses the type-assignment first to convert arguments (when possible)—e.g. in the example above, if you input |
omg, are you kidding me?? well... regardless of this behaviour, i think we should still continue using the "type" feature of the argument (since, as you said, this is standard). Should we consider checking for the type before entering the argument block? That would make the code heavy and difficult to maintain though, so probably not a good idea. |
Ahh sorry, i overwrote your comment!
(i know... seems absurd)
Matlab won't let you do anything before the arguments block—but, you can just incorporate type-checking into the validation functions—ie. why I wrote this |
The variable type cast is standard in most of modern programmation language to do checksums or other verification with compiled programming languages. |
It's sure it's not the most pleasing to the eye, but it's true that it is standard and you can try make it more beautiful: with this methodology, it is easily parsed with the @ symbols and names. It's another suggestion if not having the same syntax as the argument block is not a problem. But the one in this PR is also quite clear and easy to read. |
very interesting, i was not aware of Matlab's Class and Size Conversions. I understand better the purpose (and need for) validation function. So, moving forward, it is pretty clear to me that we do need those validation functions in the argument block. Everyone agree with this? Now, when it comes to header documentation, what should we do? Copy/pasting the argument block inside the header sounds horrible (inevitably, some inconsistencies will be introduced). I can think of:
|
i don't have any particular preference for format/style, but i do think arguments blocks + function validation should be used pretty much invariably (doc. considerations aside, the validation stage is instructive for users when clear error messages are given, and i think it will make testing/debugging multi-step processing pipelines a lot easier)
alternatively, we could alter doc header within the actual .m file, i.e.
|
but this would be done by azure (ie after we push), therefore would be pushed in a subsequent commit, right? |
could be. Or, whoever is writing the code could just call this |
i'm not in favor of this manual intervention on the developer side |
I don't really know this for github, but for Atlassian BitBucket, you can add a verification script on commits and pushes (for wichever branch you want). Is it possible on github? |
i think we should stop the discussion about docstrings/doc/testing on this repository, and save those discussions for shimming-toolbox-py. |
This PR establishes conventions for headers of .m files in this project.
Initially, the strategy was to modify genToolboxHelp to modify each .m file to match the formatting needs for Matlab's documentation browser. However, after giving it some thoughts, a better strategy consists in modifying the excellent helpDocMd to accommodate different formatting outputs.
Fixes #133
Related to shimming-toolbox/helpDocMd#5