From 6456d87d475d2a2753374e9ba05e1f5fb98061e1 Mon Sep 17 00:00:00 2001 From: liamhuber Date: Thu, 7 Sep 2023 09:49:21 -0700 Subject: [PATCH] Provide a shortcut to ase.build So that we can do common stk operations using a single import. Tests and readme are updated accordingly --- README.md | 4 ++-- structuretoolkit/build/__init__.py | 3 ++- tests/test_ase.py | 14 ++++++++++++++ 3 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 tests/test_ase.py diff --git a/README.md b/README.md index cbf5ee448..aa6117117 100644 --- a/README.md +++ b/README.md @@ -14,9 +14,8 @@ The `structuretoolkit` is currently under development. ```python import structuretoolkit as stk -from ase.build import bulk -structure = bulk("Al", cubic=True) +structure = stk.build.ase.bulk("Al", cubic=True) stk.analyse.get_adaptive_cna_descriptors(structure) stk.plot3d(structure) ``` @@ -43,6 +42,7 @@ stk.plot3d(structure) * `stk.analyse.get_strain()` ### Build +* `stk.build.ase` (Merely a shortcut to the `ase.build` module) * `stk.build.get_grainboundary_info()` * `stk.build.grainboundary()` * `stk.build.high_index_surface()` diff --git a/structuretoolkit/build/__init__.py b/structuretoolkit/build/__init__.py index 27251a9a5..680932835 100644 --- a/structuretoolkit/build/__init__.py +++ b/structuretoolkit/build/__init__.py @@ -1,3 +1,4 @@ +from ase import build as ase # Just a shortcut structuretoolkit.build.ase == ase.build from structuretoolkit.build.aimsgb import ( grainboundary, get_grainboundary_info @@ -8,4 +9,4 @@ from structuretoolkit.build.surface import ( high_index_surface, get_high_index_surface_info -) \ No newline at end of file +) diff --git a/tests/test_ase.py b/tests/test_ase.py new file mode 100644 index 000000000..8ba21ed98 --- /dev/null +++ b/tests/test_ase.py @@ -0,0 +1,14 @@ +# coding: utf-8 +# Copyright (c) Max-Planck-Institut für Eisenforschung GmbH - Computational Materials Design (CM) Department +# Distributed under the terms of "New BSD License", see the LICENSE file. + +import unittest + +from ase import build + +from structuretoolkit.build import ase + + +class TestAse(unittest.TestCase): + def test_build_shortcut(self): + self.assertIs(ase, build, msg="Our link should be a simple shortcut.")