Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.4.7 #84

Merged
merged 5 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "fasttrackpy"
version = "0.4.6"
version = "0.4.7"
description = "A python implementation of FastTrack"
authors = [
"JoFrhwld <[email protected]>",
Expand Down Expand Up @@ -30,10 +30,11 @@ python-magic-bin = {version = "^0.4.14", markers = "sys_platform == 'win32'"}
click = "^8.1.7"
cloup = "^3.0.3"
matplotlib = "^3.8.2"
aligned-textgrid = "^0.6.2"
aligned-textgrid = "^0.6.7"
tqdm = "^4.66.1"
joblib = "^1.3.2"
pyyaml = "^6.0.1"
cloudpickle = "^3.0.0"

[tool.poetry.group.dev.dependencies]
jupyter = "^1.0.0"
Expand Down
13 changes: 7 additions & 6 deletions src/fasttrackpy/processors/outputs.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import numpy as np
import pickle
import cloudpickle
import parselmouth as pm
import polars as pl
from aligned_textgrid import SequenceInterval
from pathlib import Path
import matplotlib.pyplot as mp
import copy
import logging
import sys

ptolmap = {"F1" :"#4477AA",
"F1_s": "#4477AA",
Expand Down Expand Up @@ -425,11 +426,11 @@ def pickle_candidates(
"""
if type(file) is str:
file = Path(file)

tmp_candidates = copy.deepcopy (candidates)
sys.setrecursionlimit(3000)
#tmp_candidates = copy.deepcopy (candidates)

with file.open('wb') as f:
pickle.dump(tmp_candidates, f)
cloudpickle.dump(candidates, f)


def unpickle_candidates(
Expand All @@ -450,8 +451,8 @@ def unpickle_candidates(
"""
if type(file) is str:
file = Path(file)

sys.setrecursionlimit(3000)
with file.open('rb') as f:
candidates = pickle.load(f)
candidates = cloudpickle.load(f)

return candidates
16 changes: 15 additions & 1 deletion tests/test_outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
pickle_candidates,\
unpickle_candidates
from fasttrackpy.patterns.just_audio import process_audio_file
from fasttrackpy import process_audio_textgrid
import parselmouth as pm
import polars as pl
import numpy as np
Expand Down Expand Up @@ -142,6 +143,7 @@ def test_save_cand_spectrogram(self, tmp_path):

class TestPickle:
cands = CandidateTracks(SOUND)


def test_pickle_unpickle(self, tmp_path):
pickle_file = tmp_path / "cand.pkl"
Expand All @@ -154,4 +156,16 @@ def test_pickle_unpickle(self, tmp_path):
re_read.winner.maximum_formant,
self.cands.winner.maximum_formant
)
assert len(re_read.candidates) == len(self.cands.candidates)
assert len(re_read.candidates) == len(self.cands.candidates)

def test_big_pickle_unpickle(self, tmp_path):
cands2 = process_audio_textgrid(
audio_path=Path("tests", "test_data", "corpus", "josef-fruehwald_speaker.wav"),
textgrid_path=Path("tests", "test_data", "corpus", "josef-fruehwald_speaker.TextGrid"),
)
pickle_file = tmp_path / "cand2.pkl"
pickle_candidates(cands2[0], file = pickle_file)
assert pickle_file.exists()

re_read = unpickle_candidates(file = pickle_file)
assert len(re_read.candidates) == len(cands2[0].candidates)
Loading