CellProfiler icon indicating copy to clipboard operation
CellProfiler copied to clipboard

Finalize grammar for library functions/modules

Open bethac07 opened this issue 2 years ago • 2 comments

We have quite a bit of mixed thisfunction and this_function, let's decide on one (or at least consistently where we used one vs the other) and then go through and clean up.

bethac07 avatar Mar 04 '23 01:03 bethac07

I think the module level functions should be named in the style of CellProfiler GUI, but without the capitalization of words to avoid confusion with python classes. As for the individual functions (ie. functions that are found within modules, like shrink_to_point), I think they should be named with standard python conventions: lowercase word or words separated by underscores.

callum-jpg avatar Mar 21 '23 13:03 callum-jpg

To add to this, how do we want to pass certain method options to library that contain spaces? For example, threshold has a method called "Minimum Cross-Entropy", should this be converted to minimum_cross_entropy or minimumcrossentropy? Currently, the former is what happens and I added this helper function to threshold (shown below), but it'd be much better living somewhere accessible for all modules since I'm running into the same space-removal problem in other modules. So, it would be great to standardize this grammar too.

    def convert_setting(self, gui_setting_str):
        """
        Convert GUI setting strings to something cellprofiler
        library compatible. That is, remove spaces and hyphens.
        """
        rep_list = ((" ", "_"), ("-", "_"))
        converted_str = gui_setting_str
        for replacement in rep_list:
            converted_str = converted_str.replace(*replacement)
        return converted_str

callum-jpg avatar Mar 24 '23 18:03 callum-jpg