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 simple progress bar to simulations #233

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

viljarjf
Copy link

@viljarjf viljarjf commented Jan 14, 2025

Description of the change

Adds a simple progress bar for simulations with SimulationGenerator

Progress of the PR

Minimal example of the bug fix or new feature

from orix.quaternion import Rotation
from orix.crystal_map import Phase
from diffsims.generators.simulation_generator import SimulationGenerator
from diffpy.structure import Atom, Lattice, Structure

# Each phase gets its own progress bar
l = Lattice(1, 2, 3, 90, 100, 110)
atoms = [Atom("C", (0, 0, 0))]
s = Structure(atoms, l)
p1 = Phase("first phase", space_group=1, structure=s)
p2 = Phase("number 2", space_group=191, structure=s)

rots1 = Rotation.random(1000)
rots2 = Rotation.random(2000)

gen = SimulationGenerator()
sims = gen.calculate_diffraction2d(
    phase=[p1, p2],
    rotation=[rots1, rots2],
    show_progressbar=True,
)

>>> first phase: 100%|██████████| 1000/1000 [00:00<00:00, 2725.90it/s]
>>> number 2: 100%|██████████| 2000/2000 [00:01<00:00, 1909.23it/s]

For reviewers

  • The PR title is short, concise, and will make sense 1 year later.
  • New functions are imported in corresponding __init__.py.
  • New features, API changes, and deprecations are mentioned in the
    unreleased section in CHANGELOG.rst.
  • Contributor(s) are listed correctly in credits in diffsims/release_info.py and
    in .zenodo.json.

Copy link
Member

@pc494 pc494 left a comment

Choose a reason for hiding this comment

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

LGTM, will merge in a couple of days if nobody else reviews :)

@pc494
Copy link
Member

pc494 commented Jan 18, 2025

@viljarjf I've just realised you aren't on the contributors list. I think you would go in above Isabel Wood. Similarly if you're happy to update the changelog that would be great :)

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