schrodinger.application.matsci.codeutils module

Module for utilities related to code maintenance

Copyright Schrodinger, LLC. All rights reserved.

schrodinger.application.matsci.codeutils.check_moved_variables(var_name, moved_variables)[source]

Check if the target variable has been moved, and if yes, post a warning about it and return the variable in the new module Raises AttributeError if a moved variable isn’t found.

Parameters
  • var_name (str) – Name of the target variable

  • moved_variables (tuple) – Tuple of tuples. Each inner tuple has a format of (module, remove_release, variables), where module is the new module name, remove_release is the release in which the link will stop working, and variables are the set of variables that were moved

Raises

AttributeError – If var_name is not a moved variable

Return type

Any

Returns

The moved variable

schrodinger.application.matsci.codeutils.deprecate(func, to_remove_in=None, replacement=None, *args, **kwargs)[source]

Post a warning about the function being deprecated

Parameters
  • func (callable) – The function that is deprecated

  • to_remove_in (str) – The release in which the function will be removed

  • replacement (callable) – The function to call instead

schrodinger.application.matsci.codeutils.is_python_file(path)[source]

Return whether the passed path is a python file

Parameters

path (str) – The file path

Return type

bool

Returns

Whether the path is a python file

schrodinger.application.matsci.codeutils.get_matsci_module_paths()[source]

Return a dict of file paths and dot paths of all matsci modules, sorted

Return dict

A dict mapping file paths to dot paths

class schrodinger.application.matsci.codeutils.MissingModule[source]

Bases: object

Dummy class to return instead of missing modules. Will raise if any attribute is accessed.

schrodinger.application.matsci.codeutils.get_safe_package(name)[source]

Get a desmond or jaguar package without raising if the package doesn’t exist

Parameters

name (str) – “namespace.package” where namespace is either desmond or jaguar

Raises
  • ValueError – If the namespace is not included or correct

  • ImportError – If the package name is incorrect

Return type

module or MissingModule

Returns

The module or a MissingModule object

class schrodinger.application.matsci.codeutils.readonly_cached_property(func)[source]

Bases: functools.cached_property

A cached property that cannot be set or deleted

__init__(func)
class schrodinger.application.matsci.codeutils.frozenset_cached_property(func)[source]

Bases: functools.cached_property

A cached property that automatically converts the property into a frozenset. Useful for ensuring that a set property is immutable.

__init__(func)