コード例 #1
0
ファイル: test_core.py プロジェクト: pavoljuhas/periodictable
def test():
    # Check that we can access element properties
    assert H.name == "hydrogen"
    assert H.symbol == "H"
    assert H.number == 1
    assert helium.symbol == 'He'

    # Check that isotopes work and produce the correct strings and symbols
    O.add_isotope(18)
    assert H[2].symbol == 'D'
    assert H[3].symbol == 'T'
    assert O[18].symbol == 'O'
    assert str(H[2]) == 'D'
    assert str(H[3]) == 'T'
    assert str(O[18]) == '18-O'
    try:
        Fe[12]
    except KeyError as msg:
        assert msg.args[0] == '12 is not an isotope of Fe'

    # Check that "for el in elements" works and for iso in el works
    els = tuple(el for el in elements)
    assert els[0].number == 0
    assert els[1].number == 1
    isotopes = tuple(iso for iso in O)
    assert isotopes[0].isotope == 12  # 12 is the first oxygen isotope listed

    # Check that table lookup works and fails appropriately
    Fe.add_isotope(56)
    assert elements.symbol('Fe') == Fe
    assert elements.name('iron') == Fe
    assert elements.isotope('Fe') == Fe
    assert elements.isotope('56-Fe') == Fe[56]
    assert elements.isotope('D') == H[2]
    try:
        elements.symbol('Qu')
    except ValueError as msg:
        assert str(msg) == "unknown element Qu"
    try:
        elements.name('Qu')
    except ValueError as msg:
        assert str(msg) == "unknown element Qu"
    try:
        elements.isotope('Qu')
    except ValueError as msg:
        assert str(msg) == "unknown element Qu"
    try:
        elements.isotope('4-D')
    except ValueError as msg:
        assert str(msg) == "unknown element 4-D"

    # Check that ions work
    assert Fe.ion[2].charge == 2
    assert Fe.ions == (-4, -2, -1, 1, 2, 3, 4, 5, 6, 7)
    assert str(Fe.ion[2]) == "Fe{2+}"
    assert str(O.ion[-2]) == "O{2-}"
    try:
        Fe.ion[-3]
        raise Exception("accepts invalid ions")
    except ValueError as msg:
        assert str(msg) == "-3 is not a valid charge for Fe"

    assert data_files()[0][0] == "periodictable-data/xsf"
コード例 #2
0
ファイル: setup_py2app.py プロジェクト: agreen991/refl1d
import refl1d
import bumps
import periodictable

NAME = 'Refl1D'
# Until we figure out why packages=... doesn't work reliably,
# use py2app_main with explicit imports of everything we
# might need.
#SCRIPT = 'py2app_main.py'
SCRIPT = 'bin/refl1d_gui.py'
VERSION = refl1d.__version__
ICON = 'extra/refl1d.icns'
ID = 'Refl1D'
COPYRIGHT = 'This program is public domain'
DATA_FILES = bumps.data_files() + periodictable.data_files()

plist = dict(
    CFBundleIconFile            = ICON,
    CFBundleName                = NAME,
    CFBundleShortVersionString  = ' '.join([NAME, VERSION]),
    CFBundleGetInfoString       = NAME,
    CFBundleExecutable          = NAME,
    CFBundleIdentifier          = 'gov.nist.ncnr.%s' % ID,
    NSHumanReadableCopyright    = COPYRIGHT
)


