diff --git a/dios/__init__.py b/dios/__init__.py index 525c5b66cd5d9396859833ddabc016e0effb0b82..a1c967bd0dfd895d3b003320279a88a4c903e6f7 100644 --- a/dios/__init__.py +++ b/dios/__init__.py @@ -1,4 +1,4 @@ -from dios.lib import * -from dios.dios import * +from .lib import * +from .dios import * diff --git a/dios/dios.py b/dios/dios.py index f907d1caa1cfbcc697b261326683e5bd068c11cd..3bf9bef4ad10eb7ecf78e0991375ac1d02e6b1d8 100644 --- a/dios/dios.py +++ b/dios/dios.py @@ -1,7 +1,7 @@ -from dios.operators import OP_MAP as _OP_MAP +from .operators import OP_MAP as _OP_MAP -from dios.lib import * -from dios.lib import _CAST_POLICIES, _itype_le, _throw_MixedItype_err_or_warn +from .lib import * +from .lib import _CAST_POLICIES, _itype_le, _throw_MixedItype_err_or_warn import pandas as pd import numpy as np @@ -49,12 +49,12 @@ def _is_bool_series(obj): class DictOfSeries: """ - DictionaryOfSeries is a collection of pd.Series's which aim to be as close as possible similar to + DictOfSeries is a collection of pd.Series's which aim to be as close as possible similar to pd.DataFrame. The advantage over pd.DataFrame is, that every `column` has its own row-index, unlike the former, which provide a single row-index for all columns. This solves problems with unaligned pd.Series. - DictionaryOfSeries: + DictOfSeries: - ``dios['a']`` indexing with single label, work on columns, return series - ``dios[iterable]`` indexing with list, work on columns, return dios - ``dios[slice]`` indexing with slice, work on (all) index'es, return dios @@ -224,7 +224,7 @@ class DictOfSeries: raise KeyError(f"{key}. tuples are not allowed") elif _is_hashable(key): - if isinstance(value, pd.Series): + if isinstance(value, pd.Series) or key not in self.columns: self._insert(key, value) else: self._data.at[key][:] = value @@ -249,27 +249,27 @@ class DictOfSeries: @property def loc(self): - from dios.locator import _LocIndexer + from .locator import _LocIndexer return _LocIndexer(self) @property def iloc(self): - from dios.locator import _iLocIndexer + from .locator import _iLocIndexer return _iLocIndexer(self) @property def aloc(self): - from dios.locator import _aLocIndexer + from .locator import _aLocIndexer return _aLocIndexer(self) @property def at(self): - from dios.locator import _AtIndexer + from .locator import _AtIndexer return _AtIndexer(self) @property def iat(self): - from dios.locator import _iAtIndexer + from .locator import _iAtIndexer return _iAtIndexer(self) @property @@ -479,7 +479,7 @@ class DictOfSeries: def pprint_dios(dios, max_rows=10, max_cols=2, delim=' '): if dios.empty: - return f"Empty DictionaryOfSeries\n" \ + return f"Empty DictOfSeries\n" \ f"Columns: {dios.columns.to_list()}" sstr = [] diff --git a/dios/lib.py b/dios/lib.py index 4ca07cb3912f8df04b48c29d4ff662b746356211..d224fd785872384bd0aca762dca955adedf94d30 100644 --- a/dios/lib.py +++ b/dios/lib.py @@ -260,7 +260,7 @@ dios_options = { def _throw_MixedItype_err_or_warn(itype): - msg = f"'{itype.repr}'. Using a non-unique Itype for a DictionaryOfSeries, is not recommend. " \ + msg = f"'{itype.repr}'. Using a non-unique Itype for a DictOfSeries, is not recommend. " \ f"As soon as series \nwith different index types are inserted, selecting and slicing data will " \ f"almost always fail. You are hereby warned!" if dios_options[OptsFields.mixed_itype_warn_policy] in ['ignore', Opts.itype_ignore]: diff --git a/dios/locator.py b/dios/locator.py index f42d3e15ab04bf0baf960230b6fe0d18bff458ba..6dadb5905b8ff45ab1ccd44bb9e538ccb0650998 100644 --- a/dios/locator.py +++ b/dios/locator.py @@ -1,4 +1,4 @@ -from dios.dios import ( +from .dios import ( _is_dios_like, _is_bool_series, _is_list_like_not_nested, diff --git a/profiling/__init__.py b/profiling/__init__.py index 34c8fe901fd5efd3428df1304e8159bc5f173c3c..76bd5b5dbb9f96e699ee31d29211cbcb35191074 100644 --- a/profiling/__init__.py +++ b/profiling/__init__.py @@ -1,3 +1,3 @@ from .generate_testsets import * -from profiling.performance import find_index_range, gen_random_timestamps +from .performance import find_index_range, gen_random_timestamps diff --git a/profiling/generate_testsets.py b/profiling/generate_testsets.py index 9d95cc3405fa7be21ab474302cd237f3e7a54489..6aa7a48f61654e2d4a017e778158992a8649731c 100644 --- a/profiling/generate_testsets.py +++ b/profiling/generate_testsets.py @@ -3,7 +3,7 @@ import time import pandas as pd import numpy as np import datetime as dt -from dios import dios +from ..dios import DictOfSeries import pickle import os @@ -12,7 +12,7 @@ var_prefix = 'var' def _gen_testset(rowsz, colsz, freq='1min', disalign=True, randstart=True): df = pd.DataFrame() - dos = dios.DictOfSeries() + dos = DictOfSeries() start = dt.datetime.strptime("2000-01-01 00:00:00", "%Y-%m-%d %H:%M:%S") times = pd.date_range(periods=rowsz, start=start, freq=freq) diff --git a/profiling/memory.py b/profiling/memory.py index d577464ea22b2e51416a5ac452393a5d3e23f14c..d837d9193ab4590125ffe07c9d7390d3647e7ea8 100644 --- a/profiling/memory.py +++ b/profiling/memory.py @@ -1,5 +1,5 @@ import gc -from profiling.generate_testsets import get_random_df_and_dios +from .generate_testsets import get_random_df_and_dios def calc_mem(rows, cols, shifted=False, dtypesz=(64 / 8)): diff --git a/profiling/performance.py b/profiling/performance.py index de2e58a70e12aa335c5635d5a1497e60bc3a883c..5ba5cd4da17c173d23b742a16a763c049ba22e4e 100644 --- a/profiling/performance.py +++ b/profiling/performance.py @@ -1,7 +1,7 @@ import pandas as pd import numpy as np import time -from profiling.generate_testsets import get_testset, var_prefix +from .generate_testsets import get_testset, var_prefix profile_assignment = False diff --git a/test/run_dios.py b/test/run_dios.py index 1409433a032a55aef8feef0eb1c85843cc5e24d0..bde77740a68f42faed4e283906899c7b371db1af 100644 --- a/test/run_dios.py +++ b/test/run_dios.py @@ -1,5 +1,5 @@ -from dios import * +from ..dios import * import numpy as np if __name__ == '__main__': diff --git a/test/test__getitem__.py b/test/test__getitem__.py index 78ab3333893ee78759ed9ec4be41a5ef5c342e8f..d94ee4ed0964b57c592a398f4570660940dbda2f 100644 --- a/test/test__getitem__.py +++ b/test/test__getitem__.py @@ -1,5 +1,5 @@ -from dios import * -from test.test_setup import * +from ..dios import * +from .test_setup import * from pandas.core.dtypes.common import is_scalar # s1 = pd.Series(range(10), index=range(10)) diff --git a/test/test__setitem__.py b/test/test__setitem__.py index 6f9d4f531fc25740fad183f945cb7d964988d5d4..28dfe6177a2d8ebff1106732e4ef5d97dc471d28 100644 --- a/test/test__setitem__.py +++ b/test/test__setitem__.py @@ -1,5 +1,5 @@ -from dios import * -from test.test_setup import * +from ..dios import * +from .test_setup import * import pytest s1 = pd.Series(range(10), index=range(10)) diff --git a/test/test_df_like.py b/test/test_df_like.py index 77d661c3cda4d7f93230db2675ce5afa5fd44b60..d706321cd06d77b2c3a01c7dbb16c981a30d6f57 100644 --- a/test/test_df_like.py +++ b/test/test_df_like.py @@ -1,6 +1,6 @@ #!/usr/bin/env python import pytest -from dios import * +from ..dios import * import pandas as pd from pandas.core.dtypes.common import is_dict_like, is_nested_list_like diff --git a/test/test_dflike__setget__.py b/test/test_dflike__setget__.py index a3c5ca59523c95ec8a9cdda4c9ef5af43fe8f068..453a91490d48b2d66d8a4eb67e222f6b1afb0eda 100644 --- a/test/test_dflike__setget__.py +++ b/test/test_dflike__setget__.py @@ -1,5 +1,5 @@ -from dios import * -from test.test_setup import * +from ..dios import * +from .test_setup import * import pytest diff --git a/test/test_dios_old.py b/test/test_dios_old.py index 4b720ca0a31960a3cd4b0da88f37fd29d0aee018..7e0a024df55c948aecd00435ba8324f2cf1ad0be 100644 --- a/test/test_dios_old.py +++ b/test/test_dios_old.py @@ -1,5 +1,5 @@ -from dios import * -from profiling import * +from ..dios import * +from ..profiling import * import pandas as pd import datetime as dt import numpy as np diff --git a/test/test_magic_methods.py b/test/test_magic_methods.py index 9faaa1e80f054c6ee49ebaf3568dc951b72c977b..d76f400e075b80b012ba8975380edebcf1f0014c 100644 --- a/test/test_magic_methods.py +++ b/test/test_magic_methods.py @@ -1,4 +1,4 @@ -from test.test_setup import * +from .test_setup import * def test__len__(datetime_series, maxlen=10): diff --git a/test/test_methods.py b/test/test_methods.py index 221f189bd2e21ac23a2ca67df9078eae7b9fbe8c..95dfb347f301550e560f510d54047410a562ee3c 100644 --- a/test/test_methods.py +++ b/test/test_methods.py @@ -1,4 +1,4 @@ -from test.test_setup import * +from .test_setup import * def test_copy_copy_empty(getDtDiosAligned): diff --git a/test/test_ops.py b/test/test_ops.py index bb5acfe32b55a9bcdc17a283ae2a6d24901c20a7..1e835d40b06167bd18a157fc908f9b3285901f5c 100644 --- a/test/test_ops.py +++ b/test/test_ops.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -from test.test_setup import * -from dios.operators import * +from .test_setup import * +from ..dios.operators import * __author__ = "Bert Palm" diff --git a/test/test_setup.py b/test/test_setup.py index d0dc43b252d39511512156a448a123cf3ad77b2f..b98ace0a58f1322e9f376a756e13406cde578c1d 100644 --- a/test/test_setup.py +++ b/test/test_setup.py @@ -1,6 +1,6 @@ import pytest -from dios import * -from dios.operators import _OP1_MAP, _OP2_DIV_MAP, _OP2_ARITH_MAP, _OP2_BOOL_MAP, _OP2_COMP_MAP +from ..dios import * +from ..dios.operators import _OP1_MAP, _OP2_DIV_MAP, _OP2_ARITH_MAP, _OP2_BOOL_MAP, _OP2_COMP_MAP import pandas as pd import numpy as np from copy import deepcopy