Example #1
0
	def __init__(self, tilesx, tilesy, posx, posy):
		self.tilesx = tilesx
		self.tilesy = tilesy
		
		self.font = pyglet.image.load(data_path("tiles.png")).get_texture()
		self.ch_tex = Texture(tilesx, tilesy, GL_RED, GL_UNSIGNED_BYTE)
		self.fg_tex = Texture(tilesx, tilesy, GL_RGB, GL_UNSIGNED_BYTE)
		self.bg_tex = Texture(tilesx, tilesy, GL_RGB, GL_UNSIGNED_BYTE)
		
		self.shader = Shader(
			data_file("tiles.vert"),
			data_file("tiles.frag")
		)
		self.shader.bind()
		self.shader.uniformf("ntiles", tilesx, tilesy)
		self.shader.uniformf("potsize", self.ch_tex.pot_width, self.ch_tex.pot_height)
		self.shader.uniformf("fontscale", self.font.tex_coords[6], self.font.tex_coords[7])
		self.shader.uniformf("fontbg", 1.0, 0.0, 1.0)
		self.shader.uniformf("nchars", 16.0, 16.0)
		self.shader.unbind()
		
		self.batch = pyglet.graphics.Batch()
		w = tilesx * self.CHAR_WIDTH; h = tilesy * self.CHAR_HEIGHT
		self.batch.add(
			4, GL_QUADS, None,
			("v2f/static", (posx, posy, posx+w, posy, posx+w, posy+h, posx, posy+h)),
			("t2f/static", (0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0))
		)
Example #2
0
    def __init__(self, tilesx, tilesy, posx, posy):
        self.tilesx = tilesx
        self.tilesy = tilesy

        self.font = pyglet.image.load(data_path("tiles.png")).get_texture()
        self.ch_tex = Texture(tilesx, tilesy, GL_RED, GL_UNSIGNED_BYTE)
        self.fg_tex = Texture(tilesx, tilesy, GL_RGB, GL_UNSIGNED_BYTE)
        self.bg_tex = Texture(tilesx, tilesy, GL_RGB, GL_UNSIGNED_BYTE)

        self.shader = Shader(data_file("tiles.vert"), data_file("tiles.frag"))
        self.shader.bind()
        self.shader.uniformf("ntiles", tilesx, tilesy)
        self.shader.uniformf("potsize", self.ch_tex.pot_width,
                             self.ch_tex.pot_height)
        self.shader.uniformf("fontscale", self.font.tex_coords[6],
                             self.font.tex_coords[7])
        self.shader.uniformf("fontbg", 1.0, 0.0, 1.0)
        self.shader.uniformf("nchars", 16.0, 16.0)
        self.shader.unbind()

        self.batch = pyglet.graphics.Batch()
        w = tilesx * self.CHAR_WIDTH
        h = tilesy * self.CHAR_HEIGHT
        self.batch.add(
            4, GL_QUADS, None,
            ("v2f/static",
             (posx, posy, posx + w, posy, posx + w, posy + h, posx, posy + h)),
            ("t2f/static", (0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0)))
Example #3
0
def _load_data(fn):
	data = []
	o = open(data_path(fn))
	for w in re.split("\s+", o.read()):
		if len(w) > 0:
			data.append(w.lower().strip())
	o.close()
	return list(set(data))	
Example #4
0
def _load_data(fn):
    data = []
    o = open(data_path(fn))
    for w in re.split("\s+", o.read()):
        if len(w) > 0:
            data.append(w.lower().strip())
    o.close()
    return list(set(data))
Example #5
0
	def __init__(self, filename):
		self.init()
		f = open(data_path(filename))
		self.all = []
		self.tags = {}
		for line in f.readlines():
			if len(line.strip()) == 0:
				continue
			parts = line.split("|")
			w = self.add_word(parts[0].strip().split(":"))
			self.all.append(w)
			if len(parts) == 2:
				for tag in parts[1].strip().split():
					self.tags.setdefault(tag, []).append(w)
		f.close()
Example #6
0
 def __init__(self, filename):
     self.init()
     f = open(data_path(filename))
     self.all = []
     self.tags = {}
     for line in f.readlines():
         if len(line.strip()) == 0:
             continue
         parts = line.split("|")
         w = self.add_word(parts[0].strip().split(":"))
         self.all.append(w)
         if len(parts) == 2:
             for tag in parts[1].strip().split():
                 self.tags.setdefault(tag, []).append(w)
     f.close()
