Skip to content
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

[RFC] style guide and performance guide #214

Draft
wants to merge 1 commit into
base: source
Choose a base branch
from
Draft

Conversation

johnnychen94
Copy link
Member

@johnnychen94 johnnychen94 commented Aug 3, 2021

We need a style guide and performance guide for so long. This PR is currently a very very early draft and is far away from complete. It's not even readable but I figure I should open a PR to get some discussions and ideas.

This PR is expected to be a long run so I won't rush to merge it. I'll instead add and tweak the words when I have more ideas. Also feel free to directly modify this branch.

Some of the contents come from my maintenance experiences, and some come from other related issues:

@johnnychen94 johnnychen94 changed the title [RFC] style guide [RFC] style guide and performance guide Aug 3, 2021
Copy link
Member

@timholy timholy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love it! Thanks so much.

are some justified reasons, it is a bad practice to write codes like `img .= img ./ 255` or
`im2double(img)` variants.

## Consistant usage of 0-1 range
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## Consistant usage of 0-1 range
## Consistent usage of 0-1 range


## Consistant usage of 0-1 range

The rule of thumb in JuliaImages is that we consistantly treat all colors in a 0-1 range
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've noticed one exception: in ImageView, grayscale 16-bit images still generally have to dynamically scale the contrast. It's a bit frusturating but I don't know of a good workaround.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, the only color types that can be considered normalized in the range [0,1] are AbstractRGB and AbstractGray. Considering other color types such as HSV and Lab, this sentence is somewhat misleading.

macros. Don't overuse macros only for convenient purposes.

Specifically, MacroTools.jl and other macro packages that aims to provide extended syntaxes are
delibrately not used; they are powerful but it makes the code a lot harder to understand.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✔️

Comment on lines +41 to +42
various array types (e.g., `Array`, `OffsetArray`). There are more array types than you could have
know. To make the codes more reliable and usable, it is recommended to code in a generic way.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
various array types (e.g., `Array`, `OffsetArray`). There are more array types than you could have
know. To make the codes more reliable and usable, it is recommended to code in a generic way.
various array types (e.g., `Array`, `OffsetArray`). There are more array types than you can anticipate.
To make the codes more reliable and usable, it is recommended to code in a generic way.

Comment on lines +74 to +75
codes are written generally. With that check list passed, it's highly likely that your code works
seamless with the JuliaImages ecosystem.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
codes are written generally. With that check list passed, it's highly likely that your code works
seamless with the JuliaImages ecosystem.
codes are written generally. With that check list passed, it's quite likely that your code will work
seamlessly with the JuliaImages ecosystem.

## Keep small dependency

Images.jl is an out-of-box solution for users of JuliaImages ecosystem. However, if you're
developing image processing packages, you should instead depends on the more lightweight
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
developing image processing packages, you should instead depends on the more lightweight
developing image processing packages, you should instead depend on the more lightweight

Comment on lines +85 to +86
Various functions have their own limitations, so by no means your function should pass all the
checklist.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Various functions have their own limitations, so by no means your function should pass all the
checklist.
We recommend several specific kinds of tests, although not all will be applicable in all cases:

- axes agnostic check: `Array` and `OffsetArray`(e.g., `OffsetArray.centered(img)`) are good test
candidates.
- dimension agnostic check: make sure your function accepts `Vector`, `Matrix` and `Array{T, 3}`
inputs. For some function, 0-dimensional array (e.g., `x=zeros(); x[]=1.0`) is also worth testing.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
inputs. For some function, 0-dimensional array (e.g., `x=zeros(); x[]=1.0`) is also worth testing.
inputs. For some functions, 0-dimensional array (e.g., `x=zeros(); x[]=1.0`) is also worth testing.


## API specification

Because there are various algorithms to do one single task, we recommend the verb+noun+how API most
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Because there are various algorithms to do one single task, we recommend the verb+noun+how API most
Because there are various algorithms to do one single task, we recommend the verb+noun+how API for most


## If possible, implement the in-place version

Many image processing algorithms admits a filter property: that it accepts an image (or series of
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Many image processing algorithms admits a filter property: that it accepts an image (or series of
Many image processing algorithms admit a filter property: that it accepts an image (or series of

@johnnychen94 johnnychen94 added the best practice workflows and best practice that are useful in JuliaImages and/or Julia label Aug 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
best practice workflows and best practice that are useful in JuliaImages and/or Julia
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants