Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ dependencies = [
"matplotlib >=3.5.0",
"numpy >=1.21.0",
"platformdirs >=3.8.1",
"six",
]
dynamic = ["version"]

Expand Down
3 changes: 1 addition & 2 deletions src/cocopp/bestalg.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import warnings
import numpy as np
import tarfile
from six import advance_iterator

from . import readalign, pproc
from .toolsdivers import print_done
Expand Down Expand Up @@ -266,7 +265,7 @@ def __init__(self, dict_alg, algId="Virtual Best Algorithm"):
curLine = dictcurLine.setdefault(alg, np.array([np.inf, 0]))
while curLine[0] > funval:
try:
curLine = advance_iterator(it)
curLine = next(it)
except StopIteration:
break
dictcurLine[alg] = curLine.copy()
Expand Down
9 changes: 4 additions & 5 deletions src/cocopp/comp2/pprldistr2.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import matplotlib.pyplot as plt
from .. import toolsstats, pproc, toolsdivers
from ..ppfig import save_figure, consecutiveNumbers, plotUnifLogXMarkers
from six import advance_iterator

# __all__ = []

Expand Down Expand Up @@ -244,17 +243,17 @@ def plotLogRel(indexEntries0, indexEntries1, isByInstance=True):
it0 = iter(i0.funvals)
it1 = iter(i1.funvals)
try:
nline0 = advance_iterator(it0)
nline0 = next(it0)
while nline0[0] < curevals:
line0 = nline0
nline0 = advance_iterator(it0)
nline0 = next(it0)
except StopIteration:
pass # we keep the last line obtained.
try:
nline1 = advance_iterator(it1)
nline1 = next(it1)
while nline1[0] < curevals:
line1 = nline1
nline1 = advance_iterator(it1)
nline1 = next(it1)
except StopIteration:
pass # we keep the last line obtained.

Expand Down
5 changes: 2 additions & 3 deletions src/cocopp/ppfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import numpy as np
from matplotlib import pyplot as plt
import shutil
from six import advance_iterator
# from pdb import set_trace

# absolute_import => . refers to where ppfig resides in the package:
Expand Down Expand Up @@ -744,13 +743,13 @@ def generateData(dataSet, targetFuncValue):
finally the median on successful runs.
"""
it = iter(reversed(dataSet.evals))
i = advance_iterator(it)
i = next(it)
prev = np.array([np.nan] * len(i))

while i[0] <= targetFuncValue:
prev = i
try:
i = advance_iterator(it)
i = next(it)
except StopIteration:
break

Expand Down
5 changes: 2 additions & 3 deletions src/cocopp/ppfigcons1.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

import matplotlib.pyplot as plt
import numpy as np
from six import advance_iterator

from . import genericsettings, toolsstats, bestalg, pproc, ppfig, ppfigparam, htmldesc, toolsdivers
from . import testbedsettings
Expand Down Expand Up @@ -202,13 +201,13 @@ def generateData(dataSet, targetFuncValue):
"""

it = iter(reversed(dataSet.evals))
i = advance_iterator(it)
i = next(it)
prev = np.array([np.nan] * len(i))

while i[0] <= targetFuncValue:
prev = i
try:
i = advance_iterator(it)
i = next(it)
except StopIteration:
break

Expand Down
5 changes: 2 additions & 3 deletions src/cocopp/ppfigdim.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@

import matplotlib.pyplot as plt
import numpy as np
from six import advance_iterator

