diff --git a/diofant/printing/dot.py b/diofant/printing/dot.py index 65f9124ffc3..75ca7336028 100644 --- a/diofant/printing/dot.py +++ b/diofant/printing/dot.py @@ -1,7 +1,7 @@ from ..core import Basic, Expr -__all__ = 'dotprint' +__all__ = 'dotprint', default_styles = [(Basic, {'color': 'blue', 'shape': 'ellipse'}), (Expr, {'color': 'black'})] diff --git a/diofant/tests/core/test_args.py b/diofant/tests/core/test_args.py index 1486b4944a0..d1e375a6214 100644 --- a/diofant/tests/core/test_args.py +++ b/diofant/tests/core/test_args.py @@ -3,7 +3,6 @@ # NOTE: keep tests sorted by (module, class name) key. import inspect -import io import os import re import warnings @@ -178,7 +177,7 @@ def test_all_classes_are_tested(): if not file.endswith('.py'): continue - with io.open(os.path.join(root, file), 'r', encoding='utf-8') as f: + with open(os.path.join(root, file), encoding='utf-8') as f: text = f.read() submodule = module + '.' + file[:-3] diff --git a/diofant/tests/external/test_autowrap.py b/diofant/tests/external/test_autowrap.py index 0ffe03d0af8..7b389d82eea 100644 --- a/diofant/tests/external/test_autowrap.py +++ b/diofant/tests/external/test_autowrap.py @@ -115,7 +115,7 @@ def runtest_autowrap_helpers(language, backend): for file in os.listdir(tmp): if file.startswith('wrapped_code_') and file.endswith('.c'): - fil = open(tmp + '/' + file) + fil = open(tmp + '/' + file, encoding='utf-8') assert fil.read() == ('/******************************************************************************\n' ' *' + ('Code generated with diofant ' + diofant.__version__).center(76) + '*\n' ' * *\n' diff --git a/diofant/tests/external/test_codegen.py b/diofant/tests/external/test_codegen.py index e6572399ee4..744541ba283 100644 --- a/diofant/tests/external/test_codegen.py +++ b/diofant/tests/external/test_codegen.py @@ -120,7 +120,7 @@ def try_run(commands): """Run a series of commands and only return True if all ran fine.""" - null = open(os.devnull, 'w') + null = open(os.devnull, 'w', encoding='utf-8') for command in commands: retcode = subprocess.call(command, stdout=null, shell=True, stderr=subprocess.STDOUT) @@ -185,7 +185,7 @@ def run_test(label, routines, numerical_tests, language, commands, friendly=True raise NotImplementedError( f'FIXME: filename extension unknown for language: {language}') - with open(f_name, 'w') as f: + with open(f_name, 'w', encoding='utf-8') as f: f.write( main_template[language] % {'statements': ''.join(test_strings)}) diff --git a/diofant/tests/logic/test_dimacs.py b/diofant/tests/logic/test_dimacs.py index c78e56f7eac..9966dcb3adb 100644 --- a/diofant/tests/logic/test_dimacs.py +++ b/diofant/tests/logic/test_dimacs.py @@ -17,7 +17,7 @@ def load_file(location): """Loads a boolean expression from a file.""" location = os.path.dirname(__file__) + '/' + location - with open(location) as f: + with open(location, encoding='utf-8') as f: s = f.read() return load(s) diff --git a/diofant/tests/solvers/test_diophantine.py b/diofant/tests/solvers/test_diophantine.py index c02302602ca..37b94e96f52 100644 --- a/diofant/tests/solvers/test_diophantine.py +++ b/diofant/tests/solvers/test_diophantine.py @@ -871,7 +871,7 @@ def test_sum_of_squares_powers(): assert list(sum_of_powers(5, 1, 2, True)) == [(0, 5), (1, 4), (2, 3)] assert list(sum_of_powers(6, 2, 2)) == [] assert list(sum_of_powers(3**5, 3, 1)) == [] - assert list(sum_of_powers(3**6, 3, 1)) == [(9,)] and (9**3 == 3**6) + assert list(sum_of_powers(3**6, 3, 1)) == [(9,)] assert list(sum_of_powers(2**1000, 5, 2)) == [] diff --git a/diofant/utilities/autowrap.py b/diofant/utilities/autowrap.py index 815f38a610f..ad2df2bb75f 100644 --- a/diofant/utilities/autowrap.py +++ b/diofant/utilities/autowrap.py @@ -167,7 +167,7 @@ def _prepare_files(self, routine): return def _generate_code(self, routine, helpers): - with open(f'{self.module_name}.py', 'w') as f: + with open(f'{self.module_name}.py', 'w', encoding='utf-8') as f: printed = ', '.join( [str(res.expr) for res in routine.result_variables]) # convert OutputArguments to return value like f2py @@ -239,7 +239,7 @@ def _prepare_files(self, routine): codefilename = f'{self.filename}.{self.generator.code_extension}' # pyx - with open(pyxfilename, 'w') as f: + with open(pyxfilename, 'w', encoding='utf-8') as f: self.dump_pyx([routine], f, self.filename) # setup.py @@ -250,7 +250,7 @@ def _prepare_files(self, routine): else: np_import = '' np_includes = '' - with open('setup.py', 'w') as f: + with open('setup.py', 'w', encoding='utf-8') as f: f.write(self.setup_template.format(ext_args=', '.join(ext_args), np_import=np_import, np_includes=np_includes)) @@ -651,11 +651,11 @@ def _prepare_files(self, routine): # C codefilename = self.module_name + '.c' - with open(codefilename, 'w') as f: + with open(codefilename, 'w', encoding='utf-8') as f: self.dump_c([routine], f, self.filename) # setup.py - with open('setup.py', 'w') as f: + with open('setup.py', 'w', encoding='utf-8') as f: self.dump_setup(f) @classmethod diff --git a/diofant/utilities/codegen.py b/diofant/utilities/codegen.py index e6266d79d9a..ee7d0776bc1 100644 --- a/diofant/utilities/codegen.py +++ b/diofant/utilities/codegen.py @@ -663,7 +663,7 @@ def write(self, routines, prefix, to_files=False, header=True, empty=True): if to_files: for dump_fn in self.dump_fns: filename = f'{prefix}.{dump_fn.extension}' - with open(filename, 'w') as f: + with open(filename, 'w', encoding='utf-8') as f: dump_fn(self, routines, f, prefix, header, empty) else: result = []