Changeset 5521


Ignore:
Timestamp:
Jul 17, 2008, 10:57:41 PM (11 years ago)
Author:
ole
Message:

Deprecated 'edges' as an option for location in set_values.
Validation tests pass as well as all unit tests except for two references to
this functionality.

Location:
anuga_core/source/anuga/abstract_2d_finite_volumes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/abstract_2d_finite_volumes/quantity.py

    r5520 r5521  
    368368        from Numeric import ArrayType
    369369
    370 
    371370        # Treat special case: Polygon situation
    372371        # Location will be ignored and set to 'centroids'
     
    376375        # FIXME (Ole): Need to compute indices based on polygon (and location) and
    377376        # use existing code after that.
     377       
     378        # Perhaps deprecate 'centroids' as a location option. It is really just a
     379        # first order version of what is currently called vertices 
    378380       
    379381        if polygon is not None:
     
    423425
    424426
    425         if location not in ['vertices', 'centroids', 'edges',
    426                             'unique vertices']:
     427        if location == 'edges':
     428            msg = 'edges has been deprecated as valid location'
     429            raise Exception, msg
     430           
     431           
     432        if location not in ['vertices', 'centroids', 'unique vertices']:
    427433            msg = 'Invalid location: %s' %location
    428434            raise Exception, msg
     
    522528                    self.centroid_values[i] = X
    523529
    524         elif location == 'edges':
    525             if indices is None:
    526                 self.edge_values[:] = X
    527             else:
    528                 # Brute force
    529                 for i in indices:
    530                     self.edge_values[i] = X
     530        #elif location == 'edges':
     531        #    if indices is None:
     532        #        self.edge_values[:] = X
     533        #    else:
     534        #        # Brute force
     535        #        for i in indices:
     536        #            self.edge_values[i] = X
    531537
    532538        elif location == 'unique vertices':
     
    570576        values: Numeric array
    571577        location: Where values are to be stored.
    572         Permissible options are: vertices, edges, centroid, unique vertices
     578        Permissible options are: vertices, centroid, unique vertices
    573579        Default is 'vertices'
    574580
     
    621627                    self.centroid_values[indices[i]] = values[i]
    622628
    623         elif location == 'edges':
    624             # FIXME (Ole): No mention of indices here. However, I don't
    625             # think we ever need to set values at edges anyway
    626             assert len(values.shape) == 2, 'Values array must be 2d'
    627 
    628             msg = 'Number of values must match number of elements'
    629             assert values.shape[0] == N, msg
    630 
    631             msg = 'Array must be N x 3'
    632             assert values.shape[1] == 3, msg
    633 
    634             self.edge_values = values
     629        #elif location == 'edges':
     630        #    # FIXME (Ole): No mention of indices here. However, I don't
     631        #    # think we ever need to set values at edges anyway
     632        #    assert len(values.shape) == 2, 'Values array must be 2d'
     633        #
     634        #    msg = 'Number of values must match number of elements'
     635        #    assert values.shape[0] == N, msg
     636        #
     637        #       msg = 'Array must be N x 3'
     638        #    assert values.shape[1] == 3, msg
     639        #
     640        #     self.edge_values = values
    635641
    636642        elif location == 'unique vertices':
     
    692698        f: x, y -> z Function where x, y and z are arrays
    693699        location: Where values are to be stored.
    694                   Permissible options are: vertices, centroid, edges,
     700                  Permissible options are: vertices, centroid,
    695701                  unique vertices
    696702                  Default is "vertices"
     
    10961102       
    10971103       
    1098 
     1104        # FIXME (Ole): Consider deprecating 'edges' - but not if it is used
     1105        # elsewhere in ANUGA.
    10991106        if location not in ['vertices', 'centroids', 'edges',
    11001107                            'unique vertices']:
  • anuga_core/source/anuga/abstract_2d_finite_volumes/test_quantity.py

    r5519 r5521  
    253253
    254254
    255         #Test default
     255        # Test default
    256256        quantity.set_values([[1,2,3], [5,5,5], [0,0,9], [-6, 3, 3]])
    257257        assert allclose(quantity.vertex_values,
     
    263263                                               [3.0, -1.5, -1.5]])
    264264
    265         #Test centroids
     265        # Test centroids
    266266        quantity.set_values([1,2,3,4], location = 'centroids')
    267267        assert allclose(quantity.centroid_values, [1., 2., 3., 4.]) #Centroid
    268268
    269         #Test edges
    270         quantity.set_values([[1,2,3], [5,5,5], [0,0,9], [-6, 3, 3]],
    271                             location = 'edges')
    272         assert allclose(quantity.edge_values,
    273                         [[1,2,3], [5,5,5], [0,0,9], [-6, 3, 3]])
    274 
    275         #Test exceptions
     269        # Test exceptions
    276270        try:
    277271            quantity.set_values([[1,2,3], [5,5,5], [0,0,9], [-6, 3, 3]],
     
    306300        quantity.set_values(2.0, location = 'centroids')
    307301        assert allclose(quantity.centroid_values, [2, 2, 2, 2])
    308 
    309         quantity.set_values(3.0, location = 'edges')
    310         assert allclose(quantity.edge_values, [[3, 3, 3],
    311                                                [3, 3, 3],
    312                                                [3, 3, 3],
    313                                                [3, 3, 3]])
    314302
    315303
Note: See TracChangeset for help on using the changeset viewer.