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

One-argument fmapstructure(x) #56

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

One-argument fmapstructure(x) #56

wants to merge 1 commit into from

Conversation

mcabbott
Copy link
Member

Maybe this should be called fstructure(x) since there's no map. The point is to strip all the types for saving etc. Apparently others believe this method should exist: https://discourse.julialang.org/t/how-to-load-bson-file-of-the-model-build-with-flux-0-12-10-to-use-with-flux-0-13-flux-diagonal-deprecated-problem/91588/2

PR Checklist

  • Tests are added
  • Documentation, if applicable

@ToucheSir
Copy link
Member

Could we find a more descriptive name by ditching the f<verb> convention here? Frankly it only made sense for functions which might've been confused for Base ones, and otherwise mostly serves to confuse folks who don't know about FP idioms.

@mcabbott
Copy link
Member Author

Is structure(x) going to be confusing next to destructure which isn't the opposite? Other words... plain or simple etc?

@ToucheSir
Copy link
Member

As long as it isn't exported I don't see an issue. We've been given to using "restructure" as the inverse of "destructure", after all. That said, made up verbs like "structurize" might also work.

@darsnack
Copy link
Member

Jax uses tree_structure to return the treedef. I think it could be confusing to use *structure both in verb and noun form. Could we do structural_def(x) or structural(x) to imply that we are keeping the structural definition of the tree?

@ToucheSir ToucheSir mentioned this pull request Apr 25, 2023
3 tasks
@mcabbott
Copy link
Member Author

What I don't like about fmapstructure as a name (in any form) is that the "structures" are precisely what it does not preserve. It preserves the graph of children, it uses only Base objects...

@darsnack
Copy link
Member

darsnack commented Apr 25, 2023

What about tree_def(x) or graph_def(x)? So "give me the graph definition that underlies these nested structures."

@mcabbott
Copy link
Member Author

There has got to be a nice name somewhere. They aren't strictly trees due to cache. "simple" or "strip" or "raw"... It's basically a recursive application of children, does that go anywhere, "family", "grandkids"?! child_graph(x)?

@darsnack
Copy link
Member

I think any ancestral tree/graph analogies beyond referring to the parent/children of a single node is confusing. I am okay with something like strip or simplify (or the noun versions).

@CarloLucibello
Copy link
Member

CarloLucibello commented Mar 9, 2024

fstructure feels consistent for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants