From 49ec3f30dbab94b8acd124fcb1e413b9307dd892 Mon Sep 17 00:00:00 2001 From: TBeaufils <beaufils.timothe@gmail.com> Date: Tue, 14 Nov 2023 18:42:03 +0100 Subject: [PATCH 1/3] Define default imports --- __init__.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/__init__.py b/__init__.py index e69de29..1ad7f2d 100644 --- a/__init__.py +++ b/__init__.py @@ -0,0 +1,5 @@ +from .mrio import MRIO +from .eeio import EEIO +from .mrio_formatter import format_table + +__all__ = [MRIO,EEIO,format_table] \ No newline at end of file -- GitLab From 93bba67ecaccfd0f55ed4efe9cf4a9a683b1a1b9 Mon Sep 17 00:00:00 2001 From: TBeaufils <beaufils.timothe@gmail.com> Date: Tue, 14 Nov 2023 18:42:49 +0100 Subject: [PATCH 2/3] Implement relative import and fix filename style --- EEIO.py | 4 ++-- _parts/__init__.py | 4 ---- _preformatters/__init__.py | 9 +++++++++ MRIOBase.py => mrio.py | 12 ++++++------ mrio_formatter.py | 6 +----- 5 files changed, 18 insertions(+), 17 deletions(-) rename MRIOBase.py => mrio.py (98%) diff --git a/EEIO.py b/EEIO.py index 60e8186..4f33121 100644 --- a/EEIO.py +++ b/EEIO.py @@ -7,8 +7,8 @@ Created on Thu Apr 6 14:25:07 2023 import os import numpy as np -from MRIOBase import MRIO -from _parts._Part import Part +from .mrio import MRIO +from ._parts._Part import Part crf = '2021_1' hist = '2.4' diff --git a/_parts/__init__.py b/_parts/__init__.py index 0eeacd2..e69de29 100644 --- a/_parts/__init__.py +++ b/_parts/__init__.py @@ -1,4 +0,0 @@ -# -*- coding: utf-8 -*- - -__all__ = ["_BasePart","_FdPart","_ArrayPart","_ExtensionPart", - "_FdExtensionPart"] diff --git a/_preformatters/__init__.py b/_preformatters/__init__.py index e69de29..0c93bb3 100644 --- a/_preformatters/__init__.py +++ b/_preformatters/__init__.py @@ -0,0 +1,9 @@ +from . import icio2021 +from . import eora26 +from . import exiobase_ixi +from . import exiobase_pxp +from . import icio2021 +from . import wiod16 + +__all__ = [icio2021,eora26,exiobase_ixi,exiobase_pxp, + icio2021,wiod16] \ No newline at end of file diff --git a/MRIOBase.py b/mrio.py similarity index 98% rename from MRIOBase.py rename to mrio.py index c8587ee..718e4b1 100644 --- a/MRIOBase.py +++ b/mrio.py @@ -9,10 +9,10 @@ Representation of economic MRIO tables import os import numpy as np -import mrio_formatter +from .mrio_formatter import format_table from pathlib import Path -from _parts._Part import Part as Part -from _parts._zones import Zones as Zones +from ._parts._Part import Part as Part +from ._parts._zones import Zones as Zones mrio_folder = r'C:\Users\beaufils\Documents\\Projects\Ressources\MRIO' zones_folder = os.path.abspath(os.path.join(Path(__file__).parent,"data")) @@ -412,9 +412,9 @@ class MRIO: try: #Remove the version and table name of the data path main_path = os.path.join(*Path(self.data_path).parts[:-2]) - mrio_formatter.format_table(self.year,self.table, - version_name=self.version, - path=main_path) + format_table(self.year,self.table, + version_name=self.version, + path=main_path) print("Preformatting successful") except Exception as e: raise e diff --git a/mrio_formatter.py b/mrio_formatter.py index 4b418c2..230b7ea 100644 --- a/mrio_formatter.py +++ b/mrio_formatter.py @@ -17,11 +17,7 @@ import sys import numpy as np #Available table extractors -import _preformatters.icio2021 as icio2021 #icio2021 -import _preformatters.wiod16 as wiod16 #wiod16 -import _preformatters.eora26 as eora26 #eora26 -import _preformatters.exiobase_pxp as exiobase_pxp #exiobase_pxp -import _preformatters.exiobase_ixi as exiobase_ixi #exiobase_ixi +from ._preformatters import * def format_table(year,table,source_name="raw",version_name="formatted", -- GitLab From d630599269fa3ad25163ab33fc3cbd107533e5da Mon Sep 17 00:00:00 2001 From: TBeaufils <beaufils.timothe@gmail.com> Date: Tue, 14 Nov 2023 18:47:02 +0100 Subject: [PATCH 3/3] Fix init behavior --- __init__.py | 2 +- _preformatters/__init__.py | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/__init__.py b/__init__.py index 1ad7f2d..9014dc3 100644 --- a/__init__.py +++ b/__init__.py @@ -2,4 +2,4 @@ from .mrio import MRIO from .eeio import EEIO from .mrio_formatter import format_table -__all__ = [MRIO,EEIO,format_table] \ No newline at end of file +__all__ = ["MRIO","EEIO","format_table"] \ No newline at end of file diff --git a/_preformatters/__init__.py b/_preformatters/__init__.py index 0c93bb3..5f0806f 100644 --- a/_preformatters/__init__.py +++ b/_preformatters/__init__.py @@ -1,9 +1,8 @@ -from . import icio2021 from . import eora26 from . import exiobase_ixi from . import exiobase_pxp from . import icio2021 from . import wiod16 -__all__ = [icio2021,eora26,exiobase_ixi,exiobase_pxp, - icio2021,wiod16] \ No newline at end of file +__all__ = ["eora26","exiobase_ixi","exiobase_pxp", + "icio2021","wiod16"] \ No newline at end of file -- GitLab