<s> """<STR_LIT>""" <EOL> import unittest <EOL> from nose . tools import assert_raises <EOL> import os <EOL> import multiprocessing as mp <EOL> try : <EOL> import zmq <EOL> except : <EOL> zmq = None <EOL> import pylearn2 <EOL> from pylearn2 . scripts . train import train <EOL> import pylearn2 . train_extensions . live_monitoring as lm <EOL> def verify_zmq ( ) : <EOL> """<STR_LIT>""" <EOL> if zmq is None : <EOL> raise unittest . SkipTest <EOL> def train_mlp ( ) : <EOL> """<STR_LIT>""" <EOL> train ( os . path . join ( <EOL> pylearn2 . __path__ [ <NUM_LIT:0> ] , <EOL> '<STR_LIT>' <EOL> ) ) <EOL> def test_live_monitoring ( ) : <EOL> """<STR_LIT>""" <EOL> verify_zmq ( ) <EOL> p = mp . Process ( target = train_mlp ) <EOL> p . start ( ) <EOL> correct_result = set ( [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' <EOL> ] ) <EOL> monitor = lm . LiveMonitor ( ) <EOL> result = set ( monitor . list_channels ( ) . data ) <EOL> if result != correct_result : <EOL> raise ValueError ( str ( result ) ) <EOL> assert ( result == correct_result ) <EOL> monitor = lm . LiveMonitor ( ) <EOL> monitor . update_channels ( [ '<STR_LIT>' ] , start = <NUM_LIT:0> , end = <NUM_LIT:2> ) <EOL> assert ( len ( monitor . channels [ '<STR_LIT>' ] . val_record ) == <NUM_LIT:2> ) <EOL> monitor = lm . LiveMonitor ( ) <EOL> monitor . update_channels ( [ '<STR_LIT>' ] , start = <NUM_LIT:1> , end = <NUM_LIT:2> ) <EOL> assert ( len ( monitor . channels [ '<STR_LIT>' ] . val_record ) == <NUM_LIT:1> ) <EOL> p . join ( ) <EOL> assert_raises ( <EOL> AssertionError , <EOL> monitor . update_channels , <EOL> <NUM_LIT:0> <EOL> ) <EOL> assert_raises ( <EOL> AssertionError , <EOL> monitor . update_channels , <EOL> [ ] <EOL> ) <EOL> assert_raises ( <EOL> AssertionError , <EOL> monitor . update_channels , <EOL> [ '<STR_LIT>' ] , start = <NUM_LIT:2> , end = <NUM_LIT:1> <EOL> ) </s>
