<s> """<STR_LIT>""" <EOL> from __future__ import absolute_import , division , print_function <EOL> import numpy as np <EOL> import matplotlib . pyplot as plt <EOL> try : <EOL> import mpmath <EOL> except : <EOL> from sympy import mpmath <EOL> def err_metric ( a , b , atol = <NUM_LIT> ) : <EOL> m = abs ( a - b ) / ( atol + abs ( b ) ) <EOL> m [ np . isinf ( b ) & ( a == b ) ] = <NUM_LIT:0> <EOL> return m <EOL> def do_plot ( is_h = True ) : <EOL> from scipy . special . _ufuncs import _struve_power_series , _struve_asymp_large_z , _struve_bessel_series <EOL> vs = np . linspace ( - <NUM_LIT:1000> , <NUM_LIT:1000> , <NUM_LIT> ) <EOL> zs = np . sort ( np . r_ [ <NUM_LIT> , <NUM_LIT:1.0> , np . linspace ( <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT> ) [ <NUM_LIT:1> : ] ] ) <EOL> rp = _struve_power_series ( vs [ : , None ] , zs [ None , : ] , is_h ) <EOL> ra = _struve_asymp_large_z ( vs [ : , None ] , zs [ None , : ] , is_h ) <EOL> rb = _struve_bessel_series ( vs [ : , None ] , zs [ None , : ] , is_h ) <EOL> mpmath . mp . dps = <NUM_LIT:50> <EOL> if is_h : <EOL> sh = lambda v , z : float ( mpmath . struveh ( mpmath . mpf ( v ) , mpmath . mpf ( z ) ) ) <EOL> else : <EOL> sh = lambda v , z : float ( mpmath . struvel ( mpmath . mpf ( v ) , mpmath . mpf ( z ) ) ) <EOL> ex = np . vectorize ( sh , otypes = '<STR_LIT:d>' ) ( vs [ : , None ] , zs [ None , : ] ) <EOL> err_a = err_metric ( ra [ <NUM_LIT:0> ] , ex ) + <NUM_LIT> <EOL> err_p = err_metric ( rp [ <NUM_LIT:0> ] , ex ) + <NUM_LIT> <EOL> err_b = err_metric ( rb [ <NUM_LIT:0> ] , ex ) + <NUM_LIT> <EOL> err_est_a = abs ( ra [ <NUM_LIT:1> ] / ra [ <NUM_LIT:0> ] ) <EOL> err_est_p = abs ( rp [ <NUM_LIT:1> ] / rp [ <NUM_LIT:0> ] ) <EOL> err_est_b = abs ( rb [ <NUM_LIT:1> ] / rb [ <NUM_LIT:0> ] ) <EOL> z_cutoff = <NUM_LIT> * abs ( vs ) + <NUM_LIT:12> <EOL> levels = [ - <NUM_LIT:1000> , - <NUM_LIT:12> ] <EOL> plt . cla ( ) <EOL> plt . hold ( <NUM_LIT:1> ) <EOL> plt . contourf ( vs , zs , np . log10 ( err_p ) . T , levels = levels , colors = [ '<STR_LIT:r>' , '<STR_LIT:r>' ] , alpha = <NUM_LIT:0.1> ) <EOL> plt . contourf ( vs , zs , np . log10 ( err_a ) . T , levels = levels , colors = [ '<STR_LIT:b>' , '<STR_LIT:b>' ] , alpha = <NUM_LIT:0.1> ) <EOL> plt . contourf ( vs , zs , np . log10 ( err_b ) . T , levels = levels , colors = [ '<STR_LIT:g>' , '<STR_LIT:g>' ] , alpha = <NUM_LIT:0.1> ) <EOL> plt . contour ( vs , zs , np . log10 ( err_p ) . T , levels = levels , colors = [ '<STR_LIT:r>' , '<STR_LIT:r>' ] , linestyles = [ '<STR_LIT::>' , '<STR_LIT::>' ] ) <EOL> plt . contour ( vs , zs , np . log10 ( err_a ) . T , levels = levels , colors = [ '<STR_LIT:b>' , '<STR_LIT:b>' ] , linestyles = [ '<STR_LIT::>' , '<STR_LIT::>' ] ) <EOL> plt . contour ( vs , zs , np . log10 ( err_b ) . T , levels = levels , colors = [ '<STR_LIT:g>' , '<STR_LIT:g>' ] , linestyles = [ '<STR_LIT::>' , '<STR_LIT::>' ] ) <EOL> lp = plt . contour ( vs , zs , np . log10 ( err_est_p ) . T , levels = levels , colors = [ '<STR_LIT:r>' , '<STR_LIT:r>' ] , linestyles = [ '<STR_LIT:->' , '<STR_LIT:->' ] ) <EOL> la = plt . contour ( vs , zs , np . log10 ( err_est_a ) . T , levels = levels , colors = [ '<STR_LIT:b>' , '<STR_LIT:b>' ] , linestyles = [ '<STR_LIT:->' , '<STR_LIT:->' ] ) <EOL> lb = plt . contour ( vs , zs , np . log10 ( err_est_b ) . T , levels = levels , colors = [ '<STR_LIT:g>' , '<STR_LIT:g>' ] , linestyles = [ '<STR_LIT:->' , '<STR_LIT:->' ] ) <EOL> plt . clabel ( lp , fmt = { - <NUM_LIT:1000> : '<STR_LIT:P>' , - <NUM_LIT:12> : '<STR_LIT:P>' } ) <EOL> plt . clabel ( la , fmt = { - <NUM_LIT:1000> : '<STR_LIT:A>' , - <NUM_LIT:12> : '<STR_LIT:A>' } ) <EOL> plt . clabel ( lb , fmt = { - <NUM_LIT:1000> : '<STR_LIT:B>' , - <NUM_LIT:12> : '<STR_LIT:B>' } ) <EOL> plt . plot ( vs , z_cutoff , '<STR_LIT>' ) <EOL> plt . xlim ( vs . min ( ) , vs . max ( ) ) <EOL> plt . ylim ( zs . min ( ) , zs . max ( ) ) <EOL> plt . xlabel ( '<STR_LIT:v>' ) <EOL> plt . ylabel ( '<STR_LIT:z>' ) <EOL> def main ( ) : <EOL> plt . clf ( ) <EOL> plt . subplot ( <NUM_LIT> ) <EOL> do_plot ( True ) <EOL> plt . title ( '<STR_LIT>' ) <EOL> plt . subplot ( <NUM_LIT> ) <EOL> do_plot ( False ) <EOL> plt . title ( '<STR_LIT>' ) <EOL> plt . savefig ( '<STR_LIT>' ) <EOL> plt . show ( ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> import os <EOL> import sys <EOL> if '<STR_LIT>' in sys . argv : <EOL> main ( ) <EOL> else : <EOL> import subprocess <EOL> subprocess . call ( [ sys . executable , os . path . join ( '<STR_LIT:..>' , '<STR_LIT:..>' , '<STR_LIT:..>' , '<STR_LIT>' ) , <EOL> '<STR_LIT>' , '<STR_LIT>' , __file__ , '<STR_LIT>' ] ) </s>
