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

Small typo, docstring update, and fixed a bug. #706

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from

Conversation

tcpekin
Copy link
Collaborator

@tcpekin tcpekin commented Jan 29, 2025

size_marker wasn't doing anything in the plot_structure function when I was testing it. It looks like radius was hardcoded with a magic number. I've just slotted in size_marker, added a new magic number, and updated the docstring.

It seems to work for me, but I haven't extensively tested it with a variety of structures, just one.

Also, why is this code written like this, instead of using the commented out ax.scatter method? I was certainly confused.

@sezelt
Copy link
Member

sezelt commented Jan 29, 2025

This part of the code is for structures with partial occupancy, and it displays the atoms as little pies broken up by the occupancy fraction on each site. For structures with all sites fully occupied, it uses ax.scatter.

@tcpekin
Copy link
Collaborator Author

tcpekin commented Jan 31, 2025

@sezelt I'm not sure this code ever hits the scatter call to be honest. I am testing with https://legacy.materialsproject.org/materials/mp-81/ (pure gold) and get the following occupancy when I drop a print statement right before the plotting of the atoms.

image
structure = get_mp_structure('mp-81')
crystal = py4DSTEM.process.diffraction.Crystal.from_pymatgen_structure(
    structure=structure,
)

fig, ax = crystal.plot_structure(
    returnfig=True,
    size_marker=200,
    zone_axis_lattice=[1,1,0],
    perspective_axes=True,
)

So I think the check of if occ is None: will never execute. That's where my confusion stems from. If I remember, I'll submit a small bugfix.

@sezelt
Copy link
Member

sezelt commented Feb 3, 2025

I think you're right and there's an incorrect assumption, as the Crystal initializer will always set self.occupancy and thus the if occ is None: branches are never taken. Instead we should test for any element of occupancy being non-one.

@sezelt sezelt self-assigned this Feb 3, 2025
@tcpekin
Copy link
Collaborator Author

tcpekin commented Feb 3, 2025

The latest commit should fix it, but I didn't test it to be honest. It may have an extra cast to an array, but that's probably fine.

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