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

class_name_to_file_name breaks for class names that aren't CamelCase #13

Open
gngdb opened this issue Feb 3, 2022 · 0 comments
Open

Comments

@gngdb
Copy link

gngdb commented Feb 3, 2022

def class_name_to_file_name(class_name):
'''
Converts class name to the containing file name.
Assumes class name is in CamelCase and file name is the same
name but in snake_case.
Can be used for models and datasets.
'''
toks = re.findall('[A-Z][^A-Z]*', class_name)
toks = [tok.lower() for tok in toks]
file_name = '_'.join(toks)
return file_name

For example, AMASSFitDataset is not supported. There might be an elegant way to do this by inspecting the name spaces of all the files in the library that this function should support, but to be honest a hardcoded dictionary might be better because it will at least fail in a predictable and easy to debug way.

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

No branches or pull requests

1 participant