Skip to content

Commit

Permalink
vm updates
Browse files Browse the repository at this point in the history
  • Loading branch information
JoFrhwld committed Apr 1, 2024
1 parent 1003fe6 commit 6826d49
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 6 deletions.
18 changes: 17 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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"]
Expand Down
17 changes: 12 additions & 5 deletions src/new_fave/measurements/vowel_measurement.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 6826d49

Please sign in to comment.