Skip to content

Commit

Permalink
use bigger int for time concept
Browse files Browse the repository at this point in the history
work around #124, need more consideration
  • Loading branch information
semio committed May 27, 2020
1 parent 2e218e7 commit c1fe41e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion ddf_utils/model/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def load_ddf(self):
# 2. dtype for time
for c_id, c in concepts.items():
if c.concept_type == 'time':
dtypes[c_id] = 'int16' # TODO: maybe there are other format for time.
dtypes[c_id] = 'uint64' # TODO: maybe there are other format for time.
# 3. group files for same indicator together
indicators = dict()
for field, pkey, path in self._gen_datapoints():
Expand Down
12 changes: 6 additions & 6 deletions tests/chef/test_procedures.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def test_filter():

assert set(dps.keys()) == {'imr_upper', 'imr_lower'}
for dp in dps.values():
assert dp.year.dtype == np.int16
assert dp.year.dtype == np.uint64
assert np.all(dp.year > 2000)
assert set(dp.country.unique()) == {'usa', 'swe'}

Expand All @@ -81,7 +81,7 @@ def test_flatten():
'agriculture_percentage_f', 'agriculture_percentage_m',
'agriculture_thousands', 'agriculture_percentage'}

assert res[0].compute()['agriculture_percentage_m'].dtypes['year'] == np.int16
assert res[0].compute()['agriculture_percentage_m'].dtypes['year'] == np.uint64


def test_groupby():
Expand Down Expand Up @@ -115,7 +115,7 @@ def test_translate_column():
chef.run()

res = chef.dag.get_node('bp-datapoints-aligned').evaluate().compute()
assert res['biofuels_production_kboed'].dtypes['year'] == np.int16
assert res['biofuels_production_kboed'].dtypes['year'] == np.uint64


def test_translate_header():
Expand All @@ -128,7 +128,7 @@ def test_translate_header():
assert set(data.keys()) == set(indicators)
for i in indicators:
assert set(data[i].columns) == set(['geo', 'time', i])
assert data[i].dtypes['time'] == np.int16
assert data[i].dtypes['time'] == np.uint64

data = res[1].get_data()
assert 'city' in data.keys()
Expand All @@ -155,7 +155,7 @@ def test_trend_bridge():
chef.run()

res = chef.dag.get_node('res-1').evaluate().compute()
assert res['imr_lower'].dtypes['year'] == np.int16
assert res['imr_lower'].dtypes['year'] == np.uint64


def test_window():
Expand Down Expand Up @@ -192,7 +192,7 @@ def test_merge():
indicators = ['imr_lower', 'imr_median', 'imr_upper',
'biofuels_production_kboed', 'biofuels_production_ktoe']
assert set(data.keys()) == set(indicators)
assert data['imr_median'].dtypes['year'] == np.int16
assert data['imr_median'].dtypes['year'] == np.uint64

imr_lower = data['imr_lower'].set_index(['geo', 'year'])
assert imr_lower.loc[('afg', 1961), 'imr_lower'] == 2055
Expand Down

0 comments on commit c1fe41e

Please sign in to comment.