예제 #1
0
파일: md_test.py 프로젝트: winpat/md
def test_md():

    text = """
# Heading 1

This is the first paragraph.

* First item
* Second item
  * Sub item
"""
    assert md(text) == [
        Header(level=1, text="Heading 1"),
        Paragraph(text="This is the first paragraph."),
        ListItem(level=1, text="First item"),
        ListItem(level=1, text="Second item"),
        ListItem(level=2, text="Sub item"),
    ]
예제 #2
0
def test_get_energy():
    N = int(len(Test_Labels[:, 0]))
    Positions = np.zeros((N, 3))
    Positions[:, 0] = np.linspace(0.1, Test_L[0], N, endpoint=False)
    Positions[:, 1] = np.linspace(0.1, Test_L[1], N, endpoint=False)
    Positions[:, 2] = np.linspace(0.1, Test_L[2], N, endpoint=False)
    np.random.shuffle(Positions[:, 0])
    np.random.shuffle(Positions[:, 1])
    np.random.shuffle(Positions[:, 2])
    Velocities = maxwellboltzmann().sample_distribution(N, Test_Labels[:, 0], ip.T)
    Forces = np.zeros(Velocities.shape)

    MDobj = md(positions=Positions, properties=Test_Labels, velocities=Velocities, forces=Forces, box=Test_L,
              Temperature=ip.T, Sigma_LJ=ip.sigma, Epsilon_LJ=ip.epsilon, r_switch=r_switch, r_cut_LJ=ip.r_cut_LJ,
              n_boxes_short_range=n_boxes_short_range, dt=ip.dt, p_rea=10 ** -2, p_error=ip.p, Symbols=Symbols)

    assert isinstance(MDobj,md) == True, "The md Object could not be created"
    assert isinstance(MDobj.get_energy(), float) == True, "The energy is not a number"
    assert len(MDobj.get_potential()) == N, "The potential vector size does not match the particle number"
    assert MDobj.get_forces().shape == np.zeros((N,3)).shape, "The forces array does not match the expected size"
    assert isinstance(MDobj.get_Temperature(), float) == True, "The temperature is not a number"
    return
예제 #3
0
파일: test.py 프로젝트: jeberle/ws
def test_md():
    title, body = md('files/md.md')
    open('files/last.html', 'w').write(body.encode('utf-8'))
    assert title == ''
    assert body == unicode(open('files/md.html').read(), encoding='utf-8').rstrip()
from md import md

x = md()
x.a.b = 1
x.a.c = [1, 2, 3]

y = md()
y.q.w.e = 999
x.a.d = y

d = x.exportDict()

print x  # json format
print d  # native dict to string from python
예제 #5
0
from md import md

x = md()
x.l1.l2.l3.name = "John Doe"
x.l1.l2.l3.score += 5
x.l1.l2.l3.score += 3

# will result in the 'score' property with the value 8
# the md library detects that an increment and initializes the values with 0
print x
예제 #6
0
def make_md(text):
    text = re.sub(r"(<code>)(<em>)", r"\2\1", text)
    text = re.sub(r"(</em>)(</code>)", r"\2\1", text)
    return md(text, heading_style=ATX)
예제 #7
0
파일: md_test.py 프로젝트: winpat/md
def test_list(text, expected):
    assert md(text) == [expected]
예제 #8
0
파일: md_test.py 프로젝트: winpat/md
def test_paragraph():
    assert md("Hello World!") == [Paragraph("Hello World!")]
예제 #9
0
파일: md_test.py 프로젝트: winpat/md
def test_empty_lines(text):
    assert md(text) == []
예제 #10
0
파일: md_test.py 프로젝트: winpat/md
def test_headers(text, expected):
    assert md(text) == [expected]
from md import md

x = {"a": 1, "b": {"c": 2, "d": [{"t": 1, "r": 2}, {"t": 3, "r": 4}]}}

y = md.createFromDict(**x)

z = md()
z.importDict(**x)

# the following should be the same
print y
print z