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

New and updated reprs for Variable, ParticleFile, Field, VectorField, and ParticleSet #1743

Merged
merged 17 commits into from
Oct 28, 2024

Conversation

VeckoTheGecko
Copy link
Contributor

@VeckoTheGecko VeckoTheGecko commented Oct 25, 2024

New/updated reprs for:

  • Variable
  • ParticleFile
  • Field
  • VectorField
  • ParticleSet
  • FieldSet

contributes to #1693

@VeckoTheGecko VeckoTheGecko changed the title Updated reprs for New and updated reprs for Variable, ParticleFile, Field, and ParticleSet Oct 25, 2024
Copy link
Member

@erikvansebille erikvansebille left a comment

Choose a reason for hiding this comment

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

Nice start to better printing! See below a few comments. I'll also trigger them in the Parcels tutorial notebook, so that users see these print statements in action

parcels/tools/_helpers.py Outdated Show resolved Hide resolved
parcels/tools/_helpers.py Show resolved Hide resolved
parcels/field.py Outdated Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

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

The _warn_outputdt_release_desync() call should be fixed by #1744

But it would be nice if the particles are listed one per line in the other cells?

Multiline particle printing
Update function naming
FieldSet repr
return textwrap.dedent(out).strip()


def fieldset_repr(fieldset: FieldSet) -> str:
Copy link
Member

Choose a reason for hiding this comment

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

The fields now don't print their own name; that would be the most important information?

return f"[\n{items_str}\n{indentation_str_end}]"


def particleset_repr(pset: ParticleSet) -> str:
Copy link
Member

Choose a reason for hiding this comment

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

print(pset) now also prints all the fields, that would be a bit redundant?
And the list of particles is a generator object?
Screenshot 2024-10-28 at 08 42 41

@VeckoTheGecko VeckoTheGecko changed the title New and updated reprs for Variable, ParticleFile, Field, and ParticleSet New and updated reprs for Variable, ParticleFile, Field, VectorField, and ParticleSet Oct 28, 2024
@erikvansebille erikvansebille merged commit e728d46 into master Oct 28, 2024
14 checks passed
@erikvansebille erikvansebille deleted the better-prints branch October 28, 2024 09:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants