Skip to content

Commit

Permalink
remove previous edit
Browse files Browse the repository at this point in the history
  • Loading branch information
killiansheriff committed Jan 18, 2024
1 parent 39d9086 commit ed07390
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions src/WarrenCowleyParameters/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,9 @@ def _find_neighbor_indices(self):
return neighbor_indices

def _calculate_concentration(self, particle_types):
# This is to deal with the case whenever type 3 and 1 are assigned but no atoms have type 2
ntypes = np.max(particle_types)
unique_types = np.arange(1, ntypes + 1)
counts = np.bincount(particle_types)[1:]
return unique_types, counts / len(particle_types)

# This used to be the old way
# unique_types, counts = np.unique(particle_types, return_counts=True)
unique_types, counts = np.unique(particle_types, return_counts=True)

# return unique_types, counts / len(particle_types)
return unique_types, counts / len(particle_types)

def _create_central_atom_type_mask(self, unique_types, particle_types):
unique_types_array = unique_types[:, np.newaxis]
Expand Down Expand Up @@ -192,12 +185,8 @@ def __init__(self, data: DataCollection) -> None:

def get_type_name(self, id: int) -> str:
"""Get the name of a particle type by its ID"""
try:
particle_type = self.data.particles["Particle Type"].type_by_id(id)
except:
# This is to deal with the case whenever type 3 and 1 are assigned but no atoms have type 2
ParticleType = lambda name=False: type('ParticleType', (), {'name': name})()
particle_type = ParticleType()

particle_type = self.data.particles["Particle Type"].type_by_id(id)
return particle_type.name or f"Type {id}"

def create_visualization_tables(self, unique_types, nshells, wc_for_shells):
Expand Down

0 comments on commit ed07390

Please sign in to comment.