Skip to content

Ticket8297 remove six usage #113

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ init-import=no

# List of qualified module names which can have objects that can redefine
# builtins.
redefining-builtins-modules=six.moves,future.builtins
redefining-builtins-modules=future.builtins


[SIMILARITIES]
Expand Down
2 changes: 1 addition & 1 deletion general/scans/.pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ init-import=no

# List of qualified module names which can have objects that can redefine
# builtins.
redefining-builtins-modules=six.moves,future.builtins
redefining-builtins-modules=future.builtins


[SIMILARITIES]
Expand Down
4 changes: 1 addition & 3 deletions general/scans/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

from abc import ABCMeta, abstractmethod
import os
from six import add_metaclass
import matplotlib.pyplot as plt
import numpy as np

Expand All @@ -29,8 +28,7 @@
from .mocks import g


@add_metaclass(ABCMeta)
class Defaults(object):
class Defaults(object, metaclass=ABCMeta):
"""A defaults object to store the correct functions for this instrument"""

SINGLE_FIGURE = False
Expand Down
7 changes: 2 additions & 5 deletions general/scans/fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,13 @@
import warnings
import numpy as np
from scipy.stats import linregress
from six import add_metaclass
from scipy.special import erf # pylint: disable=no-name-in-module

# pylint: disable=wrong-import-position
from scipy.optimize import curve_fit, OptimizeWarning # noqa: E402


@add_metaclass(ABCMeta)
class Fit(object):
class Fit(object, metaclass=ABCMeta):
"""The Fit class combines the common requirements needed for fitting.
We need to be able to turn a set of data points into a set of
parameters, get the simulated curve from a set of parameters, and
Expand Down Expand Up @@ -258,8 +256,7 @@ def title(self, center):
return "Peak at {}".format(smart_number_format(center))


@add_metaclass(ABCMeta)
class CurveFit(Fit):
class CurveFit(Fit, metaclass=ABCMeta):
"""
A class for fitting models based on the scipy curve_fit optimizer
"""
Expand Down
4 changes: 1 addition & 3 deletions general/scans/monoid.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@

from abc import ABCMeta, abstractmethod
import numpy as np
from six import add_metaclass


@add_metaclass(ABCMeta)
class Monoid(object):
class Monoid(object, metaclass=ABCMeta):
"""
The Monoid base class enforces the two laws: There must be a zero
operation and a combining function (add).
Expand Down
4 changes: 1 addition & 3 deletions general/scans/motion.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
except ImportError:
from .mocks import g

from six import text_type


class Motion(object):
# pylint: disable=too-many-instance-attributes
Expand Down Expand Up @@ -225,7 +223,7 @@ def get_motion(motion_or_block_name):
"""
if isinstance(motion_or_block_name, Motion):
motion = motion_or_block_name
elif isinstance(motion_or_block_name, (str, text_type)):
elif isinstance(motion_or_block_name, (str, str)):
motion = BlockMotion(motion_or_block_name, get_units(motion_or_block_name))
else:
raise TypeError("Cannot run scan on axis {}. Try a string or a motion object instead.".format(
Expand Down
7 changes: 2 additions & 5 deletions general/scans/scans.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
import time
import warnings
import numpy as np
import six
from six import add_metaclass
import matplotlib.pyplot as plt

if TYPE_CHECKING:
Expand Down Expand Up @@ -94,8 +92,7 @@ def get_input(prompt: str):



@add_metaclass(ABCMeta)
class Scan(object):
class Scan(object, metaclass=ABCMeta):
"""The virtual class that represents all controlled scans. This class
should never be instantiated directly, but rather by one of its
subclasses."""
Expand Down Expand Up @@ -729,7 +726,7 @@ def __init__(self, first, second):
self.defaults = self.first.defaults

def __iter__(self):
for x, y in six.moves.zip(self.first, self.second):
for x, y in zip(self.first, self.second):
yield merge_dicts(x, y)

def __repr__(self):
Expand Down
4 changes: 1 addition & 3 deletions nee_scripts/instrument.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import csv
from logging import info, warning
import os.path
from six import add_metaclass
from .genie import gen
from .util import user_script

Expand All @@ -25,9 +24,8 @@ def _get_times(times):
raise RuntimeError("No valid time found")


@add_metaclass(ABCMeta)
# pylint: disable=too-many-public-methods
class ScanningInstrument(object):
class ScanningInstrument(object, metaclass=ABCMeta):
"""
The base class for scanning measurement instruments.

Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ matplotlib
pylint
flake8
scipy
six
sphinx
mock
parameterized
Expand Down
1 change: 0 additions & 1 deletion technique/muon/muon_begin_end.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import print_function
from genie_python import genie as g
from six.moves import input
import time


Expand Down
7 changes: 2 additions & 5 deletions technique/muon/tests/test_background_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@
# Imports come after to prevent import of genie python not in simulation
import datetime
import unittest
import six.moves
from technique.muon.background_plot import BackgroundPlot
if six.PY3:
from unittest.mock import patch, mock_open
else:
from mock import patch, mock_open
from unittest.mock import patch, mock_open


THIS_DIR = os.path.dirname(os.path.abspath(__file__))

Expand Down
6 changes: 1 addition & 5 deletions technique/muon/tests/test_muon_begin_end.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,9 @@

# Imports come after to prevent import of genie python not in simulation
import unittest
import six.moves
from technique.muon import muon_begin_end
from genie_python import genie as g
if six.PY3:
from unittest.mock import patch, MagicMock
else:
from mock import patch, MagicMock
from unittest.mock import patch, MagicMock


class TestRunControl(unittest.TestCase):
Expand Down
1 change: 0 additions & 1 deletion technique/reflectometry/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from future.moves import itertools
from math import tan, radians, sin

from six.moves import input
from genie_python import genie as g

import general.utilities.io
Expand Down
1 change: 0 additions & 1 deletion technique/sans/auto_reduction.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from __future__ import print_function
from xml.etree import ElementTree as ET
from collections import defaultdict
from six.moves import input

SCHEMA = "{http://definition.nexusformat.org/schema/3.0}"

Expand Down
4 changes: 1 addition & 3 deletions technique/sans/instrument.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import csv
from logging import info, warning
import os.path
from six import add_metaclass
from .genie import gen
from .util import user_script

Expand All @@ -25,9 +24,8 @@ def _get_times(times):
raise ValueError("No valid time found")


@add_metaclass(ABCMeta)
# pylint: disable=too-many-public-methods
class ScanningInstrument(object):
class ScanningInstrument(object, metaclass=ABCMeta):
"""
The base class for scanning measurement instruments.

Expand Down