__init__ of damask package not crashing in python 2.5 if core module not available
added some Matlab-like utility functions (damask.sind, cosd, tand, acosd, ...) that take and return degree instead of radians
This commit is contained in:
parent
ddf3fcc877
commit
b2a7f85101
|
@ -9,7 +9,12 @@ from .result import Result # one class with subclasses
|
|||
from .geometry import Geometry # one class with subclasses
|
||||
from .solver import Solver # one class with subclasses
|
||||
from .test import Test
|
||||
from util import *
|
||||
|
||||
try:
|
||||
from . import core
|
||||
except Exception, e:
|
||||
sys.stderr.write('\nWARNING: Core module (Fortran code) not available, try to run setup_processing.py\nError Message when importing core.so: %s\n\n'%e)
|
||||
except ImportError:
|
||||
sys.stderr.write('\nWARNING: Core module (Fortran code) not available, try to run setup_processing.py\nError Message when importing core.so: \n\n')
|
||||
core = None # from http://www.python.org/dev/peps/pep-0008/
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
# some utility functions
|
||||
import math
|
||||
try:
|
||||
import numpy
|
||||
except:
|
||||
numpy=None
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
for f in ['cos', 'sin', 'tan']:
|
||||
exec('def %sd(deg): return ((numpy or math).%s(deg/180.*math.pi))'%(f,f))
|
||||
if numpy:
|
||||
exec('def a%sd(val): return (numpy.arc%s(val)*180./math.pi)'%(f,f))
|
||||
else:
|
||||
exec('def a%sd(val): return (math.a%s(val)*180./math.pi)'%(f,f))
|
||||
# Matlab like functions to allow for cosd(degree),...
|
||||
# it is open how these compare to the numpy.cos, which can operate on arrays
|
||||
# ->full array compatibility can be achieved through numpy.deg2rad|rad2deg
|
||||
|
Loading…
Reference in New Issue