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

Logger.add does not handle only_default as documented. #1328

Closed
joaander opened this issue May 16, 2022 · 1 comment
Closed

Logger.add does not handle only_default as documented. #1328

joaander opened this issue May 16, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@joaander
Copy link
Member

Description

Logger.add(instance, quantities=['some_non_default_quantity']) does not add the quantity as documented:

This is what the documentation states:

The only_default flag is mainly a convenience by allowing quantities not commonly logged (but available) to be passed over unless explicitly asked for. You can override the only_default flag by explicitly listing the quantities you want in add ...

Script

# Include a minimal script that reproduces the problem
import hoomd

cell = hoomd.md.nlist.Cell(buffer=0.4)
logger = hoomd.logging.Logger(categories=['scalar'])
logger.add(cell, quantities=['num_builds'])

print("logger items:")
for key,value in logger.items():
    print(key,value)

logger2 = hoomd.logging.Logger(categories=['scalar'], only_default=False)
logger2.add(cell, quantities=['num_builds'])

print("logger2 items:")
for key,value in logger2.items():
    print(key,value)

Output

logger items:
logger2 items:
('md', 'nlist', 'Cell', 'num_builds') <hoomd.logging._LoggerEntry object at 0x7fa45fbea740>
('md', 'nlist', 'Cell') {'num_builds': <hoomd.logging._LoggerEntry object at 0x7fa45fbea7a0>}
('md', 'nlist') {'Cell': {'num_builds': <hoomd.logging._LoggerEntry object at 0x7fa45fbea8f0>}}
('md',) {'nlist': {'Cell': {'num_builds': <hoomd.logging._LoggerEntry object at 0x7fa45fbeace0>}}}

Expected output

logger items:
('md', 'nlist', 'Cell', 'num_builds') <hoomd.logging._LoggerEntry object at 0x7fa45fbea740>
('md', 'nlist', 'Cell') {'num_builds': <hoomd.logging._LoggerEntry object at 0x7fa45fbea7a0>}
('md', 'nlist') {'Cell': {'num_builds': <hoomd.logging._LoggerEntry object at 0x7fa45fbea8f0>}}
('md',) {'nlist': {'Cell': {'num_builds': <hoomd.logging._LoggerEntry object at 0x7fa45fbeace0>}}}
logger2 items:
('md', 'nlist', 'Cell', 'num_builds') <hoomd.logging._LoggerEntry object at 0x7fa45fbea740>
('md', 'nlist', 'Cell') {'num_builds': <hoomd.logging._LoggerEntry object at 0x7fa45fbea7a0>}
('md', 'nlist') {'Cell': {'num_builds': <hoomd.logging._LoggerEntry object at 0x7fa45fbea8f0>}}
('md',) {'nlist': {'Cell': {'num_builds': <hoomd.logging._LoggerEntry object at 0x7fa45fbeace0>}}}

Configuration

Platform:

  • Mac
  • Linux
  • GPU
  • CPU

Installation method:

  • Compiled from source

Versions:

  • Python version: 3.9
  • HOOMD-blue version: trunk-minor

Developer

@b-butler can you look into this?

@joaander joaander added the bug Something isn't working label May 16, 2022
@joaander
Copy link
Member Author

joaander commented Jun 1, 2022

Fixed in #1331.

@joaander joaander closed this as completed Jun 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant