Skip to content

Commit

Permalink
Blacken with Black 23.9
Browse files Browse the repository at this point in the history
  • Loading branch information
berland committed Sep 20, 2023
1 parent 469546e commit 10d9c5b
Show file tree
Hide file tree
Showing 35 changed files with 31 additions and 65 deletions.
2 changes: 1 addition & 1 deletion python/docs/examples/cmp_nnc.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
nnc_list.append((g1, g2, t))

nnc_list = sorted(nnc_list, key=itemgetter(0))
for (g1, g2, T) in nnc_list:
for g1, g2, T in nnc_list:
# grid_ijk assumes 0-based indexing, g1/g2 are 1-based (FORTRAN)
# Convert them to zero based ones.
g1 = g1 - 1
Expand Down
1 change: 0 additions & 1 deletion python/ecl/ecl_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class EclTypeEnum(BaseCEnum):


class EclDataType(BaseCClass):

TYPE_NAME = "ecl_data_type"

_alloc = EclPrototype(
Expand Down
1 change: 0 additions & 1 deletion python/ecl/eclfile/fortio.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ def seek(self, position, whence=0):

@classmethod
def is_fortran_file(cls, filename, endian_flip=True):

"""@rtype: bool
@type filename: str
Expand Down
2 changes: 1 addition & 1 deletion python/ecl/gravimetry/ecl_grav_calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def deltag(xyz, grid, init_file, restart_file1, restart_file2):
porv2 = restart_file2.iget_named_kw("RPORV", 0)

deltag = 0
for (sat1, sat2) in phase_list:
for sat1, sat2 in phase_list:
rho_name = "%s_DEN" % sat1.name[1:]
rho1 = restart_file1.iget_named_kw(rho_name, 0)
rho2 = restart_file2.iget_named_kw(rho_name, 0)
Expand Down
4 changes: 1 addition & 3 deletions python/ecl/grid/ecl_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@ def load_from_file(cls, filename):

@classmethod
def create(cls, specgrid, zcorn, coord, actnum, mapaxes=None):

"""
Create a new grid instance from existing keywords.
Expand Down Expand Up @@ -277,7 +276,7 @@ def create_rectangular(cls, dims, dV, actnum=None):
else:
if not isinstance(actnum, IntVector):
tmp = IntVector(initial_size=len(actnum))
for (index, value) in enumerate(actnum):
for index, value in enumerate(actnum):
tmp[index] = value
actnum = tmp

Expand Down Expand Up @@ -1016,7 +1015,6 @@ def get_cell_dims(self, active_index=None, global_index=None, ijk=None):
return (dx, dy, dz)

def get_num_lgr(self):

"""
How many LGRs are attached to this main grid?
Expand Down
7 changes: 1 addition & 6 deletions python/ecl/grid/ecl_grid_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ def pre_mapaxes_translation(translation, mapaxes):


class EclGridGenerator:

_alloc_rectangular = EclPrototype(
"ecl_grid_obj ecl_grid_alloc_rectangular(int, int, int, double, double, double, int*)",
bind=False,
Expand All @@ -70,7 +69,7 @@ def create_rectangular(cls, dims, dV, actnum=None):
else:
if not isinstance(actnum, IntVector):
tmp = IntVector(initial_size=len(actnum))
for (index, value) in enumerate(actnum):
for index, value in enumerate(actnum):
tmp[index] = value
actnum = tmp

Expand Down Expand Up @@ -137,7 +136,6 @@ def create_zcorn(
concave=False,
faults=False,
):

cls.__assert_zcorn_parameters(
dims,
dV,
Expand Down Expand Up @@ -194,7 +192,6 @@ def create_coord(
rotate=False,
misalign=False,
):

nx, ny, nz = dims
dx, dy, dz = dV

Expand Down Expand Up @@ -236,7 +233,6 @@ def __assert_zcorn_parameters(
concave,
faults,
):

nx, ny, nz = dims
dx, dy, dz = dV

Expand Down Expand Up @@ -588,7 +584,6 @@ def __translate_coord(cls, coord, translation):
def extract_subgrid(
cls, grid, ijk_bounds, decomposition_change=False, translation=None
):

"""
Extracts a subgrid from the given grid according to the specified
bounds.
Expand Down
1 change: 0 additions & 1 deletion python/ecl/grid/ecl_region.py
Original file line number Diff line number Diff line change
Expand Up @@ -987,7 +987,6 @@ def select_from_layer(self, layer, k, value, intersect=False):
#################################################################

def scalar_apply_kw(self, target_kw, scalar, func_dict, force_active=False):

"""
Helper function to apply a function with one scalar arg on target_kw.
"""
Expand Down
2 changes: 1 addition & 1 deletion python/ecl/grid/faults/fault.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def __sort_fault_lines(self):
perm_list.sort(key=lambda x: x[1])

fault_lines = []
for (index, d) in perm_list:
for index, d in perm_list:
fault_lines.append(self.__fault_lines[index])
self.__fault_lines = fault_lines

Expand Down
2 changes: 1 addition & 1 deletion python/ecl/grid/faults/fault_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def get_edge_polygon(self):

self._trace_edge(x_list, y_list, cell_list)
p = Polyline()
for (x, y) in zip(x_list, y_list):
for x, y in zip(x_list, y_list):
p.addPoint(x, y)
return p

Expand Down
2 changes: 1 addition & 1 deletion python/ecl/grid/faults/fault_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def __init_ij_polyline(self):

def __init_polyline(self):
pl = CPolyline()
for (i, j) in self.getIJPolyline():
for i, j in self.getIJPolyline():
x, y, z = self.__grid.getNodeXYZ(i, j, self.__k)
pl.addPoint(x, y)
self.__polyline = pl
Expand Down
6 changes: 3 additions & 3 deletions python/ecl/grid/faults/fault_segments.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def __str__(self):
return self.__segment_map.__str__()

def verify(self):
for (C, count) in self.__count_map.iteritems():
for C, count in self.__count_map.iteritems():
if count > 0:
d = self.__segment_map[C]
if len(d) != count:
Expand Down Expand Up @@ -112,7 +112,7 @@ def del_segment(self, segment):

def pop_start(self):
end_segments = []
for (C, count) in self.__count_map.items():
for C, count in self.__count_map.items():
if count == 1:
end_segments.append(list(self.__segment_map[C].values())[0])

Expand All @@ -135,7 +135,7 @@ def pop_next(self, segment):

def print_content(self):
for d in self.__segment_map.values():
for (C, S) in d.iteritems():
for C, S in d.iteritems():
print(S)


Expand Down
2 changes: 1 addition & 1 deletion python/ecl/grid/faults/layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def cells_equal(self, value):
j_list = IntVector()
self._cells_equal(value, i_list, j_list)
ij_list = []
for (i, j) in zip(i_list, j_list):
for i, j in zip(i_list, j_list):
ij_list.append((i, j))
return ij_list

Expand Down
2 changes: 1 addition & 1 deletion python/ecl/summary/ecl_npv.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def compile(self, expression):
self.code = (
"trange = self.baseCase.timeRange(self.start, self.end, self.interval)\n"
)
for (key, var) in self.keyList.items():
for key, var in self.keyList.items():
self.code += '%s = self.baseCase.blockedProduction("%s", trange)\n' % (
var,
key,
Expand Down
2 changes: 0 additions & 2 deletions python/ecl/summary/ecl_sum.py
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,6 @@ def check_sim_time(self, date):
return self._check_sim_time(date)

def get_interp_direct(self, key, date):

if not isinstance(date, CTime):
date = CTime(date)
return self._get_general_var_from_sim_time(date, key)
Expand Down Expand Up @@ -853,7 +852,6 @@ def get_interp(self, key, days=None, date=None):
if self.check_sim_time(t):
return self._get_general_var_from_sim_time(t, key)
else:

raise ValueError("date:%s is outside range of simulation data" % date)
elif date is None:
if self._check_sim_days(days):
Expand Down
2 changes: 1 addition & 1 deletion python/ecl/util/geometry/cpolyline.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class CPolyline(BaseCClass):
def __init__(self, name=None, init_points=()):
c_ptr = self._alloc_new(name)
super(CPolyline, self).__init__(c_ptr)
for (xc, yc) in init_points:
for xc, yc in init_points:
self.addPoint(xc, yc)

@classmethod
Expand Down
8 changes: 2 additions & 6 deletions python/ecl/util/geometry/geometry_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,17 +394,13 @@ def connectPolylines(polyline, target_polyline):
p0 = polyline[-1]
p1 = polyline[-2]
ray = GeometryTools.lineToRay(p1, p0)
for (index, p) in GeometryTools.rayPolygonIntersections(
p0, ray, target_polyline
):
for index, p in GeometryTools.rayPolygonIntersections(p0, ray, target_polyline):
d_list.append((GeometryTools.distance(p0, p), [p0, p]))

p0 = polyline[0]
p1 = polyline[1]
ray = GeometryTools.lineToRay(p1, p0)
for (index, p) in GeometryTools.rayPolygonIntersections(
p0, ray, target_polyline
):
for index, p in GeometryTools.rayPolygonIntersections(p0, ray, target_polyline):
d_list.append((GeometryTools.distance(p0, p), [p0, p]))

if len(d_list) == 0:
Expand Down
2 changes: 1 addition & 1 deletion python/ecl/util/geometry/polyline.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def __eq__(self, other):
if len(self) != len(other):
return False

for (p1, p2) in zip(self, other):
for p1, p2 in zip(self, other):
if p1 != p2:
return False

Expand Down
1 change: 0 additions & 1 deletion python/ecl/util/geometry/surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ def copy(self, copy_data=True):
return self._copy(copy_data)

def write(self, filename):

"""
Will write the surface as an ascii formatted file to @filename.
"""
Expand Down
3 changes: 1 addition & 2 deletions python/ecl/util/test/ecl_mock/ecl_sum_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@ def createEclSum(
restart_case=None,
restart_step=-1,
):

ecl_sum = EclSum.restart_writer(
case, restart_case, restart_step, sim_start, dims[0], dims[1], dims[2]
)
var_list = []
for (kw, wgname, num, unit) in keys:
for kw, wgname, num, unit in keys:
var_list.append(ecl_sum.addVariable(kw, wgname=wgname, num=num, unit=unit))

# This is a bug! This should not be integer division, but tests are written
Expand Down
2 changes: 1 addition & 1 deletion python/ecl/util/test/ert_test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def findTestsInDirectory(path, recursive=True, pattern="test*.py"):
loader = TestLoader()
test_suite = loader.discover(path, pattern=pattern)

for (root, dirnames, filenames) in os.walk(path):
for root, dirnames, filenames in os.walk(path):
for directory in dirnames:
test_suite.addTests(
ErtTestRunner.findTestsInDirectory(
Expand Down
1 change: 0 additions & 1 deletion python/ecl/util/test/extended_testcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ def createTestPath(cls, path):
return os.path.realpath(os.path.join(cls.TESTDATA_ROOT, path))

def assertNotRaises(self, func=None):

context = _AssertNotRaisesContext(self)
if func is None:
return context
Expand Down
3 changes: 0 additions & 3 deletions python/ecl/util/test/test_area.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@


class TestArea(BaseCClass):

__test__ = False

_test_area_alloc = EclPrototype(
Expand Down Expand Up @@ -34,7 +33,6 @@ class TestArea(BaseCClass):
)

def __init__(self, test_name, store_area=False, c_ptr=None):

if c_ptr is None:
c_ptr = self._test_area_alloc(test_name, store_area)

Expand Down Expand Up @@ -107,7 +105,6 @@ def getFullPath(self, path):


class TestAreaContext(object):

__test__ = False

def __init__(self, test_name, store_area=False):
Expand Down
2 changes: 1 addition & 1 deletion python/ecl/util/test/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def run(self):

status_list = [status]
if status[0]:
for (check_func, arg) in self.check_list:
for check_func, arg in self.check_list:
status = check_func(arg)
status_list.append(status)
if not status[0]:
Expand Down
2 changes: 1 addition & 1 deletion python/ecl/util/util/vector_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ def permutationSort(self, reverse=False):

def asList(self):
l = [0] * len(self)
for (index, value) in enumerate(self):
for index, value in enumerate(self):
l[index] = value

return l
Expand Down
7 changes: 2 additions & 5 deletions python/tests/ecl_tests/test_ecl_kw.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def kw_test(self, data_type, data, fmt):
name1 = "file1.txt"
name2 = "file2.txt"
kw = EclKW("TEST", len(data), data_type)
for (i, d) in enumerate(data):
for i, d in enumerate(data):
kw[i] = d

file1 = cwrap.open(name1, "w")
Expand Down Expand Up @@ -138,7 +138,6 @@ def test_fprintf(self):

def test_kw_write(self):
with TestAreaContext("python/ecl_kw/writing"):

data = [random.random() for i in range(10000)]

kw = EclKW("TEST", len(data), EclDataType.ECL_DOUBLE)
Expand Down Expand Up @@ -194,7 +193,7 @@ def test_fprintf_data(self):
for elm in tmp:
data.append(int(elm))

for (v1, v2) in zip(data, kw):
for v1, v2 in zip(data, kw):
self.assertEqual(v1, v2)

def test_sliced_set(self):
Expand Down Expand Up @@ -424,7 +423,6 @@ def test_string_alloc(self):
def test_string_write_read_unformatted(self):
for str_len in range(1000):
with TestAreaContext("my_space"):

kw = EclKW("TEST_KW", 10, EclDataType.ECL_STRING(str_len))
for i in range(10):
kw[i] = str(i) * str_len
Expand All @@ -442,7 +440,6 @@ def test_string_write_read_unformatted(self):
def test_string_write_read_formatted(self):
for str_len in range(1000):
with TestAreaContext("my_space"):

kw = EclKW("TEST_KW", 10, EclDataType.ECL_STRING(str_len))
for i in range(10):
kw[i] = str(i) * str_len
Expand Down
Loading

0 comments on commit 10d9c5b

Please sign in to comment.