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

Eliminate extra docstrings for FunctionField #3678

Merged
merged 3 commits into from
Aug 6, 2024

Conversation

glwagner
Copy link
Member

@glwagner glwagner commented Aug 5, 2024

Because the extra docstrings cause confusion, here we want to recommend just one way of building FunctionField. See #2515

Copy link

@loganpknudsen loganpknudsen left a comment

Choose a reason for hiding this comment

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

I think this will help with clarity when trying to use this function!

@navidcy
Copy link
Collaborator

navidcy commented Aug 5, 2024

I don't see where the confusion comes when there are docstrings for each method. Could you elaborate?

@glwagner
Copy link
Member Author

glwagner commented Aug 5, 2024

Here's the docstring before this PR

help?> Oceananigans.Fields.FunctionField
  FunctionField{LX, LY, LZ}(func, grid; clock=nothing, parameters=nothing) where {LX, LY, LZ}

  Returns a FunctionField on grid and at location LX, LY, LZ.

  If clock is not specified, then func must be a function with signature func(x, y, z). If clock is specified, func must be a
  function with signature func(x, y, z, t), where t is internally determined from clock.time.

  A FunctionField will return the result of func(x, y, z [, t]) at LX, LY, LZ on grid when indexed at i, j, k.

  ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

  FunctionField{LX, LY, LZ}(func::FunctionField, grid; clock) where {LX, LY, LZ}

  Adds clock to an existing FunctionField and relocates it to (LX, LY, LZ) on grid.

  ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

  FunctionField(L::Tuple, func, grid)

  Returns a stationary FunctionField on grid and at location L = (LX, LY, LZ), where func is callable with signature func(x, y, z).

Three docstrings come up. But we only want users to use one of them. Moreover the second one is actually redundant with the first and provides no new information. The last one is supposed to be for internal use only. But as a user who is new to julia (perhaps), you may see only the last docstring. This is what happened over on the discussion linked at the top.

@navidcy
Copy link
Collaborator

navidcy commented Aug 5, 2024

OK fair. The statement wasn't generic -- it was only for this case :)

Is there a value to convert the docstrings for the methods we don't intend to be for users to comments so that developers know what the intention was there?

Copy link
Collaborator

@navidcy navidcy left a comment

Choose a reason for hiding this comment

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

Perhaps for the methods we don't intend to be for users we can consider converting the docstrings to comments so that developers know what the intention was?

I'll leave that up to you. LGTM!

@glwagner
Copy link
Member Author

glwagner commented Aug 5, 2024

OK fair. The statement wasn't generic -- it was only for this case :)

Is there a value to convert the docstrings for the methods we don't intend to be for users to comments so that developers know what the intention was there?

That's what I did for one of them. For the other one the second function is not actually different from the first so I don't think there's much value.

@navidcy
Copy link
Collaborator

navidcy commented Aug 5, 2024

I had missed that green line addition for the comment! Nice!

@glwagner
Copy link
Member Author

glwagner commented Aug 5, 2024

OK fair. The statement wasn't generic -- it was only for this case :)

Right and we should note this is also an issue for some other stuff; we have too many docstrings and it is probably confusing / not helpful

@navidcy
Copy link
Collaborator

navidcy commented Aug 5, 2024

It's less confusing than not having any docstrings, which was my experience with some other state-of-the-art ocean models out there (no need to name names).

@glwagner
Copy link
Member Author

glwagner commented Aug 5, 2024

It's less confusing than not having any docstrings, which was my experience with some other state-of-the-art ocean models out there (no need to name names).

That's a rather low bar!

@navidcy navidcy added the documentation 📜 The sacred scrolls label Aug 6, 2024
@navidcy navidcy merged commit c191386 into main Aug 6, 2024
46 checks passed
@navidcy navidcy deleted the glw/streamline-function-field-docs branch August 6, 2024 23:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation 📜 The sacred scrolls
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants