Пример #1
0
 def test_create( self ):
     s = StringList()
     
     s = StringList( initial = initList )
     self.assertTrue( len(s) == 3 )
     for i in range(len(s)):
         self.assertTrue( s[i] == initList[i] )
         
     s2 = s.strings
     for i in range(len(s)):
         self.assertTrue( s2[i] == initList[i] )
 
     s3 = self.create()
     for i in range(len(s)):
         self.assertTrue( s3[i] == initList[i] )
Пример #2
0
    def test_pop( self ):
        s = StringList( initial = initList )
        s1 = s.pop()
        self.assertTrue( len(s) == 2 )
        self.assertTrue( s1 == "S33")

        s1 = s.pop()
        self.assertTrue( len(s) == 1 )
        self.assertTrue( s1 == "SABC")

        s1 = s.pop()
        self.assertTrue( len(s) == 0 )
        self.assertTrue( s1 == "S1")

        self.assertRaises( IndexError , pop_empty )
Пример #3
0
    def run(self, *args):
        ert = self.ert()
        if ert is None:
            # This is usually used for testing purposes without an ert instance
            return self.__function(*args)
        else:
            str_args = StringList()
            for arg in args:
                str_args.append(arg)

            if hasattr(ert, "from_param"):
                pointer = ert.from_param(ert)
            else:
                pointer = ert # ...

            return self.__function(pointer, str_args)
Пример #4
0
 def test_enkf_conf_node(self):
     main = enkf.EnKFMain.bootstrap(case, site_conf_file)
     conf = main.config
     s = StringList(initial=None, c_ptr=conf.alloc_keylist)
     self.assertTrue(
         isinstance(conf.getNode("MULTFLT"),
                    ert.enkf.enkf_config_node.EnkfConfigNode))
     self.assertTrue(isinstance(s, ert.util.stringlist.StringList))
    def createCustomKWConfig(self, name, data):
        with TestAreaContext(
                "python/enkf/custom_kw_config_set_config") as test_area:
            self.createResultFile("result_file", data)

            config = CustomKWConfig(name, "")
            config.parseResultFile("result_file", StringList())

        return config
Пример #6
0
    def groups(self, pattern=None):
        """
        Will return a list of all the group names in case.

        If the pattern variable is different from None only groups
        matching the pattern will be returned; the matching is based
        on fnmatch(), i.e. shell style wildcards.
        """
        c_ptr = cfunc.create_group_list(self, pattern)
        return StringList(c_ptr=c_ptr)
Пример #7
0
 def keys(self, pattern=None):
     """
     Return a list of summary keys matching @pattern.
     
     The matching algorithm is ultimately based on the fnmatch()
     function, i.e. normal shell-character syntax is used. With
     @pattern == "WWCT:*" you will get a list of watercut keys for
     all wells. 
     
     If pattern is None you will get all the keys of summary
     object.
     """
     s = StringList()
     cfunc.select_matching_keys(self, pattern, s)
     return s.strings
Пример #8
0
print v2[77]

v2.default = 100
print v2.default

B = BoolVector(True)
B[4] = False
B.printf()

l = ["CASE-9", "CASE-10"]
print l.sort()
print l.sort(strcmp_int)

v.default = 13
v[1000] = 99
print v.size
np = v.numpy_copy()
v[0] = 77
v[5] = 99
print v.str(max_lines=None)

S = StringList(["A", "list", "of", "strings"])

print S

if "A" in S:
    print "S contains A"

if not "Bjarne" in S:
    print "S does not contain BJARNE"
Пример #9
0
 def test_last( self ):
     s = StringList( initial = initList )
     l = s.last
     self.assertTrue( "S33" == l )
     self.assertRaises( IndexError , last_empty)
Пример #10
0
 def create(self):
     s = StringList( initial = initList )
     st = s.strings
     del s
     return st
Пример #11
0
def last_empty():
    s = StringList( initial = initList )
    s.pop()
    s.pop()
    s.pop()
    s.last
Пример #12
0
def pop_empty():
    s = StringList( initial = initList )
    s.pop()
    s.pop()
    s.pop()
    s.pop()