Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

clease

Package Overview
Dependencies
Maintainers
2
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clease - npm Package Compare versions

Comparing version
1.0.1
to
1.0.2
+1
-1
clease.egg-info/PKG-INFO
Metadata-Version: 2.1
Name: clease
Version: 1.0.1
Version: 1.0.2
Summary: CLuster Expansion in Atomistic Simulation Environment

@@ -5,0 +5,0 @@ Home-page: https://gitlab.com/computationalmaterials/clease/

@@ -1,2 +0,2 @@

ase<3.23,>=3.20
ase>=3.22
numpy

@@ -16,21 +16,21 @@ cython

[all]
sphinx
pytest-benchmark[histogram]>=3.4.1
pre-commit
ipython
pyclean>=2.0.0
pytest-benchmark[histogram]>=3.4.1
pylint
black>=22.1.0
pip
black>=22.1.0
twine
sphinx_rtd_theme
build
pytest-cov
cython
clang-format>=14.0.3
pytest-cov
pytest-mock
tox>=3.24.0
cython
build
pytest
pytest-mock
pyclean>=2.0.0
pylint
sphinx_rtd_theme
clease-gui
mock
sphinx
clease-gui
ipython
twine

@@ -37,0 +37,0 @@ [dev]

@@ -1,1 +0,1 @@

1.0.1
1.0.2
from typing import Dict, Optional, Iterable, Set, List, Union, Sequence
from ase import Atoms
from ase.calculators.calculator import Calculator
from clease.datastructures import SystemChange

@@ -234,15 +233,12 @@ from clease.settings import ClusterExpansionSettings

self,
atoms: Atoms,
properties: List[str],
system_changes: Union[Sequence[SystemChange], None],
atoms: Atoms = None,
properties: List[str] = None,
system_changes: Union[Sequence[SystemChange], None] = None,
) -> float:
"""Calculate the energy of the passed Atoms object.
If accept=True, the most recently used atoms object is used as a
reference structure to calculate the energy of the passed atoms.
Returns energy.
Parameters:
:param atoms: ASE Atoms object
:param atoms: ASE Atoms object, or None. If None is passed,
the internal one is used, if the calculator has been initialized.

@@ -253,3 +249,3 @@ :param system_changes:

"""
Calculator.calculate(self, atoms)
super().calculate(atoms, properties, system_changes)
self.update_cf()

@@ -256,0 +252,0 @@ return self.get_energy_given_change([], keep_changes=True)

"""Calculator for Cluster Expansion."""
import sys
import contextlib
from typing import Dict, Optional, TextIO, Union, List
from typing import Dict, Optional, TextIO, Union, List, Sequence, Any
import numpy as np
from ase import Atoms
from ase.calculators.calculator import Calculator
from ase.calculators.calculator import PropertyNotImplementedError
from clease_cxx import PyCEUpdater, has_parallel

@@ -27,4 +27,4 @@ from clease.datastructures import SystemChange, SystemChanges

# pylint: disable=too-many-instance-attributes
class Clease(Calculator):
# pylint: disable=too-many-instance-attributes, too-many-public-methods
class Clease:
"""Class for calculating energy using CLEASE.

@@ -56,3 +56,2 @@

) -> None:
Calculator.__init__(self)

@@ -64,3 +63,3 @@ if not isinstance(settings, ClusterExpansionSettings):

self.updater = None
self.parameters["eci"] = eci
self.results = {}
self.settings = settings

@@ -147,11 +146,3 @@ self.corrFunc = CorrFunction(settings)

def check_state(self, atoms: Atoms, tol: float = 1e-15):
res = super().check_state(atoms)
syst_ch = self.indices_of_changed_atoms
if syst_ch and "energy" not in res:
res.append("energy")
return res
def reset(self):
def reset(self) -> None:
self.results = {}

@@ -161,2 +152,3 @@

"""Calculate correlation functions from scratch."""
self.require_updater()
return self.updater.calculate_cf_from_scratch(self.atoms, self.cf_names)

@@ -172,8 +164,7 @@

# pylint: disable=signature-differs
def calculate(
self,
atoms: Atoms,
properties: Union[List[str], str],
system_changes: SystemChanges,
atoms: Optional[Atoms] = None,
properties: List[str] = None,
system_changes: SystemChanges = None,
) -> float:

@@ -189,3 +180,3 @@ """Calculate the energy of the passed Atoms object.

