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 indices info in show(io, ::Field) for fields with non-default indices #3303

Merged
merged 5 commits into from
Oct 4, 2023

Conversation

navidcy
Copy link
Collaborator

@navidcy navidcy commented Oct 2, 2023

Before this PR:

julia> using Oceananigans

julia> grid = RectilinearGrid(size = (5, 5, 4), extent = (100, 100, 20));

julia> η = Field{Center, Center, Face}(grid, indices = (:, :, size(grid, 3)+1))
5×5×1 Field{Center, Center, Face} on RectilinearGrid on CPU
├── grid: 5×5×4 RectilinearGrid{Float64, Periodic, Periodic, Bounded} on CPU with 3×3×3 halo
├── boundary conditions: FieldBoundaryConditions
│   └── west: Periodic, east: Periodic, south: Periodic, north: Periodic, bottom: Nothing, top: Nothing, immersed: ZeroFlux
└── data: 11×11×1 OffsetArray(::Array{Float64, 3}, -2:8, -2:8, 5:5) with eltype Float64 with indices -2:8×-2:8×5:5
    └── max=0.0, min=0.0, mean=0.0

After this PR:

julia> using Oceananigans

julia> grid = RectilinearGrid(size = (5, 5, 4), extent = (100, 100, 20));

julia> η = Field{Center, Center, Face}(grid, indices = (:, :, size(grid, 3)+1))
5×5×1 Field{Center, Center, Face} on RectilinearGrid on CPU
├── grid: 5×5×4 RectilinearGrid{Float64, Periodic, Periodic, Bounded} on CPU with 3×3×3 halo
├── boundary conditions: FieldBoundaryConditions
│   └── west: Periodic, east: Periodic, south: Periodic, north: Periodic, bottom: Nothing, top: Nothing, immersed: ZeroFlux
├── indices: (:, :, 5:5)
└── data: 11×11×1 OffsetArray(::Array{Float64, 3}, -2:8, -2:8, 5:5) with eltype Float64 with indices -2:8×-2:8×5:5
    └── max=0.0, min=0.0, mean=0.0

@navidcy navidcy marked this pull request as ready for review October 2, 2023 11:13
@glwagner
Copy link
Member

glwagner commented Oct 2, 2023

I think we should only show it if the indices are non-default?

src/Fields/show_fields.jl Outdated Show resolved Hide resolved
@navidcy navidcy changed the title Add indices info in show(io, ::Field) Add indices info in show(io, ::Field) for fields with non-default indices Oct 2, 2023
@navidcy
Copy link
Collaborator Author

navidcy commented Oct 2, 2023

I think we should only show it if the indices are non-default?

agreed; have a look now

@siddharthabishnu
Copy link
Contributor

I think we should only show it if the indices are non-default?

agreed; have a look now

I've reviewed the modifications, and they appear satisfactory. Only the non-default indices are displayed, regardless of whether it's a single index value or a range.

siddharthabishnu
siddharthabishnu approved these changes Oct 2, 2023
src/Fields/show_fields.jl Outdated Show resolved Hide resolved
@navidcy navidcy merged commit d45f670 into main Oct 4, 2023
47 checks passed
@navidcy navidcy deleted the ncc/show-fields branch December 17, 2023 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants