Example #1
0
 def test_illegal_no_common_dim(self):
     with self.assertRaises(ValidationError) as cm:
         plot_scatter(ds1=self.ds1,
                      ds2=self.ds2,
                      var1='local_msl_trend',
                      var2='period',
                      indexers1=None,
                      indexers2=dict(period=0.5),
                      type='Point')
     self.assertTrue(f'{cm.exception}'.startswith('"var1" and "var2" have no dimensions in common: '))
Example #2
0
 def test_illegal_no_common_dim(self):
     with self.assertRaises(ValidationError) as cm:
         plot_scatter(ds1=self.ds1,
                      ds2=self.ds2,
                      var1='local_msl_trend',
                      var2='period',
                      indexers1=None,
                      indexers2=dict(period=0.5),
                      type='Point')
     self.assertTrue(f'{cm.exception}'.startswith(
         '"var1" and "var2" have no dimensions in common: '))
Example #3
0
 def test_illegal_var(self):
     with self.assertRaises(ValidationError) as cm:
         plot_scatter(ds1=self.ds1,
                      ds2=self.ds2,
                      var1='global_msl_trend',
                      var2='ampl',
                      indexers1=None,
                      indexers2=dict(period=0.5),
                      type='Point')
     self.assertEqual('"global_msl_trend" is not a variable in dataset given by "ds1"',
                      f'{cm.exception}')
Example #4
0
 def test_illegal_var(self):
     with self.assertRaises(ValidationError) as cm:
         plot_scatter(ds1=self.ds1,
                      ds2=self.ds2,
                      var1='global_msl_trend',
                      var2='ampl',
                      indexers1=None,
                      indexers2=dict(period=0.5),
                      type='Point')
     self.assertEqual(
         '"global_msl_trend" is not a variable in dataset given by "ds1"',
         f'{cm.exception}')
Example #5
0
 def test_illegal_no_common_dims(self):
     with self.assertRaises(ValidationError) as cm:
         plot_scatter(ds1=self.ds1,
                      ds2=self.ds2,
                      var1='local_msl_trend',
                      var2='phase',
                      indexers1=None,
                      indexers2=None,
                      type='Point')
     self.assertTrue(f'{cm.exception}'.startswith('Remaining dimensions of data from "var1"'
                                                  ' must be equal to remaining dimensions'
                                                  ' of data from "var2", but '))
Example #6
0
 def test_illegal_type(self):
     with self.assertRaises(ValidationError) as cm:
         plot_scatter(ds1=self.ds1,
                      ds2=self.ds2,
                      var1='local_msl_trend',
                      var2='ampl',
                      indexers1=None,
                      indexers2=dict(period=0.5),
                      type='2D Density')
     self.assertEqual("Input 'type' for operation 'cate.ops.plot.plot_scatter'"
                      " must be one of ['Point', 'Hexbin', '2D Histogram'].",
                      f'{cm.exception}')
Example #7
0
 def test_illegal_no_common_dims(self):
     with self.assertRaises(ValidationError) as cm:
         plot_scatter(ds1=self.ds1,
                      ds2=self.ds2,
                      var1='local_msl_trend',
                      var2='phase',
                      indexers1=None,
                      indexers2=None,
                      type='Point')
     self.assertTrue(f'{cm.exception}'.startswith(
         'Remaining dimensions of data from "var1"'
         ' must be equal to remaining dimensions'
         ' of data from "var2", but '))
Example #8
0
 def test_illegal_type(self):
     with self.assertRaises(ValidationError) as cm:
         plot_scatter(ds1=self.ds1,
                      ds2=self.ds2,
                      var1='local_msl_trend',
                      var2='ampl',
                      indexers1=None,
                      indexers2=dict(period=0.5),
                      type='2D Density')
     self.assertEqual(
         "Input 'type' for operation 'cate.ops.plot.plot_scatter'"
         " must be one of ['Point', 'Hexbin', '2D Histogram'].",
         f'{cm.exception}')
Example #9
0
 def test_all_types_work_fine(self):
     for type in ('Point', 'Hexbin', '2D Histogram'):
         with create_tmp_file('remove_me', 'png') as tmp_file:
             plot_scatter(ds1=self.ds1,
                          ds2=self.ds2,
                          var1='local_msl_trend',
                          var2='ampl',
                          indexers1=None,
                          indexers2=dict(period=0.5),
                          type=type,
                          title='Local MSL vs Amplitude',
                          properties=None,
                          file=tmp_file)
             self.assertTrue(os.path.isfile(tmp_file))
Example #10
0
 def test_all_types_work_fine(self):
     for type in ('Point', 'Hexbin', '2D Histogram'):
         with create_tmp_file('remove_me', 'png') as tmp_file:
             plot_scatter(ds1=self.ds1,
                          ds2=self.ds2,
                          var1='local_msl_trend',
                          var2='ampl',
                          indexers1=None,
                          indexers2=dict(period=0.5),
                          type=type,
                          title='Local MSL vs Amplitude',
                          properties=None,
                          file=tmp_file)
             self.assertTrue(os.path.isfile(tmp_file))