:param properties: List of what needs to be calculated.
It can only by 'energy' at the moment.
It can only be ['energy'] for the basic Clease calculator.

@@ -196,8 +187,38 @@ :param system_changes: List of system changes. For example, if the

index 26 is swapped with an Al atom occupying the atomic index 12,
system_change = [(26, Mg, Al), (12, Al, Mg)]
system_change = [(26, Mg, Al), (12, Al, Mg)].
Currently not supported.
"""
if atoms is not None:
if self.atoms is None:
# We havn't yet initialized, so initialize with the passed atoms object.
self.set_atoms(atoms)
else:
# Use the symbols of the passed atoms object
self.atoms.symbols[:] = atoms.symbols
self.require_updater()
_check_properties(properties, self.implemented_properties)
if system_changes is not None:
raise ValueError("system_changes in calculate is currently not supported.")
self.update_energy()
self.energy = self.updater.get_energy()
return self.energy
def get_property(self, name: str, atoms: Atoms = None, allow_calculation: bool = True):
"""Get a property from the calculator.
Exists due to compatibility with ASE, should not be used directly.
"""
_check_properties([name], self.implemented_properties)
if not allow_calculation:
return self.energy
return self.get_potential_energy(atoms=atoms)
def get_potential_energy(self, atoms: Atoms = None) -> float:
"""Calculate the energy from scratch with an atoms object"""
# self.set_atoms(atoms)
return self.calculate(atoms=atoms)
def clear_history(self) -> None:

@@ -225,2 +246,24 @@ self.updater.clear_history()

def calculation_required(self, atoms: Atoms, properties: Sequence[str] = None) -> bool:
"""Check whether a calculation is required for a given atoms object.
The ``properties`` argument only exists for compatibility reasons, and has no effect.
Primarily for ASE compatibility.
"""
_check_properties(properties, self.implemented_properties)
if self.updater is None:
return True
if "energy" not in self.results:
return True
changed_indices = self.get_changed_sites(atoms)
return bool(changed_indices)
def check_state(self, atoms: Atoms) -> List[str]:
"""Method for checking if energy needs calculation.
Primarily for ASE compatibility.
"""
res = []
if self.calculation_required(atoms):
res.append("energy")
return res
@property

@@ -237,3 +280,3 @@ def energy(self):

"""Return the indices of atoms that have been changed."""
changed = self.updater.get_changed_sites(self.atoms)
changed = self.get_changed_sites(self.atoms)
for index in changed:

@@ -246,2 +289,7 @@ if self.is_backround_index[index] and not self.settings.include_background_atoms:

def get_changed_sites(self, atoms: Atoms) -> List[int]:
"""Return the list of indices which differ from the internal ones."""
self.require_updater()
return self.updater.get_changed_sites(atoms)
def get_cf(self) -> Dict[str, float]:

@@ -353,4 +401,3 @@ """Return the correlation functions as a dict"""

"""Get the number of threads from the C++ updater."""
if self.updater is None:
raise UnitializedCEError("Updater hasn't been initialized yet.")
self.require_updater()
return self.updater.get_num_threads()

@@ -369,4 +416,4 @@

raise ValueError("Number of threads must be at least 1")
if self.updater is None:
raise UnitializedCEError("Updater hasn't been initialized yet.")
self.require_updater()
if value != 1 and not has_parallel():

@@ -376,1 +423,30 @@ # Having a value of 1 is OK, since that's not threading.

self.updater.set_num_threads(value)
def require_updater(self) -> None:
if self.updater is None:
raise UnitializedCEError("Updater hasn't been initialized yet.")
@property
def parameters(self) -> Dict[str, Any]:
"""Return a dictionary with relevant parameters."""
return {"eci": self.eci}
def todict(self) -> dict:
"""Return the parameters, i.e. the ECI values.
For ASE compatibility.
"""
return self.parameters
def _check_properties(properties: Optional[List[str]], implemented_properties: List[str]) -> None:
"""Check whether the passed properties is supported. If it is None, nothing is checked.
Raises PropertyNotImplementedError upon finding a bad property.
"""
if properties is None:
return
for prop in properties:
if prop not in implemented_properties:
allowed = ", ".join(implemented_properties)
raise PropertyNotImplementedError(
f"Property '{prop}' is unsupported. Implemented properties: {allowed}"
)

@@ -5,3 +5,3 @@ """Module for generating new structures for training."""

from functools import reduce
from typing import List, Dict, Optional, Union, Any
from typing import List, Dict, Optional, Union, Any, Tuple
import logging

@@ -715,9 +715,8 @@ from itertools import product

warn_on_skip: bool = True,
) -> Optional[int]:
) -> Optional[Union[int, Tuple[int, int]]]:
"""Insert a structure to the database.
Returns the ID of the initial structure which was inserted into the database.
If a row for the final structure is also inserted, this id can be retrieved of the
initial row from the ``final_struct_id`` entry. If no structure was inserted,
``Ǹone`` is returned, instead.
If a row for the final structure is also inserted, a tuple of (initial_id, final_id)
is returned. If no structure was inserted, ``Ǹone`` is returned, instead.

