29e9baaa473886436532596fb816f72993be5cfd,tools/make_examples.py,,,#,48

Before Change


// Remove leading and trailing white space from example names
validated_examples = [line.strip() for line in validated_examples]
// Remove blank lines
validated_examples = filter(None, validated_examples)

for example in validated_examples:
    fullpath = pjoin(EG_SRC_DIR, example)
    if not example.endswith(".py"):
        print ("%s not a python file, skipping." % example)
        continue
    elif not os.path.isfile(fullpath):
        print ("Cannot find file, %s, skipping." % example)
        continue
    shutil.copyfile(fullpath, example)

    // Check that example file is included in the docs
    file_root = example[:-3]
    if file_root not in eg_index_contents:
        msg = "Example, %s, not in index file %s."
        msg = msg % (example, EG_INDEX_FNAME)
        print(msg)

// Run the conversion from .py to rst file
check_call("python ../../tools/ex2rst --project dipy --outdir . .", shell=True)

// added the path so that scripts can import other scripts on the same directory
sys.path.insert(0, os.getcwd())

// Execute each python script in the directory.
if not os.path.isdir("fig"):
    os.mkdir("fig")

use_xvfb = os.environ.get("TEST_WITH_XVFB", False)

if use_xvfb:
    from xvfbwrapper import Xvfb
    display = Xvfb(width=1920, height=1080)
    display.start()

for script in validated_examples:
    namespace = {}
    figure_basename = os.path.join("fig", os.path.splitext(script)[0])
    print(script)
    execfile(script, namespace)
    del namespace

After Change


// Remove leading and trailing white space from example names
validated_examples = [line.strip() for line in validated_examples]
// Remove blank lines
validated_examples = list(filter(None, validated_examples))

for example in validated_examples:
    fullpath = pjoin(EG_SRC_DIR, example)
    if not example.endswith(".py"):
        print("%s not a python file, skipping." % example)
        continue
    elif not os.path.isfile(fullpath):
        print("Cannot find file, %s, skipping." % example)
        continue
    shutil.copyfile(fullpath, example)

    // Check that example file is included in the docs
    file_root = example[:-3]
    if file_root not in eg_index_contents:
        msg = "Example, %s, not in index file %s."
        msg = msg % (example, EG_INDEX_FNAME)
        print(msg)

// Run the conversion from .py to rst file
check_call("python ../../tools/ex2rst --project dipy --outdir . .", shell=True)

// added the path so that scripts can import other scripts on the same directory
sys.path.insert(0, os.getcwd())

// Execute each python script in the directory.
if not os.path.isdir("fig"):
    os.mkdir("fig")

use_xvfb = os.environ.get("TEST_WITH_XVFB", False)

if use_xvfb:
    from xvfbwrapper import Xvfb
    display = Xvfb(width=1920, height=1080)
    display.start()

for script in validated_examples:
    namespace = {}
    figure_basename = os.path.join("fig", os.path.splitext(script)[0])
    print(script)
    exec(open(script).read(), namespace)
    del namespace
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 9

Instances


Project Name: nipy/dipy
Commit Name: 29e9baaa473886436532596fb816f72993be5cfd
Time: 2016-07-29
Author: ghoshbishakh@gmail.com
File Name: tools/make_examples.py
Class Name:
Method Name:


Project Name: YerevaNN/mimic3-benchmarks
Commit Name: d1345ff46bef8696d3a1d95d66cd57529c50a4ff
Time: 2017-10-31
Author: jgc128@outlook.com
File Name: scripts/split_train_and_test.py
Class Name:
Method Name:


Project Name: p2irc/deepplantphenomics
Commit Name: ae2cdb9e7eaf91fdd9e9b695858d1ed95ab75af3
Time: 2018-06-07
Author: nicoreekohiggs@gmail.com
File Name: deepplantphenomics/deepplantpheno.py
Class Name: DPPModel
Method Name: load_dataset_from_directory_with_auto_labels