forked from pool/python-casacore
Atri Bhattacharya
af3a7fba93
* The build system has seen a major upgrade.
* Wheel related changes.
- do not require six
- added patches
fix afb5cbf88e
+ python-casacore-no-six.patch
OBS-URL: https://build.opensuse.org/package/show/science/python-casacore?expand=0&rev=12
457 lines
17 KiB
Diff
457 lines
17 KiB
Diff
From afb5cbf88eb6e78dd2aefe53d5ddf5179e1f8110 Mon Sep 17 00:00:00 2001
|
|
From: Tammo Jan Dijkema <dijkema@astron.nl>
|
|
Date: Wed, 28 Aug 2024 10:41:12 +0200
|
|
Subject: [PATCH] Remove dependency on six
|
|
|
|
---
|
|
casacore/fitting/fitting.py | 6 ++----
|
|
casacore/functionals/functional.py | 9 ++++-----
|
|
casacore/images/image.py | 9 ++++-----
|
|
casacore/measures/__init__.py | 7 +++----
|
|
casacore/quanta/quantity.py | 3 +--
|
|
casacore/tables/msutil.py | 3 +--
|
|
casacore/tables/table.py | 29 +++++++++++++----------------
|
|
casacore/tables/tablehelper.py | 9 ++++-----
|
|
casacore/tables/tableutil.py | 5 ++---
|
|
casacore/util/substitute.py | 3 +--
|
|
pyproject.toml | 1 -
|
|
11 files changed, 35 insertions(+), 49 deletions(-)
|
|
|
|
diff --git a/casacore/fitting/fitting.py b/casacore/fitting/fitting.py
|
|
index b0ec1e05..42d9b106 100644
|
|
--- a/casacore/fitting/fitting.py
|
|
+++ b/casacore/fitting/fitting.py
|
|
@@ -2,9 +2,7 @@
|
|
|
|
from ._fitting import fitting
|
|
import numpy as NUM
|
|
-import six
|
|
from casacore.functionals import *
|
|
-from six import string_types
|
|
|
|
|
|
class fitserver(object):
|
|
@@ -102,13 +100,13 @@ def init(self, n=0, ftype="real", colfac=1.0e-8, lmfac=1.0e-3, fid=0):
|
|
return False
|
|
|
|
def _gettype(self, ftype):
|
|
- if isinstance(ftype, string_types):
|
|
+ if isinstance(ftype, str):
|
|
ftype = ftype.lower()
|
|
if ftype not in self._typeids:
|
|
raise TypeError("Illegal fitting type")
|
|
else:
|
|
return self._typeids[ftype]
|
|
- elif isinstance(ftype, six.integer_types):
|
|
+ elif isinstance(ftype, int):
|
|
if ftype not in self._typeids.values():
|
|
raise TypeError("Illegal fitting type")
|
|
else:
|
|
diff --git a/casacore/functionals/functional.py b/casacore/functionals/functional.py
|
|
index 4f671881..301b40de 100644
|
|
--- a/casacore/functionals/functional.py
|
|
+++ b/casacore/functionals/functional.py
|
|
@@ -1,4 +1,3 @@
|
|
-from six import string_types, integer_types
|
|
from ._functionals import _functional
|
|
|
|
import numpy
|
|
@@ -20,19 +19,19 @@ def _decorator(func):
|
|
|
|
class functional(_functional):
|
|
def __init__(self, name=None, order=-1, params=None, mode=None, dtype=0):
|
|
- if isinstance(dtype, string_types):
|
|
+ if isinstance(dtype, str):
|
|
dtypes = {'real': 0, 'complex': 1}
|
|
dtype = dtypes.get(dtype.lower())
|
|
if numpy.iscomplexobj(params):
|
|
dtype = 1
|
|
self._dtype = dtype
|
|
progtext = ""
|
|
- if not isinstance(name, string_types):
|
|
+ if not isinstance(name, str):
|
|
raise TypeError("'name' was not of type string")
|
|
- if not (isinstance(order, integer_types) or isinstance(order, string_types)):
|
|
+ if not (isinstance(order, int) or isinstance(order, str)):
|
|
raise TypeError("'order' was not of type integer or string")
|
|
else:
|
|
- if isinstance(order, string_types):
|
|
+ if isinstance(order, str):
|
|
progtext = order
|
|
order = -1
|
|
# our own functionals server
|
|
diff --git a/casacore/images/image.py b/casacore/images/image.py
|
|
index ef4ce8dc..c931f73d 100644
|
|
--- a/casacore/images/image.py
|
|
+++ b/casacore/images/image.py
|
|
@@ -25,7 +25,6 @@
|
|
|
|
from __future__ import print_function
|
|
|
|
-from six import string_types, integer_types
|
|
from ._images import Image
|
|
import numpy
|
|
import numpy.ma as nma
|
|
@@ -128,7 +127,7 @@ def __init__(self, imagename, axis=0, maskname="", images=(), values=None,
|
|
if isinstance(imagename, tuple) or isinstance(imagename, list):
|
|
if len(imagename) == 0:
|
|
raise ValueError('No images given in list or tuple')
|
|
- if isinstance(imagename[0], string_types):
|
|
+ if isinstance(imagename[0], str):
|
|
# Concatenate from image names
|
|
Image.__init__(self, imagename, axis)
|
|
opened = True
|
|
@@ -137,7 +136,7 @@ def __init__(self, imagename, axis=0, maskname="", images=(), values=None,
|
|
Image.__init__(self, imagename, axis, 0, 0)
|
|
opened = True
|
|
if not opened:
|
|
- if not isinstance(imagename, string_types):
|
|
+ if not isinstance(imagename, str):
|
|
raise ValueError("first argument must be name or" +
|
|
" sequence of images or names")
|
|
if shape is None:
|
|
@@ -259,7 +258,7 @@ def attrgetrow(self, groupname, key, value=None):
|
|
It can only be used for unique attribute keys. An IndexError exception
|
|
is raised if no or multiple matches are found.
|
|
"""
|
|
- if not isinstance(key, string_types):
|
|
+ if not isinstance(key, str):
|
|
return self._attrgetrow(groupname, key)
|
|
# The key is an attribute name whose value has to be found.
|
|
rownrs = self.attrfindrows(groupname, key, value)
|
|
@@ -610,7 +609,7 @@ def view(self, tempname='/tmp/tempimage'):
|
|
|
|
def _adaptAxes(self, axes):
|
|
# If axes is a single integer value, turn it into a list.
|
|
- if isinstance(axes, integer_types):
|
|
+ if isinstance(axes, int):
|
|
axes = [axes]
|
|
# ImageProxy expects Fortran-numbered axes.
|
|
# So reverse the axes.
|
|
diff --git a/casacore/measures/__init__.py b/casacore/measures/__init__.py
|
|
index b91a1255..89c9cf97 100755
|
|
--- a/casacore/measures/__init__.py
|
|
+++ b/casacore/measures/__init__.py
|
|
@@ -31,7 +31,6 @@
|
|
import casacore.quanta as dq
|
|
import os
|
|
|
|
-from six import string_types
|
|
|
|
if 'MEASURESDATA' in os.environ.keys():
|
|
if 'AIPSPATH' not in os.environ.keys():
|
|
@@ -436,7 +435,7 @@ def tofrequency(self, rf, v0, rfq):
|
|
"""
|
|
if is_measure(rfq) and rfq['type'] == 'frequency':
|
|
rfq = dq.quantity(rfq['m0'])
|
|
- elif isinstance(rfq, string_types):
|
|
+ elif isinstance(rfq, str):
|
|
rfq = dq.quantity(rfq)
|
|
if is_measure(v0) and v0['type'] == 'doppler' \
|
|
and dq.is_quantity(rfq) \
|
|
@@ -488,7 +487,7 @@ def todoppler(self, rf, v0, rfq):
|
|
"""
|
|
if is_measure(rfq) and rfq['type'] == 'frequency':
|
|
rfq = dq.quantity(rfq['m0'])
|
|
- elif isinstance(rfq, string_types):
|
|
+ elif isinstance(rfq, str):
|
|
rfq = dq.quantity(rfq)
|
|
if is_measure(v0):
|
|
if v0['type'] == 'radialvelocity':
|
|
@@ -823,7 +822,7 @@ def riseset(self, crd, ev="5deg"):
|
|
"""
|
|
|
|
a = self.rise(crd, ev)
|
|
- if isinstance(a['rise'], string_types):
|
|
+ if isinstance(a['rise'], str):
|
|
return {"rise": {"last": a[0], "utc": a[0]},
|
|
"set": {"last": a[1], "utc": a[1]},
|
|
"solved": False}
|
|
diff --git a/casacore/quanta/quantity.py b/casacore/quanta/quantity.py
|
|
index 0e92a009..ddc23755 100644
|
|
--- a/casacore/quanta/quantity.py
|
|
+++ b/casacore/quanta/quantity.py
|
|
@@ -1,4 +1,3 @@
|
|
-from six import string_types
|
|
from ._quanta import QuantVec
|
|
from ._quanta import Quantity
|
|
from ._quanta import from_string, from_dict, from_dict_v
|
|
@@ -52,7 +51,7 @@ def quantity(*args):
|
|
|
|
"""
|
|
if len(args) == 1:
|
|
- if isinstance(args[0], string_types):
|
|
+ if isinstance(args[0], str):
|
|
# use copy constructor to create quantity from string
|
|
return Quantity(from_string(args[0]))
|
|
elif isinstance(args[0], dict):
|
|
diff --git a/casacore/tables/msutil.py b/casacore/tables/msutil.py
|
|
index 6d49908f..eedb8e1d 100644
|
|
--- a/casacore/tables/msutil.py
|
|
+++ b/casacore/tables/msutil.py
|
|
@@ -25,7 +25,6 @@
|
|
#
|
|
from __future__ import print_function
|
|
|
|
-from six import string_types
|
|
import numpy as np
|
|
from casacore.tables.table import (table, taql,
|
|
_required_ms_desc,
|
|
@@ -315,7 +314,7 @@ def msconcat(names, newname, concatTime=False):
|
|
for key in keywords:
|
|
if key != 'SORTED_TABLE':
|
|
val = keywords[key]
|
|
- if isinstance(val, string_types):
|
|
+ if isinstance(val, str):
|
|
tsub = table(val, ack=False)
|
|
tsubn = tsub.copy(newname + '/' + key, deep=True)
|
|
tnew.putkeyword(key, tsubn)
|
|
diff --git a/casacore/tables/table.py b/casacore/tables/table.py
|
|
index 189f0dae..f4f164ae 100755
|
|
--- a/casacore/tables/table.py
|
|
+++ b/casacore/tables/table.py
|
|
@@ -38,7 +38,6 @@
|
|
|
|
from __future__ import print_function
|
|
|
|
-from six import string_types
|
|
from ._tables import (Table,
|
|
_default_ms,
|
|
_default_ms_subtable,
|
|
@@ -47,8 +46,6 @@
|
|
|
|
from .tablehelper import (_add_prefix, _remove_prefix, _do_remove_prefix,
|
|
_format_row)
|
|
-import six
|
|
-
|
|
|
|
def default_ms(name, tabdesc=None, dminfo=None):
|
|
"""
|
|
@@ -344,7 +341,7 @@ def __init__(self, tablename, tabledesc=False, nrow=0, readonly=True,
|
|
# - concatenate open tables (ConcatTable)
|
|
tabname = _remove_prefix(tablename)
|
|
lockopt = lockoptions
|
|
- if isinstance(lockoptions, string_types):
|
|
+ if isinstance(lockoptions, str):
|
|
lockopt = {'option': lockoptions}
|
|
if isinstance(tabledesc, dict):
|
|
# Create a new table.
|
|
@@ -371,7 +368,7 @@ def __init__(self, tablename, tabledesc=False, nrow=0, readonly=True,
|
|
opt = 5
|
|
if _delete:
|
|
opt = 6
|
|
- if isinstance(tabname, string_types):
|
|
+ if isinstance(tabname, str):
|
|
Table.__init__(self, tabname, lockopt, opt)
|
|
if ack:
|
|
print('Successful', typstr, 'open of',
|
|
@@ -379,7 +376,7 @@ def __init__(self, tablename, tabledesc=False, nrow=0, readonly=True,
|
|
tabname + ':',
|
|
self.ncols(), 'columns,',
|
|
self.nrows(), 'rows')
|
|
- elif isinstance(tabname[0], string_types):
|
|
+ elif isinstance(tabname[0], str):
|
|
# Concatenate and open named tables.
|
|
Table.__init__(self, tabname, concatsubtables,
|
|
lockopt, opt)
|
|
@@ -1277,7 +1274,7 @@ def fieldnames(self, keyword=''):
|
|
of the struct value of the i-th keyword.
|
|
|
|
"""
|
|
- if isinstance(keyword, string_types):
|
|
+ if isinstance(keyword, str):
|
|
return self._getfieldnames('', keyword, -1)
|
|
else:
|
|
return self._getfieldnames('', '', keyword)
|
|
@@ -1299,7 +1296,7 @@ def colfieldnames(self, columnname, keyword=''):
|
|
of the struct value of the i-th keyword.
|
|
|
|
"""
|
|
- if isinstance(keyword, string_types):
|
|
+ if isinstance(keyword, str):
|
|
return self._getfieldnames(columnname, keyword, -1)
|
|
else:
|
|
return self._getfieldnames(columnname, '', keyword)
|
|
@@ -1327,7 +1324,7 @@ def getkeyword(self, keyword):
|
|
of the i-th keyword.
|
|
|
|
"""
|
|
- if isinstance(keyword, string_types):
|
|
+ if isinstance(keyword, str):
|
|
return self._getkeyword('', keyword, -1)
|
|
else:
|
|
return self._getkeyword('', '', keyword)
|
|
@@ -1338,7 +1335,7 @@ def getcolkeyword(self, columnname, keyword):
|
|
It is similar to :func:`getkeyword`.
|
|
|
|
"""
|
|
- if isinstance(keyword, string_types):
|
|
+ if isinstance(keyword, str):
|
|
return self._getkeyword(columnname, keyword, -1)
|
|
else:
|
|
return self._getkeyword(columnname, '', keyword)
|
|
@@ -1366,7 +1363,7 @@ def getsubtables(self):
|
|
keyset = self.getkeywords()
|
|
names = []
|
|
for key, value in keyset.items():
|
|
- if isinstance(value, string_types) and value.find('Table: ') == 0:
|
|
+ if isinstance(value, str) and value.find('Table: ') == 0:
|
|
names.append(_do_remove_prefix(value))
|
|
return names
|
|
|
|
@@ -1402,7 +1399,7 @@ def putkeyword(self, keyword, value, makesubrecord=False):
|
|
val = value
|
|
if isinstance(val, table):
|
|
val = _add_prefix(val.name())
|
|
- if isinstance(keyword, string_types):
|
|
+ if isinstance(keyword, str):
|
|
return self._putkeyword('', keyword, -1, makesubrecord, val)
|
|
else:
|
|
return self._putkeyword('', '', keyword, makesubrecord, val)
|
|
@@ -1416,7 +1413,7 @@ def putcolkeyword(self, columnname, keyword, value, makesubrecord=False):
|
|
val = value
|
|
if isinstance(val, table):
|
|
val = _add_prefix(val.name())
|
|
- if isinstance(keyword, string_types):
|
|
+ if isinstance(keyword, str):
|
|
return self._putkeyword(columnname, keyword, -1,
|
|
makesubrecord, val)
|
|
else:
|
|
@@ -1451,7 +1448,7 @@ def removekeyword(self, keyword):
|
|
the i-th keyword.
|
|
|
|
"""
|
|
- if isinstance(keyword, string_types):
|
|
+ if isinstance(keyword, str):
|
|
self._removekeyword('', keyword, -1)
|
|
else:
|
|
self._removekeyword('', '', keyword)
|
|
@@ -1462,7 +1459,7 @@ def removecolkeyword(self, columnname, keyword):
|
|
It is similar to :func:`removekeyword`.
|
|
|
|
"""
|
|
- if isinstance(keyword, string_types):
|
|
+ if isinstance(keyword, str):
|
|
self._removekeyword(columnname, keyword, -1)
|
|
else:
|
|
self._removekeyword(columnname, '', keyword)
|
|
@@ -1482,7 +1479,7 @@ def getdesc(self, actual=True):
|
|
# as these aren't valid. (See tabledefinehypercolumn)
|
|
hcdefs = tabledesc.get('_define_hypercolumn_', {})
|
|
|
|
- for c, hcdef in six.iteritems(hcdefs):
|
|
+ for c, hcdef in hcdefs.items():
|
|
if "HCcoordnames" in hcdef and len(hcdef["HCcoordnames"]) == 0:
|
|
del hcdef["HCcoordnames"]
|
|
if "HCidnames" in hcdef and len(hcdef["HCidnames"]) == 0:
|
|
diff --git a/casacore/tables/tablehelper.py b/casacore/tables/tablehelper.py
|
|
index bc40b8be..7de6d2af 100644
|
|
--- a/casacore/tables/tablehelper.py
|
|
+++ b/casacore/tables/tablehelper.py
|
|
@@ -25,7 +25,6 @@
|
|
#
|
|
# $Id: tableutil.py,v 1.6 2006/11/08 00:12:55 gvandiep Exp $
|
|
|
|
-from six import string_types, integer_types
|
|
import numpy
|
|
import re
|
|
from ..quanta import quantity
|
|
@@ -42,7 +41,7 @@ def _add_prefix(name):
|
|
def _do_remove_prefix(name):
|
|
"""Strip the possible prefix 'Table: ' from a table name."""
|
|
res = name
|
|
- if isinstance(res, string_types):
|
|
+ if isinstance(res, str):
|
|
if res.find('Table: ') == 0:
|
|
res = res.replace('Table: ', '', 1)
|
|
return res
|
|
@@ -50,7 +49,7 @@ def _do_remove_prefix(name):
|
|
|
|
def _remove_prefix(name):
|
|
"""Strip the possible prefix 'Table: ' from one or more table names."""
|
|
- if isinstance(name, string_types):
|
|
+ if isinstance(name, str):
|
|
return _do_remove_prefix(name)
|
|
return [_do_remove_prefix(nm) for nm in name]
|
|
|
|
@@ -114,13 +113,13 @@ def _check_key_slice(key, nrows, name):
|
|
def _value_type_name(value):
|
|
if isinstance(value, bool):
|
|
return 'boolean'
|
|
- if isinstance(value, integer_types):
|
|
+ if isinstance(value, int):
|
|
return 'integer'
|
|
if isinstance(value, float):
|
|
return 'double'
|
|
if isinstance(value, complex):
|
|
return 'dcomplex'
|
|
- if isinstance(value, string_types):
|
|
+ if isinstance(value, str):
|
|
return 'string'
|
|
if isinstance(value, dict):
|
|
return 'record'
|
|
diff --git a/casacore/tables/tableutil.py b/casacore/tables/tableutil.py
|
|
index 9ec24ed3..4563fde5 100755
|
|
--- a/casacore/tables/tableutil.py
|
|
+++ b/casacore/tables/tableutil.py
|
|
@@ -28,7 +28,6 @@
|
|
|
|
from collections import defaultdict
|
|
|
|
-import six
|
|
from .table import table
|
|
from .tablehelper import _remove_prefix, _value_type_name
|
|
|
|
@@ -525,7 +524,7 @@ def __init__(self):
|
|
|
|
# Iterate through the table columns, grouping them
|
|
# by their dataManagerGroup
|
|
- for c, d in six.iteritems(tabdesc):
|
|
+ for c, d in tabdesc.items():
|
|
if c in ('_define_hypercolumn_', '_keywords_', '_private_keywords_'):
|
|
continue
|
|
|
|
@@ -568,7 +567,7 @@ def __init__(self):
|
|
'SPEC' : dm_group.spec,
|
|
'SEQNR': i
|
|
} for i, (group, dm_group)
|
|
- in enumerate(six.iteritems(dm_groups))
|
|
+ in enumerate(dm_groups.items())
|
|
}
|
|
|
|
# Create the old glish names for them.
|
|
diff --git a/casacore/util/substitute.py b/casacore/util/substitute.py
|
|
index f3203cbf..46bad62c 100644
|
|
--- a/casacore/util/substitute.py
|
|
+++ b/casacore/util/substitute.py
|
|
@@ -23,7 +23,6 @@
|
|
# 520 Edgemont Road
|
|
# Charlottesville, VA 22903-2475 USA
|
|
|
|
-from six import string_types
|
|
import numpy as np
|
|
|
|
__all__ = ['getlocals', 'getvariable', 'substitute']
|
|
@@ -266,7 +265,7 @@ def substitutevar(v):
|
|
def substituteonevar(v):
|
|
# A string needs to be enclosed in quotes.
|
|
# A vector value is enclosed in square brackets and separated by commas.
|
|
- if isinstance(v, string_types):
|
|
+ if isinstance(v, str):
|
|
return substitutestring(v)
|
|
# A numeric or boolean value is converted to a string.
|
|
# A vector value is enclosed in square brackets and separated by commas.
|
|
diff --git a/pyproject.toml b/pyproject.toml
|
|
index 28ac9d58..99ea3d0b 100644
|
|
--- a/pyproject.toml
|
|
+++ b/pyproject.toml
|
|
@@ -40,7 +40,6 @@ classifiers=[
|
|
]
|
|
dependencies = [
|
|
"numpy",
|
|
- "six",
|
|
]
|
|
|
|
[project.urls]
|
|
|