From 31bf8a717e18d0106e7e4b0b6932fb3404594ac0 Mon Sep 17 00:00:00 2001 From: Thorsten Vitt Date: Sat, 10 Oct 2020 17:59:29 +0200 Subject: [PATCH] Fixed some warnings and deprecations. This includes the warning from #6, although the underlying task of refactoring the inheritance stuff still needs to be tackled (#7). --- delta/cluster.py | 2 +- delta/corpus.py | 6 +++++- delta/deltas.py | 5 ++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/delta/cluster.py b/delta/cluster.py index 8ff7560..dde2775 100644 --- a/delta/cluster.py +++ b/delta/cluster.py @@ -193,7 +193,7 @@ def evaluate(self): Returns: pandas.Series: All scores for the current clustering """ - result = pd.Series() + result = pd.Series(dtype='float64') result["Cluster Errors"] = self.cluster_errors() result["Adjusted Rand Index"] = self.adjusted_rand_index() result["Homogeneity"], result["Completeness"], result["V Measure"] = \ diff --git a/delta/corpus.py b/delta/corpus.py index 55283f9..5f1dcce 100644 --- a/delta/corpus.py +++ b/delta/corpus.py @@ -10,6 +10,8 @@ class which represents the feature matrix. Also contained are default import os import glob from fnmatch import fnmatch +from typing import Type + import regex as re import pandas as pd import collections @@ -249,6 +251,8 @@ def __init__(self, operation): class Corpus(pd.DataFrame): + _metadata = ['metadata'] + def __init__(self, subdir=None, file=None, corpus=None, feature_generator=FeatureGenerator(), document_describer=DefaultDocumentDescriber(), @@ -444,7 +448,7 @@ def _load_wordlist(self, filename, **kwargs): Yields: Features from the given file """ - ENTRY = re.compile('\s*([^#]+)') + ENTRY = re.compile(r'\s*([^#]+)') with open(filename, 'r', **kwargs) as f: for line in f: match = ENTRY.match(line) diff --git a/delta/deltas.py b/delta/deltas.py index 0c005ba..419986e 100644 --- a/delta/deltas.py +++ b/delta/deltas.py @@ -600,6 +600,9 @@ def __call__(self, corpus): class DistanceMatrix(pd.DataFrame): + + _metadata = ['metadata'] + """ A distance matrix is the result of applying a :class:`DeltaFunction` to a :class:`Corpus`. @@ -781,7 +784,7 @@ def evaluate(self): Returns: pandas.Series: All scores implemented for distance matrixes """ - result = pd.Series() + result = pd.Series(dtype='float64') result["F-Ratio"] = self.f_ratio() result["Fisher's LD"] = self.fisher_ld() result["Simple Score"] = self.simple_score()