Refactoring #1071

Feature #861: === Website & Examples ===

Example scripts: No global import from Python module bornagain

Added by wuttke about 4 years ago. Updated about 3 years ago.

Status:ResolvedStart date:09 May 2015
Priority:LowDue date:
Assignee:wuttke% Done:

100%

Category:-Estimated time:2.00 hours
Target version:-

Description

Instead of

from bornagain import *

our Python examples should use
import bornagain as ba

which enforces a more explicit source code.

For heavily used trivia we might need an additional

from bornagain import nanometer, degree, angstrom, deg2rad

History

#1 Updated by wuttke about 4 years ago

  • Subject changed from to discuss: no global import from Python module bornagain to No global import from Python module bornagain
  • Status changed from New to In Progress
  • Assignee set to wuttke
  • Priority changed from Normal to Low

#2 Updated by pospelov almost 4 years ago

  • Target version set to Sprint 29

#3 Updated by pospelov over 3 years ago

  • Target version changed from Sprint 29 to Sprint 30

#4 Updated by pospelov over 3 years ago

  • Tracker changed from Documentation to Refactoring
  • Status changed from In Progress to Backlog
  • Target version deleted (Sprint 30)

#5 Updated by wuttke over 3 years ago

  • Assignee deleted (wuttke)

#6 Updated by wuttke over 3 years ago

  • Subject changed from No global import from Python module bornagain to Example scripts: No global import from Python module bornagain

#7 Updated by wuttke over 3 years ago

  • Parent task set to #966

#8 Updated by wuttke about 3 years ago

  • Parent task changed from #966 to #861

#9 Updated by wuttke about 3 years ago

  • Status changed from Backlog to Sprint

#10 Updated by wuttke about 3 years ago

  • Status changed from Sprint to Resolved
  • Assignee set to wuttke
  • % Done changed from 0 to 100
  • Estimated time set to 2.00

Resolved in 3b5d014b0, using the regular expressions appended below, plus very little hand editing.

All scripts in Examples/python/simulation and Examples/python/fitting are tested. They all work, except for one which was broken before (#1436).

Still to do (#1437): upon library release, move them to Drupal.


t = re.sub( r'from bornagain import \*', 'import bornagain as ba\nfrom bornagain import degree, angstrom, nanometer', t )
for x in [ 'FormF', 'Homog', 'Layer', 'MultiL', 'Partic', 'GISASSi', 'Interf', 'Distr', 'Param', 'Rota', 'kvector_t', 'FTDec', 'FTDis', 'IForm', 'Spec', 'Spheri', 'Rect', 'OffS', 'Fixed', 'Resol', 'IHist', 'IDet', 'Ellip', 'Fit', 'IFit', 'Default', 'Poly', 'Horiz', 'Vertic', 'AttL', 'ISam', 'Intens', 'ILayou' ]:
t = re.sub( ' '+x, ' ba.'+x, t )
t = re.sub( r'\('+x, '(ba.'+x, t )
t = re.sub( r'deg2rad\((.*?)\)', r'\1*degree', t )
t = re.sub( '/deg,', '/degree,', t )
t = re.sub( '/deg]', '/degree]', t )
t = re.sub( r'/deg\)', '/degree)', t )
t = re.sub( r'\*deg,', '*degree,', t )
t = re.sub( r'\*deg ', '*degree ', t )
t = re.sub( r'\*deg]', '*degree]', t )
t = re.sub( r'\*deg\)', '*degree)', t )

Also available in: Atom PDF