<s> '''<STR_LIT>''' <EOL> import numpy as np <EOL> import muda <EOL> import jams <EOL> import librosa <EOL> import tempfile <EOL> import os <EOL> from nose . tools import eq_ , raises <EOL> def test_jam_pack ( ) : <EOL> jam = jams . JAMS ( ) <EOL> sr = <NUM_LIT> <EOL> y = np . zeros ( sr ) <EOL> muda . jam_pack ( jam , y = y , sr = sr ) <EOL> assert hasattr ( jam . sandbox , '<STR_LIT>' ) <EOL> assert hasattr ( jam . sandbox . muda , '<STR_LIT>' ) <EOL> assert hasattr ( jam . sandbox . muda , '<STR_LIT:state>' ) <EOL> assert jam . sandbox . muda [ '<STR_LIT:y>' ] is y <EOL> assert jam . sandbox . muda [ '<STR_LIT>' ] == sr <EOL> def test_load_jam_audio ( ) : <EOL> def __test ( jam_in , audio_file ) : <EOL> jam = muda . load_jam_audio ( jam_in , audio_file ) <EOL> assert hasattr ( jam . sandbox , '<STR_LIT>' ) <EOL> eq_ ( jam . file_metadata . duration , <EOL> librosa . get_duration ( ** jam . sandbox . muda . _audio ) ) <EOL> yield __test , '<STR_LIT>' , '<STR_LIT>' <EOL> yield __test , jams . load ( '<STR_LIT>' ) , '<STR_LIT>' <EOL> with open ( '<STR_LIT>' , '<STR_LIT:r>' ) as fdesc : <EOL> yield __test , fdesc , '<STR_LIT>' <EOL> def test_save ( ) : <EOL> jam = muda . load_jam_audio ( '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> _ , jamfile = tempfile . mkstemp ( suffix = '<STR_LIT>' ) <EOL> _ , audfile = tempfile . mkstemp ( suffix = '<STR_LIT>' ) <EOL> muda . save ( audfile , jamfile , jam ) <EOL> jam2 = muda . load_jam_audio ( jamfile , audfile ) <EOL> jam2_raw = jams . load ( jamfile ) <EOL> os . unlink ( audfile ) <EOL> os . unlink ( jamfile ) <EOL> assert hasattr ( jam2 . sandbox , '<STR_LIT>' ) <EOL> assert '<STR_LIT>' in jam2 . sandbox . muda <EOL> assert '<STR_LIT>' not in jam2_raw . sandbox . muda <EOL> eq_ ( jam2 . file_metadata . duration , <EOL> librosa . get_duration ( ** jam2 . sandbox . muda [ '<STR_LIT>' ] ) ) <EOL> def test_serialize_deformer ( ) : <EOL> D = muda . deformers . LogspaceTimeStretch ( ) <EOL> D_ser = muda . serialize ( D ) <EOL> D2 = muda . deserialize ( D_ser ) <EOL> eq_ ( D . get_params ( ) , D2 . get_params ( ) ) <EOL> assert D is not D2 <EOL> def test_serialize_pipeline ( ) : <EOL> D1 = muda . deformers . LogspaceTimeStretch ( ) <EOL> D2 = muda . deformers . LogspaceTimeStretch ( ) <EOL> P_orig = muda . Pipeline ( [ ( '<STR_LIT>' , D1 ) , <EOL> ( '<STR_LIT>' , D2 ) ] ) <EOL> P_ser = muda . serialize ( P_orig ) <EOL> P_new = muda . deserialize ( P_ser ) <EOL> eq_ ( P_orig . get_params ( ) , P_new . get_params ( ) ) <EOL> assert P_orig is not P_new </s>
