Changeset 9615


Ignore:
Timestamp:
Feb 5, 2015, 4:18:25 PM (10 years ago)
Author:
steve
Message:

cleaned up some polt tests to avoid needed DISPLAY variable

Location:
trunk/anuga_core
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/anuga_core/.travis.yml

    r9613 r9615  
    11language: python
     2virtualenv:
     3  system_site_packages: true
    24env:
    3 matrix:
    4 - PYTHON_VERSION="2.7"
    5 - PYTHON_VERSION="2.6"
     5  matrix:
     6    - PYTHON_VERSION="2.7"
     7    - PYTHON_VERSION="2.6"
    68install:
    79  - sudo apt-get update
     
    1921  # Useful for debugging any issues with conda
    2022  - conda info -a
     23  # More debugging
     24  - printenv
    2125
    2226  # Conda dependencies
    23   - conda create -q -n test-environment python="$PYTHON_VERSION" scipy gdal netcdf4 nose matplotlib
     27  - conda create -n test-environment --yes python=$PYTHON_VERSION numpy scipy gdal geos netcdf4 nose matplotlib
    2428  - source activate test-environment
     29  - conda install -c https://conda.binstar.org/pingucarsti gdal-data
    2530  # python 2.6 doesn't have argparse by default
    26   - if [[ "$PYTHON_VERSION" == "2.6" ]]; then
    27       conda install argparse
    28     fi
     31  - if [[ "$PYTHON_VERSION" == "2.6" ]]; then conda install argparse; fi
    2932  - python setup.py install
    3033
  • trunk/anuga_core/anuga/abstract_2d_finite_volumes/generic_domain.py

    r9292 r9615  
    539539            msg = 'Setting CFL > 2.0'
    540540            #warnings.warn(msg)
    541             log.warn()
     541            log.warning(msg)
    542542
    543543        assert cfl > 0.0
     
    14491449            triang = num.array(range(0,3*n))
    14501450            triang.shape = (n, 3)
    1451             plt.triplot(gx, g, triang, 'b--')
     1451            plt.triplot(gx, gy, triang, 'b--')
    14521452
    14531453        # Save triangulation to location pointed by filename
  • trunk/anuga_core/anuga/abstract_2d_finite_volumes/tests/test_util.py

    r9562 r9615  
    14791479    def test_make_plots_from_csv_files(self):
    14801480       
    1481         #if sys.platform == 'win32':  #Windows
    1482             try:
    1483                 import pylab
    1484             except ImportError:
    1485                 #ANUGA don't need pylab to work so the system doesn't
    1486                 #rely on pylab being installed
    1487                 return
    1488            
    1489        
    1490             current_dir=getcwd()+sep+'abstract_2d_finite_volumes'
    1491             temp_dir = tempfile.mkdtemp('','figures')
    1492     #        print 'temp_dir',temp_dir
    1493             fileName = temp_dir+sep+'time_series_3.csv'
    1494             file = open(fileName,"w")
    1495             file.write("time,stage,speed,momentum,elevation\n\
     1481#         #if sys.platform == 'win32':  #Windows
     1482#         try:
     1483#             import pylab
     1484#         except ImportError:
     1485#             #ANUGA don't need pylab to work so the system doesn't
     1486#             #rely on pylab being installed
     1487#             return
     1488       
     1489        try:
     1490            import matplotlib
     1491            matplotlib.use('Agg')
     1492            import matplotlib.pyplot as plt
     1493        except:
     1494            #print "Couldn't import module from matplotlib, probably you need to update matplotlib"
     1495            return
     1496       
     1497   
     1498        current_dir=getcwd()+sep+'abstract_2d_finite_volumes'
     1499        temp_dir = tempfile.mkdtemp('','tmp_figures')
     1500#        print 'temp_dir',temp_dir
     1501        fileName = temp_dir+sep+'time_series_3.csv'
     1502        fid = open(fileName,"w")
     1503        fid.write("time,stage,speed,momentum,elevation\n\
    149615041.0, 0, 0, 0, 10 \n\
    149715052.0, 5, 2, 4, 10 \n\
    149815063.0, 3, 3, 5, 10 \n")
    1499             file.close()
    1500    
    1501             fileName1 = temp_dir+sep+'time_series_4.csv'
    1502             file1 = open(fileName1,"w")
    1503             file1.write("time,stage,speed,momentum,elevation\n\
     1507        fid.close()
     1508
     1509        fileName1 = temp_dir+sep+'time_series_4.csv'
     1510        fid1 = open(fileName1,"w")
     1511        fid1.write("time,stage,speed,momentum,elevation\n\
    150415121.0, 0, 0, 0, 5 \n\
    150515132.0, -5, -2, -4, 5 \n\
    150615143.0, -4, -3, -5, 5 \n")
    1507             file1.close()
    1508    
    1509             fileName2 = temp_dir+sep+'time_series_5.csv'
    1510             file2 = open(fileName2,"w")
    1511             file2.write("time,stage,speed,momentum,elevation\n\
     1515        fid1.close()
     1516
     1517        fileName2 = temp_dir+sep+'time_series_5.csv'
     1518        fid2 = open(fileName2,"w")
     1519        fid2.write("time,stage,speed,momentum,elevation\n\
    151215201.0, 0, 0, 0, 7 \n\
    151315212.0, 4, -0.45, 57, 7 \n\
    151415223.0, 6, -0.5, 56, 7 \n")
    1515             file2.close()
    1516            
    1517             dir, name=os.path.split(fileName)
    1518             csv2timeseries_graphs(directories_dic={dir:['gauge', 0, 0]},
    1519                                   output_dir=temp_dir,
    1520                                   base_name='time_series_',
    1521                                   plot_numbers=['3-5'],
    1522                                   quantities=['speed','stage','momentum'],
    1523                                   assess_all_csv_files=True,
    1524                                   extra_plot_name='test')
    1525            
    1526             #print dir+sep+name[:-4]+'_stage_test.png'
    1527             assert(access(dir+sep+name[:-4]+'_stage_test.png',F_OK)==True)
    1528             assert(access(dir+sep+name[:-4]+'_speed_test.png',F_OK)==True)
    1529             assert(access(dir+sep+name[:-4]+'_momentum_test.png',F_OK)==True)
    1530    
    1531             dir1, name1=os.path.split(fileName1)
    1532             assert(access(dir+sep+name1[:-4]+'_stage_test.png',F_OK)==True)
    1533             assert(access(dir+sep+name1[:-4]+'_speed_test.png',F_OK)==True)
    1534             assert(access(dir+sep+name1[:-4]+'_momentum_test.png',F_OK)==True)
    1535    
    1536    
    1537             dir2, name2=os.path.split(fileName2)
    1538             assert(access(dir+sep+name2[:-4]+'_stage_test.png',F_OK)==True)
    1539             assert(access(dir+sep+name2[:-4]+'_speed_test.png',F_OK)==True)
    1540             assert(access(dir+sep+name2[:-4]+'_momentum_test.png',F_OK)==True)
    1541    
    1542             del_dir(temp_dir)
     1523        fid2.close()
     1524       
     1525        dir, name=os.path.split(fileName)
     1526        csv2timeseries_graphs(directories_dic={dir:['gauge', 0, 0]},
     1527                              output_dir=temp_dir,
     1528                              base_name='time_series_',
     1529                              plot_numbers=['3-5'],
     1530                              quantities=['speed','stage','momentum'],
     1531                              assess_all_csv_files=True,
     1532                              extra_plot_name='test')
     1533       
     1534        #print dir+sep+name[:-4]+'_stage_test.png'
     1535        assert(access(dir+sep+name[:-4]+'_stage_test.png',F_OK)==True)
     1536        assert(access(dir+sep+name[:-4]+'_speed_test.png',F_OK)==True)
     1537        assert(access(dir+sep+name[:-4]+'_momentum_test.png',F_OK)==True)
     1538
     1539        dir1, name1=os.path.split(fileName1)
     1540        assert(access(dir+sep+name1[:-4]+'_stage_test.png',F_OK)==True)
     1541        assert(access(dir+sep+name1[:-4]+'_speed_test.png',F_OK)==True)
     1542        assert(access(dir+sep+name1[:-4]+'_momentum_test.png',F_OK)==True)
     1543
     1544
     1545        dir2, name2=os.path.split(fileName2)
     1546        assert(access(dir+sep+name2[:-4]+'_stage_test.png',F_OK)==True)
     1547        assert(access(dir+sep+name2[:-4]+'_speed_test.png',F_OK)==True)
     1548        assert(access(dir+sep+name2[:-4]+'_momentum_test.png',F_OK)==True)
     1549
     1550        del_dir(temp_dir)
    15431551       
    15441552
  • trunk/anuga_core/anuga/abstract_2d_finite_volumes/util.py

    r8718 r9615  
    441441    """
    442442
    443     try:
    444         import pylab
    445     except ImportError:
    446         msg='csv2timeseries_graphs needs pylab to be installed correctly'
    447         raise Exception(msg)
    448             #ANUGA don't need pylab to work so the system doesn't
    449             #rely on pylab being installed
     443#     try:
     444#         import pylab
     445#     except ImportError:
     446#         msg='csv2timeseries_graphs needs pylab to be installed correctly'
     447#         raise Exception(msg)
     448#             #ANUGA don't need pylab to work so the system doesn't
     449#             #rely on pylab being installed
     450#         return
     451   
     452    try:
     453        import matplotlib
     454        matplotlib.use('Agg')
     455        import matplotlib.pyplot as pylab
     456    except:
     457        #print "Couldn't import module from matplotlib, probably you need to update matplotlib"
    450458        return
    451459
     
    544552                #add tide to stage if provided
    545553                if quantity == 'stage':
    546                      quantity_value[quantity] = num.array(quantity_value[quantity],
     554                    quantity_value[quantity] = num.array(quantity_value[quantity],
    547555                                                          num.float) + directory_add_tide
    548556
  • trunk/anuga_core/anuga/geometry/polygon.py

    r9214 r9615  
    724724       
    725725
    726     from matplotlib.pyplot import hold, plot, savefig, xlabel, \
     726
     727    try:
     728        import matplotlib
     729        matplotlib.use('Agg')
     730        from matplotlib.pyplot import hold, plot, savefig, xlabel, \
    727731                    ylabel, title, close, title, fill
     732    except:
     733        return
    728734
    729735    assert type(polygons_points) == list, \
     
    780786    #ioff()
    781787    hold(False)
     788   
    782789    close('all')
    783790
Note: See TracChangeset for help on using the changeset viewer.