Skip to content

Commit

Permalink
Merge branch 'unit_test_for_dassert_strictly_increasing_index-#999' of
Browse files Browse the repository at this point in the history
…https://github.com/kaizen-ai/kaizenflow into unit_test_for_dassert_strictly_increasing_index-#999
  • Loading branch information
mayank922 committed Jun 10, 2024
2 parents 022a0da + 6a3efd2 commit c7a6755
Show file tree
Hide file tree
Showing 8 changed files with 1,234 additions and 269 deletions.
4 changes: 2 additions & 2 deletions docs/coding/all.coding_style.how_to_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@
(software developer, DevOps or data scientist) should abide. Read it on long
commutes, during lunch, and treat yourself to a physical copy on Christmas.
The book is summarized
[here](https://github.com/cryptokaizen/cmamp/blob/master/docs/coding/all.code_like_pragmatic_programmer.how_to_guide.md),
[here](/docs/coding/all.code_like_pragmatic_programmer.how_to_guide.md),
but do not deprive yourself of the engaging manner in which Thomas & Hunt
elaborate on these points -- on top of it all, it is a very, very enjoyable
read.
Expand Down Expand Up @@ -658,7 +658,7 @@
- The linter is in charge of reformatting the code according to our conventions
and reporting potential problems
- You can find instructions on how to run linter at the
[First review process](First_review_process.md) doc
[First review process](/docs/coding/all.submit_code_for_review.how_to_guide.md) doc
### Remove linter messages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ Happy coding!
```
- More information about Linter -
[Link](/docs/infra/linter_gh_workflow.explanation.md)
[Link](/docs/build/all.linter_gh_workflow.explanation.md)
- Internalize the guidelines to maintain code consistency
## Writing and Contributing Code
Expand All @@ -355,3 +355,5 @@ Happy coding!
- Add your assigned reviewers for your PR so that they are informed of your PR
- After being reviewed, the PR will be merged to the master branch by your
reviewers
- Do not respond to emails for replies to comments in issues or PRs. Use the
GitHub GUI instead, as replying through email adds unwanted information.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
# Ask somebody if you have any doubts

- If you have doubts on how to do something you want to do:
- Look in the [documentation](https://github.com/cryptokaizen/cmamp/tree/master/docs) and our
- Look in the [documentation](/docs) and our
[Google drive](https://drive.google.com/drive/u/0/folders/1LXwKpmaFWJI-887IoA50sVC8-dw_1L8I)
- Google search is your friend
- Ask your team-members
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
- Avoid emails any time possible

- Communication should happen on GitHub around specific Issues
- Read [General Rules of Collaboration](General_rules_of_collaboration.md) for
- Read [General Rules of Collaboration](/docs/work_organization/all.team_collaboration.how_to_guide.md) for
more details

- Use Telegram chat when you are blocked on something
Expand Down
90 changes: 87 additions & 3 deletions im_v2/common/data/extract/test/test_extract_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
import os
import unittest.mock as umock
from datetime import datetime, timedelta
from typing import Any, Dict, Optional
from typing import Any, Dict, List, Optional

import pandas as pd
import pytest

import helpers.hdatetime as hdateti
import helpers.henv as henv
import helpers.hmoto as hmoto
import helpers.hpandas as hpandas
Expand Down Expand Up @@ -820,6 +819,88 @@ def test_download_and_resample_bid_ask_data(self) -> None:
self.check_resampler()


class TestSplitUniverse(hunitest.TestCase):
def helper(self, group_size: int, universe_part: int) -> List:
"""
Run the function and get a string representation of its output.
"""
universe = [
"ALICE_USDT",
"GALA_USDT",
"FLOW_USDT",
"HBAR_USDT",
"INJ_USDT",
"NEAR_USDT",
]
actual_output = imvcdeexut._split_universe(
universe, group_size, universe_part
)
output_str = str(actual_output)
return output_str

def test1(self) -> None:
"""
Check that universe is split correctly.
"""
group_size = 0
universe_part = 0
actual_str = self.helper(group_size, universe_part)
expected_str = r"""
[]
"""
self.assert_equal(actual_str, expected_str, fuzzy_match=True)

def test2(self) -> None:
"""
Check that universe is split correctly.
"""
group_size = 6
universe_part = 1
actual_str = self.helper(group_size, universe_part)
expected_str = r"""
['ALICE_USDT', 'GALA_USDT', 'FLOW_USDT', 'HBAR_USDT', 'INJ_USDT', 'NEAR_USDT']
"""
self.assert_equal(actual_str, expected_str, fuzzy_match=True)

def test3(self) -> None:
"""
Check that universe is split correctly.
"""
group_size = 6
universe_part = 2
actual_str = self.helper(group_size, universe_part)
expected_str = r"""
[]
"""
self.assert_equal(actual_str, expected_str, fuzzy_match=True)

def test4(self) -> None:
"""
Check that universe is split correctly.
"""
group_size = 4
universe_part = 2
actual_str = self.helper(group_size, universe_part)
expected_str = r"""
['INJ_USDT', 'NEAR_USDT']
"""
self.assert_equal(actual_str, expected_str, fuzzy_match=True)

def test5(self) -> None:
"""
Check the error is raised if universe does not have input part.
"""
group_size = 6
universe_part = 7
with self.assertRaises(RuntimeError) as cm:
self.helper(group_size, universe_part)
actual_str = str(cm.exception)
expected_str = r"""
Universe does not have 7 parts of 6 pairs. It has 6 symbols.
"""
self.assert_equal(actual_str, expected_str, fuzzy_match=True)


@pytest.mark.requires_ck_infra
@pytest.mark.requires_aws
@pytest.mark.skipif(
Expand Down Expand Up @@ -1766,7 +1847,9 @@ def test_download_websocket_ohlcv_futures1(
) -> None:
"""
Test the correct download of OHLCV data with consideration for
incomplete bars. Invariant #1.
incomplete bars.
Invariant #1.
"""
# Data received from exchange in second iteration.
next_data = {}
Expand Down Expand Up @@ -1815,6 +1898,7 @@ def test_download_websocket_ohlcv_futures3(
) -> None:
"""
Test the correct download of OHLCV data with backfilling.
Invariant #2.
"""
# Data received from exchange in second iteration.
Expand Down
Loading

0 comments on commit c7a6755

Please sign in to comment.