Skip to content

Commit

Permalink
remove unnecessary int before math.floor/ceil
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielYang59 committed Apr 14, 2024
1 parent 42ac77b commit f8f43a2
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
12 changes: 6 additions & 6 deletions docs/_modules/pymatgen/command_line/enumlib_caller.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions pymatgen/analysis/local_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -4164,10 +4164,10 @@ def _get_radius(site):
return el.ionic_radii[oxi]

# e.g., oxi = 2.667, average together 2+ and 3+ radii
if int(math.floor(oxi)) in el.ionic_radii and int(math.ceil(oxi)) in el.ionic_radii:
oxi_low = el.ionic_radii[int(math.floor(oxi))]
oxi_high = el.ionic_radii[int(math.ceil(oxi))]
x = oxi - int(math.floor(oxi))
if math.floor(oxi) in el.ionic_radii and math.ceil(oxi) in el.ionic_radii:
oxi_low = el.ionic_radii[math.floor(oxi)]
oxi_high = el.ionic_radii[math.ceil(oxi)]
x = oxi - math.floor(oxi)
return (1 - x) * oxi_low + x * oxi_high

if oxi > 0 and el.average_cationic_radius > 0:
Expand Down
4 changes: 2 additions & 2 deletions pymatgen/command_line/enumlib_caller.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ def get_sg_info(ss):
# enumeration. See Cu7Te5.cif test file.
base *= 10

# base = n_disordered # 10 ** int(math.ceil(math.log10(n_disordered)))
# base = n_disordered # 10 ** math.ceil(math.log10(n_disordered))
# To get a reasonable number of structures, we fix concentrations to the
# range expected in the original structure.
total_amounts = sum(index_amounts)
Expand All @@ -266,7 +266,7 @@ def get_sg_info(ss):
if abs(conc * base - round(conc * base)) < 1e-5:
output.append(f"{int(round(conc * base))} {int(round(conc * base))} {base}")
else:
min_conc = int(math.floor(conc * base))
min_conc = math.floor(conc * base)
output.append(f"{min_conc - 1} {min_conc + 1} {base}")
output.append("")
logger.debug("Generated input file:\n" + "\n".join(output))
Expand Down
4 changes: 2 additions & 2 deletions pymatgen/electronic_structure/boltztrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ def write_energy(self, output_file) -> None:
# use 90% of bottom bands since highest eigenvalues
# are usually incorrect
# ask Geoffroy Hautier for more details
nb_bands = int(math.floor(self._bs.nb_bands * (1 - self.cb_cut)))
nb_bands = math.floor(self._bs.nb_bands * (1 - self.cb_cut))
for j in range(nb_bands):
eigs.append(
Energy(
Expand Down Expand Up @@ -384,7 +384,7 @@ def write_proj(self, output_file_proj: str, output_file_def: str) -> None:
file.write(str(len(self._bs.kpoints)) + "\n")
for i, kpt in enumerate(self._bs.kpoints):
tmp_proj = []
for j in range(int(math.floor(self._bs.nb_bands * (1 - self.cb_cut)))):
for j in range(math.floor(self._bs.nb_bands * (1 - self.cb_cut))):
tmp_proj.append(self._bs.projections[Spin(self.spin)][j][i][oi][site_nb])
# TODO deal with the sorting going on at
# the energy level!!!
Expand Down
2 changes: 1 addition & 1 deletion pymatgen/ext/matproj_legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -1660,5 +1660,5 @@ def get_chunks(sequence: Sequence[Any], size=1):
Returns:
list[Sequence[Any]]: input sequence in chunks of length size.
"""
chunks = int(math.ceil(len(sequence) / float(size)))
chunks = math.ceil(len(sequence) / float(size))
return [sequence[i * size : (i + 1) * size] for i in range(chunks)]
2 changes: 1 addition & 1 deletion pymatgen/transformations/advanced_transformations.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ def apply_transformation(
raise ValueError(f"Too many disordered sites! ({n_disordered} > {self.max_disordered_sites})")
max_cell_sizes: Iterable[int] = range(
self.min_cell_size,
int(math.floor(self.max_disordered_sites / n_disordered)) + 1,
math.floor(self.max_disordered_sites / n_disordered) + 1,
)
else:
max_cell_sizes = [self.max_cell_size]
Expand Down
2 changes: 1 addition & 1 deletion pymatgen/vis/structure_vtk.py
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,7 @@ def make_movie(structures, output_filename="movie.mp4", zoom=1.0, fps=20, bitrat
vis.show_help = False
vis.redraw()
vis.zoom(zoom)
sig_fig = int(math.floor(math.log10(len(structures))) + 1)
sig_fig = math.floor(math.log10(len(structures))) + 1
filename = f"image{{0:0{sig_fig}d}}.png"
for idx, site in enumerate(structures):
vis.set_structure(site)
Expand Down

0 comments on commit f8f43a2

Please sign in to comment.