following PEP style guide

This commit is contained in:
Martin Diehl 2019-05-30 20:02:55 +02:00
parent 4cb0ba3803
commit 37de73535d
7 changed files with 18 additions and 34 deletions

View File

@ -1,5 +1,3 @@
# -*- coding: UTF-8 no BOM -*-
#################################################################################################### ####################################################################################################
# Code below available according to the followin conditions on https://github.com/MarDiehl/3Drotations # Code below available according to the followin conditions on https://github.com/MarDiehl/3Drotations
#################################################################################################### ####################################################################################################

View File

@ -1,6 +1,9 @@
# -*- coding: UTF-8 no BOM -*- import os
import sys
import re
import shlex
from collections import Iterable
import os, sys
import numpy as np import numpy as np
# ------------------------------------------------------------------ # ------------------------------------------------------------------
@ -80,8 +83,6 @@ class ASCIItable():
def _quote(self, def _quote(self,
what): what):
"""Quote empty or white space-containing output""" """Quote empty or white space-containing output"""
import re
return '{quote}{content}{quote}'.format( return '{quote}{content}{quote}'.format(
quote = ('"' if str(what)=='' or re.search(r"\s",str(what)) else ''), quote = ('"' if str(what)=='' or re.search(r"\s",str(what)) else ''),
content = what) content = what)
@ -147,8 +148,6 @@ class ASCIItable():
by either reading the first row or, by either reading the first row or,
if keyword "head[*]" is present, the last line of the header if keyword "head[*]" is present, the last line of the header
""" """
import re,shlex
try: try:
self.__IO__['in'].seek(0) self.__IO__['in'].seek(0)
except IOError: except IOError:
@ -276,8 +275,6 @@ class ASCIItable():
"x" for "1_x","2_x",... unless raw output is requested. "x" for "1_x","2_x",... unless raw output is requested.
operates on object tags or given list. operates on object tags or given list.
""" """
from collections import Iterable
if tags is None: tags = self.tags if tags is None: tags = self.tags
if isinstance(tags, Iterable) and not raw: # check whether list of tags is requested if isinstance(tags, Iterable) and not raw: # check whether list of tags is requested
@ -313,8 +310,6 @@ class ASCIItable():
return numpy array if asked for list of labels. return numpy array if asked for list of labels.
transparently deals with label positions implicitly given as numbers or their headings given as strings. transparently deals with label positions implicitly given as numbers or their headings given as strings.
""" """
from collections import Iterable
if isinstance(labels, Iterable) and not isinstance(labels, str): # check whether list of labels is requested if isinstance(labels, Iterable) and not isinstance(labels, str): # check whether list of labels is requested
idx = [] idx = []
for label in labels: for label in labels:
@ -354,8 +349,6 @@ class ASCIItable():
return numpy array if asked for list of labels. return numpy array if asked for list of labels.
transparently deals with label positions implicitly given as numbers or their headings given as strings. transparently deals with label positions implicitly given as numbers or their headings given as strings.
""" """
from collections import Iterable
listOfLabels = isinstance(labels, Iterable) and not isinstance(labels, str) # check whether list of labels is requested listOfLabels = isinstance(labels, Iterable) and not isinstance(labels, str) # check whether list of labels is requested
if not listOfLabels: labels = [labels] if not listOfLabels: labels = [labels]
@ -389,8 +382,6 @@ class ASCIItable():
return numpy array if asked for list of labels. return numpy array if asked for list of labels.
transparently deals with label positions implicitly given as numbers or their headings given as strings. transparently deals with label positions implicitly given as numbers or their headings given as strings.
""" """
from collections import Iterable
start = self.label_index(labels) start = self.label_index(labels)
dim = self.label_dimension(labels) dim = self.label_dimension(labels)
@ -436,8 +427,6 @@ class ASCIItable():
advance = True, advance = True,
respectLabels = True): respectLabels = True):
"""Read next line (possibly buffered) and parse it into data array""" """Read next line (possibly buffered) and parse it into data array"""
import shlex
self.line = self.__IO__['readBuffer'].pop(0) if len(self.__IO__['readBuffer']) > 0 \ self.line = self.__IO__['readBuffer'].pop(0) if len(self.__IO__['readBuffer']) > 0 \
else self.__IO__['in'].readline().strip() # take buffered content or get next data row from file else self.__IO__['in'].readline().strip() # take buffered content or get next data row from file
@ -458,8 +447,6 @@ class ASCIItable():
def data_readArray(self, def data_readArray(self,
labels = []): labels = []):
"""Read whole data of all (given) labels as numpy array""" """Read whole data of all (given) labels as numpy array"""
from collections import Iterable
try: self.data_rewind() # try to wind back to start of data try: self.data_rewind() # try to wind back to start of data
except: pass # assume/hope we are at data start already... except: pass # assume/hope we are at data start already...

View File

@ -1,8 +1,6 @@
# -*- coding: UTF-8 no BOM -*- import math
import math,numpy as np import numpy as np
### --- COLOR CLASS --------------------------------------------------
class Color(): class Color():
""" """

View File

@ -1,6 +1,5 @@
# -*- coding: UTF-8 no BOM -*- import os
import re
import os,re
class Environment(): class Environment():
__slots__ = [ \ __slots__ = [ \

View File

@ -1,7 +1,7 @@
# -*- coding: UTF-8 no BOM -*-
import math import math
import numpy as np import numpy as np
from . import Lambert from . import Lambert
from .quaternion import Quaternion from .quaternion import Quaternion
from .quaternion import P from .quaternion import P

View File

@ -1,5 +1,3 @@
# -*- coding: UTF-8 no BOM -*-
import numpy as np import numpy as np
P = -1 # convention (see DOI:10.1088/0965-0393/23/8/083501) P = -1 # convention (see DOI:10.1088/0965-0393/23/8/083501)

View File

@ -1,8 +1,12 @@
# -*- coding: UTF-8 no BOM -*- import sys
import sys,time,os,subprocess,shlex import time
import numpy as np import os
import subprocess
import shlex
from optparse import Option from optparse import Option
import numpy as np
class bcolors: class bcolors:
""" """
ASCII Colors (Blender code) ASCII Colors (Blender code)