from . import genericsettings, toolsstats, bestalg, pproc, ppfig, ppfigparam, htmldesc, toolsdivers
from . import testbedsettings
Expand Down Expand Up @@ -241,13 +240,13 @@ def generateData(dataSet, targetFuncValue):
"""

it = iter(reversed(dataSet.evals))
i = advance_iterator(it)
i = next(it)
prev = np.array([np.nan] * len(i))

while i[0] <= targetFuncValue:
prev = i
try:
i = advance_iterator(it)
i = next(it)
except StopIteration:
break

Expand Down
9 changes: 4 additions & 5 deletions src/cocopp/pplogloss.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
except ImportError:
# compatibility matplotlib 0.8
from matplotlib.transforms import blend_xy_sep_transform as blend
from six import advance_iterator

from . import toolsstats, toolsdivers, bestalg, genericsettings, captions
from .pptex import writeFEvals2
Expand Down Expand Up @@ -593,10 +592,10 @@ def generateSingleTableTex(dsList, funcs, mFE, d, prcOfInterest, EVALS, data, ou
for i in dsList:
it = reversed(i.evals)
curline = None
nextline = advance_iterator(it)
nextline = next(it)
while nextline[0] <= f_thresh:
curline = nextline[1:]
nextline = advance_iterator(it)
nextline = next(it)
if curline is None:
tmpdata.extend(i.maxevals)
else:
Expand Down Expand Up @@ -660,10 +659,10 @@ def generateSingleTableHtml(dsList, funcs, mFE, d, prcOfInterest, EVALS, data, o
for i in dsList:
it = reversed(i.evals)
curline = None
nextline = advance_iterator(it)
nextline = next(it)
while nextline[0] <= f_thresh:
curline = nextline[1:]
nextline = advance_iterator(it)
nextline = next(it)
if curline is None:
tmpdata.extend(i.maxevals)
else:
Expand Down
37 changes: 18 additions & 19 deletions src/cocopp/pproc.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import functools
import collections
import time
from six import string_types, advance_iterator
import numpy
import numpy as np
import matplotlib.pyplot as plt
Expand Down Expand Up @@ -375,7 +374,7 @@ def initialize(self):

self.reference_data = bestalg.load_reference_algorithm(self.reference_algorithm, force=True)
# TODO: remove targets smaller than 1e-8
elif isinstance(self.reference_data, string_types): # self.reference_data in ('RANDOMSEARCH', 'IPOP-CMA-ES') should work
elif isinstance(self.reference_data, str): # self.reference_data in ('RANDOMSEARCH', 'IPOP-CMA-ES') should work
self._short_info = "reference budgets from " + self.reference_data
# dsl = DataSetList(os.path.join(sys.modules[globals()['__name__']].__file__.split('cocopp')[0],
# 'cocopp', 'data', self.reference_data))
Expand All @@ -386,7 +385,7 @@ def initialize(self):
dsd[(ds.funcId, ds.dim)] = ds
self.reference_data = dsd
elif isinstance(self.reference_data, list):
if not isinstance(self.reference_data[0], string_types):
if not isinstance(self.reference_data[0], str):
raise ValueError(
"RunlengthBasedTargetValues() expected a string, dict, or list of strings as second argument,"
+ (" got a list of %s" % str(type(self.reference_data[0])))
Expand Down Expand Up @@ -2005,7 +2004,7 @@ def generateRLData(self, targets):
it = reversed(self.evals)
prevline = numpy.array([-numpy.inf] + [numpy.nan] * self.nbRuns())
try:
line = advance_iterator(it)
line = next(it)
except StopIteration:
# evals is an empty array
return res # list()
Expand All @@ -2014,7 +2013,7 @@ def generateRLData(self, targets):
while line[0] <= t:
prevline = line
try:
line = advance_iterator(it)
line = next(it)
except StopIteration:
break
res[t] = prevline.copy()
Expand Down Expand Up @@ -2110,7 +2109,7 @@ def detERT(self, targets):

prevline = numpy.array([-numpy.inf, numpy.inf])
try:
line = advance_iterator(it)
line = next(it)
except StopIteration:
# evals is an empty array
return list()
Expand All @@ -2119,7 +2118,7 @@ def detERT(self, targets):
while line[0] <= t:
prevline = line
try:
line = advance_iterator(it)
line = next(it)
except StopIteration:
break
res[t] = prevline.copy() # is copy necessary? Yes.
Expand Down Expand Up @@ -2297,7 +2296,7 @@ def _detEvals2(self, targets):
it = reversed(self.evals)
prevline = numpy.array([-numpy.inf] + [numpy.nan] * self.nbRuns())
try:
line = advance_iterator(it)
line = next(it)
except StopIteration:
# evals is an empty array
return tmp # list()
Expand All @@ -2306,7 +2305,7 @@ def _detEvals2(self, targets):
while line[0] <= t:
prevline = line
try:
line = advance_iterator(it)
line = next(it)
except StopIteration:
break
tmp[t] = prevline.copy()
Expand Down Expand Up @@ -2978,9 +2977,9 @@ def save_pickle(name, dsl):
if _ignore_pickle_files or len(args) != 1 or len(kwargs) or sys.version_info[0] < 3:
return fallback()
arg1 = args[0]
if isinstance(arg1, string_types):
if isinstance(arg1, str):
arg1 = [arg1]
if len(args) != 1 or not isinstance(arg1[0], string_types) or not findfiles.is_recognized_repository_filetype2(arg1[0]):
if len(args) != 1 or not isinstance(arg1[0], str) or not findfiles.is_recognized_repository_filetype2(arg1[0]):
return fallback()
try:
import pickle
Expand Down Expand Up @@ -3060,7 +3059,7 @@ def __init__(self, args=[], check_data_type=True):
super(DataSetList, self).__init__()
return

if isinstance(args, string_types):
if isinstance(args, str):
args = [args]

self._cocopp_version = _version.__version__
Expand All @@ -3078,7 +3077,7 @@ def __init__(self, args=[], check_data_type=True):
fnames = [] # data file names
alg_names = [] # may be the same algorithm name for (many) different fnames
for name in args:
if isinstance(name, string_types) and findfiles.is_recognized_repository_filetype(name):
if isinstance(name, str) and findfiles.is_recognized_repository_filetype(name):
# the found names may not at all reflect name anymore
fnames.extend(findfiles.main(name))
else:
Expand Down Expand Up @@ -3174,17 +3173,17 @@ def processIndexFile(self, indexFile, alg_name=None):
while True:
try:
if "indicator" not in header:
header = advance_iterator(f)
header = next(f)
while not header.strip(): # remove blank lines
header = advance_iterator(f)
header = next(f)
nbLine += 1
comment = advance_iterator(f)
comment = next(f)
if not comment.startswith("%"):
warnings.warn("Entry in file %s at line %d is faulty: " % (indexFile, nbLine) + "it will be skipped.")
nbLine += 2
continue

data = advance_iterator(f) # this is the filename of the data file!?
data = next(f) # this is the filename of the data file!?
data_file_names.append(data)
nbLine += 3
# TODO: check that something is not wrong with the 3 lines.
Expand Down Expand Up @@ -4105,10 +4104,10 @@ def parseinfoold(s):
res = []
while True:
try:
elem = advance_iterator(it)
elem = next(it)
tmp = p.match(elem)
while not tmp:
elem = advance_iterator(it) + elem
elem = next(it) + elem
# add up elements of list_kv until we have a whole key = value

elem0, elem1 = tmp.groups()
Expand Down
5 changes: 2 additions & 3 deletions src/cocopp/readalign.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

from . import genericsettings, testbedsettings, dataformatsettings

from six import advance_iterator


# CLASS DEFINITIONS
Expand Down Expand Up @@ -118,7 +117,7 @@ def __init__(self, data, isHArray=False):
self.isNearlyFinished = False
self.isFinished = False
self.currentLine = None
self.nextLine = advance_iterator(self.it)
self.nextLine = next(self.it)
if isHArray:
self.idxEvals = range(1, numpy.shape(data)[1])
else:
Expand All @@ -134,7 +133,7 @@ def next(self):
self.currentLine = self.nextLine.copy()
# Update nextLine
try:
self.nextLine = advance_iterator(self.it)
self.nextLine = next(self.it)
except StopIteration:
self.isNearlyFinished = True
else:
Expand Down
Loading