Skip to content

Commit

Permalink
refactor!: remove load_json
Browse files Browse the repository at this point in the history
This function was required by `batch_clean`, which is no longer
necessary due to new storing scheme.
  • Loading branch information
adosar committed Jan 22, 2025
1 parent c3a516a commit d691847
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 25 deletions.
3 changes: 2 additions & 1 deletion docs/source/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ Version 0.2.0

* :mod:`moxel.visualize` since PyVista already provides a simple way to
visualize voxels (:issue:`9`).
* :mod:`moxel.utils.batch_clean` since it is no longer necessary to "clean"
* :func:`~moxel.utils.load_json` which was needed by :func:`~moxel.utils.batch_clean`.
* :func:`~moxel.utils.batch_clean` since it is no longer necessary to "clean"
voxels due to new storing scheme.

Version 0.1.2
Expand Down
22 changes: 1 addition & 21 deletions src/moxel/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
"""

import os
import json
import itertools
from pathlib import Path
from multiprocessing import Pool
Expand All @@ -48,25 +47,6 @@
warnings.filterwarnings('ignore')


def load_json(fname):
r"""
Load a ``.json`` file.
Parameters
----------
fname : str
Pathname to the ``.json`` file.
Returns
-------
names : list
"""
with open(fname, 'r') as fhand:
data = json.load(fhand)

return data


def mic_scale_factors(r, lattice_vectors):
r"""
Return scale factors to satisfy minimum image convention [MIC]_.
Expand Down Expand Up @@ -186,7 +166,7 @@ def calculate(self, cubic_box=False, length=30, potential='lj', n_jobs=None):
probe_coords = np.linspace(0, 1, self.grid_size) # Fractional.
scale = mic_scale_factors(self.cutoff, self.structure.lattice.matrix)
self._simulation_box = self.structure * scale

if potential == 'lj':
# Cache LJ parameters for all atoms in the simulation box.
self._lj_params = np.array(
Expand Down
7 changes: 4 additions & 3 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import os
import sys
import json
import unittest
import tempfile
from pathlib import Path
import numpy as np
from pymatgen.core import Structure
from moxel.utils import *
from moxel.utils import (
Grid, mic_scale_factors, voxels_from_file,
voxels_from_files, voxels_from_dir
)


class TestUtils(unittest.TestCase):
Expand Down

0 comments on commit d691847

Please sign in to comment.