<commit_before># -*- coding:utf-8 -*-
# Copyright © 2011 <NAME>, <NAME>

"""
openFisca, Logiciel libre de simulation du système socio-fiscal français
Copyright © 2011 <NAME>, <NAME>

This file is part of openFisca.

    openFisca is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    openFisca is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with openFisca.  If not, see <http://www.gnu.org/licenses/>.
"""

from __future__ import division
import numpy as np
from Config import CONF
from datetime import datetime
import sys, csv
from calmar.calmar import calmar

class Column(object):
    """
    DataSet data item
    
    `label` : (str, unicode)
    `default` : any type, optional
    """
    count = 0
    def __init__(self, label = None, default=None):
        self._order = Column.count
        Column.count += 1
        self._name = None
        self._nrows = None
        self._value = None
        self._label = label
        self._default = default
        self._dtype = None

    def set_name(self, name):
        self._name = name
        
    def get_name(self):
        return self._name

    def set_nrows(self, nrows):
        self._nrows = nrows

    def _init_value(self, nrows):
        self._nrows = nrows
        if not self._dtype: self._dtype= np.float
        self._value = np.ones(nrows, dtype = self._dtype)*self._default

    def get_value(self, index = None, opt = None, dflt = 0, sum_ = False):
        '''
        method to read the value in an array
        index is a dict with the coordinates of each person in the array
            - if index is none, returns the whole column (every person)
            - if index is not none, return an array of length len(unit)
        opt is a dict with the id of the person for which you want the value
            - if opt is None, returns the value for the person 0 (i.e. 'vous' for 'foy', 'chef' for 'fam', 'pref' for 'men')
            - if opt is not None, return a dict with key 'person' and values for this person
        '''
#        try:
        var = self._value
        if index is None:
            return var
        nb = index['nb']
        if self._dtype == np.bool: dflt= (dflt != 0)
        if opt is None:
            temp = np.ones(nb, dtype = self._dtype)*dflt
            idx = index[0]
            temp[idx['idxUnit']] = var[idx['idxIndi']]
            return temp
        else:
            out = {}
            for person in opt:
                temp = np.ones(nb, dtype = self._dtype)*dflt
                idx = index[person]
                temp[idx['idxUnit']] = var[idx['idxIndi']]
                out[person] = temp
            if sum_ is False:
                return out
            else:
                sumout = 0
                for val in out.itervalues():
                    sumout += val
                return sumout
#        except Exception, e:
#            raise Exception('Can not get %s value: %s' % (self._name, e))

    def set_value(self, value, index, opt = None):
        
        print self._name
        # TODO: there should be dtype in Prestation __init__...
        if value.dtype == np.bool:
            self._dtype = np.bool
        
        if opt is None:
        # TODO: check if it's really right?
            idx = index[0]
        else:
            idx = index[opt]
        var = np.array(self._value, dtype = self._dtype)
        val = np.array(value, dtype = self._dtype)
        var[idx['idxIndi']] = val[idx['idxUnit']]
        self._value = var

    def __str__(self):
        return '%s' % self._name

class DataTableMeta(type):<commit_msg>bug fix on credit impot scellier<commit_after># -*- coding:utf-8 -*-
# Copyright © 2011 <NAME>, <NAME>

"""
openFisca, Logiciel libre de simulation du système socio-fiscal français
Copyright © 2011 <NAME>, <NAME>

This file is part of openFisca.

    openFisca is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    openFisca is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with openFisca.  If not, see <http://www.gnu.org/licenses/>.
"""

from __future__ import division
import numpy as np
from Config import CONF
from datetime import datetime
import sys, csv
from calmar.calmar import calmar

class Column(object):
    """
    DataSet data item
    
    `label` : (str, unicode)
    `default` : any type, optional
    """
    count = 0
    def __init__(self, label = None, default=None):
        self._order = Column.count
        Column.count += 1
        self._name = None
        self._nrows = None
        self._value = None
        self._label = label
        self._default = default
        self._dtype = None

    def set_name(self, name):
        self._name = name
        
    def get_name(self):
        return self._name

    def set_nrows(self, nrows):
        self._nrows = nrows

    def _init_value(self, nrows):
        self._nrows = nrows
        if not self._dtype: self._dtype= np.float
        self._value = np.ones(nrows, dtype = self._dtype)*self._default

    def get_value(self, index = None, opt = None, dflt = 0, sum_ = False):
        '''
        method to read the value in an array
        index is a dict with the coordinates of each person in the array
            - if index is none, returns the whole column (every person)
            - if index is not none, return an array of length len(unit)
        opt is a dict with the id of the person for which you want the value
            - if opt is None, returns the value for the person 0 (i.e. 'vous' for 'foy', 'chef' for 'fam', 'pref' for 'men')
            - if opt is not None, return a dict with key 'person' and values for this person
        '''
#        try:
        var = self._value
        if index is None:
            return var
        nb = index['nb']
        if self._dtype == np.bool: dflt= (dflt != 0)
        if opt is None:
            temp = np.ones(nb, dtype = self._dtype)*dflt
            idx = index[0]
            temp[idx['idxUnit']] = var[idx['idxIndi']]
            return temp
        else:
            out = {}
            for person in opt:
                temp = np.ones(nb, dtype = self._dtype)*dflt
                idx = index[person]
                temp[idx['idxUnit']] = var[idx['idxIndi']]
                out[person] = temp
            if sum_ is False:
                return out
            else:
                sumout = 0
                for val in out.itervalues():
                    sumout += val
                return sumout
#        except Exception, e:
#            raise Exception('Can not get %s value: %s' % (self._name, e))

    def set_value(self, value, index, opt = None):
        
        # TODO: there should be dtype in Prestation __init__...
        if value.dtype == np.bool:
            self._dtype = np.bool
        
        if opt is None:
        # TODO: check if it's really right?
            idx = index[0]
        else:
            idx = index[opt]
        var = np.array(self._value, dtype = self._dtype)
        val = np.array(value, dtype = self._dtype)
        var[idx['idxIndi']] = val[idx['idxUnit']]
        self._value = var

    def __str__(self):
        return '%s' % self._name

class DataTableMeta(type):
{'fraction_non_alphanumeric': 0.09067228975440338, 'fraction_numerical': 0.004465393202679236, 'mean_word_length': 1.9266787658802178, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6776241', 'n_tokens_mistral': 2341, 'n_tokens_neox': 2288, 'n_words': 892}