Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev(hansbug): add generic_flatten, generic_unflatten and register_integrate_container for integration module #81

Merged
merged 4 commits into from
Feb 27, 2023

Conversation

HansBug
Copy link
Member

@HansBug HansBug commented Feb 27, 2023

Description

Please review #79 before review this pr.

from collections import namedtuple
from dataclasses import dataclass

from easydict import EasyDict

from treevalue import FastTreeValue, generic_flatten, generic_unflatten


class MyTreeValue(FastTreeValue):
    pass


@dataclass
class DC:
    x: int
    y: float

    def __repr__(self):
        return f'DC({self.x}, {self.y})'


nt = namedtuple('nt', ['a', 'b'])

origin = {
    'a': 1,
    'b': [2, 3, 'f', ],
    'c': (2, 5, 'ds', EasyDict({  # dict's child class
        'x': None,
        'z': DC(34, '1.2'),  # dataclass
    })),
    'd': nt('f', 100),  # namedtuple
    'e': MyTreeValue({'x': 1, 'y': 'dsfljk'})  # treevalue
}
v, spec = generic_flatten(origin)
print(v)

rv = generic_unflatten(v, spec)
print(rv)

Check List

  • merge the latest version source branch/repo, and resolve all the conflicts
  • pass style check
  • pass all the tests

@HansBug HansBug requested a review from PaParaZz1 February 27, 2023 09:48
@HansBug HansBug self-assigned this Feb 27, 2023
@codecov
Copy link

codecov bot commented Feb 27, 2023

Codecov Report

Merging #81 (dd9ff51) into main (adc645e) will decrease coverage by 0.04%.
The diff coverage is 97.97%.

@@            Coverage Diff             @@
##             main      #81      +/-   ##
==========================================
- Coverage   99.04%   99.00%   -0.04%     
==========================================
  Files          42       43       +1     
  Lines        2624     2723      +99     
==========================================
+ Hits         2599     2696      +97     
- Misses         25       27       +2     
Flag Coverage Δ
unittests 99.00% <97.97%> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
treevalue/tree/integration/base.pyx 100.00% <ø> (ø)
treevalue/tree/integration/general.pyx 97.95% <97.95%> (ø)
treevalue/tree/integration/__init__.py 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@HansBug
Copy link
Member Author

HansBug commented Feb 27, 2023

Maybe some great new features for sail-sg/envpool#246 and sail-sg/envpool#249.

@HansBug HansBug merged commit fbb7ad1 into main Feb 27, 2023
@HansBug HansBug deleted the dev/int branch February 27, 2023 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants