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

Additions required for simson trade module #58

Merged
merged 7 commits into from
Nov 28, 2024
Merged

Additions required for simson trade module #58

merged 7 commits into from
Nov 28, 2024

Conversation

Merjo
Copy link
Contributor

@Merjo Merjo commented Nov 6, 2024

No description provided.

Copy link
Collaborator

@SallyDa SallyDa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's looking much cleaner, thanks! Still a few minor comments, but all up for discussion, since I'm not fully convinced either way :)

sodym/trade.py Outdated Show resolved Hide resolved
sodym/trade.py Outdated Show resolved Hide resolved
sodym/trade.py Outdated Show resolved Hide resolved
sodym/trade.py Outdated
Comment on lines 41 to 42
def balance(self, **kwargs):
pass
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potentially would be nice to have this with an inplace: bool=True option, along with the **kwargs. I guess it could be useful for debugging to make the Trade that has been balanced as a separate object from the starting unbalanced Trade object. But, this makes me think that we don't need it as an abstractmethod. Still undecided tbh. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea of having the inplace option - I guess we could then have this function as not an abstract method but something like

class BalancedTrade(Trade)
    def balance(self, inplace : bool=True, **kwargs):
        if inplace:
            self.balance_function(**kwargs)
        else:
            new_trade = self.__class__(imports=self.imports, exports=self.exports)
            new_trade.balance_function(**kwargs)
            return new_trade

    @abstractmethod
    def balance_function(**kwargs):
        pass

class SpecificBalancedTrade(BalancedTrade):
    def balance_function(**kwargs):
        #foo

This way every balanced trade instance still has the balance function, the inplace works and you can specify what happens via the (abstract) balance_function in the subclasses (feel free to suggest a better name :) ). Or is that overcomplicating it? Just would like to keep the general idea.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another option could be to call it '_balance' instead of 'balance_function' to make it clear that one is for public use and the other for internal use.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great :)

@SallyDa SallyDa marked this pull request as ready for review November 28, 2024 14:09
@SallyDa
Copy link
Collaborator

SallyDa commented Nov 28, 2024

Thanks @Merjo! The trade module has been moved out of sodym, so this pr only has extra named_dim_array functionality :) Want to take a look @JakobBD?

@JakobBD
Copy link
Collaborator

JakobBD commented Nov 28, 2024

Already did, looks great!

@JakobBD JakobBD self-requested a review November 28, 2024 14:14
@JakobBD
Copy link
Collaborator

JakobBD commented Nov 28, 2024

Thanks to both of you!

@JakobBD JakobBD changed the title added trade module, trade balancing Additions required for simson trade module Nov 28, 2024
@SallyDa SallyDa merged commit 0e40f14 into main Nov 28, 2024
2 checks passed
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.

3 participants