From 6826d4954cf3e7e9e5c625cb7795efc69d5bb83a Mon Sep 17 00:00:00 2001 From: JoFrhwld Date: Mon, 1 Apr 2024 12:07:38 -0400 Subject: [PATCH] vm updates --- poetry.lock | 18 +++++++++++++++++- pyproject.toml | 2 ++ src/new_fave/measurements/vowel_measurement.py | 17 ++++++++++++----- 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/poetry.lock b/poetry.lock index 668292b..c339701 100644 --- a/poetry.lock +++ b/poetry.lock @@ -705,6 +705,22 @@ files = [ {file = "defusedxml-0.7.1.tar.gz", hash = "sha256:1bb3032db185915b62d7c6209c5a8792be6a32ab2fedacc84e01b52c51aa3e69"}, ] +[[package]] +name = "dill" +version = "0.3.8" +description = "serialize all of Python" +category = "dev" +optional = false +python-versions = ">=3.8" +files = [ + {file = "dill-0.3.8-py3-none-any.whl", hash = "sha256:c36ca9ffb54365bdd2f8eb3eff7d2a21237f8452b57ace88b1ac615b7e815bd7"}, + {file = "dill-0.3.8.tar.gz", hash = "sha256:3ebe3c479ad625c4553aca177444d89b486b1d84982eeacded644afc0cf797ca"}, +] + +[package.extras] +graph = ["objgraph (>=1.7.2)"] +profile = ["gprof2dot (>=2022.7.29)"] + [[package]] name = "executing" version = "2.0.1" @@ -3532,4 +3548,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "p [metadata] lock-version = "2.0" python-versions = ">=3.11,<3.12" -content-hash = "0a9a6856bf72497805e863b3252e8d080dcd59dbe0d5e4003f5dec03caf5d5b9" +content-hash = "25ff88f4c4a4ddc6ccf003250affd04cf3ab8e51a9850056f52d1d88537a68b5" diff --git a/pyproject.toml b/pyproject.toml index 3da832b..0dacb7e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,6 +13,7 @@ aligned-textgrid = "^0.6.3" fasttrackpy = "^0.4.0" numpy = "^1.26.4" polars = "<0.20" +tqdm = "^4.66.2" [tool.poetry.group.docs.dependencies] @@ -25,6 +26,7 @@ jupyter = "^1.0.0" [tool.poetry.group.dev.dependencies] ipykernel = "^6.29.2" matplotlib = "^3.8.3" +dill = "^0.3.8" [build-system] requires = ["poetry-core"] diff --git a/src/new_fave/measurements/vowel_measurement.py b/src/new_fave/measurements/vowel_measurement.py index 7114522..5f59583 100644 --- a/src/new_fave/measurements/vowel_measurement.py +++ b/src/new_fave/measurements/vowel_measurement.py @@ -7,11 +7,18 @@ import warnings +def blank(): + return VowelClass() + +def blank_list(): + return [] + class VowelClassCollection(defaultdict): def __init__(self, track_list:list, param_optim = 3): - super().__init__(lambda : VowelClass()) + + super().__init__(blank) self.param_optim = param_optim - self.tracks_dict = defaultdict(lambda: []) + self.tracks_dict = defaultdict(blank_list) self._make_tracks_dict(track_list) self._dictify() self._vowel_system() @@ -119,14 +126,14 @@ def winners_maximum_formant(self): @property def params_means(self): N = len(self.tracks) - winner_mean = self.winner_param_norm.reshape(-1, N).mean(axis = 1) + winner_mean = self.winner_params.reshape(-1, N).mean(axis = 1) winner_mean = winner_mean[:, np.newaxis] return winner_mean @property def params_covs(self): N = len(self.tracks) - square_param = self.winner_param_norm.reshape(-1, N) + square_param = self.winner_params.reshape(-1, N) with warnings.catch_warnings(): warnings.simplefilter("ignore") param_cov = np.cov(square_param) @@ -242,7 +249,7 @@ def cand_errors(self): @property def cand_mahals(self): N = len(self.candidates) - square_params = self.cand_param_norm.reshape(-1, N) + square_params = self.cand_params.reshape(-1, N) inv_covmat = self.vowel_class.params_icov x_mu = square_params - self.vowel_class.params_means left = np.dot(x_mu.T, inv_covmat)