app_data = dict(script=SCRIPT, plist=plist)
py2app_opt = dict(argv_emulation=True,
                  packages=packages,
コード例 #3
0
ファイル: setup_py2exe.py プロジェクト: agreen991/refl1d
# Add resource files that need to reside in the same directory as the image.
data_files.append( ('.', [os.path.join(here, 'LICENSE.txt')]) )
data_files.append( ('.', [os.path.join(here, 'README.rst')]) )
data_files.append( ('.', [os.path.join(here, 'bin', 'refl1d_launch.bat')]) )
data_files.append( ('.', [os.path.join(here, 'extra', 'refl1d.ico')]) )

# Add application specific data files from the refl1d\refl1d-data folder.
data_files += bumps.data_files()

# Add data files from the matplotlib\mpl-data folder and its subfolders.
# For matploblib prior to version 0.99 see the examples at the end of the file.
data_files += matplotlib.get_py2exe_datafiles()

# Add data files from the periodictable\xsf folder.
data_files += periodictable.data_files()

# Add example directories and their files.  An empty directory is ignored.
# Note that Inno Setup will determine where these files will be placed such as
# C:\My Documents\... instead of the installation folder.
for path in glob.glob(os.path.join('examples', '*')):
    if os.path.isdir(path):
        for file in glob.glob(os.path.join(path, '*.*')):
            data_files.append( (path, [file]) )
    else:
        data_files.append( ('examples', [path]) )

for path in glob.glob(os.path.join('doc', 'examples', '*')):
    if os.path.isdir(path):
        for file in glob.glob(os.path.join(path, '*.*')):
            data_files.append( (path, [file]) )
コード例 #4
0
ファイル: setup_exe.py プロジェクト: andyfaff/sasview
test_upcoming_dir = os.path.join(path, "test\\upcoming_formats")

matplotlibdatadir = matplotlib.get_data_path()
matplotlibdata = findall(matplotlibdatadir)

site_loc = get_python_lib()
opencl_include_dir = os.path.join(site_loc, "pyopencl", "cl")

data_files = []

if tinycc:
    data_files += tinycc.data_files()

# Copying SLD data
import periodictable
data_files += periodictable.data_files()

import sas.sasgui.perspectives.fitting as fitting
data_files += fitting.data_files()

import sas.sasgui.perspectives.calculator as calculator
data_files += calculator.data_files()

import sas.sasgui.perspectives.invariant as invariant
data_files += invariant.data_files()

import sas.sasgui.guiframe as guiframe
data_files += guiframe.data_files()

# precompile sas models into the sasview build path; doesn't matter too much
# where it is so long as it is a place that will get cleaned up afterwards.
コード例 #5
0
        elements.symbol('Qu')
    except ValueError,msg:
        assert str(msg) == "unknown element Qu"
    try:
        elements.name('Qu')
    except ValueError,msg:
        assert str(msg) == "unknown element Qu"
    try:
        elements.isotope('Qu')
    except ValueError,msg:
        assert str(msg) == "unknown element Qu"
    try:
        elements.isotope('4-D')
    except ValueError,msg:
        assert str(msg) == "unknown element 4-D"

    # Check that ions work
    assert Fe.ion[2].charge==2
    assert Fe.ions == (2,3)
    assert str(Fe.ion[2]) == "Fe^{2+}"
    assert str(O.ion[-2]) == "O^{2-}"
    try:
        Fe.ion[1]
        raise Exception("accepts invalid ions")
    except ValueError,msg:
        assert str(msg) == "1 is not a valid charge for Fe"

    assert data_files()[0][0] == "periodictable-data/xsf"

if __name__ == "__main__": test()
コード例 #6
0
# Adapted from http://www.py2exe.org/index.cgi/MatPlotLib
# to use the MatPlotLib.
#
path = os.getcwd()

matplotlibdatadir = matplotlib.get_data_path()
matplotlibdata = findall(matplotlibdatadir)

DATA_FILES = []

if tinycc:
    DATA_FILES += tinycc.data_files()

# Copying SLD data
import periodictable
DATA_FILES += periodictable.data_files()

from sas.sasgui.perspectives import fitting
DATA_FILES += fitting.data_files()

from sas.sasgui.perspectives import calculator
DATA_FILES += calculator.data_files()

from sas.sasgui.perspectives import invariant
DATA_FILES += invariant.data_files()

from sas.sasgui import guiframe
DATA_FILES += guiframe.data_files()

# precompile sas models into the sasview build path; doesn't matter too much
# where it is so long as it is a place that will get cleaned up afterwards.
コード例 #7
0
import refl1d
import bumps
import periodictable

NAME = 'Refl1D'
# Until we figure out why packages=... doesn't work reliably,
# use py2app_main with explicit imports of everything we
# might need.
#SCRIPT = 'py2app_main.py'
SCRIPT = 'bin/refl1d_gui.py'
VERSION = refl1d.__version__
ICON = 'extra/refl1d.icns'
ID = 'Refl1D'
COPYRIGHT = 'This program is public domain'
DATA_FILES = bumps.data_files() + periodictable.data_files()

plist = dict(CFBundleIconFile=ICON,
             CFBundleName=NAME,
             CFBundleShortVersionString=' '.join([NAME, VERSION]),
             CFBundleGetInfoString=NAME,
             CFBundleExecutable=NAME,
             CFBundleIdentifier='gov.nist.ncnr.%s' % ID,
             NSHumanReadableCopyright=COPYRIGHT)

app_data = dict(script=SCRIPT, plist=plist)
py2app_opt = dict(argv_emulation=True,
                  packages=packages,
                  includes=includes,
                  excludes=excludes,
                  iconfile=ICON,
コード例 #8
0
def test():
    # Check that we can access element properties
    assert H.name == "hydrogen"
    assert H.symbol == "H"
    assert H.number == 1
    assert helium.symbol == 'He'

    # Check that isotopes work and produce the correct strings and symbols
    O.add_isotope(18)
    assert H[2].symbol == 'D'
    assert H[3].symbol == 'T'
    assert O[18].symbol == 'O'
    assert str(H[2]) == 'D'
    assert str(H[3]) == 'T'
    assert str(O[18]) == '18-O'
    try:
        Fe[12]
    except KeyError as msg:
        assert msg.args[0] == '12 is not an isotope of Fe'

    # Check that "for el in elements" works and for iso in el works
    els = tuple(el for el in elements)
    assert els[0].number == 0
    assert els[1].number == 1
    isotopes = tuple(iso for iso in O)
    assert isotopes[0].isotope == 12  # 12 is the first oxygen isotope listed

    # Check that table lookup works and fails appropriately
    Fe.add_isotope(56)
    assert elements.symbol('Fe') == Fe
    assert elements.name('iron') == Fe
    assert elements.isotope('Fe') == Fe
    assert elements.isotope('56-Fe') == Fe[56]
    assert elements.isotope('D') == H[2]
    try:
        elements.symbol('Qu')
    except ValueError as msg:
        assert str(msg) == "unknown element Qu"
    try:
        elements.name('Qu')
    except ValueError as msg:
        assert str(msg) == "unknown element Qu"
    try:
        elements.isotope('Qu')
    except ValueError as msg:
        assert str(msg) == "unknown element Qu"
    try:
        elements.isotope('4-D')
    except ValueError as msg:
        assert str(msg) == "unknown element 4-D"

    # Check that ions work
    assert Fe.ion[2].charge == 2
    assert Fe.ions == (2, 3)
    assert str(Fe.ion[2]) == "Fe{2+}"
    assert str(O.ion[-2]) == "O{2-}"
    try:
        Fe.ion[1]
        raise Exception("accepts invalid ions")
    except ValueError as msg:
        assert str(msg) == "1 is not a valid charge for Fe"

    assert data_files()[0][0] == "periodictable-data/xsf"