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

Fix setLogfile method to handle None path #813

Merged
merged 4 commits into from
Apr 1, 2024

Conversation

liangbug
Copy link
Contributor

No description provided.

@Opt-Mucca
Copy link
Collaborator

Opt-Mucca commented Mar 19, 2024

Could this not be accomplished with the following code?

if path is not None:
    c_path = str_conversion(path)
else:
    c_path = NULL
SCIPset.......

@Joao-Dionisio
Copy link
Collaborator

Joao-Dionisio commented Mar 19, 2024

Or even

c_path = str_conversion(path) if path else NULL
SCIPset ...

If we want to keep the same syntax.

But the PR looks good to me overall. It's just missing a test and an entry in the CHANGELOG @liangbug, and possibly one of these suggestions we made.

@Opt-Mucca
Copy link
Collaborator

I like the suggestion of @Joao-Dionisio !

@liangbug
Copy link
Contributor Author

I added unittest and changelog.

@Joao-Dionisio, @Opt-Mucca, The follownng codes would cause compiling error.

if path is not None:
    c_path = str_conversion(path)
else:
    c_path = NULL
SCIPset.......
c_path = str_conversion(path) if path else NULL
SCIPset ...
Error compiling Cython file:
src\pyscipopt\scip.pxi:4914:21: Cannot convert 'void *' to Python object

Or you prefer the following code instead.

if path:
    c_path = str_conversion(path)
    SCIPsetMessagehdlrLogfile(self._scip, c_path)
else:
    SCIPsetMessagehdlrLogfile(self._scip, NULL)

Copy link

codecov bot commented Mar 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 52.81%. Comparing base (1f858fe) to head (f13c198).

❗ Current head f13c198 differs from pull request most recent head e14edbe. Consider uploading reports for the commit e14edbe to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #813      +/-   ##
==========================================
+ Coverage   51.85%   52.81%   +0.96%     
==========================================
  Files          18       17       -1     
  Lines        3890     3834      -56     
==========================================
+ Hits         2017     2025       +8     
+ Misses       1873     1809      -64     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Opt-Mucca
Copy link
Collaborator

@liangbug I'd prefer the code you suggested!

@liangbug
Copy link
Contributor Author

liangbug commented Apr 1, 2024

@Opt-Mucca, I commited the code

if path:
    c_path = str_conversion(path)
    SCIPsetMessagehdlrLogfile(self._scip, c_path)
else:
    SCIPsetMessagehdlrLogfile(self._scip, NULL)

Copy link
Member

@mmghannam mmghannam left a comment

Choose a reason for hiding this comment

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

Thanks @liangbug for your contribution!

@mmghannam mmghannam merged commit 30148ab into scipopt:master Apr 1, 2024
1 check passed
@liangbug liangbug deleted the fix_setLogFile branch April 2, 2024 01:48
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.

None yet

4 participants