Пример #1
0
def make_paper_with_internal_module(filename):

    paper = ActivePaper(filename, "w")

    paper.add_module("my_math",
"""
import numpy as np

def my_func(x):
    return np.sin(x)
""")

    paper.data.create_dataset("frequency", data=0.2)
    paper.data.create_dataset("time", data=0.1*np.arange(100))

    calc_sine = paper.create_calclet("calc_sine",
"""
from activepapers.contents import data
import numpy as np
from my_math import my_func

frequency = data['frequency'][...]
time = data['time'][...]
data.create_dataset("sine", data=my_func(2.*np.pi*frequency*time))
""")
    calc_sine.run()

    paper.close()
Пример #2
0
def make_paper_with_internal_module(filename):

    paper = ActivePaper(filename, "w")

    paper.add_module(
        "my_math", """
import numpy as np

def my_func(x):
    return np.sin(x)
""")

    paper.data.create_dataset("frequency", data=0.2)
    paper.data.create_dataset("time", data=0.1 * np.arange(100))

    calc_sine = paper.create_calclet(
        "calc_sine", """
from activepapers.contents import data
import numpy as np
from my_math import my_func

frequency = data['frequency'][...]
time = data['time'][...]
data.create_dataset("sine", data=my_func(2.*np.pi*frequency*time))
""")
    calc_sine.run()

    paper.close()
def make_library_paper(filename):

    paper = ActivePaper(filename, "w")

    paper.add_module("my_math",
"""
import numpy as np

def my_func(x):
    return np.sin(x)
""")

    paper.close()
Пример #4
0
def make_paper_with_module(filename, value):
    paper = ActivePaper(filename, "w")
    paper.add_module("some_values", """
a_value = %d
""" % value)
    script = paper.create_calclet(
        "test", """
from activepapers.contents import data
from some_values import a_value
data['a_value'] = a_value
""")
    script.run()
    paper.close()
Пример #5
0
def make_library_paper(filename):

    paper = ActivePaper(filename, "w")

    paper.add_module(
        "my_math", """
import numpy as np

def my_func(x):
    return np.sin(x)
""")

    paper.close()
def make_paper_with_module(filename, value):
    paper = ActivePaper(filename, "w")
    paper.add_module("some_values",
"""
a_value = %d
""" % value)
    script = paper.create_calclet("test",
"""
from activepapers.contents import data
from some_values import a_value
data['a_value'] = a_value
""")
    script.run()
    paper.close()
Пример #7
0
def make_local_paper(filename):

    paper = ActivePaper(filename, "w")

    paper.data.create_dataset("frequency", data=0.2)
    paper.data.create_dataset("time", data=0.1*np.arange(100))

    paper.add_module("my_math",
"""
import numpy as np

def my_func(x):
    return np.sin(x)
""")

    paper.close()
Пример #8
0
from activepapers.storage import ActivePaper
import numpy as np

paper = ActivePaper("internal_modules.ap", "w")

paper.add_module("my_math",
"""
import numpy as np

def my_func(x):
    return np.sin(x)
""")


paper.data.create_dataset("frequency", data = 0.2)
paper.data.create_dataset("time", data=0.1*np.arange(100))

calc_sine = paper.create_calclet("calc_sine",
"""
from activepapers.contents import data
import numpy as np
from my_math import my_func

frequency = data['frequency'][...]
time = data['time'][...]
data.create_dataset("sine", data=my_func(2.*np.pi*frequency*time))
""")
calc_sine.run()

paper.close()