MCPcopy Create free account
hub / github.com/numpy/numpy / replace

Function replace

numpy/f2py/auxfuncs.py:787–803  ·  view source on GitHub ↗
(str, d, defaultsep='')

Source from the content-addressed store, hash-verified

785
786
787def replace(str, d, defaultsep=''):
788 if isinstance(d, list):
789 return [replace(str, _m, defaultsep) for _m in d]
790 if isinstance(str, list):
791 return [replace(_m, d, defaultsep) for _m in str]
792 for k in 2 * list(d.keys()):
793 if k == 'separatorsfor':
794 continue
795 if 'separatorsfor' in d and k in d['separatorsfor']:
796 sep = d['separatorsfor'][k]
797 else:
798 sep = defaultsep
799 if isinstance(d[k], list):
800 str = str.replace('#%s#' % (k), sep.join(flatlist(d[k])))
801 else:
802 str = str.replace('#%s#' % (k), d[k])
803 return str
804
805
806def dictappend(rd, ar):

Callers 3

applyrulesFunction · 0.70
buildcallbackFunction · 0.70
buildapiFunction · 0.70

Calls 4

flatlistFunction · 0.85
keysMethod · 0.80
replaceMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected