I am experiencing a different error. I am getting the following complaint:

Traceback (most recent call last):
  File "/server1/users/jonathan/creations/inventions/software/insight/alchemy", line 5798, in ?
    init()
  File "/server1/users/jonathan/creations/inventions/software/insight/alchemy", line 5470, in init
    database_init()
  File "/server1/users/jonathan/creations/inventions/software/insight/alchemy", line 4980, in database_init
    histogram.mapper = sqlalchemy.mapper(histogram, histogram_table)
  File "/usr/lib/python2.4/site-packages/PIL/__init__.py", line 75, in mapper

  File "build/bdist.linux-i686/egg/sqlalchemy/mapping/mapper.py", line 61, in __init__
TypeError: Class 'histogram' is not a new-style class

The line being complained about is:

        histogram.mapper = sqlalchemy.mapper(histogram, histogram_table)

Class histogram is defined as:

class histogram(ancestor):
    """Class for a (possibly weighted) histogram."""
    def __init__(self):
        ancestor.__init__(self)
        self.occurrences = {}
        self.total_occurrences = 0
    def add_occurrence(self, category, number=1):
        if category in sequence(self.occurrences):
            self.occurrences[category] += number
        else:
            self.occurrences[category] = number
        self.total_occurrences += number
    def finalize(self):
        occurrences_as_list = []
        for word in sequence(self.occurrences):
            occurrences_as_list.append((word, self.occurrences[word]))
        sort_by_item(occurrences_as_list, 0)
        self.finalized_data = tuple(occurrences_as_list)
        #self.occurrences = None
    def get_occurrences(self, category):
        if self.occurrences == None:
            result = binary_search(self.finalized_data, category, (0,0))[1]
            return result
        else:
            if category in sequence(self.occurrences):
                return self.occurrences[category]
            else:
                return 0
    def get_proportion(self, category):
        if self.total_occurrences > 0:
            return float(self.get_occurrences(category)) / \
              float(self.total_occurrences)
        else:
            return 0
    def get_score(self, other_histogram, thesaurus = None):
        if self.total_occurrences == 0 or \
          other_histogram.total_occurrences == 0:
            return 0
        else:
            numerator = 0
            for key in sequence(self.occurrences):
                if thesaurus == None:
                    numerator += self.get_occurrences(key) * \
                      other_histogram.get_occurrences(key)
                else:
                    if thesaurus.contains(key):
                        numerator += self.get_occurrences(key) * \
                          other_histogram.get_occurrences(key)
            denominator = self.total_occurrences * \
              other_histogram.total_occurrences
            return float(numerator) / float(denominator)
    def get_total_occurrences(self):
        return total_occurrences
    def get_words(self):
        return self.occurrences.keys()
    def remove_occurrence(self, category, number=1):
        if category in sequence(self.occurrences):
            difference = min(number, self.occurrences[category])
            self.occurrences[category] -= number
            if self.occurrences[category] <= 0:
                del self.occurrences[category]
            self.total_occurrences -= min



--
++ Jonathan Hayward, [EMAIL PROTECTED]
** To see an award-winning website with stories, essays, artwork,
** games, and a four-dimensional maze, why not visit my home page?
** All of this is waiting for you at http://JonathansCorner.com

** If you'd like a Google Mail (gmail.com) account, please tell me!

Reply via email to