From 3353bffb7211d5521f365ffacd491707b4a958a5 Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Thu, 22 Aug 2019 10:45:24 -0600 Subject: [PATCH] Remove magic numbers and additional data types in extract_global --- python/lammps.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/python/lammps.py b/python/lammps.py index e7062ba514..cd22a2bceb 100644 --- a/python/lammps.py +++ b/python/lammps.py @@ -32,6 +32,11 @@ import select import re import sys +LAMMPS_INT = 0 +LAMMPS_DOUBLE = 1 +LAMMPS_BIGINT = 2 +LAMMPS_TAGINT = 3 + def get_ctypes_int(size): if size == 4: return c_int32 @@ -283,10 +288,14 @@ class lammps(object): def extract_global(self,name,type): if name: name = name.encode() - if type == 0: + if type == LAMMPS_INT: self.lib.lammps_extract_global.restype = POINTER(c_int) - elif type == 1: + elif type == LAMMPS_DOUBLE: self.lib.lammps_extract_global.restype = POINTER(c_double) + elif type == LAMMPS_BIGINT: + self.lib.lammps_extract_global.restype = POINTER(self.c_bigint) + elif type == LAMMPS_TAGINT: + self.lib.lammps_extract_global.restype = POINTER(self.c_tagint) else: return None ptr = self.lib.lammps_extract_global(self.lmp,name) return ptr[0]