Example #7
0
File: io.py Project: dmsul/bIncome
from os.path import join

import pandas as pd

from econtools import load_or_build, loadbuild_cli, force_iterable

from util import src_path, data_path
from clean.psid.codebook import family_std, indiv_std

PSID_PATH = src_path('psid')

BANKVARS = ('bank_filed', 'bank_year', 'bank_state',
            'bank_count', 'bank_debt_filed', 'bank_debt_remained',)


@load_or_build(data_path('panel_full.p'))
def load_full_panel(_rebuild_down=False):
    """
    Create full PSID panel, conditional on being interviewed in 1996.

    This does not create any variables or restrict the sample in any way, other
    than starting with 1996 households.
    """

    df = load_individual_panel(_rebuild=_rebuild_down)
    df.index.name = 'person_id'
    # Merge family_1996 and indiv, inner
    match_cols = ('interview_number', 1996)
    this_family = load_family_year(1996, _rebuild=_rebuild_down)
    this_family.index = this_family.pop(match_cols).squeeze().values
    df = df.join(this_family, on=[match_cols], how='inner')
Example #8
0
from __future__ import division, print_function

import numpy as np
import pandas as pd

from econtools import load_or_build

from util import data_path
from clean.psid import load_full_panel


@load_or_build(data_path('nonbankruptpeople2.dta'))
def load_nonbankrupt_panel(_rebuild_down=False):

    df = uniform_cleaning(_rebuild_down=_rebuild_down)
    df = df.query('bank_filed == 0').copy()

    return df


@load_or_build(data_path('bankruptpeople2.dta'))
def load_bankrupt_panel(_rebuild_down=False):

    df = uniform_cleaning(_rebuild_down=_rebuild_down)
    df = df.query('bank_filed == 1').copy()

    df['event_year'] = df['year'] - df['bank_year']

    # Restrict to filling years after 1985
    df = df[df['event_year'].notnull()].copy()
    df = df[df['bank_year'] >= 1985].copy()
def packages_path(*args):
    '''
    Get path to the packages directory.
    '''
    return util.data_path('packages')
def package_path(package, *args):
    '''
    Get path to a package data directory or file.
    '''
    return util.data_path('packages', package, *args)
Example #11
0
from util import src_path, data_path
from clean.psid.codebook import family_std, indiv_std

PSID_PATH = src_path('psid')

BANKVARS = (
    'bank_filed',
    'bank_year',
    'bank_state',
    'bank_count',
    'bank_debt_filed',
    'bank_debt_remained',
)


@load_or_build(data_path('panel_full.p'))
def load_full_panel(_rebuild_down=False):
    """
    Create full PSID panel, conditional on being interviewed in 1996.

    This does not create any variables or restrict the sample in any way, other
    than starting with 1996 households.
    """

    df = load_individual_panel(_rebuild=_rebuild_down)
    df.index.name = 'person_id'
    # Merge family_1996 and indiv, inner
    match_cols = ('interview_number', 1996)
    this_family = load_family_year(1996, _rebuild=_rebuild_down)
    this_family.index = this_family.pop(match_cols).squeeze().values
    df = df.join(this_family, on=[match_cols], how='inner')
def service_path(service, *args):
    '''
    Get path to a service data directory or file.
    '''
    return util.data_path('service', service, *args)
def services_path():
    '''
    Get path to the services data directory.
    '''
    return util.data_path('service')
Example #14
0
from __future__ import division, print_function

import numpy as np
import pandas as pd

from econtools import load_or_build

from util import data_path
from clean.psid import load_full_panel


@load_or_build(data_path('nonbankruptpeople2.dta'))
def load_nonbankrupt_panel(_rebuild_down=False):

    df = uniform_cleaning(_rebuild_down=_rebuild_down)
    df = df.query('bank_filed == 0').copy()

    return df

@load_or_build(data_path('bankruptpeople2.dta'))
def load_bankrupt_panel(_rebuild_down=False):

    df = uniform_cleaning(_rebuild_down=_rebuild_down)
    df = df.query('bank_filed == 1').copy()

    df['event_year'] = df['year'] - df['bank_year']

    # Restrict to filling years after 1985
    df = df[df['event_year'].notnull()].copy()
    df = df[df['bank_year'] >= 1985].copy()
def _logfile():
    return util.data_path('monit.log')
def _cfgfile():
    return util.data_path('monit.rc')