@@ -4457,28 +4457,30 @@ def test_Data__init__datetime(self):
44574457 self .assertTrue ((q == d ).array .all ())
44584458 self .assertTrue ((d == q ).array .all ())
44594459
4460- def test_Data__str__ (self ):
4461- """Test `Data.__str__`"""
4462- elements0 = (0 , - 1 , 1 )
4463- for array in ([1 ], [1 , 2 ], [1 , 2 , 3 ]):
4464- d = cf .Data (array )
4465- d [0 ] = 1
4466- self .assertEqual (str (d ), str (array ))
4467- d += 0
4468- self .assertEqual (str (d ), str (array ))
4469-
4470- # Test when size > 3, i.e. second element is not there.
4471- d = cf .Data ([1 , 2 , 3 , 4 ])
4472-
4473- self .assertEqual (str (d ), "[1, ..., 4]" )
4474- cache = d .get_cached_elements ()
4475- self .assertNotIn (1 , cache )
4476- for element in elements0 [:2 ]:
4477- self .assertIn (element , cache )
4478-
4479- d [0 ] = 1
4480- for element in elements0 :
4481- self .assertNotIn (element , d .get_cached_elements ())
4460+ def test_Data__repr__str (self ):
4461+ """Test all means of Data inspection."""
4462+ for d in [
4463+ cf .Data (9 , units = "km" ),
4464+ cf .Data ([9 ], units = "km" ),
4465+ cf .Data ([[9 ]], units = "km" ),
4466+ cf .Data ([8 , 9 ], units = "km" ),
4467+ cf .Data ([[8 , 9 ]], units = "km" ),
4468+ cf .Data ([7 , 8 , 9 ], units = "km" ),
4469+ cf .Data ([[7 , 8 , 9 ]], units = "km" ),
4470+ cf .Data ([6 , 7 , 8 , 9 ], units = "km" ),
4471+ cf .Data ([[6 , 7 , 8 , 9 ]], units = "km" ),
4472+ cf .Data ([[6 , 7 ], [8 , 9 ]], units = "km" ),
4473+ cf .Data ([[6 , 7 , 8 , 9 ], [6 , 7 , 8 , 9 ]], units = "km" ),
4474+ ]:
4475+ _ = repr (d )
4476+ _ = str (d )
4477+
4478+ # Test when the data contains date-times with the first
4479+ # element masked
4480+ dt = np .ma .array ([10 , 20 ], mask = [True , False ])
4481+ d = cf .Data (dt , units = "days since 2000-01-01" )
4482+ self .assertTrue (str (d ) == "[--, 2000-01-21 00:00:00]" )
4483+ self .assertTrue (repr (d ) == "<CF Data(2): [--, 2000-01-21 00:00:00]>" )
44824484
44834485 def test_Data_cull_graph (self ):
44844486 """Test Data.cull_graph."""
0 commit comments