Skip to content

Commit

Permalink
Converter: suppress global numpy import
Browse files Browse the repository at this point in the history
  • Loading branch information
benoit128 committed Sep 2, 2024
1 parent d958255 commit 4db9ffa
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
17 changes: 16 additions & 1 deletion Cassiopee/Converter/Converter/Converter.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Conversion module for Cassiopee package.
"""
from numpy import *
#from numpy import *
__version__ = '4.0'
__author__ = "Stephanie Peron, Christophe Benoit, Gaelle Jeanfaivre, Pascal Raud, Benoit Rodriguez, Simon Verley, Bruno Maugars, Thomas Renaud"
#
Expand Down Expand Up @@ -608,6 +608,21 @@ def _initVarByEq__(a, eq):
eq = eq.replace('centers:', '')
eq = eq.replace('nodes:', '')

pi = numpy.pi
eq = eq.replace('minimum(', 'numpy.minimum(')
eq = eq.replace('maximum(', 'numpy.maximum(')
eq = eq.replace('cos(', 'numpy.cos(')
eq = eq.replace('cosh(', 'numpy.cosh(')
eq = eq.replace('sin(', 'numpy.sin(')
eq = eq.replace('sinh(', 'numpy.sinh(')
eq = eq.replace('sqrt(', 'numpy.sqrt(')
eq = eq.replace('log(', 'numpy.log(')
eq = eq.replace('tan(', 'numpy.tan(')
eq = eq.replace('atan(', 'numpy.atan(')
eq = eq.replace('exp(', 'numpy.exp(')
#eq = eq.replace('and(', 'numpy.logical_and(')
eq = eq.replace('logical_and(', 'numpy.logical_and(')

# Split suivant ; si plusieurs formules sont definies
eq = eq.split(';')

Expand Down
20 changes: 17 additions & 3 deletions Cassiopee/KCore/Dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,22 @@ def checkNumpy():
#=============================================================================
def getInstallPath(prefix):
mySystem = getSystem()[0]; bits = getSystem()[1]
# Based on spec

# from python3, better to use sysconfig than distutils.sysconfig
# to find the "prefix" installation path from python
#import sysconfig
#schemes = sysconfig.get_scheme_names()
#defaultScheme = sysconfig.get_default_scheme()
#preferedScheme = sysconfig.get_preferred_scheme('prefix') # user or home?
#paths = sysconfig.get_paths("posix_prefix")
#paths = paths['platlib']
#pythonLib = paths.split('/')
#pythonVersion = pythonLib[-2]
#Site = pythonLib[-1]
#Lib = pythonLib[-3]
#installPath = '%s/%s/%s/%s'%(prefix, Lib, pythonVersion, Site)

# Based on distutils (to be su)
if os.environ['ELSAPROD'][0:6] == 'msys64' or os.environ['ELSAPROD'] == 'win64':
pythonLib = distutils.sysconfig.get_python_lib()
pythonLib = pythonLib.split('/')
Expand All @@ -211,7 +226,7 @@ def getInstallPath(prefix):
pythonLib = pythonLib.split('/')
pythonVersion = pythonLib[-2]
installPath = prefix + '/lib/python'+pythonVersion+'/site-packages'
else: # unix
else: # standard unix
pythonLib = distutils.sysconfig.get_python_lib()
pythonLib = pythonLib.split('/')
# Based on python lib
Expand All @@ -220,7 +235,6 @@ def getInstallPath(prefix):
pversion = sys.version_info
pythonVersion = "python{}.{}".format(pversion[0], pversion[1])
Site = pythonLib[-1]
# Lib
Lib = pythonLib[-3]
installPath = '%s/%s/%s/site-packages'%(prefix, Lib, pythonVersion)
return installPath
Expand Down

0 comments on commit 4db9ffa

Please sign in to comment.