@@ -727,3 +726,3 @@ :param init_struct: Unrelaxed initial structure. If a string is passed,

:param final_struct: (Optional) final structure that contains energy.
It can be either ASE Atoms object or file anme ending with .traj.
It can be either ASE Atoms object or file name readable by ASE.
:param name: (Optional) name of the DB entry if a custom name is to be

@@ -786,3 +785,4 @@ used. If `None`, default naming convention will be used.

con = self.connect()
uid_init = db_util.new_row_with_single_table(con, init_struct, tab_name, cf, **kvp)
uid_init: int = db_util.new_row_with_single_table(con, init_struct, tab_name, cf, **kvp)
ret_val = uid_init

@@ -793,6 +793,7 @@ if final_struct is not None:

kvp_final = {"struct_type": "final", "name": kvp["name"]}
uid = con.write(final_struct, kvp_final)
con.update(uid_init, converged=True, started="", queued="", final_struct_id=uid)
uid_final: int = con.write(final_struct, kvp_final)
con.update(uid_init, converged=True, started="", queued="", final_struct_id=uid_final)
ret_val = (uid_init, uid_final)
return uid_init
return ret_val

@@ -799,0 +800,0 @@ def _exists_in_db(self, atoms: Atoms, formula_unit: Optional[str] = None) -> bool:

@@ -45,3 +45,3 @@ .. CLEASE documentation master file, created by

* Use one our :ref:`pre-made observers <mc_observers>` to collect thermondynamic
* Use one our :ref:`pre-made observers <mc_observers>` to collect thermodynamic
data about your system during an MC run, or

@@ -48,0 +48,0 @@ :ref:`write your own <implementing your own observer>`.

@@ -7,2 +7,8 @@ .. _releasenotes:

1.0.2
======
* :py:meth:`~clease.structgen.new_struct.NewStructures.insert_structure` returns both
the initial and final ID if both an initial and final structure was inserted.
* Fixes a bug with writing the Clease calculator to a DB row.
1.0.1

@@ -9,0 +15,0 @@ ======

Metadata-Version: 2.1
Name: clease
Version: 1.0.1
Version: 1.0.2
Summary: CLuster Expansion in Atomistic Simulation Environment

@@ -5,0 +5,0 @@ Home-page: https://gitlab.com/computationalmaterials/clease/

@@ -34,3 +34,3 @@ [metadata]

install_requires =
ase>=3.20, <3.23 # temp restriction on ASE upper version
ase>=3.22
numpy

@@ -37,0 +37,0 @@ cython

Sorry, the diff of this file is too big to display