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

Add DataLayouts convenience constructors #2033

Merged
merged 1 commit into from
Oct 11, 2024

Conversation

charleskawczynski
Copy link
Member

@charleskawczynski charleskawczynski commented Oct 10, 2024

I've found myself churning a lot of code in the test suite, related to construction of datalayouts.

This PR adds new convenience constructors for datalayouts, meant to be used at the top-level (as they are not inferable).

They have a few advantages over the existing way we construct them. Concretely, they:

  • Require less code duplication
  • Infer Nf
  • Use keywords for clarity, and are therefore order-agnostic

So, instead of writing

array = rand(FT, Nv, Nij, Nij, 3, Nh)
data = VIJFH{S, Nv, Nij}(array)

We can write:

data = VIJFH{S}(ArrayType{FT}, rand; Nv, Nij, Nh)
array = parent(data) # (if you still need `array`)

So, this will hopefully reduce the surface area of these constructors if we use them consistently in the test suite.

@charleskawczynski charleskawczynski force-pushed the ck/datalayout_kw_constructors branch 4 times, most recently from cf7776a to a32dc7a Compare October 10, 2024 20:53
@charleskawczynski charleskawczynski force-pushed the ck/datalayout_kw_constructors branch 3 times, most recently from e16d207 to 37d1584 Compare October 11, 2024 13:07
@charleskawczynski charleskawczynski force-pushed the ck/datalayout_kw_constructors branch from 37d1584 to 4474f47 Compare October 11, 2024 13:12
Copy link
Member

@Sbozzolo Sbozzolo left a comment

Choose a reason for hiding this comment

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

Thank you! Looks good to me!

@charleskawczynski charleskawczynski merged commit 49d7e80 into main Oct 11, 2024
23 checks passed
@charleskawczynski charleskawczynski deleted the ck/datalayout_kw_constructors branch October 11, 2024 17:16
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.

2 participants