Skip to content

Commit

Permalink
Basic modernisation of generic scripts
Browse files Browse the repository at this point in the history
- Drop shebang lines and "if __name__ ..." logic, rely on entry point
  configuration

- Drop __future__ import

- Drop legacy spglib name
  • Loading branch information
ajjackson committed Apr 19, 2024
1 parent 621643a commit a5d5659
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 43 deletions.
1 change: 0 additions & 1 deletion mctools/generic/get_energy.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
###############################################################################

from __future__ import absolute_import, print_function
from argparse import ArgumentParser
import ase.io

Expand Down
5 changes: 0 additions & 5 deletions mctools/generic/get_minimum.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from __future__ import print_function, absolute_import
import argparse
import ase.io

Expand Down Expand Up @@ -49,7 +48,3 @@ def get_minimum(input_file='POSCAR',
atoms.write(output_file, format="vasp", vasp5=True, direct=True)
else:
atoms.write(output_file, format=output_format)


if __name__ == "__main__":
main()
13 changes: 2 additions & 11 deletions mctools/generic/get_primitive.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
#!/usr/bin/env python

from __future__ import print_function, absolute_import
import argparse

import ase
import ase.io
try:
from spglib import spglib
except ImportError:
from pyspglib import spglib
import spglib


def main():
Expand Down Expand Up @@ -118,7 +113,3 @@ def vprint(*args):
atoms.write(output_file, format="vasp", vasp5=True)
else:
atoms.write(output_file, format=output_format)


if __name__ == "__main__":
main()
13 changes: 1 addition & 12 deletions mctools/generic/get_spacegroup.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
#! /usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import print_function, absolute_import
import argparse
import os

import ase.io


try:
import spglib.spglib as spglib
except ImportError:
import pyspglib.spglib as spglib
import spglib


def get_spacegroup(filename=False, format=False):
Expand Down Expand Up @@ -46,7 +39,3 @@ def main():
help="File format for ASE importer")
args = parser.parse_args()
get_spacegroup(filename=args.filename, format=args.format)


if __name__ == "__main__":
main()
8 changes: 0 additions & 8 deletions mctools/generic/get_volume.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#! /usr/bin/env python

###############################################################################
# Copyright 2017 Adam Jackson
###############################################################################
Expand All @@ -17,7 +15,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
###############################################################################

from __future__ import print_function
import ase.io
from argparse import ArgumentParser

Expand All @@ -28,7 +25,6 @@ def get_volume(filename):


def main():

parser = ArgumentParser(description="Read volume from chemical structure")
parser.add_argument("filename", type=str, nargs='?',
default="geometry.in",
Expand All @@ -38,7 +34,3 @@ def main():

volume = get_volume(args.filename)
print(volume)


if __name__ == '__main__':
main()
6 changes: 0 additions & 6 deletions mctools/generic/vectors.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#! /usr/bin/env python
# -*- encoding: utf-8 -*-
"""Get lattice vector in a, b, c, α, β, γ format from ase-compatible file"""

Expand All @@ -19,7 +18,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
###############################################################################

from __future__ import absolute_import, print_function, division
from optparse import OptionParser
import numpy as np
import ase.io
Expand Down Expand Up @@ -83,7 +81,3 @@ def main():
'{5:.{7}f}'.format(a, b, c, alpha, beta, gamma,
options.precision_length,
options.precision_angle))


if __name__ == '__main__':
main()

0 comments on commit a5d5659

Please sign in to comment.