repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
rene-aguirre/pywinusb
pywinusb/hid/hid_pnp_mixin.py
HidPnPWindowMixin._register_hid_notification
def _register_hid_notification(self): """Register HID notification events on any window (passed by window handler), returns a notification handler""" # create structure, self initialized notify_obj = DevBroadcastDevInterface() h_notify = RegisterDeviceNotification(self.__hid...
python
def _register_hid_notification(self): """Register HID notification events on any window (passed by window handler), returns a notification handler""" # create structure, self initialized notify_obj = DevBroadcastDevInterface() h_notify = RegisterDeviceNotification(self.__hid...
[ "def", "_register_hid_notification", "(", "self", ")", ":", "# create structure, self initialized\r", "notify_obj", "=", "DevBroadcastDevInterface", "(", ")", "h_notify", "=", "RegisterDeviceNotification", "(", "self", ".", "__hid_hwnd", ",", "ctypes", ".", "byref", "("...
Register HID notification events on any window (passed by window handler), returns a notification handler
[ "Register", "HID", "notification", "events", "on", "any", "window", "(", "passed", "by", "window", "handler", ")", "returns", "a", "notification", "handler" ]
train
https://github.com/rene-aguirre/pywinusb/blob/954c4b2105d9f01cb0c50e24500bb747d4ecdc43/pywinusb/hid/hid_pnp_mixin.py#L132-L140
rene-aguirre/pywinusb
pywinusb/hid/hid_pnp_mixin.py
HidPnPWindowMixin._unregister_hid_notification
def _unregister_hid_notification(self): "Remove PnP notification handler" if not int(self.__h_notify): return #invalid result = UnregisterDeviceNotification(self.__h_notify) self.__h_notify = None return int(result)
python
def _unregister_hid_notification(self): "Remove PnP notification handler" if not int(self.__h_notify): return #invalid result = UnregisterDeviceNotification(self.__h_notify) self.__h_notify = None return int(result)
[ "def", "_unregister_hid_notification", "(", "self", ")", ":", "if", "not", "int", "(", "self", ".", "__h_notify", ")", ":", "return", "#invalid\r", "result", "=", "UnregisterDeviceNotification", "(", "self", ".", "__h_notify", ")", "self", ".", "__h_notify", "...
Remove PnP notification handler
[ "Remove", "PnP", "notification", "handler" ]
train
https://github.com/rene-aguirre/pywinusb/blob/954c4b2105d9f01cb0c50e24500bb747d4ecdc43/pywinusb/hid/hid_pnp_mixin.py#L142-L148
rene-aguirre/pywinusb
pywinusb/hid/tools.py
write_documentation
def write_documentation(self, output_file): "Issue documentation report on output_file file like object" if not self.is_opened(): raise helpers.HIDError("Device has to be opened to get documentation") #format class CompundVarDict(object): """Compound variables dictionary. ...
python
def write_documentation(self, output_file): "Issue documentation report on output_file file like object" if not self.is_opened(): raise helpers.HIDError("Device has to be opened to get documentation") #format class CompundVarDict(object): """Compound variables dictionary. ...
[ "def", "write_documentation", "(", "self", ",", "output_file", ")", ":", "if", "not", "self", ".", "is_opened", "(", ")", ":", "raise", "helpers", ".", "HIDError", "(", "\"Device has to be opened to get documentation\"", ")", "#format\r", "class", "CompundVarDict", ...
Issue documentation report on output_file file like object
[ "Issue", "documentation", "report", "on", "output_file", "file", "like", "object" ]
train
https://github.com/rene-aguirre/pywinusb/blob/954c4b2105d9f01cb0c50e24500bb747d4ecdc43/pywinusb/hid/tools.py#L10-L137
rene-aguirre/pywinusb
pywinusb/hid/wnd_hook_mixin.py
WndProcHookMixin.hook_wnd_proc
def hook_wnd_proc(self): """Attach to OS Window message handler""" self.__local_wnd_proc_wrapped = WndProcType(self.local_wnd_proc) self.__old_wnd_proc = SetWindowLong(self.__local_win_handle, GWL_WNDPROC, self....
python
def hook_wnd_proc(self): """Attach to OS Window message handler""" self.__local_wnd_proc_wrapped = WndProcType(self.local_wnd_proc) self.__old_wnd_proc = SetWindowLong(self.__local_win_handle, GWL_WNDPROC, self....
[ "def", "hook_wnd_proc", "(", "self", ")", ":", "self", ".", "__local_wnd_proc_wrapped", "=", "WndProcType", "(", "self", ".", "local_wnd_proc", ")", "self", ".", "__old_wnd_proc", "=", "SetWindowLong", "(", "self", ".", "__local_win_handle", ",", "GWL_WNDPROC", ...
Attach to OS Window message handler
[ "Attach", "to", "OS", "Window", "message", "handler" ]
train
https://github.com/rene-aguirre/pywinusb/blob/954c4b2105d9f01cb0c50e24500bb747d4ecdc43/pywinusb/hid/wnd_hook_mixin.py#L73-L78
rene-aguirre/pywinusb
pywinusb/hid/wnd_hook_mixin.py
WndProcHookMixin.unhook_wnd_proc
def unhook_wnd_proc(self): """Restore previous Window message handler""" if not self.__local_wnd_proc_wrapped: return SetWindowLong(self.__local_win_handle, GWL_WNDPROC, self.__old_wnd_proc) ## Allow the ctypes wrapper ...
python
def unhook_wnd_proc(self): """Restore previous Window message handler""" if not self.__local_wnd_proc_wrapped: return SetWindowLong(self.__local_win_handle, GWL_WNDPROC, self.__old_wnd_proc) ## Allow the ctypes wrapper ...
[ "def", "unhook_wnd_proc", "(", "self", ")", ":", "if", "not", "self", ".", "__local_wnd_proc_wrapped", ":", "return", "SetWindowLong", "(", "self", ".", "__local_win_handle", ",", "GWL_WNDPROC", ",", "self", ".", "__old_wnd_proc", ")", "## Allow the ctypes wrapper t...
Restore previous Window message handler
[ "Restore", "previous", "Window", "message", "handler" ]
train
https://github.com/rene-aguirre/pywinusb/blob/954c4b2105d9f01cb0c50e24500bb747d4ecdc43/pywinusb/hid/wnd_hook_mixin.py#L79-L88
rene-aguirre/pywinusb
pywinusb/hid/wnd_hook_mixin.py
WndProcHookMixin.local_wnd_proc
def local_wnd_proc(self, h_wnd, msg, w_param, l_param): """ Call the handler if one exists. """ # performance note: has_key is the fastest way to check for a key when # the key is unlikely to be found (which is the case here, since most # messages will not have hand...
python
def local_wnd_proc(self, h_wnd, msg, w_param, l_param): """ Call the handler if one exists. """ # performance note: has_key is the fastest way to check for a key when # the key is unlikely to be found (which is the case here, since most # messages will not have hand...
[ "def", "local_wnd_proc", "(", "self", ",", "h_wnd", ",", "msg", ",", "w_param", ",", "l_param", ")", ":", "# performance note: has_key is the fastest way to check for a key when\r", "# the key is unlikely to be found (which is the case here, since most\r", "# messages will not have h...
Call the handler if one exists.
[ "Call", "the", "handler", "if", "one", "exists", "." ]
train
https://github.com/rene-aguirre/pywinusb/blob/954c4b2105d9f01cb0c50e24500bb747d4ecdc43/pywinusb/hid/wnd_hook_mixin.py#L94-L114
rene-aguirre/pywinusb
examples/simple_feature.py
read_values
def read_values(target_usage): """read feature report values""" # browse all devices all_devices = hid.HidDeviceFilter().get_devices() if not all_devices: print("Can't find any non system HID device connected") else: # search for our target usage usage_found = False...
python
def read_values(target_usage): """read feature report values""" # browse all devices all_devices = hid.HidDeviceFilter().get_devices() if not all_devices: print("Can't find any non system HID device connected") else: # search for our target usage usage_found = False...
[ "def", "read_values", "(", "target_usage", ")", ":", "# browse all devices\r", "all_devices", "=", "hid", ".", "HidDeviceFilter", "(", ")", ".", "get_devices", "(", ")", "if", "not", "all_devices", ":", "print", "(", "\"Can't find any non system HID device connected\"...
read feature report values
[ "read", "feature", "report", "values" ]
train
https://github.com/rene-aguirre/pywinusb/blob/954c4b2105d9f01cb0c50e24500bb747d4ecdc43/examples/simple_feature.py#L9-L34
rene-aguirre/pywinusb
examples/mute_led.py
set_mute
def set_mute(mute_value): "Browse for mute usages and set value" all_mutes = ( \ (0x8, 0x9), # LED page (0x1, 0xA7), # desktop page (0xb, 0x2f), ) all_target_usages = [hid.get_full_usage_id(u[0], u[1]) for u in all_mutes] # usually you'll find and open the target...
python
def set_mute(mute_value): "Browse for mute usages and set value" all_mutes = ( \ (0x8, 0x9), # LED page (0x1, 0xA7), # desktop page (0xb, 0x2f), ) all_target_usages = [hid.get_full_usage_id(u[0], u[1]) for u in all_mutes] # usually you'll find and open the target...
[ "def", "set_mute", "(", "mute_value", ")", ":", "all_mutes", "=", "(", "(", "0x8", ",", "0x9", ")", ",", "# LED page", "(", "0x1", ",", "0xA7", ")", ",", "# desktop page", "(", "0xb", ",", "0x2f", ")", ",", ")", "all_target_usages", "=", "[", "hid", ...
Browse for mute usages and set value
[ "Browse", "for", "mute", "usages", "and", "set", "value" ]
train
https://github.com/rene-aguirre/pywinusb/blob/954c4b2105d9f01cb0c50e24500bb747d4ecdc43/examples/mute_led.py#L13-L49
rene-aguirre/pywinusb
pywinusb/hid/winapi.py
winapi_result
def winapi_result( result ): """Validate WINAPI BOOL result, raise exception if failed""" if not result: raise WinApiException("%d (%x): %s" % (ctypes.GetLastError(), ctypes.GetLastError(), ctypes.FormatError())) return result
python
def winapi_result( result ): """Validate WINAPI BOOL result, raise exception if failed""" if not result: raise WinApiException("%d (%x): %s" % (ctypes.GetLastError(), ctypes.GetLastError(), ctypes.FormatError())) return result
[ "def", "winapi_result", "(", "result", ")", ":", "if", "not", "result", ":", "raise", "WinApiException", "(", "\"%d (%x): %s\"", "%", "(", "ctypes", ".", "GetLastError", "(", ")", ",", "ctypes", ".", "GetLastError", "(", ")", ",", "ctypes", ".", "FormatErr...
Validate WINAPI BOOL result, raise exception if failed
[ "Validate", "WINAPI", "BOOL", "result", "raise", "exception", "if", "failed" ]
train
https://github.com/rene-aguirre/pywinusb/blob/954c4b2105d9f01cb0c50e24500bb747d4ecdc43/pywinusb/hid/winapi.py#L28-L33
rene-aguirre/pywinusb
pywinusb/hid/winapi.py
enum_device_interfaces
def enum_device_interfaces(h_info, guid): """Function generator that returns a device_interface_data enumerator for the given device interface info and GUID parameters """ dev_interface_data = SP_DEVICE_INTERFACE_DATA() dev_interface_data.cb_size = sizeof(dev_interface_data) device_index...
python
def enum_device_interfaces(h_info, guid): """Function generator that returns a device_interface_data enumerator for the given device interface info and GUID parameters """ dev_interface_data = SP_DEVICE_INTERFACE_DATA() dev_interface_data.cb_size = sizeof(dev_interface_data) device_index...
[ "def", "enum_device_interfaces", "(", "h_info", ",", "guid", ")", ":", "dev_interface_data", "=", "SP_DEVICE_INTERFACE_DATA", "(", ")", "dev_interface_data", ".", "cb_size", "=", "sizeof", "(", "dev_interface_data", ")", "device_index", "=", "0", "while", "SetupDiEn...
Function generator that returns a device_interface_data enumerator for the given device interface info and GUID parameters
[ "Function", "generator", "that", "returns", "a", "device_interface_data", "enumerator", "for", "the", "given", "device", "interface", "info", "and", "GUID", "parameters" ]
train
https://github.com/rene-aguirre/pywinusb/blob/954c4b2105d9f01cb0c50e24500bb747d4ecdc43/pywinusb/hid/winapi.py#L467-L482
rene-aguirre/pywinusb
pywinusb/hid/winapi.py
get_device_path
def get_device_path(h_info, interface_data, ptr_info_data = None): """"Returns Hardware device path Parameters: h_info, interface set info handler interface_data, device interface enumeration data ptr_info_data, pointer to SP_DEVINFO_DATA() instance to receive details ...
python
def get_device_path(h_info, interface_data, ptr_info_data = None): """"Returns Hardware device path Parameters: h_info, interface set info handler interface_data, device interface enumeration data ptr_info_data, pointer to SP_DEVINFO_DATA() instance to receive details ...
[ "def", "get_device_path", "(", "h_info", ",", "interface_data", ",", "ptr_info_data", "=", "None", ")", ":", "required_size", "=", "c_ulong", "(", "0", ")", "dev_inter_detail_data", "=", "SP_DEVICE_INTERFACE_DETAIL_DATA", "(", ")", "dev_inter_detail_data", ".", "cb_...
Returns Hardware device path Parameters: h_info, interface set info handler interface_data, device interface enumeration data ptr_info_data, pointer to SP_DEVINFO_DATA() instance to receive details
[ "Returns", "Hardware", "device", "path", "Parameters", ":", "h_info", "interface", "set", "info", "handler", "interface_data", "device", "interface", "enumeration", "data", "ptr_info_data", "pointer", "to", "SP_DEVINFO_DATA", "()", "instance", "to", "receive", "detail...
train
https://github.com/rene-aguirre/pywinusb/blob/954c4b2105d9f01cb0c50e24500bb747d4ecdc43/pywinusb/hid/winapi.py#L484-L508
rene-aguirre/pywinusb
pywinusb/hid/winapi.py
DeviceInterfaceSetInfo.open
def open(self): """ Calls SetupDiGetClassDevs to obtain a handle to an opaque device information set that describes the device interfaces supported by all the USB collections currently installed in the system. The application should specify DIGCF.PRESENT and DIGCF.INTERFACED...
python
def open(self): """ Calls SetupDiGetClassDevs to obtain a handle to an opaque device information set that describes the device interfaces supported by all the USB collections currently installed in the system. The application should specify DIGCF.PRESENT and DIGCF.INTERFACED...
[ "def", "open", "(", "self", ")", ":", "self", ".", "h_info", "=", "SetupDiGetClassDevs", "(", "byref", "(", "self", ".", "guid", ")", ",", "None", ",", "None", ",", "(", "DIGCF", ".", "PRESENT", "|", "DIGCF", ".", "DEVICEINTERFACE", ")", ")", "return...
Calls SetupDiGetClassDevs to obtain a handle to an opaque device information set that describes the device interfaces supported by all the USB collections currently installed in the system. The application should specify DIGCF.PRESENT and DIGCF.INTERFACEDEVICE in the Flags parameter ...
[ "Calls", "SetupDiGetClassDevs", "to", "obtain", "a", "handle", "to", "an", "opaque", "device", "information", "set", "that", "describes", "the", "device", "interfaces", "supported", "by", "all", "the", "USB", "collections", "currently", "installed", "in", "the", ...
train
https://github.com/rene-aguirre/pywinusb/blob/954c4b2105d9f01cb0c50e24500bb747d4ecdc43/pywinusb/hid/winapi.py#L443-L454
rene-aguirre/pywinusb
pywinusb/hid/winapi.py
DeviceInterfaceSetInfo.close
def close(self): """Destroy allocated storage""" if self.h_info and self.h_info != INVALID_HANDLE_VALUE: # clean up SetupDiDestroyDeviceInfoList(self.h_info) self.h_info = None
python
def close(self): """Destroy allocated storage""" if self.h_info and self.h_info != INVALID_HANDLE_VALUE: # clean up SetupDiDestroyDeviceInfoList(self.h_info) self.h_info = None
[ "def", "close", "(", "self", ")", ":", "if", "self", ".", "h_info", "and", "self", ".", "h_info", "!=", "INVALID_HANDLE_VALUE", ":", "# clean up\r", "SetupDiDestroyDeviceInfoList", "(", "self", ".", "h_info", ")", "self", ".", "h_info", "=", "None" ]
Destroy allocated storage
[ "Destroy", "allocated", "storage" ]
train
https://github.com/rene-aguirre/pywinusb/blob/954c4b2105d9f01cb0c50e24500bb747d4ecdc43/pywinusb/hid/winapi.py#L460-L465
rene-aguirre/pywinusb
examples/simple_send.py
click_signal
def click_signal(target_usage, target_vendor_id): """This function will find a particular target_usage over output reports on target_vendor_id related devices, then it will flip the signal to simulate a 'click' event""" # usually you'll find and open the target device, here we'll browse for the ...
python
def click_signal(target_usage, target_vendor_id): """This function will find a particular target_usage over output reports on target_vendor_id related devices, then it will flip the signal to simulate a 'click' event""" # usually you'll find and open the target device, here we'll browse for the ...
[ "def", "click_signal", "(", "target_usage", ",", "target_vendor_id", ")", ":", "# usually you'll find and open the target device, here we'll browse for the\r", "# current connected devices\r", "all_devices", "=", "hid", ".", "HidDeviceFilter", "(", "vendor_id", "=", "target_vendo...
This function will find a particular target_usage over output reports on target_vendor_id related devices, then it will flip the signal to simulate a 'click' event
[ "This", "function", "will", "find", "a", "particular", "target_usage", "over", "output", "reports", "on", "target_vendor_id", "related", "devices", "then", "it", "will", "flip", "the", "signal", "to", "simulate", "a", "click", "event" ]
train
https://github.com/rene-aguirre/pywinusb/blob/954c4b2105d9f01cb0c50e24500bb747d4ecdc43/examples/simple_send.py#L7-L40
regebro/tzlocal
update_windows_mappings.py
update_old_names
def update_old_names(): """Fetches the list of old tz names and returns a mapping""" url = urlparse(ZONEINFO_URL) log.info('Connecting to %s' % url.netloc) ftp = ftplib.FTP(url.netloc) ftp.login() gzfile = BytesIO() log.info('Fetching zoneinfo database') ftp.retrbinary('RETR ' + url.pa...
python
def update_old_names(): """Fetches the list of old tz names and returns a mapping""" url = urlparse(ZONEINFO_URL) log.info('Connecting to %s' % url.netloc) ftp = ftplib.FTP(url.netloc) ftp.login() gzfile = BytesIO() log.info('Fetching zoneinfo database') ftp.retrbinary('RETR ' + url.pa...
[ "def", "update_old_names", "(", ")", ":", "url", "=", "urlparse", "(", "ZONEINFO_URL", ")", "log", ".", "info", "(", "'Connecting to %s'", "%", "url", ".", "netloc", ")", "ftp", "=", "ftplib", ".", "FTP", "(", "url", ".", "netloc", ")", "ftp", ".", "...
Fetches the list of old tz names and returns a mapping
[ "Fetches", "the", "list", "of", "old", "tz", "names", "and", "returns", "a", "mapping" ]
train
https://github.com/regebro/tzlocal/blob/b73a692c8eec1255e9018717d391aaa78bad00e7/update_windows_mappings.py#L26-L53
Trust-Code/python-cnab
cnab240/registro.py
CampoBase._normalize_str
def _normalize_str(self, string): """ Remove special characters and strip spaces """ if string: if not isinstance(string, str): string = str(string, 'utf-8', 'replace') return unicodedata.normalize('NFKD', string).encode( 'ASCII', ...
python
def _normalize_str(self, string): """ Remove special characters and strip spaces """ if string: if not isinstance(string, str): string = str(string, 'utf-8', 'replace') return unicodedata.normalize('NFKD', string).encode( 'ASCII', ...
[ "def", "_normalize_str", "(", "self", ",", "string", ")", ":", "if", "string", ":", "if", "not", "isinstance", "(", "string", ",", "str", ")", ":", "string", "=", "str", "(", "string", ",", "'utf-8'", ",", "'replace'", ")", "return", "unicodedata", "."...
Remove special characters and strip spaces
[ "Remove", "special", "characters", "and", "strip", "spaces" ]
train
https://github.com/Trust-Code/python-cnab/blob/a0c915b780e590b71073a670fc89bafb110998b1/cnab240/registro.py#L17-L27
lambdalisue/django-permission
src/permission/decorators/classbase.py
permission_required
def permission_required(perm, queryset=None, login_url=None, raise_exception=False): """ Permission check decorator for classbased generic view This decorator works as class decorator DO NOT use ``method_decorator`` or whatever while this decorator will use ``self`` argument...
python
def permission_required(perm, queryset=None, login_url=None, raise_exception=False): """ Permission check decorator for classbased generic view This decorator works as class decorator DO NOT use ``method_decorator`` or whatever while this decorator will use ``self`` argument...
[ "def", "permission_required", "(", "perm", ",", "queryset", "=", "None", ",", "login_url", "=", "None", ",", "raise_exception", "=", "False", ")", ":", "def", "wrapper", "(", "cls", ")", ":", "def", "view_wrapper", "(", "view_func", ")", ":", "@", "wraps...
Permission check decorator for classbased generic view This decorator works as class decorator DO NOT use ``method_decorator`` or whatever while this decorator will use ``self`` argument for method of classbased generic view. Parameters ---------- perm : string A permission string ...
[ "Permission", "check", "decorator", "for", "classbased", "generic", "view" ]
train
https://github.com/lambdalisue/django-permission/blob/580f7a1f857701d06ccf41163f188ac04fbc4fac/src/permission/decorators/classbase.py#L11-L58
lambdalisue/django-permission
src/permission/decorators/classbase.py
get_object_from_classbased_instance
def get_object_from_classbased_instance( instance, queryset, request, *args, **kwargs): """ Get object from an instance of classbased generic view Parameters ---------- instance : instance An instance of classbased generic view queryset : instance A queryset instance ...
python
def get_object_from_classbased_instance( instance, queryset, request, *args, **kwargs): """ Get object from an instance of classbased generic view Parameters ---------- instance : instance An instance of classbased generic view queryset : instance A queryset instance ...
[ "def", "get_object_from_classbased_instance", "(", "instance", ",", "queryset", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "from", "django", ".", "views", ".", "generic", ".", "edit", "import", "BaseCreateView", "# initialize request, a...
Get object from an instance of classbased generic view Parameters ---------- instance : instance An instance of classbased generic view queryset : instance A queryset instance request : instance A instance of HttpRequest Returns ------- instance An insta...
[ "Get", "object", "from", "an", "instance", "of", "classbased", "generic", "view" ]
train
https://github.com/lambdalisue/django-permission/blob/580f7a1f857701d06ccf41163f188ac04fbc4fac/src/permission/decorators/classbase.py#L61-L112
lambdalisue/django-permission
src/permission/logics/groupin.py
GroupInPermissionLogic.has_perm
def has_perm(self, user_obj, perm, obj=None): """ Check if user have permission (of object) If the user_obj is not authenticated, it return ``False``. If no object is specified, it return ``True`` when the corresponding permission was specified to ``True`` (changed from v0.7.0)...
python
def has_perm(self, user_obj, perm, obj=None): """ Check if user have permission (of object) If the user_obj is not authenticated, it return ``False``. If no object is specified, it return ``True`` when the corresponding permission was specified to ``True`` (changed from v0.7.0)...
[ "def", "has_perm", "(", "self", ",", "user_obj", ",", "perm", ",", "obj", "=", "None", ")", ":", "if", "not", "is_authenticated", "(", "user_obj", ")", ":", "return", "False", "# construct the permission full name", "add_permission", "=", "self", ".", "get_ful...
Check if user have permission (of object) If the user_obj is not authenticated, it return ``False``. If no object is specified, it return ``True`` when the corresponding permission was specified to ``True`` (changed from v0.7.0). This behavior is based on the django system. htt...
[ "Check", "if", "user", "have", "permission", "(", "of", "object", ")" ]
train
https://github.com/lambdalisue/django-permission/blob/580f7a1f857701d06ccf41163f188ac04fbc4fac/src/permission/logics/groupin.py#L74-L138
lambdalisue/django-permission
src/permission/decorators/methodbase.py
permission_required
def permission_required(perm, queryset=None, login_url=None, raise_exception=False): """ Permission check decorator for classbased/functionbased generic view This decorator works as method or function decorator DO NOT use ``method_decorator`` or whatever while this decorator wil...
python
def permission_required(perm, queryset=None, login_url=None, raise_exception=False): """ Permission check decorator for classbased/functionbased generic view This decorator works as method or function decorator DO NOT use ``method_decorator`` or whatever while this decorator wil...
[ "def", "permission_required", "(", "perm", ",", "queryset", "=", "None", ",", "login_url", "=", "None", ",", "raise_exception", "=", "False", ")", ":", "def", "wrapper", "(", "view_method", ")", ":", "@", "wraps", "(", "view_method", ",", "assigned", "=", ...
Permission check decorator for classbased/functionbased generic view This decorator works as method or function decorator DO NOT use ``method_decorator`` or whatever while this decorator will use ``self`` argument for method of classbased generic view. Parameters ---------- perm : string ...
[ "Permission", "check", "decorator", "for", "classbased", "/", "functionbased", "generic", "view" ]
train
https://github.com/lambdalisue/django-permission/blob/580f7a1f857701d06ccf41163f188ac04fbc4fac/src/permission/decorators/methodbase.py#L12-L77
lambdalisue/django-permission
src/permission/utils/field_lookup.py
field_lookup
def field_lookup(obj, field_path): """ Lookup django model field in similar way of django query lookup. Args: obj (instance): Django Model instance field_path (str): '__' separated field path Example: >>> from django.db import model >>> from django.contrib.auth.models i...
python
def field_lookup(obj, field_path): """ Lookup django model field in similar way of django query lookup. Args: obj (instance): Django Model instance field_path (str): '__' separated field path Example: >>> from django.db import model >>> from django.contrib.auth.models i...
[ "def", "field_lookup", "(", "obj", ",", "field_path", ")", ":", "if", "hasattr", "(", "obj", ",", "'iterator'", ")", ":", "return", "(", "field_lookup", "(", "x", ",", "field_path", ")", "for", "x", "in", "obj", ".", "iterator", "(", ")", ")", "elif"...
Lookup django model field in similar way of django query lookup. Args: obj (instance): Django Model instance field_path (str): '__' separated field path Example: >>> from django.db import model >>> from django.contrib.auth.models import User >>> class Article(models.Mod...
[ "Lookup", "django", "model", "field", "in", "similar", "way", "of", "django", "query", "lookup", "." ]
train
https://github.com/lambdalisue/django-permission/blob/580f7a1f857701d06ccf41163f188ac04fbc4fac/src/permission/utils/field_lookup.py#L6-L40
lambdalisue/django-permission
src/permission/decorators/functionbase.py
permission_required
def permission_required(perm, queryset=None, login_url=None, raise_exception=False): """ Permission check decorator for function-base generic view This decorator works as function decorator Parameters ---------- perm : string A permission string queryset : q...
python
def permission_required(perm, queryset=None, login_url=None, raise_exception=False): """ Permission check decorator for function-base generic view This decorator works as function decorator Parameters ---------- perm : string A permission string queryset : q...
[ "def", "permission_required", "(", "perm", ",", "queryset", "=", "None", ",", "login_url", "=", "None", ",", "raise_exception", "=", "False", ")", ":", "def", "wrapper", "(", "view_func", ")", ":", "@", "wraps", "(", "view_func", ",", "assigned", "=", "a...
Permission check decorator for function-base generic view This decorator works as function decorator Parameters ---------- perm : string A permission string queryset : queryset or model A queryset or model for finding object. With classbased generic view, ``None`` for using...
[ "Permission", "check", "decorator", "for", "function", "-", "base", "generic", "view" ]
train
https://github.com/lambdalisue/django-permission/blob/580f7a1f857701d06ccf41163f188ac04fbc4fac/src/permission/decorators/functionbase.py#L13-L66
lambdalisue/django-permission
src/permission/decorators/functionbase.py
get_object_from_list_detail_view
def get_object_from_list_detail_view(request, *args, **kwargs): """ Get object from generic list_detail.detail view Parameters ---------- request : instance An instance of HttpRequest Returns ------- instance An instance of model object or None """ queryset = kw...
python
def get_object_from_list_detail_view(request, *args, **kwargs): """ Get object from generic list_detail.detail view Parameters ---------- request : instance An instance of HttpRequest Returns ------- instance An instance of model object or None """ queryset = kw...
[ "def", "get_object_from_list_detail_view", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "queryset", "=", "kwargs", "[", "'queryset'", "]", "object_id", "=", "kwargs", ".", "get", "(", "'object_id'", ",", "None", ")", "slug", "=", ...
Get object from generic list_detail.detail view Parameters ---------- request : instance An instance of HttpRequest Returns ------- instance An instance of model object or None
[ "Get", "object", "from", "generic", "list_detail", ".", "detail", "view" ]
train
https://github.com/lambdalisue/django-permission/blob/580f7a1f857701d06ccf41163f188ac04fbc4fac/src/permission/decorators/functionbase.py#L69-L96
lambdalisue/django-permission
src/permission/decorators/functionbase.py
get_object_from_date_based_view
def get_object_from_date_based_view(request, *args, **kwargs): # noqa """ Get object from generic date_based.detail view Parameters ---------- request : instance An instance of HttpRequest Returns ------- instance An instance of model object or None """ import ...
python
def get_object_from_date_based_view(request, *args, **kwargs): # noqa """ Get object from generic date_based.detail view Parameters ---------- request : instance An instance of HttpRequest Returns ------- instance An instance of model object or None """ import ...
[ "def", "get_object_from_date_based_view", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# noqa", "import", "time", "import", "datetime", "from", "django", ".", "http", "import", "Http404", "from", "django", ".", "db", ".", "models", ...
Get object from generic date_based.detail view Parameters ---------- request : instance An instance of HttpRequest Returns ------- instance An instance of model object or None
[ "Get", "object", "from", "generic", "date_based", ".", "detail", "view" ]
train
https://github.com/lambdalisue/django-permission/blob/580f7a1f857701d06ccf41163f188ac04fbc4fac/src/permission/decorators/functionbase.py#L107-L171
lambdalisue/django-permission
src/permission/utils/handlers.py
PermissionHandlerRegistry.register
def register(self, model, handler=None): """ Register a permission handler to the model Parameters ---------- model : django model class A django model class handler : permission handler class, string, or None A permission handler class or a dotte...
python
def register(self, model, handler=None): """ Register a permission handler to the model Parameters ---------- model : django model class A django model class handler : permission handler class, string, or None A permission handler class or a dotte...
[ "def", "register", "(", "self", ",", "model", ",", "handler", "=", "None", ")", ":", "from", "permission", ".", "handlers", "import", "PermissionHandler", "if", "model", ".", "_meta", ".", "abstract", ":", "raise", "ImproperlyConfigured", "(", "'The model %s i...
Register a permission handler to the model Parameters ---------- model : django model class A django model class handler : permission handler class, string, or None A permission handler class or a dotted path Raises ------ ImproperlyConfi...
[ "Register", "a", "permission", "handler", "to", "the", "model" ]
train
https://github.com/lambdalisue/django-permission/blob/580f7a1f857701d06ccf41163f188ac04fbc4fac/src/permission/utils/handlers.py#L20-L62
lambdalisue/django-permission
src/permission/utils/handlers.py
PermissionHandlerRegistry.unregister
def unregister(self, model): """ Unregister a permission handler from the model Parameters ---------- model : django model class A django model class Raises ------ KeyError Raise when the model have not registered in registry yet....
python
def unregister(self, model): """ Unregister a permission handler from the model Parameters ---------- model : django model class A django model class Raises ------ KeyError Raise when the model have not registered in registry yet....
[ "def", "unregister", "(", "self", ",", "model", ")", ":", "if", "model", "not", "in", "self", ".", "_registry", ":", "raise", "KeyError", "(", "\"A permission handler class have not been \"", "\"registered for '%s' yet\"", "%", "model", ")", "# remove from registry", ...
Unregister a permission handler from the model Parameters ---------- model : django model class A django model class Raises ------ KeyError Raise when the model have not registered in registry yet.
[ "Unregister", "a", "permission", "handler", "from", "the", "model" ]
train
https://github.com/lambdalisue/django-permission/blob/580f7a1f857701d06ccf41163f188ac04fbc4fac/src/permission/utils/handlers.py#L64-L82
lambdalisue/django-permission
src/permission/handlers.py
PermissionHandler._get_app_perms
def _get_app_perms(self, *args): """ Get permissions related to the application specified in constructor Returns ------- set A set instance of `app_label.codename` formatted permission strings """ if not hasattr(self, '_app_perms_cache'): ...
python
def _get_app_perms(self, *args): """ Get permissions related to the application specified in constructor Returns ------- set A set instance of `app_label.codename` formatted permission strings """ if not hasattr(self, '_app_perms_cache'): ...
[ "def", "_get_app_perms", "(", "self", ",", "*", "args", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'_app_perms_cache'", ")", ":", "self", ".", "_app_perms_cache", "=", "get_app_perms", "(", "self", ".", "app_label", ")", "return", "self", ".", ...
Get permissions related to the application specified in constructor Returns ------- set A set instance of `app_label.codename` formatted permission strings
[ "Get", "permissions", "related", "to", "the", "application", "specified", "in", "constructor" ]
train
https://github.com/lambdalisue/django-permission/blob/580f7a1f857701d06ccf41163f188ac04fbc4fac/src/permission/handlers.py#L59-L70
lambdalisue/django-permission
src/permission/handlers.py
PermissionHandler._get_model_perms
def _get_model_perms(self, *args): """ Get permissions related to the model specified in constructor Returns ------- set A set instance of `app_label.codename` formatted permission strings """ if not hasattr(self, '_model_perms_cache'): if...
python
def _get_model_perms(self, *args): """ Get permissions related to the model specified in constructor Returns ------- set A set instance of `app_label.codename` formatted permission strings """ if not hasattr(self, '_model_perms_cache'): if...
[ "def", "_get_model_perms", "(", "self", ",", "*", "args", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'_model_perms_cache'", ")", ":", "if", "self", ".", "model", "is", "None", ":", "self", ".", "_model_perms_cache", "=", "set", "(", ")", "els...
Get permissions related to the model specified in constructor Returns ------- set A set instance of `app_label.codename` formatted permission strings
[ "Get", "permissions", "related", "to", "the", "model", "specified", "in", "constructor" ]
train
https://github.com/lambdalisue/django-permission/blob/580f7a1f857701d06ccf41163f188ac04fbc4fac/src/permission/handlers.py#L72-L86
lambdalisue/django-permission
src/permission/handlers.py
PermissionHandler.get_supported_permissions
def get_supported_permissions(self): """ Get permissions which this handler can treat. Specified with :attr:`includes` and :attr:`excludes` of this instance. Returns ------- set A set instance of `app_label.codename` formatted permission strings """ ...
python
def get_supported_permissions(self): """ Get permissions which this handler can treat. Specified with :attr:`includes` and :attr:`excludes` of this instance. Returns ------- set A set instance of `app_label.codename` formatted permission strings """ ...
[ "def", "get_supported_permissions", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'_perms_cache'", ")", ":", "if", "(", "self", ".", "includes", "and", "isinstance", "(", "self", ".", "includes", ",", "collections", ".", "Callable", ")"...
Get permissions which this handler can treat. Specified with :attr:`includes` and :attr:`excludes` of this instance. Returns ------- set A set instance of `app_label.codename` formatted permission strings
[ "Get", "permissions", "which", "this", "handler", "can", "treat", ".", "Specified", "with", ":", "attr", ":", "includes", "and", ":", "attr", ":", "excludes", "of", "this", "instance", "." ]
train
https://github.com/lambdalisue/django-permission/blob/580f7a1f857701d06ccf41163f188ac04fbc4fac/src/permission/handlers.py#L88-L113
lambdalisue/django-permission
src/permission/handlers.py
PermissionHandler.get_supported_app_labels
def get_supported_app_labels(self): """ Get app labels which this handler can treat. Specified with :attr:`includes` and :attr:`excludes` of this instance. Returns ------- set A set instance of app_label """ get_app_label = lambda x: x.split("...
python
def get_supported_app_labels(self): """ Get app labels which this handler can treat. Specified with :attr:`includes` and :attr:`excludes` of this instance. Returns ------- set A set instance of app_label """ get_app_label = lambda x: x.split("...
[ "def", "get_supported_app_labels", "(", "self", ")", ":", "get_app_label", "=", "lambda", "x", ":", "x", ".", "split", "(", "\".\"", ",", "1", ")", "[", "0", "]", "if", "not", "hasattr", "(", "self", ",", "'_app_labels_cache'", ")", ":", "perms", "=", ...
Get app labels which this handler can treat. Specified with :attr:`includes` and :attr:`excludes` of this instance. Returns ------- set A set instance of app_label
[ "Get", "app", "labels", "which", "this", "handler", "can", "treat", ".", "Specified", "with", ":", "attr", ":", "includes", "and", ":", "attr", ":", "excludes", "of", "this", "instance", "." ]
train
https://github.com/lambdalisue/django-permission/blob/580f7a1f857701d06ccf41163f188ac04fbc4fac/src/permission/handlers.py#L115-L129
lambdalisue/django-permission
src/permission/handlers.py
PermissionHandler.has_module_perms
def has_module_perms(self, user_obj, app_label): """ Check if user have permission of specified app Parameters ---------- user_obj : django user model instance A django user model instance which be checked app_label : string Django application nam...
python
def has_module_perms(self, user_obj, app_label): """ Check if user have permission of specified app Parameters ---------- user_obj : django user model instance A django user model instance which be checked app_label : string Django application nam...
[ "def", "has_module_perms", "(", "self", ",", "user_obj", ",", "app_label", ")", ":", "cache_name", "=", "\"_has_module_perms_%s_%s_cache\"", "%", "(", "app_label", ",", "user_obj", ".", "pk", ")", "if", "hasattr", "(", "self", ",", "cache_name", ")", ":", "r...
Check if user have permission of specified app Parameters ---------- user_obj : django user model instance A django user model instance which be checked app_label : string Django application name Returns ------- boolean Whethe...
[ "Check", "if", "user", "have", "permission", "of", "specified", "app" ]
train
https://github.com/lambdalisue/django-permission/blob/580f7a1f857701d06ccf41163f188ac04fbc4fac/src/permission/handlers.py#L158-L186
lambdalisue/django-permission
src/permission/handlers.py
LogicalPermissionHandler.has_perm
def has_perm(self, user_obj, perm, obj=None): """ Check if user have permission (of object) based on specified models's ``_permission_logics`` attribute. The result will be stored in user_obj as a cache to reduce method call. Parameters ---------- user_obj : dja...
python
def has_perm(self, user_obj, perm, obj=None): """ Check if user have permission (of object) based on specified models's ``_permission_logics`` attribute. The result will be stored in user_obj as a cache to reduce method call. Parameters ---------- user_obj : dja...
[ "def", "has_perm", "(", "self", ",", "user_obj", ",", "perm", ",", "obj", "=", "None", ")", ":", "if", "perm", "not", "in", "self", ".", "get_supported_permissions", "(", ")", ":", "return", "False", "# use cache to reduce method call", "CACHE_NAME", "=", "'...
Check if user have permission (of object) based on specified models's ``_permission_logics`` attribute. The result will be stored in user_obj as a cache to reduce method call. Parameters ---------- user_obj : django user model instance A django user model instance w...
[ "Check", "if", "user", "have", "permission", "(", "of", "object", ")", "based", "on", "specified", "models", "s", "_permission_logics", "attribute", "." ]
train
https://github.com/lambdalisue/django-permission/blob/580f7a1f857701d06ccf41163f188ac04fbc4fac/src/permission/handlers.py#L214-L246
lambdalisue/django-permission
src/permission/decorators/permission_required.py
permission_required
def permission_required(perm, queryset_or_model=None, login_url=None, raise_exception=False): """ Permission check decorator for classbased/functional generic view This decorator works as class, method or function decorator without any modification. DO NOT use ``method_decor...
python
def permission_required(perm, queryset_or_model=None, login_url=None, raise_exception=False): """ Permission check decorator for classbased/functional generic view This decorator works as class, method or function decorator without any modification. DO NOT use ``method_decor...
[ "def", "permission_required", "(", "perm", ",", "queryset_or_model", "=", "None", ",", "login_url", "=", "None", ",", "raise_exception", "=", "False", ")", ":", "# convert model to queryset", "if", "queryset_or_model", "and", "issubclass", "(", "queryset_or_model", ...
Permission check decorator for classbased/functional generic view This decorator works as class, method or function decorator without any modification. DO NOT use ``method_decorator`` or whatever while this decorator will use ``self`` argument for method of classbased generic view. Parameters ...
[ "Permission", "check", "decorator", "for", "classbased", "/", "functional", "generic", "view" ]
train
https://github.com/lambdalisue/django-permission/blob/580f7a1f857701d06ccf41163f188ac04fbc4fac/src/permission/decorators/permission_required.py#L11-L71
lambdalisue/django-permission
src/permission/utils/permissions.py
get_perm_codename
def get_perm_codename(perm, fail_silently=True): """ Get permission codename from permission-string. Examples -------- >>> get_perm_codename('app_label.codename_model') 'codename_model' >>> get_perm_codename('app_label.codename') 'codename' >>> get_perm_codename('codename_model') ...
python
def get_perm_codename(perm, fail_silently=True): """ Get permission codename from permission-string. Examples -------- >>> get_perm_codename('app_label.codename_model') 'codename_model' >>> get_perm_codename('app_label.codename') 'codename' >>> get_perm_codename('codename_model') ...
[ "def", "get_perm_codename", "(", "perm", ",", "fail_silently", "=", "True", ")", ":", "try", ":", "perm", "=", "perm", ".", "split", "(", "'.'", ",", "1", ")", "[", "1", "]", "except", "IndexError", "as", "e", ":", "if", "not", "fail_silently", ":", ...
Get permission codename from permission-string. Examples -------- >>> get_perm_codename('app_label.codename_model') 'codename_model' >>> get_perm_codename('app_label.codename') 'codename' >>> get_perm_codename('codename_model') 'codename_model' >>> get_perm_codename('codename') ...
[ "Get", "permission", "codename", "from", "permission", "-", "string", "." ]
train
https://github.com/lambdalisue/django-permission/blob/580f7a1f857701d06ccf41163f188ac04fbc4fac/src/permission/utils/permissions.py#L12-L34
lambdalisue/django-permission
src/permission/utils/permissions.py
permission_to_perm
def permission_to_perm(permission): """ Convert a permission instance to a permission-string. Examples -------- >>> permission = Permission.objects.get( ... content_type__app_label='auth', ... codename='add_user', ... ) >>> permission_to_perm(permission) 'auth.add_user' ...
python
def permission_to_perm(permission): """ Convert a permission instance to a permission-string. Examples -------- >>> permission = Permission.objects.get( ... content_type__app_label='auth', ... codename='add_user', ... ) >>> permission_to_perm(permission) 'auth.add_user' ...
[ "def", "permission_to_perm", "(", "permission", ")", ":", "app_label", "=", "permission", ".", "content_type", ".", "app_label", "codename", "=", "permission", ".", "codename", "return", "'%s.%s'", "%", "(", "app_label", ",", "codename", ")" ]
Convert a permission instance to a permission-string. Examples -------- >>> permission = Permission.objects.get( ... content_type__app_label='auth', ... codename='add_user', ... ) >>> permission_to_perm(permission) 'auth.add_user'
[ "Convert", "a", "permission", "instance", "to", "a", "permission", "-", "string", "." ]
train
https://github.com/lambdalisue/django-permission/blob/580f7a1f857701d06ccf41163f188ac04fbc4fac/src/permission/utils/permissions.py#L37-L52
lambdalisue/django-permission
src/permission/utils/permissions.py
perm_to_permission
def perm_to_permission(perm): """ Convert a permission-string to a permission instance. Examples -------- >>> permission = perm_to_permission('auth.add_user') >>> permission.content_type.app_label 'auth' >>> permission.codename 'add_user' """ from django.contrib.auth.models ...
python
def perm_to_permission(perm): """ Convert a permission-string to a permission instance. Examples -------- >>> permission = perm_to_permission('auth.add_user') >>> permission.content_type.app_label 'auth' >>> permission.codename 'add_user' """ from django.contrib.auth.models ...
[ "def", "perm_to_permission", "(", "perm", ")", ":", "from", "django", ".", "contrib", ".", "auth", ".", "models", "import", "Permission", "try", ":", "app_label", ",", "codename", "=", "perm", ".", "split", "(", "'.'", ",", "1", ")", "except", "(", "Va...
Convert a permission-string to a permission instance. Examples -------- >>> permission = perm_to_permission('auth.add_user') >>> permission.content_type.app_label 'auth' >>> permission.codename 'add_user'
[ "Convert", "a", "permission", "-", "string", "to", "a", "permission", "instance", "." ]
train
https://github.com/lambdalisue/django-permission/blob/580f7a1f857701d06ccf41163f188ac04fbc4fac/src/permission/utils/permissions.py#L55-L80
lambdalisue/django-permission
src/permission/utils/permissions.py
get_app_perms
def get_app_perms(model_or_app_label): """ Get permission-string list of the specified django application. Parameters ---------- model_or_app_label : model class or string A model class or app_label string to specify the particular django application. Returns ------- se...
python
def get_app_perms(model_or_app_label): """ Get permission-string list of the specified django application. Parameters ---------- model_or_app_label : model class or string A model class or app_label string to specify the particular django application. Returns ------- se...
[ "def", "get_app_perms", "(", "model_or_app_label", ")", ":", "from", "django", ".", "contrib", ".", "auth", ".", "models", "import", "Permission", "if", "isinstance", "(", "model_or_app_label", ",", "string_types", ")", ":", "app_label", "=", "model_or_app_label",...
Get permission-string list of the specified django application. Parameters ---------- model_or_app_label : model class or string A model class or app_label string to specify the particular django application. Returns ------- set A set of perms of the specified django ap...
[ "Get", "permission", "-", "string", "list", "of", "the", "specified", "django", "application", "." ]
train
https://github.com/lambdalisue/django-permission/blob/580f7a1f857701d06ccf41163f188ac04fbc4fac/src/permission/utils/permissions.py#L83-L113
lambdalisue/django-permission
src/permission/utils/permissions.py
get_model_perms
def get_model_perms(model): """ Get permission-string list of a specified django model. Parameters ---------- model : model class A model class to specify the particular django model. Returns ------- set A set of perms of the specified django model. Examples --...
python
def get_model_perms(model): """ Get permission-string list of a specified django model. Parameters ---------- model : model class A model class to specify the particular django model. Returns ------- set A set of perms of the specified django model. Examples --...
[ "def", "get_model_perms", "(", "model", ")", ":", "from", "django", ".", "contrib", ".", "auth", ".", "models", "import", "Permission", "app_label", "=", "model", ".", "_meta", ".", "app_label", "model_name", "=", "model", ".", "_meta", ".", "object_name", ...
Get permission-string list of a specified django model. Parameters ---------- model : model class A model class to specify the particular django model. Returns ------- set A set of perms of the specified django model. Examples -------- >>> sorted(get_model_perms(Pe...
[ "Get", "permission", "-", "string", "list", "of", "a", "specified", "django", "model", "." ]
train
https://github.com/lambdalisue/django-permission/blob/580f7a1f857701d06ccf41163f188ac04fbc4fac/src/permission/utils/permissions.py#L116-L145
lambdalisue/django-permission
src/permission/logics/collaborators.py
CollaboratorsPermissionLogic.has_perm
def has_perm(self, user_obj, perm, obj=None): """ Check if user have permission (of object) If the user_obj is not authenticated, it return ``False``. If no object is specified, it return ``True`` when the corresponding permission was specified to ``True`` (changed from v0.7.0)...
python
def has_perm(self, user_obj, perm, obj=None): """ Check if user have permission (of object) If the user_obj is not authenticated, it return ``False``. If no object is specified, it return ``True`` when the corresponding permission was specified to ``True`` (changed from v0.7.0)...
[ "def", "has_perm", "(", "self", ",", "user_obj", ",", "perm", ",", "obj", "=", "None", ")", ":", "if", "not", "is_authenticated", "(", "user_obj", ")", ":", "return", "False", "# construct the permission full name", "change_permission", "=", "self", ".", "get_...
Check if user have permission (of object) If the user_obj is not authenticated, it return ``False``. If no object is specified, it return ``True`` when the corresponding permission was specified to ``True`` (changed from v0.7.0). This behavior is based on the django system. htt...
[ "Check", "if", "user", "have", "permission", "(", "of", "object", ")" ]
train
https://github.com/lambdalisue/django-permission/blob/580f7a1f857701d06ccf41163f188ac04fbc4fac/src/permission/logics/collaborators.py#L72-L137
lambdalisue/django-permission
src/permission/utils/logics.py
add_permission_logic
def add_permission_logic(model, permission_logic): """ Add permission logic to the model Parameters ---------- model : django model class A django model class which will be treated by the specified permission logic permission_logic : permission logic instance A permissio...
python
def add_permission_logic(model, permission_logic): """ Add permission logic to the model Parameters ---------- model : django model class A django model class which will be treated by the specified permission logic permission_logic : permission logic instance A permissio...
[ "def", "add_permission_logic", "(", "model", ",", "permission_logic", ")", ":", "if", "not", "isinstance", "(", "permission_logic", ",", "PermissionLogic", ")", ":", "raise", "AttributeError", "(", "'`permission_logic` must be an instance of PermissionLogic'", ")", "if", ...
Add permission logic to the model Parameters ---------- model : django model class A django model class which will be treated by the specified permission logic permission_logic : permission logic instance A permission logic instance which will be used to determine permission ...
[ "Add", "permission", "logic", "to", "the", "model" ]
train
https://github.com/lambdalisue/django-permission/blob/580f7a1f857701d06ccf41163f188ac04fbc4fac/src/permission/utils/logics.py#L9-L41
lambdalisue/django-permission
src/permission/utils/logics.py
remove_permission_logic
def remove_permission_logic(model, permission_logic, fail_silently=True): """ Remove permission logic to the model Parameters ---------- model : django model class A django model class which will be treated by the specified permission logic permission_logic : permission logic cl...
python
def remove_permission_logic(model, permission_logic, fail_silently=True): """ Remove permission logic to the model Parameters ---------- model : django model class A django model class which will be treated by the specified permission logic permission_logic : permission logic cl...
[ "def", "remove_permission_logic", "(", "model", ",", "permission_logic", ",", "fail_silently", "=", "True", ")", ":", "if", "not", "hasattr", "(", "model", ",", "'_permission_logics'", ")", ":", "model", ".", "_permission_logics", "=", "set", "(", ")", "if", ...
Remove permission logic to the model Parameters ---------- model : django model class A django model class which will be treated by the specified permission logic permission_logic : permission logic class or instance A permission logic class or instance which will be used to det...
[ "Remove", "permission", "logic", "to", "the", "model" ]
train
https://github.com/lambdalisue/django-permission/blob/580f7a1f857701d06ccf41163f188ac04fbc4fac/src/permission/utils/logics.py#L44-L84
lambdalisue/django-permission
src/permission/utils/autodiscover.py
autodiscover
def autodiscover(module_name=None): """ Autodiscover INSTALLED_APPS perms.py modules and fail silently when not present. This forces an import on them to register any permissions bits they may want. """ from django.utils.module_loading import module_has_submodule from permission.compat impor...
python
def autodiscover(module_name=None): """ Autodiscover INSTALLED_APPS perms.py modules and fail silently when not present. This forces an import on them to register any permissions bits they may want. """ from django.utils.module_loading import module_has_submodule from permission.compat impor...
[ "def", "autodiscover", "(", "module_name", "=", "None", ")", ":", "from", "django", ".", "utils", ".", "module_loading", "import", "module_has_submodule", "from", "permission", ".", "compat", "import", "import_module", "from", "permission", ".", "conf", "import", ...
Autodiscover INSTALLED_APPS perms.py modules and fail silently when not present. This forces an import on them to register any permissions bits they may want.
[ "Autodiscover", "INSTALLED_APPS", "perms", ".", "py", "modules", "and", "fail", "silently", "when", "not", "present", ".", "This", "forces", "an", "import", "on", "them", "to", "register", "any", "permissions", "bits", "they", "may", "want", "." ]
train
https://github.com/lambdalisue/django-permission/blob/580f7a1f857701d06ccf41163f188ac04fbc4fac/src/permission/utils/autodiscover.py#L7-L31
lambdalisue/django-permission
src/permission/utils/autodiscover.py
discover
def discover(app, module_name=None): """ Automatically apply the permission logics written in the specified module. Examples -------- Assume if you have a ``perms.py`` in ``your_app`` as:: from permission.logics import AuthorPermissionLogic PERMISSION_LOGICS = ( ('y...
python
def discover(app, module_name=None): """ Automatically apply the permission logics written in the specified module. Examples -------- Assume if you have a ``perms.py`` in ``your_app`` as:: from permission.logics import AuthorPermissionLogic PERMISSION_LOGICS = ( ('y...
[ "def", "discover", "(", "app", ",", "module_name", "=", "None", ")", ":", "from", "permission", ".", "compat", "import", "import_module", "from", "permission", ".", "compat", "import", "get_model", "from", "permission", ".", "conf", "import", "settings", "from...
Automatically apply the permission logics written in the specified module. Examples -------- Assume if you have a ``perms.py`` in ``your_app`` as:: from permission.logics import AuthorPermissionLogic PERMISSION_LOGICS = ( ('your_app.your_model', AuthorPermissionLogic), ...
[ "Automatically", "apply", "the", "permission", "logics", "written", "in", "the", "specified", "module", "." ]
train
https://github.com/lambdalisue/django-permission/blob/580f7a1f857701d06ccf41163f188ac04fbc4fac/src/permission/utils/autodiscover.py#L34-L72
lambdalisue/django-permission
src/permission/logics/oneself.py
OneselfPermissionLogic.has_perm
def has_perm(self, user_obj, perm, obj=None): """ Check if user have permission of himself If the user_obj is not authenticated, it return ``False``. If no object is specified, it return ``True`` when the corresponding permission was specified to ``True`` (changed from v0.7.0)....
python
def has_perm(self, user_obj, perm, obj=None): """ Check if user have permission of himself If the user_obj is not authenticated, it return ``False``. If no object is specified, it return ``True`` when the corresponding permission was specified to ``True`` (changed from v0.7.0)....
[ "def", "has_perm", "(", "self", ",", "user_obj", ",", "perm", ",", "obj", "=", "None", ")", ":", "if", "not", "is_authenticated", "(", "user_obj", ")", ":", "return", "False", "# construct the permission full name", "change_permission", "=", "self", ".", "get_...
Check if user have permission of himself If the user_obj is not authenticated, it return ``False``. If no object is specified, it return ``True`` when the corresponding permission was specified to ``True`` (changed from v0.7.0). This behavior is based on the django system. http...
[ "Check", "if", "user", "have", "permission", "of", "himself" ]
train
https://github.com/lambdalisue/django-permission/blob/580f7a1f857701d06ccf41163f188ac04fbc4fac/src/permission/logics/oneself.py#L58-L118
lambdalisue/django-permission
src/permission/logics/base.py
PermissionLogic.get_full_permission_string
def get_full_permission_string(self, perm): """ Return full permission string (app_label.perm_model) """ if not getattr(self, 'model', None): raise AttributeError("You need to use `add_permission_logic` to " "register the instance to the model...
python
def get_full_permission_string(self, perm): """ Return full permission string (app_label.perm_model) """ if not getattr(self, 'model', None): raise AttributeError("You need to use `add_permission_logic` to " "register the instance to the model...
[ "def", "get_full_permission_string", "(", "self", ",", "perm", ")", ":", "if", "not", "getattr", "(", "self", ",", "'model'", ",", "None", ")", ":", "raise", "AttributeError", "(", "\"You need to use `add_permission_logic` to \"", "\"register the instance to the model c...
Return full permission string (app_label.perm_model)
[ "Return", "full", "permission", "string", "(", "app_label", ".", "perm_model", ")" ]
train
https://github.com/lambdalisue/django-permission/blob/580f7a1f857701d06ccf41163f188ac04fbc4fac/src/permission/logics/base.py#L8-L18
lambdalisue/django-permission
src/permission/decorators/utils.py
redirect_to_login
def redirect_to_login(request, login_url=None, redirect_field_name=REDIRECT_FIELD_NAME): """redirect to login""" path = request.build_absolute_uri() # if the login url is the same scheme and net location then just # use the path as the "next" url. login_scheme, login_netloc = \...
python
def redirect_to_login(request, login_url=None, redirect_field_name=REDIRECT_FIELD_NAME): """redirect to login""" path = request.build_absolute_uri() # if the login url is the same scheme and net location then just # use the path as the "next" url. login_scheme, login_netloc = \...
[ "def", "redirect_to_login", "(", "request", ",", "login_url", "=", "None", ",", "redirect_field_name", "=", "REDIRECT_FIELD_NAME", ")", ":", "path", "=", "request", ".", "build_absolute_uri", "(", ")", "# if the login url is the same scheme and net location then just", "#...
redirect to login
[ "redirect", "to", "login" ]
train
https://github.com/lambdalisue/django-permission/blob/580f7a1f857701d06ccf41163f188ac04fbc4fac/src/permission/decorators/utils.py#L13-L27
lambdalisue/django-permission
src/permission/backends.py
PermissionBackend.has_perm
def has_perm(self, user_obj, perm, obj=None): """ Check if user have permission (of object) based on registered handlers. It will raise ``ObjectDoesNotExist`` exception when the specified string permission does not exist and ``PERMISSION_CHECK_PERMISSION_PRESENCE`` is ``True`` i...
python
def has_perm(self, user_obj, perm, obj=None): """ Check if user have permission (of object) based on registered handlers. It will raise ``ObjectDoesNotExist`` exception when the specified string permission does not exist and ``PERMISSION_CHECK_PERMISSION_PRESENCE`` is ``True`` i...
[ "def", "has_perm", "(", "self", ",", "user_obj", ",", "perm", ",", "obj", "=", "None", ")", ":", "if", "settings", ".", "PERMISSION_CHECK_PERMISSION_PRESENCE", ":", "# get permission instance from string permission (perm)", "# it raise ObjectDoesNotExists when the permission ...
Check if user have permission (of object) based on registered handlers. It will raise ``ObjectDoesNotExist`` exception when the specified string permission does not exist and ``PERMISSION_CHECK_PERMISSION_PRESENCE`` is ``True`` in ``settings`` module. Parameters -------...
[ "Check", "if", "user", "have", "permission", "(", "of", "object", ")", "based", "on", "registered", "handlers", "." ]
train
https://github.com/lambdalisue/django-permission/blob/580f7a1f857701d06ccf41163f188ac04fbc4fac/src/permission/backends.py#L28-L79
lambdalisue/django-permission
src/permission/backends.py
PermissionBackend.has_module_perms
def has_module_perms(self, user_obj, app_label): """ Check if user have permission of specified app based on registered handlers. It will raise ``ObjectDoesNotExist`` exception when the specified string permission does not exist and ``PERMISSION_CHECK_PERMISSION_PRESENCE...
python
def has_module_perms(self, user_obj, app_label): """ Check if user have permission of specified app based on registered handlers. It will raise ``ObjectDoesNotExist`` exception when the specified string permission does not exist and ``PERMISSION_CHECK_PERMISSION_PRESENCE...
[ "def", "has_module_perms", "(", "self", ",", "user_obj", ",", "app_label", ")", ":", "# get permission handlers fot this perm", "cache_name", "=", "'_%s_cache'", "%", "app_label", "if", "hasattr", "(", "self", ",", "cache_name", ")", ":", "handlers", "=", "getattr...
Check if user have permission of specified app based on registered handlers. It will raise ``ObjectDoesNotExist`` exception when the specified string permission does not exist and ``PERMISSION_CHECK_PERMISSION_PRESENCE`` is ``True`` in ``settings`` module. Parameters ...
[ "Check", "if", "user", "have", "permission", "of", "specified", "app", "based", "on", "registered", "handlers", "." ]
train
https://github.com/lambdalisue/django-permission/blob/580f7a1f857701d06ccf41163f188ac04fbc4fac/src/permission/backends.py#L81-L121
lambdalisue/django-permission
src/permission/templatetags/permissionif.py
of_operator
def of_operator(context, x, y): """ 'of' operator of permission if This operator is used to specify the target object of permission """ return x.eval(context), y.eval(context)
python
def of_operator(context, x, y): """ 'of' operator of permission if This operator is used to specify the target object of permission """ return x.eval(context), y.eval(context)
[ "def", "of_operator", "(", "context", ",", "x", ",", "y", ")", ":", "return", "x", ".", "eval", "(", "context", ")", ",", "y", ".", "eval", "(", "context", ")" ]
'of' operator of permission if This operator is used to specify the target object of permission
[ "of", "operator", "of", "permission", "if" ]
train
https://github.com/lambdalisue/django-permission/blob/580f7a1f857701d06ccf41163f188ac04fbc4fac/src/permission/templatetags/permissionif.py#L17-L23
lambdalisue/django-permission
src/permission/templatetags/permissionif.py
has_operator
def has_operator(context, x, y): """ 'has' operator of permission if This operator is used to specify the user object of permission """ user = x.eval(context) perm = y.eval(context) if isinstance(perm, (list, tuple)): perm, obj = perm else: obj = None return user.has...
python
def has_operator(context, x, y): """ 'has' operator of permission if This operator is used to specify the user object of permission """ user = x.eval(context) perm = y.eval(context) if isinstance(perm, (list, tuple)): perm, obj = perm else: obj = None return user.has...
[ "def", "has_operator", "(", "context", ",", "x", ",", "y", ")", ":", "user", "=", "x", ".", "eval", "(", "context", ")", "perm", "=", "y", ".", "eval", "(", "context", ")", "if", "isinstance", "(", "perm", ",", "(", "list", ",", "tuple", ")", "...
'has' operator of permission if This operator is used to specify the user object of permission
[ "has", "operator", "of", "permission", "if" ]
train
https://github.com/lambdalisue/django-permission/blob/580f7a1f857701d06ccf41163f188ac04fbc4fac/src/permission/templatetags/permissionif.py#L26-L38
lambdalisue/django-permission
src/permission/templatetags/permissionif.py
do_permissionif
def do_permissionif(parser, token): """ Permission if templatetag Examples -------- :: {% if user has 'blogs.add_article' %} <p>This user have 'blogs.add_article' permission</p> {% elif user has 'blog.change_article' of object %} <p>This user have 'blogs.cha...
python
def do_permissionif(parser, token): """ Permission if templatetag Examples -------- :: {% if user has 'blogs.add_article' %} <p>This user have 'blogs.add_article' permission</p> {% elif user has 'blog.change_article' of object %} <p>This user have 'blogs.cha...
[ "def", "do_permissionif", "(", "parser", ",", "token", ")", ":", "bits", "=", "token", ".", "split_contents", "(", ")", "ELIF", "=", "\"el%s\"", "%", "bits", "[", "0", "]", "ELSE", "=", "\"else\"", "ENDIF", "=", "\"end%s\"", "%", "bits", "[", "0", "]...
Permission if templatetag Examples -------- :: {% if user has 'blogs.add_article' %} <p>This user have 'blogs.add_article' permission</p> {% elif user has 'blog.change_article' of object %} <p>This user have 'blogs.change_article' permission of {{object}}</p> ...
[ "Permission", "if", "templatetag" ]
train
https://github.com/lambdalisue/django-permission/blob/580f7a1f857701d06ccf41163f188ac04fbc4fac/src/permission/templatetags/permissionif.py#L77-L128
coddingtonbear/django-mailbox
django_mailbox/utils.py
get_body_from_message
def get_body_from_message(message, maintype, subtype): """ Fetchs the body message matching main/sub content type. """ body = six.text_type('') for part in message.walk(): if part.get('content-disposition', '').startswith('attachment;'): continue if part.get_content_maint...
python
def get_body_from_message(message, maintype, subtype): """ Fetchs the body message matching main/sub content type. """ body = six.text_type('') for part in message.walk(): if part.get('content-disposition', '').startswith('attachment;'): continue if part.get_content_maint...
[ "def", "get_body_from_message", "(", "message", ",", "maintype", ",", "subtype", ")", ":", "body", "=", "six", ".", "text_type", "(", "''", ")", "for", "part", "in", "message", ".", "walk", "(", ")", ":", "if", "part", ".", "get", "(", "'content-dispos...
Fetchs the body message matching main/sub content type.
[ "Fetchs", "the", "body", "message", "matching", "main", "/", "sub", "content", "type", "." ]
train
https://github.com/coddingtonbear/django-mailbox/blob/fafc183e28dd0b5c76cd245a3ba9c1401e7e676e/django_mailbox/utils.py#L105-L143
AguaClara/aguaclara
aguaclara/core/physchem.py
diam_circle
def diam_circle(AreaCircle): """Return the diameter of a circle.""" ut.check_range([AreaCircle, ">0", "AreaCircle"]) return np.sqrt(4 * AreaCircle / np.pi)
python
def diam_circle(AreaCircle): """Return the diameter of a circle.""" ut.check_range([AreaCircle, ">0", "AreaCircle"]) return np.sqrt(4 * AreaCircle / np.pi)
[ "def", "diam_circle", "(", "AreaCircle", ")", ":", "ut", ".", "check_range", "(", "[", "AreaCircle", ",", "\">0\"", ",", "\"AreaCircle\"", "]", ")", "return", "np", ".", "sqrt", "(", "4", "*", "AreaCircle", "/", "np", ".", "pi", ")" ]
Return the diameter of a circle.
[ "Return", "the", "diameter", "of", "a", "circle", "." ]
train
https://github.com/AguaClara/aguaclara/blob/8dd4e734768b166a7fc2b60388a24df2f93783fc/aguaclara/core/physchem.py#L27-L30
AguaClara/aguaclara
aguaclara/core/physchem.py
density_water
def density_water(temp): """Return the density of water at a given temperature. If given units, the function will automatically convert to Kelvin. If not given units, the function will assume Kelvin. """ ut.check_range([temp, ">0", "Temperature in Kelvin"]) rhointerpolated = interpolate.CubicSp...
python
def density_water(temp): """Return the density of water at a given temperature. If given units, the function will automatically convert to Kelvin. If not given units, the function will assume Kelvin. """ ut.check_range([temp, ">0", "Temperature in Kelvin"]) rhointerpolated = interpolate.CubicSp...
[ "def", "density_water", "(", "temp", ")", ":", "ut", ".", "check_range", "(", "[", "temp", ",", "\">0\"", ",", "\"Temperature in Kelvin\"", "]", ")", "rhointerpolated", "=", "interpolate", ".", "CubicSpline", "(", "WATER_DENSITY_TABLE", "[", "0", "]", ",", "...
Return the density of water at a given temperature. If given units, the function will automatically convert to Kelvin. If not given units, the function will assume Kelvin.
[ "Return", "the", "density", "of", "water", "at", "a", "given", "temperature", "." ]
train
https://github.com/AguaClara/aguaclara/blob/8dd4e734768b166a7fc2b60388a24df2f93783fc/aguaclara/core/physchem.py#L63-L72
AguaClara/aguaclara
aguaclara/core/physchem.py
viscosity_kinematic
def viscosity_kinematic(temp): """Return the kinematic viscosity of water at a given temperature. If given units, the function will automatically convert to Kelvin. If not given units, the function will assume Kelvin. """ ut.check_range([temp, ">0", "Temperature in Kelvin"]) return (viscosity_d...
python
def viscosity_kinematic(temp): """Return the kinematic viscosity of water at a given temperature. If given units, the function will automatically convert to Kelvin. If not given units, the function will assume Kelvin. """ ut.check_range([temp, ">0", "Temperature in Kelvin"]) return (viscosity_d...
[ "def", "viscosity_kinematic", "(", "temp", ")", ":", "ut", ".", "check_range", "(", "[", "temp", ",", "\">0\"", ",", "\"Temperature in Kelvin\"", "]", ")", "return", "(", "viscosity_dynamic", "(", "temp", ")", ".", "magnitude", "/", "density_water", "(", "te...
Return the kinematic viscosity of water at a given temperature. If given units, the function will automatically convert to Kelvin. If not given units, the function will assume Kelvin.
[ "Return", "the", "kinematic", "viscosity", "of", "water", "at", "a", "given", "temperature", "." ]
train
https://github.com/AguaClara/aguaclara/blob/8dd4e734768b166a7fc2b60388a24df2f93783fc/aguaclara/core/physchem.py#L76-L84
AguaClara/aguaclara
aguaclara/core/physchem.py
re_pipe
def re_pipe(FlowRate, Diam, Nu): """Return the Reynolds Number for a pipe.""" #Checking input validity ut.check_range([FlowRate, ">0", "Flow rate"], [Diam, ">0", "Diameter"], [Nu, ">0", "Nu"]) return (4 * FlowRate) / (np.pi * Diam * Nu)
python
def re_pipe(FlowRate, Diam, Nu): """Return the Reynolds Number for a pipe.""" #Checking input validity ut.check_range([FlowRate, ">0", "Flow rate"], [Diam, ">0", "Diameter"], [Nu, ">0", "Nu"]) return (4 * FlowRate) / (np.pi * Diam * Nu)
[ "def", "re_pipe", "(", "FlowRate", ",", "Diam", ",", "Nu", ")", ":", "#Checking input validity", "ut", ".", "check_range", "(", "[", "FlowRate", ",", "\">0\"", ",", "\"Flow rate\"", "]", ",", "[", "Diam", ",", "\">0\"", ",", "\"Diameter\"", "]", ",", "["...
Return the Reynolds Number for a pipe.
[ "Return", "the", "Reynolds", "Number", "for", "a", "pipe", "." ]
train
https://github.com/AguaClara/aguaclara/blob/8dd4e734768b166a7fc2b60388a24df2f93783fc/aguaclara/core/physchem.py#L88-L93
AguaClara/aguaclara
aguaclara/core/physchem.py
radius_hydraulic
def radius_hydraulic(Width, DistCenter, openchannel): """Return the hydraulic radius. Width and DistCenter are length values and openchannel is a boolean. """ ut.check_range([Width, ">0", "Width"], [DistCenter, ">0", "DistCenter"], [openchannel, "boolean", "openchannel"]) if open...
python
def radius_hydraulic(Width, DistCenter, openchannel): """Return the hydraulic radius. Width and DistCenter are length values and openchannel is a boolean. """ ut.check_range([Width, ">0", "Width"], [DistCenter, ">0", "DistCenter"], [openchannel, "boolean", "openchannel"]) if open...
[ "def", "radius_hydraulic", "(", "Width", ",", "DistCenter", ",", "openchannel", ")", ":", "ut", ".", "check_range", "(", "[", "Width", ",", "\">0\"", ",", "\"Width\"", "]", ",", "[", "DistCenter", ",", "\">0\"", ",", "\"DistCenter\"", "]", ",", "[", "ope...
Return the hydraulic radius. Width and DistCenter are length values and openchannel is a boolean.
[ "Return", "the", "hydraulic", "radius", "." ]
train
https://github.com/AguaClara/aguaclara/blob/8dd4e734768b166a7fc2b60388a24df2f93783fc/aguaclara/core/physchem.py#L98-L110
AguaClara/aguaclara
aguaclara/core/physchem.py
re_rect
def re_rect(FlowRate, Width, DistCenter, Nu, openchannel): """Return the Reynolds Number for a rectangular channel.""" #Checking input validity - inputs not checked here are checked by #functions this function calls. ut.check_range([FlowRate, ">0", "Flow rate"], [Nu, ">0", "Nu"]) return (4 * FlowRat...
python
def re_rect(FlowRate, Width, DistCenter, Nu, openchannel): """Return the Reynolds Number for a rectangular channel.""" #Checking input validity - inputs not checked here are checked by #functions this function calls. ut.check_range([FlowRate, ">0", "Flow rate"], [Nu, ">0", "Nu"]) return (4 * FlowRat...
[ "def", "re_rect", "(", "FlowRate", ",", "Width", ",", "DistCenter", ",", "Nu", ",", "openchannel", ")", ":", "#Checking input validity - inputs not checked here are checked by", "#functions this function calls.", "ut", ".", "check_range", "(", "[", "FlowRate", ",", "\">...
Return the Reynolds Number for a rectangular channel.
[ "Return", "the", "Reynolds", "Number", "for", "a", "rectangular", "channel", "." ]
train
https://github.com/AguaClara/aguaclara/blob/8dd4e734768b166a7fc2b60388a24df2f93783fc/aguaclara/core/physchem.py#L121-L128
AguaClara/aguaclara
aguaclara/core/physchem.py
re_general
def re_general(Vel, Area, PerimWetted, Nu): """Return the Reynolds Number for a general cross section.""" #Checking input validity - inputs not checked here are checked by #functions this function calls. ut.check_range([Vel, ">=0", "Velocity"], [Nu, ">0", "Nu"]) return 4 * radius_hydraulic_general(A...
python
def re_general(Vel, Area, PerimWetted, Nu): """Return the Reynolds Number for a general cross section.""" #Checking input validity - inputs not checked here are checked by #functions this function calls. ut.check_range([Vel, ">=0", "Velocity"], [Nu, ">0", "Nu"]) return 4 * radius_hydraulic_general(A...
[ "def", "re_general", "(", "Vel", ",", "Area", ",", "PerimWetted", ",", "Nu", ")", ":", "#Checking input validity - inputs not checked here are checked by", "#functions this function calls.", "ut", ".", "check_range", "(", "[", "Vel", ",", "\">=0\"", ",", "\"Velocity\"",...
Return the Reynolds Number for a general cross section.
[ "Return", "the", "Reynolds", "Number", "for", "a", "general", "cross", "section", "." ]
train
https://github.com/AguaClara/aguaclara/blob/8dd4e734768b166a7fc2b60388a24df2f93783fc/aguaclara/core/physchem.py#L134-L139
AguaClara/aguaclara
aguaclara/core/physchem.py
fric
def fric(FlowRate, Diam, Nu, PipeRough): """Return the friction factor for pipe flow. This equation applies to both laminar and turbulent flows. """ #Checking input validity - inputs not checked here are checked by #functions this function calls. ut.check_range([PipeRough, "0-1", "Pipe roughnes...
python
def fric(FlowRate, Diam, Nu, PipeRough): """Return the friction factor for pipe flow. This equation applies to both laminar and turbulent flows. """ #Checking input validity - inputs not checked here are checked by #functions this function calls. ut.check_range([PipeRough, "0-1", "Pipe roughnes...
[ "def", "fric", "(", "FlowRate", ",", "Diam", ",", "Nu", ",", "PipeRough", ")", ":", "#Checking input validity - inputs not checked here are checked by", "#functions this function calls.", "ut", ".", "check_range", "(", "[", "PipeRough", ",", "\"0-1\"", ",", "\"Pipe roug...
Return the friction factor for pipe flow. This equation applies to both laminar and turbulent flows.
[ "Return", "the", "friction", "factor", "for", "pipe", "flow", "." ]
train
https://github.com/AguaClara/aguaclara/blob/8dd4e734768b166a7fc2b60388a24df2f93783fc/aguaclara/core/physchem.py#L143-L161
AguaClara/aguaclara
aguaclara/core/physchem.py
fric_rect
def fric_rect(FlowRate, Width, DistCenter, Nu, PipeRough, openchannel): """Return the friction factor for a rectangular channel.""" #Checking input validity - inputs not checked here are checked by #functions this function calls. ut.check_range([PipeRough, "0-1", "Pipe roughness"]) if re_rect(FlowRa...
python
def fric_rect(FlowRate, Width, DistCenter, Nu, PipeRough, openchannel): """Return the friction factor for a rectangular channel.""" #Checking input validity - inputs not checked here are checked by #functions this function calls. ut.check_range([PipeRough, "0-1", "Pipe roughness"]) if re_rect(FlowRa...
[ "def", "fric_rect", "(", "FlowRate", ",", "Width", ",", "DistCenter", ",", "Nu", ",", "PipeRough", ",", "openchannel", ")", ":", "#Checking input validity - inputs not checked here are checked by", "#functions this function calls.", "ut", ".", "check_range", "(", "[", "...
Return the friction factor for a rectangular channel.
[ "Return", "the", "friction", "factor", "for", "a", "rectangular", "channel", "." ]
train
https://github.com/AguaClara/aguaclara/blob/8dd4e734768b166a7fc2b60388a24df2f93783fc/aguaclara/core/physchem.py#L166-L188
AguaClara/aguaclara
aguaclara/core/physchem.py
fric_general
def fric_general(Area, PerimWetted, Vel, Nu, PipeRough): """Return the friction factor for a general channel.""" #Checking input validity - inputs not checked here are checked by #functions this function calls. ut.check_range([PipeRough, "0-1", "Pipe roughness"]) if re_general(Vel, Area, PerimWetted...
python
def fric_general(Area, PerimWetted, Vel, Nu, PipeRough): """Return the friction factor for a general channel.""" #Checking input validity - inputs not checked here are checked by #functions this function calls. ut.check_range([PipeRough, "0-1", "Pipe roughness"]) if re_general(Vel, Area, PerimWetted...
[ "def", "fric_general", "(", "Area", ",", "PerimWetted", ",", "Vel", ",", "Nu", ",", "PipeRough", ")", ":", "#Checking input validity - inputs not checked here are checked by", "#functions this function calls.", "ut", ".", "check_range", "(", "[", "PipeRough", ",", "\"0-...
Return the friction factor for a general channel.
[ "Return", "the", "friction", "factor", "for", "a", "general", "channel", "." ]
train
https://github.com/AguaClara/aguaclara/blob/8dd4e734768b166a7fc2b60388a24df2f93783fc/aguaclara/core/physchem.py#L193-L215
AguaClara/aguaclara
aguaclara/core/physchem.py
headloss_fric
def headloss_fric(FlowRate, Diam, Length, Nu, PipeRough): """Return the major head loss (due to wall shear) in a pipe. This equation applies to both laminar and turbulent flows. """ #Checking input validity - inputs not checked here are checked by #functions this function calls. ut.check_range(...
python
def headloss_fric(FlowRate, Diam, Length, Nu, PipeRough): """Return the major head loss (due to wall shear) in a pipe. This equation applies to both laminar and turbulent flows. """ #Checking input validity - inputs not checked here are checked by #functions this function calls. ut.check_range(...
[ "def", "headloss_fric", "(", "FlowRate", ",", "Diam", ",", "Length", ",", "Nu", ",", "PipeRough", ")", ":", "#Checking input validity - inputs not checked here are checked by", "#functions this function calls.", "ut", ".", "check_range", "(", "[", "Length", ",", "\">0\"...
Return the major head loss (due to wall shear) in a pipe. This equation applies to both laminar and turbulent flows.
[ "Return", "the", "major", "head", "loss", "(", "due", "to", "wall", "shear", ")", "in", "a", "pipe", "." ]
train
https://github.com/AguaClara/aguaclara/blob/8dd4e734768b166a7fc2b60388a24df2f93783fc/aguaclara/core/physchem.py#L219-L230
AguaClara/aguaclara
aguaclara/core/physchem.py
headloss_exp
def headloss_exp(FlowRate, Diam, KMinor): """Return the minor head loss (due to expansions) in a pipe. This equation applies to both laminar and turbulent flows. """ #Checking input validity ut.check_range([FlowRate, ">0", "Flow rate"], [Diam, ">0", "Diameter"], [KMinor, ">=0", "...
python
def headloss_exp(FlowRate, Diam, KMinor): """Return the minor head loss (due to expansions) in a pipe. This equation applies to both laminar and turbulent flows. """ #Checking input validity ut.check_range([FlowRate, ">0", "Flow rate"], [Diam, ">0", "Diameter"], [KMinor, ">=0", "...
[ "def", "headloss_exp", "(", "FlowRate", ",", "Diam", ",", "KMinor", ")", ":", "#Checking input validity", "ut", ".", "check_range", "(", "[", "FlowRate", ",", "\">0\"", ",", "\"Flow rate\"", "]", ",", "[", "Diam", ",", "\">0\"", ",", "\"Diameter\"", "]", "...
Return the minor head loss (due to expansions) in a pipe. This equation applies to both laminar and turbulent flows.
[ "Return", "the", "minor", "head", "loss", "(", "due", "to", "expansions", ")", "in", "a", "pipe", "." ]
train
https://github.com/AguaClara/aguaclara/blob/8dd4e734768b166a7fc2b60388a24df2f93783fc/aguaclara/core/physchem.py#L234-L242
AguaClara/aguaclara
aguaclara/core/physchem.py
headloss
def headloss(FlowRate, Diam, Length, Nu, PipeRough, KMinor): """Return the total head loss from major and minor losses in a pipe. This equation applies to both laminar and turbulent flows. """ #Inputs do not need to be checked here because they are checked by #functions this function calls. ret...
python
def headloss(FlowRate, Diam, Length, Nu, PipeRough, KMinor): """Return the total head loss from major and minor losses in a pipe. This equation applies to both laminar and turbulent flows. """ #Inputs do not need to be checked here because they are checked by #functions this function calls. ret...
[ "def", "headloss", "(", "FlowRate", ",", "Diam", ",", "Length", ",", "Nu", ",", "PipeRough", ",", "KMinor", ")", ":", "#Inputs do not need to be checked here because they are checked by", "#functions this function calls.", "return", "(", "headloss_fric", "(", "FlowRate", ...
Return the total head loss from major and minor losses in a pipe. This equation applies to both laminar and turbulent flows.
[ "Return", "the", "total", "head", "loss", "from", "major", "and", "minor", "losses", "in", "a", "pipe", "." ]
train
https://github.com/AguaClara/aguaclara/blob/8dd4e734768b166a7fc2b60388a24df2f93783fc/aguaclara/core/physchem.py#L246-L254
AguaClara/aguaclara
aguaclara/core/physchem.py
headloss_fric_rect
def headloss_fric_rect(FlowRate, Width, DistCenter, Length, Nu, PipeRough, openchannel): """Return the major head loss due to wall shear in a rectangular channel. This equation applies to both laminar and turbulent flows. """ #Checking input validity - inputs not checked here are checked by #functi...
python
def headloss_fric_rect(FlowRate, Width, DistCenter, Length, Nu, PipeRough, openchannel): """Return the major head loss due to wall shear in a rectangular channel. This equation applies to both laminar and turbulent flows. """ #Checking input validity - inputs not checked here are checked by #functi...
[ "def", "headloss_fric_rect", "(", "FlowRate", ",", "Width", ",", "DistCenter", ",", "Length", ",", "Nu", ",", "PipeRough", ",", "openchannel", ")", ":", "#Checking input validity - inputs not checked here are checked by", "#functions this function calls.", "ut", ".", "che...
Return the major head loss due to wall shear in a rectangular channel. This equation applies to both laminar and turbulent flows.
[ "Return", "the", "major", "head", "loss", "due", "to", "wall", "shear", "in", "a", "rectangular", "channel", "." ]
train
https://github.com/AguaClara/aguaclara/blob/8dd4e734768b166a7fc2b60388a24df2f93783fc/aguaclara/core/physchem.py#L258-L272
AguaClara/aguaclara
aguaclara/core/physchem.py
headloss_exp_rect
def headloss_exp_rect(FlowRate, Width, DistCenter, KMinor): """Return the minor head loss due to expansion in a rectangular channel. This equation applies to both laminar and turbulent flows. """ #Checking input validity ut.check_range([FlowRate, ">0", "Flow rate"], [Width, ">0", "Width"], ...
python
def headloss_exp_rect(FlowRate, Width, DistCenter, KMinor): """Return the minor head loss due to expansion in a rectangular channel. This equation applies to both laminar and turbulent flows. """ #Checking input validity ut.check_range([FlowRate, ">0", "Flow rate"], [Width, ">0", "Width"], ...
[ "def", "headloss_exp_rect", "(", "FlowRate", ",", "Width", ",", "DistCenter", ",", "KMinor", ")", ":", "#Checking input validity", "ut", ".", "check_range", "(", "[", "FlowRate", ",", "\">0\"", ",", "\"Flow rate\"", "]", ",", "[", "Width", ",", "\">0\"", ","...
Return the minor head loss due to expansion in a rectangular channel. This equation applies to both laminar and turbulent flows.
[ "Return", "the", "minor", "head", "loss", "due", "to", "expansion", "in", "a", "rectangular", "channel", "." ]
train
https://github.com/AguaClara/aguaclara/blob/8dd4e734768b166a7fc2b60388a24df2f93783fc/aguaclara/core/physchem.py#L276-L286
AguaClara/aguaclara
aguaclara/core/physchem.py
headloss_rect
def headloss_rect(FlowRate, Width, DistCenter, Length, KMinor, Nu, PipeRough, openchannel): """Return the total head loss in a rectangular channel. Total head loss is a combination of the major and minor losses. This equation applies to both laminar and turbulent flows. """ #Input...
python
def headloss_rect(FlowRate, Width, DistCenter, Length, KMinor, Nu, PipeRough, openchannel): """Return the total head loss in a rectangular channel. Total head loss is a combination of the major and minor losses. This equation applies to both laminar and turbulent flows. """ #Input...
[ "def", "headloss_rect", "(", "FlowRate", ",", "Width", ",", "DistCenter", ",", "Length", ",", "KMinor", ",", "Nu", ",", "PipeRough", ",", "openchannel", ")", ":", "#Inputs do not need to be checked here because they are checked by", "#functions this function calls.", "ret...
Return the total head loss in a rectangular channel. Total head loss is a combination of the major and minor losses. This equation applies to both laminar and turbulent flows.
[ "Return", "the", "total", "head", "loss", "in", "a", "rectangular", "channel", "." ]
train
https://github.com/AguaClara/aguaclara/blob/8dd4e734768b166a7fc2b60388a24df2f93783fc/aguaclara/core/physchem.py#L290-L301
AguaClara/aguaclara
aguaclara/core/physchem.py
headloss_fric_general
def headloss_fric_general(Area, PerimWetted, Vel, Length, Nu, PipeRough): """Return the major head loss due to wall shear in the general case. This equation applies to both laminar and turbulent flows. """ #Checking input validity - inputs not checked here are checked by #functions this function ca...
python
def headloss_fric_general(Area, PerimWetted, Vel, Length, Nu, PipeRough): """Return the major head loss due to wall shear in the general case. This equation applies to both laminar and turbulent flows. """ #Checking input validity - inputs not checked here are checked by #functions this function ca...
[ "def", "headloss_fric_general", "(", "Area", ",", "PerimWetted", ",", "Vel", ",", "Length", ",", "Nu", ",", "PipeRough", ")", ":", "#Checking input validity - inputs not checked here are checked by", "#functions this function calls.", "ut", ".", "check_range", "(", "[", ...
Return the major head loss due to wall shear in the general case. This equation applies to both laminar and turbulent flows.
[ "Return", "the", "major", "head", "loss", "due", "to", "wall", "shear", "in", "the", "general", "case", "." ]
train
https://github.com/AguaClara/aguaclara/blob/8dd4e734768b166a7fc2b60388a24df2f93783fc/aguaclara/core/physchem.py#L305-L316
AguaClara/aguaclara
aguaclara/core/physchem.py
headloss_exp_general
def headloss_exp_general(Vel, KMinor): """Return the minor head loss due to expansion in the general case. This equation applies to both laminar and turbulent flows. """ #Checking input validity ut.check_range([Vel, ">0", "Velocity"], [KMinor, '>=0', 'K minor']) return KMinor * Vel**2 / (2*grav...
python
def headloss_exp_general(Vel, KMinor): """Return the minor head loss due to expansion in the general case. This equation applies to both laminar and turbulent flows. """ #Checking input validity ut.check_range([Vel, ">0", "Velocity"], [KMinor, '>=0', 'K minor']) return KMinor * Vel**2 / (2*grav...
[ "def", "headloss_exp_general", "(", "Vel", ",", "KMinor", ")", ":", "#Checking input validity", "ut", ".", "check_range", "(", "[", "Vel", ",", "\">0\"", ",", "\"Velocity\"", "]", ",", "[", "KMinor", ",", "'>=0'", ",", "'K minor'", "]", ")", "return", "KMi...
Return the minor head loss due to expansion in the general case. This equation applies to both laminar and turbulent flows.
[ "Return", "the", "minor", "head", "loss", "due", "to", "expansion", "in", "the", "general", "case", "." ]
train
https://github.com/AguaClara/aguaclara/blob/8dd4e734768b166a7fc2b60388a24df2f93783fc/aguaclara/core/physchem.py#L320-L327
AguaClara/aguaclara
aguaclara/core/physchem.py
headloss_gen
def headloss_gen(Area, Vel, PerimWetted, Length, KMinor, Nu, PipeRough): """Return the total head lossin the general case. Total head loss is a combination of major and minor losses. This equation applies to both laminar and turbulent flows. """ #Inputs do not need to be checked here because they a...
python
def headloss_gen(Area, Vel, PerimWetted, Length, KMinor, Nu, PipeRough): """Return the total head lossin the general case. Total head loss is a combination of major and minor losses. This equation applies to both laminar and turbulent flows. """ #Inputs do not need to be checked here because they a...
[ "def", "headloss_gen", "(", "Area", ",", "Vel", ",", "PerimWetted", ",", "Length", ",", "KMinor", ",", "Nu", ",", "PipeRough", ")", ":", "#Inputs do not need to be checked here because they are checked by", "#functions this function calls.", "return", "(", "headloss_exp_g...
Return the total head lossin the general case. Total head loss is a combination of major and minor losses. This equation applies to both laminar and turbulent flows.
[ "Return", "the", "total", "head", "lossin", "the", "general", "case", "." ]
train
https://github.com/AguaClara/aguaclara/blob/8dd4e734768b166a7fc2b60388a24df2f93783fc/aguaclara/core/physchem.py#L331-L341
AguaClara/aguaclara
aguaclara/core/physchem.py
headloss_manifold
def headloss_manifold(FlowRate, Diam, Length, KMinor, Nu, PipeRough, NumOutlets): """Return the total head loss through the manifold.""" #Checking input validity - inputs not checked here are checked by #functions this function calls. ut.check_range([NumOutlets, ">0, int", 'Number of outlets']) retu...
python
def headloss_manifold(FlowRate, Diam, Length, KMinor, Nu, PipeRough, NumOutlets): """Return the total head loss through the manifold.""" #Checking input validity - inputs not checked here are checked by #functions this function calls. ut.check_range([NumOutlets, ">0, int", 'Number of outlets']) retu...
[ "def", "headloss_manifold", "(", "FlowRate", ",", "Diam", ",", "Length", ",", "KMinor", ",", "Nu", ",", "PipeRough", ",", "NumOutlets", ")", ":", "#Checking input validity - inputs not checked here are checked by", "#functions this function calls.", "ut", ".", "check_rang...
Return the total head loss through the manifold.
[ "Return", "the", "total", "head", "loss", "through", "the", "manifold", "." ]
train
https://github.com/AguaClara/aguaclara/blob/8dd4e734768b166a7fc2b60388a24df2f93783fc/aguaclara/core/physchem.py#L346-L356
AguaClara/aguaclara
aguaclara/core/physchem.py
flow_orifice
def flow_orifice(Diam, Height, RatioVCOrifice): """Return the flow rate of the orifice.""" #Checking input validity ut.check_range([Diam, ">0", "Diameter"], [RatioVCOrifice, "0-1", "VC orifice ratio"]) if Height > 0: return (RatioVCOrifice * area_circle(Diam).magnitude ...
python
def flow_orifice(Diam, Height, RatioVCOrifice): """Return the flow rate of the orifice.""" #Checking input validity ut.check_range([Diam, ">0", "Diameter"], [RatioVCOrifice, "0-1", "VC orifice ratio"]) if Height > 0: return (RatioVCOrifice * area_circle(Diam).magnitude ...
[ "def", "flow_orifice", "(", "Diam", ",", "Height", ",", "RatioVCOrifice", ")", ":", "#Checking input validity", "ut", ".", "check_range", "(", "[", "Diam", ",", "\">0\"", ",", "\"Diameter\"", "]", ",", "[", "RatioVCOrifice", ",", "\"0-1\"", ",", "\"VC orifice ...
Return the flow rate of the orifice.
[ "Return", "the", "flow", "rate", "of", "the", "orifice", "." ]
train
https://github.com/AguaClara/aguaclara/blob/8dd4e734768b166a7fc2b60388a24df2f93783fc/aguaclara/core/physchem.py#L361-L370
AguaClara/aguaclara
aguaclara/core/physchem.py
flow_orifice_vert
def flow_orifice_vert(Diam, Height, RatioVCOrifice): """Return the vertical flow rate of the orifice.""" #Checking input validity ut.check_range([RatioVCOrifice, "0-1", "VC orifice ratio"]) if Height > -Diam / 2: flow_vert = integrate.quad(lambda z: (Diam * np.sin(np.arccos(z/(Diam/2))) ...
python
def flow_orifice_vert(Diam, Height, RatioVCOrifice): """Return the vertical flow rate of the orifice.""" #Checking input validity ut.check_range([RatioVCOrifice, "0-1", "VC orifice ratio"]) if Height > -Diam / 2: flow_vert = integrate.quad(lambda z: (Diam * np.sin(np.arccos(z/(Diam/2))) ...
[ "def", "flow_orifice_vert", "(", "Diam", ",", "Height", ",", "RatioVCOrifice", ")", ":", "#Checking input validity", "ut", ".", "check_range", "(", "[", "RatioVCOrifice", ",", "\"0-1\"", ",", "\"VC orifice ratio\"", "]", ")", "if", "Height", ">", "-", "Diam", ...
Return the vertical flow rate of the orifice.
[ "Return", "the", "vertical", "flow", "rate", "of", "the", "orifice", "." ]
train
https://github.com/AguaClara/aguaclara/blob/8dd4e734768b166a7fc2b60388a24df2f93783fc/aguaclara/core/physchem.py#L376-L388
AguaClara/aguaclara
aguaclara/core/physchem.py
head_orifice
def head_orifice(Diam, RatioVCOrifice, FlowRate): """Return the head of the orifice.""" #Checking input validity ut.check_range([Diam, ">0", "Diameter"], [FlowRate, ">0", "Flow rate"], [RatioVCOrifice, "0-1", "VC orifice ratio"]) return ((FlowRate / (RatioVCOrifice * area...
python
def head_orifice(Diam, RatioVCOrifice, FlowRate): """Return the head of the orifice.""" #Checking input validity ut.check_range([Diam, ">0", "Diameter"], [FlowRate, ">0", "Flow rate"], [RatioVCOrifice, "0-1", "VC orifice ratio"]) return ((FlowRate / (RatioVCOrifice * area...
[ "def", "head_orifice", "(", "Diam", ",", "RatioVCOrifice", ",", "FlowRate", ")", ":", "#Checking input validity", "ut", ".", "check_range", "(", "[", "Diam", ",", "\">0\"", ",", "\"Diameter\"", "]", ",", "[", "FlowRate", ",", "\">0\"", ",", "\"Flow rate\"", ...
Return the head of the orifice.
[ "Return", "the", "head", "of", "the", "orifice", "." ]
train
https://github.com/AguaClara/aguaclara/blob/8dd4e734768b166a7fc2b60388a24df2f93783fc/aguaclara/core/physchem.py#L392-L401
AguaClara/aguaclara
aguaclara/core/physchem.py
area_orifice
def area_orifice(Height, RatioVCOrifice, FlowRate): """Return the area of the orifice.""" #Checking input validity ut.check_range([Height, ">0", "Height"], [FlowRate, ">0", "Flow rate"], [RatioVCOrifice, "0-1, >0", "VC orifice ratio"]) return FlowRate / (RatioVCOrifice * np.sqrt(2 * g...
python
def area_orifice(Height, RatioVCOrifice, FlowRate): """Return the area of the orifice.""" #Checking input validity ut.check_range([Height, ">0", "Height"], [FlowRate, ">0", "Flow rate"], [RatioVCOrifice, "0-1, >0", "VC orifice ratio"]) return FlowRate / (RatioVCOrifice * np.sqrt(2 * g...
[ "def", "area_orifice", "(", "Height", ",", "RatioVCOrifice", ",", "FlowRate", ")", ":", "#Checking input validity", "ut", ".", "check_range", "(", "[", "Height", ",", "\">0\"", ",", "\"Height\"", "]", ",", "[", "FlowRate", ",", "\">0\"", ",", "\"Flow rate\"", ...
Return the area of the orifice.
[ "Return", "the", "area", "of", "the", "orifice", "." ]
train
https://github.com/AguaClara/aguaclara/blob/8dd4e734768b166a7fc2b60388a24df2f93783fc/aguaclara/core/physchem.py#L405-L410
AguaClara/aguaclara
aguaclara/core/physchem.py
num_orifices
def num_orifices(FlowPlant, RatioVCOrifice, HeadLossOrifice, DiamOrifice): """Return the number of orifices.""" #Inputs do not need to be checked here because they are checked by #functions this function calls. return np.ceil(area_orifice(HeadLossOrifice, RatioVCOrifice, ...
python
def num_orifices(FlowPlant, RatioVCOrifice, HeadLossOrifice, DiamOrifice): """Return the number of orifices.""" #Inputs do not need to be checked here because they are checked by #functions this function calls. return np.ceil(area_orifice(HeadLossOrifice, RatioVCOrifice, ...
[ "def", "num_orifices", "(", "FlowPlant", ",", "RatioVCOrifice", ",", "HeadLossOrifice", ",", "DiamOrifice", ")", ":", "#Inputs do not need to be checked here because they are checked by", "#functions this function calls.", "return", "np", ".", "ceil", "(", "area_orifice", "("...
Return the number of orifices.
[ "Return", "the", "number", "of", "orifices", "." ]
train
https://github.com/AguaClara/aguaclara/blob/8dd4e734768b166a7fc2b60388a24df2f93783fc/aguaclara/core/physchem.py#L414-L420
AguaClara/aguaclara
aguaclara/core/physchem.py
flow_transition
def flow_transition(Diam, Nu): """Return the flow rate for the laminar/turbulent transition. This equation is used in some of the other equations for flow. """ #Checking input validity ut.check_range([Diam, ">0", "Diameter"], [Nu, ">0", "Nu"]) return np.pi * Diam * RE_TRANSITION_PIPE * Nu / 4
python
def flow_transition(Diam, Nu): """Return the flow rate for the laminar/turbulent transition. This equation is used in some of the other equations for flow. """ #Checking input validity ut.check_range([Diam, ">0", "Diameter"], [Nu, ">0", "Nu"]) return np.pi * Diam * RE_TRANSITION_PIPE * Nu / 4
[ "def", "flow_transition", "(", "Diam", ",", "Nu", ")", ":", "#Checking input validity", "ut", ".", "check_range", "(", "[", "Diam", ",", "\">0\"", ",", "\"Diameter\"", "]", ",", "[", "Nu", ",", "\">0\"", ",", "\"Nu\"", "]", ")", "return", "np", ".", "p...
Return the flow rate for the laminar/turbulent transition. This equation is used in some of the other equations for flow.
[ "Return", "the", "flow", "rate", "for", "the", "laminar", "/", "turbulent", "transition", "." ]
train
https://github.com/AguaClara/aguaclara/blob/8dd4e734768b166a7fc2b60388a24df2f93783fc/aguaclara/core/physchem.py#L425-L432
AguaClara/aguaclara
aguaclara/core/physchem.py
flow_hagen
def flow_hagen(Diam, HeadLossFric, Length, Nu): """Return the flow rate for laminar flow with only major losses.""" #Checking input validity ut.check_range([Diam, ">0", "Diameter"], [Length, ">0", "Length"], [HeadLossFric, ">=0", "Headloss due to friction"], [Nu, ">0", ...
python
def flow_hagen(Diam, HeadLossFric, Length, Nu): """Return the flow rate for laminar flow with only major losses.""" #Checking input validity ut.check_range([Diam, ">0", "Diameter"], [Length, ">0", "Length"], [HeadLossFric, ">=0", "Headloss due to friction"], [Nu, ">0", ...
[ "def", "flow_hagen", "(", "Diam", ",", "HeadLossFric", ",", "Length", ",", "Nu", ")", ":", "#Checking input validity", "ut", ".", "check_range", "(", "[", "Diam", ",", "\">0\"", ",", "\"Diameter\"", "]", ",", "[", "Length", ",", "\">0\"", ",", "\"Length\""...
Return the flow rate for laminar flow with only major losses.
[ "Return", "the", "flow", "rate", "for", "laminar", "flow", "with", "only", "major", "losses", "." ]
train
https://github.com/AguaClara/aguaclara/blob/8dd4e734768b166a7fc2b60388a24df2f93783fc/aguaclara/core/physchem.py#L436-L442
AguaClara/aguaclara
aguaclara/core/physchem.py
flow_swamee
def flow_swamee(Diam, HeadLossFric, Length, Nu, PipeRough): """Return the flow rate for turbulent flow with only major losses.""" #Checking input validity ut.check_range([Diam, ">0", "Diameter"], [Length, ">0", "Length"], [HeadLossFric, ">0", "Headloss due to friction"], ...
python
def flow_swamee(Diam, HeadLossFric, Length, Nu, PipeRough): """Return the flow rate for turbulent flow with only major losses.""" #Checking input validity ut.check_range([Diam, ">0", "Diameter"], [Length, ">0", "Length"], [HeadLossFric, ">0", "Headloss due to friction"], ...
[ "def", "flow_swamee", "(", "Diam", ",", "HeadLossFric", ",", "Length", ",", "Nu", ",", "PipeRough", ")", ":", "#Checking input validity", "ut", ".", "check_range", "(", "[", "Diam", ",", "\">0\"", ",", "\"Diameter\"", "]", ",", "[", "Length", ",", "\">0\""...
Return the flow rate for turbulent flow with only major losses.
[ "Return", "the", "flow", "rate", "for", "turbulent", "flow", "with", "only", "major", "losses", "." ]
train
https://github.com/AguaClara/aguaclara/blob/8dd4e734768b166a7fc2b60388a24df2f93783fc/aguaclara/core/physchem.py#L446-L460
AguaClara/aguaclara
aguaclara/core/physchem.py
flow_pipemajor
def flow_pipemajor(Diam, HeadLossFric, Length, Nu, PipeRough): """Return the flow rate with only major losses. This function applies to both laminar and turbulent flows. """ #Inputs do not need to be checked here because they are checked by #functions this function calls. FlowHagen = flow_hagen...
python
def flow_pipemajor(Diam, HeadLossFric, Length, Nu, PipeRough): """Return the flow rate with only major losses. This function applies to both laminar and turbulent flows. """ #Inputs do not need to be checked here because they are checked by #functions this function calls. FlowHagen = flow_hagen...
[ "def", "flow_pipemajor", "(", "Diam", ",", "HeadLossFric", ",", "Length", ",", "Nu", ",", "PipeRough", ")", ":", "#Inputs do not need to be checked here because they are checked by", "#functions this function calls.", "FlowHagen", "=", "flow_hagen", "(", "Diam", ",", "Hea...
Return the flow rate with only major losses. This function applies to both laminar and turbulent flows.
[ "Return", "the", "flow", "rate", "with", "only", "major", "losses", "." ]
train
https://github.com/AguaClara/aguaclara/blob/8dd4e734768b166a7fc2b60388a24df2f93783fc/aguaclara/core/physchem.py#L465-L476
AguaClara/aguaclara
aguaclara/core/physchem.py
flow_pipeminor
def flow_pipeminor(Diam, HeadLossExpans, KMinor): """Return the flow rate with only minor losses. This function applies to both laminar and turbulent flows. """ #Checking input validity - inputs not checked here are checked by #functions this function calls. ut.check_range([HeadLossExpans, ">=0...
python
def flow_pipeminor(Diam, HeadLossExpans, KMinor): """Return the flow rate with only minor losses. This function applies to both laminar and turbulent flows. """ #Checking input validity - inputs not checked here are checked by #functions this function calls. ut.check_range([HeadLossExpans, ">=0...
[ "def", "flow_pipeminor", "(", "Diam", ",", "HeadLossExpans", ",", "KMinor", ")", ":", "#Checking input validity - inputs not checked here are checked by", "#functions this function calls.", "ut", ".", "check_range", "(", "[", "HeadLossExpans", ",", "\">=0\"", ",", "\"Headlo...
Return the flow rate with only minor losses. This function applies to both laminar and turbulent flows.
[ "Return", "the", "flow", "rate", "with", "only", "minor", "losses", "." ]
train
https://github.com/AguaClara/aguaclara/blob/8dd4e734768b166a7fc2b60388a24df2f93783fc/aguaclara/core/physchem.py#L480-L492
AguaClara/aguaclara
aguaclara/core/physchem.py
flow_pipe
def flow_pipe(Diam, HeadLoss, Length, Nu, PipeRough, KMinor): """Return the the flow in a straight pipe. This function works for both major and minor losses and works whether the flow is laminar or turbulent. """ #Inputs do not need to be checked here because they are checked by #functions this...
python
def flow_pipe(Diam, HeadLoss, Length, Nu, PipeRough, KMinor): """Return the the flow in a straight pipe. This function works for both major and minor losses and works whether the flow is laminar or turbulent. """ #Inputs do not need to be checked here because they are checked by #functions this...
[ "def", "flow_pipe", "(", "Diam", ",", "HeadLoss", ",", "Length", ",", "Nu", ",", "PipeRough", ",", "KMinor", ")", ":", "#Inputs do not need to be checked here because they are checked by", "#functions this function calls.", "if", "KMinor", "==", "0", ":", "FlowRate", ...
Return the the flow in a straight pipe. This function works for both major and minor losses and works whether the flow is laminar or turbulent.
[ "Return", "the", "the", "flow", "in", "a", "straight", "pipe", "." ]
train
https://github.com/AguaClara/aguaclara/blob/8dd4e734768b166a7fc2b60388a24df2f93783fc/aguaclara/core/physchem.py#L499-L534
AguaClara/aguaclara
aguaclara/core/physchem.py
diam_swamee
def diam_swamee(FlowRate, HeadLossFric, Length, Nu, PipeRough): """Return the inner diameter of a pipe. The Swamee Jain equation is dimensionally correct and returns the inner diameter of a pipe given the flow rate and the head loss due to shear on the pipe walls. The Swamee Jain equation does NOT take...
python
def diam_swamee(FlowRate, HeadLossFric, Length, Nu, PipeRough): """Return the inner diameter of a pipe. The Swamee Jain equation is dimensionally correct and returns the inner diameter of a pipe given the flow rate and the head loss due to shear on the pipe walls. The Swamee Jain equation does NOT take...
[ "def", "diam_swamee", "(", "FlowRate", ",", "HeadLossFric", ",", "Length", ",", "Nu", ",", "PipeRough", ")", ":", "#Checking input validity", "ut", ".", "check_range", "(", "[", "FlowRate", ",", "\">0\"", ",", "\"Flow rate\"", "]", ",", "[", "Length", ",", ...
Return the inner diameter of a pipe. The Swamee Jain equation is dimensionally correct and returns the inner diameter of a pipe given the flow rate and the head loss due to shear on the pipe walls. The Swamee Jain equation does NOT take minor losses into account. This equation ONLY applies to turbulent...
[ "Return", "the", "inner", "diameter", "of", "a", "pipe", "." ]
train
https://github.com/AguaClara/aguaclara/blob/8dd4e734768b166a7fc2b60388a24df2f93783fc/aguaclara/core/physchem.py#L549-L570
AguaClara/aguaclara
aguaclara/core/physchem.py
diam_pipemajor
def diam_pipemajor(FlowRate, HeadLossFric, Length, Nu, PipeRough): """Return the pipe IDiam that would result in given major losses. This function applies to both laminar and turbulent flow. """ #Inputs do not need to be checked here because they are checked by #functions this function calls. Di...
python
def diam_pipemajor(FlowRate, HeadLossFric, Length, Nu, PipeRough): """Return the pipe IDiam that would result in given major losses. This function applies to both laminar and turbulent flow. """ #Inputs do not need to be checked here because they are checked by #functions this function calls. Di...
[ "def", "diam_pipemajor", "(", "FlowRate", ",", "HeadLossFric", ",", "Length", ",", "Nu", ",", "PipeRough", ")", ":", "#Inputs do not need to be checked here because they are checked by", "#functions this function calls.", "DiamLaminar", "=", "diam_hagen", "(", "FlowRate", "...
Return the pipe IDiam that would result in given major losses. This function applies to both laminar and turbulent flow.
[ "Return", "the", "pipe", "IDiam", "that", "would", "result", "in", "given", "major", "losses", ".", "This", "function", "applies", "to", "both", "laminar", "and", "turbulent", "flow", "." ]
train
https://github.com/AguaClara/aguaclara/blob/8dd4e734768b166a7fc2b60388a24df2f93783fc/aguaclara/core/physchem.py#L575-L586
AguaClara/aguaclara
aguaclara/core/physchem.py
diam_pipeminor
def diam_pipeminor(FlowRate, HeadLossExpans, KMinor): """Return the pipe ID that would result in the given minor losses. This function applies to both laminar and turbulent flow. """ #Checking input validity ut.check_range([FlowRate, ">0", "Flow rate"], [KMinor, ">=0", "K minor"], ...
python
def diam_pipeminor(FlowRate, HeadLossExpans, KMinor): """Return the pipe ID that would result in the given minor losses. This function applies to both laminar and turbulent flow. """ #Checking input validity ut.check_range([FlowRate, ">0", "Flow rate"], [KMinor, ">=0", "K minor"], ...
[ "def", "diam_pipeminor", "(", "FlowRate", ",", "HeadLossExpans", ",", "KMinor", ")", ":", "#Checking input validity", "ut", ".", "check_range", "(", "[", "FlowRate", ",", "\">0\"", ",", "\"Flow rate\"", "]", ",", "[", "KMinor", ",", "\">=0\"", ",", "\"K minor\...
Return the pipe ID that would result in the given minor losses. This function applies to both laminar and turbulent flow.
[ "Return", "the", "pipe", "ID", "that", "would", "result", "in", "the", "given", "minor", "losses", "." ]
train
https://github.com/AguaClara/aguaclara/blob/8dd4e734768b166a7fc2b60388a24df2f93783fc/aguaclara/core/physchem.py#L589-L599
AguaClara/aguaclara
aguaclara/core/physchem.py
diam_pipe
def diam_pipe(FlowRate, HeadLoss, Length, Nu, PipeRough, KMinor): """Return the pipe ID that would result in the given total head loss. This function applies to both laminar and turbulent flow and incorporates both minor and major losses. """ #Inputs do not need to be checked here because they are ...
python
def diam_pipe(FlowRate, HeadLoss, Length, Nu, PipeRough, KMinor): """Return the pipe ID that would result in the given total head loss. This function applies to both laminar and turbulent flow and incorporates both minor and major losses. """ #Inputs do not need to be checked here because they are ...
[ "def", "diam_pipe", "(", "FlowRate", ",", "HeadLoss", ",", "Length", ",", "Nu", ",", "PipeRough", ",", "KMinor", ")", ":", "#Inputs do not need to be checked here because they are checked by", "#functions this function calls.", "if", "KMinor", "==", "0", ":", "Diam", ...
Return the pipe ID that would result in the given total head loss. This function applies to both laminar and turbulent flow and incorporates both minor and major losses.
[ "Return", "the", "pipe", "ID", "that", "would", "result", "in", "the", "given", "total", "head", "loss", "." ]
train
https://github.com/AguaClara/aguaclara/blob/8dd4e734768b166a7fc2b60388a24df2f93783fc/aguaclara/core/physchem.py#L604-L636
AguaClara/aguaclara
aguaclara/core/physchem.py
width_rect_weir
def width_rect_weir(FlowRate, Height): """Return the width of a rectangular weir.""" #Checking input validity ut.check_range([FlowRate, ">0", "Flow rate"], [Height, ">0", "Height"]) return ((3 / 2) * FlowRate / (con.VC_ORIFICE_RATIO * np.sqrt(2 * gravity.magnitude) * Height ** (3 / 2)) ...
python
def width_rect_weir(FlowRate, Height): """Return the width of a rectangular weir.""" #Checking input validity ut.check_range([FlowRate, ">0", "Flow rate"], [Height, ">0", "Height"]) return ((3 / 2) * FlowRate / (con.VC_ORIFICE_RATIO * np.sqrt(2 * gravity.magnitude) * Height ** (3 / 2)) ...
[ "def", "width_rect_weir", "(", "FlowRate", ",", "Height", ")", ":", "#Checking input validity", "ut", ".", "check_range", "(", "[", "FlowRate", ",", "\">0\"", ",", "\"Flow rate\"", "]", ",", "[", "Height", ",", "\">0\"", ",", "\"Height\"", "]", ")", "return"...
Return the width of a rectangular weir.
[ "Return", "the", "width", "of", "a", "rectangular", "weir", "." ]
train
https://github.com/AguaClara/aguaclara/blob/8dd4e734768b166a7fc2b60388a24df2f93783fc/aguaclara/core/physchem.py#L640-L646
AguaClara/aguaclara
aguaclara/core/physchem.py
headloss_weir
def headloss_weir(FlowRate, Width): """Return the headloss of a weir.""" #Checking input validity ut.check_range([FlowRate, ">0", "Flow rate"], [Width, ">0", "Width"]) return (((3/2) * FlowRate / (con.VC_ORIFICE_RATIO * np.sqrt(2 * gravity.magnitude) * Width) ) ** (2/3))
python
def headloss_weir(FlowRate, Width): """Return the headloss of a weir.""" #Checking input validity ut.check_range([FlowRate, ">0", "Flow rate"], [Width, ">0", "Width"]) return (((3/2) * FlowRate / (con.VC_ORIFICE_RATIO * np.sqrt(2 * gravity.magnitude) * Width) ) ** (2/3))
[ "def", "headloss_weir", "(", "FlowRate", ",", "Width", ")", ":", "#Checking input validity", "ut", ".", "check_range", "(", "[", "FlowRate", ",", "\">0\"", ",", "\"Flow rate\"", "]", ",", "[", "Width", ",", "\">0\"", ",", "\"Width\"", "]", ")", "return", "...
Return the headloss of a weir.
[ "Return", "the", "headloss", "of", "a", "weir", "." ]
train
https://github.com/AguaClara/aguaclara/blob/8dd4e734768b166a7fc2b60388a24df2f93783fc/aguaclara/core/physchem.py#L653-L659
AguaClara/aguaclara
aguaclara/core/physchem.py
flow_rect_weir
def flow_rect_weir(Height, Width): """Return the flow of a rectangular weir.""" #Checking input validity ut.check_range([Height, ">0", "Height"], [Width, ">0", "Width"]) return ((2/3) * con.VC_ORIFICE_RATIO * (np.sqrt(2*gravity.magnitude) * Height**(3/2)) * Width)
python
def flow_rect_weir(Height, Width): """Return the flow of a rectangular weir.""" #Checking input validity ut.check_range([Height, ">0", "Height"], [Width, ">0", "Width"]) return ((2/3) * con.VC_ORIFICE_RATIO * (np.sqrt(2*gravity.magnitude) * Height**(3/2)) * Width)
[ "def", "flow_rect_weir", "(", "Height", ",", "Width", ")", ":", "#Checking input validity", "ut", ".", "check_range", "(", "[", "Height", ",", "\">0\"", ",", "\"Height\"", "]", ",", "[", "Width", ",", "\">0\"", ",", "\"Width\"", "]", ")", "return", "(", ...
Return the flow of a rectangular weir.
[ "Return", "the", "flow", "of", "a", "rectangular", "weir", "." ]
train
https://github.com/AguaClara/aguaclara/blob/8dd4e734768b166a7fc2b60388a24df2f93783fc/aguaclara/core/physchem.py#L663-L669
AguaClara/aguaclara
aguaclara/core/physchem.py
height_water_critical
def height_water_critical(FlowRate, Width): """Return the critical local water depth.""" #Checking input validity ut.check_range([FlowRate, ">0", "Flow rate"], [Width, ">0", "Width"]) return (FlowRate / (Width * np.sqrt(gravity.magnitude))) ** (2/3)
python
def height_water_critical(FlowRate, Width): """Return the critical local water depth.""" #Checking input validity ut.check_range([FlowRate, ">0", "Flow rate"], [Width, ">0", "Width"]) return (FlowRate / (Width * np.sqrt(gravity.magnitude))) ** (2/3)
[ "def", "height_water_critical", "(", "FlowRate", ",", "Width", ")", ":", "#Checking input validity", "ut", ".", "check_range", "(", "[", "FlowRate", ",", "\">0\"", ",", "\"Flow rate\"", "]", ",", "[", "Width", ",", "\">0\"", ",", "\"Width\"", "]", ")", "retu...
Return the critical local water depth.
[ "Return", "the", "critical", "local", "water", "depth", "." ]
train
https://github.com/AguaClara/aguaclara/blob/8dd4e734768b166a7fc2b60388a24df2f93783fc/aguaclara/core/physchem.py#L673-L677
AguaClara/aguaclara
aguaclara/core/physchem.py
vel_horizontal
def vel_horizontal(HeightWaterCritical): """Return the horizontal velocity.""" #Checking input validity ut.check_range([HeightWaterCritical, ">0", "Critical height of water"]) return np.sqrt(gravity.magnitude * HeightWaterCritical)
python
def vel_horizontal(HeightWaterCritical): """Return the horizontal velocity.""" #Checking input validity ut.check_range([HeightWaterCritical, ">0", "Critical height of water"]) return np.sqrt(gravity.magnitude * HeightWaterCritical)
[ "def", "vel_horizontal", "(", "HeightWaterCritical", ")", ":", "#Checking input validity", "ut", ".", "check_range", "(", "[", "HeightWaterCritical", ",", "\">0\"", ",", "\"Critical height of water\"", "]", ")", "return", "np", ".", "sqrt", "(", "gravity", ".", "m...
Return the horizontal velocity.
[ "Return", "the", "horizontal", "velocity", "." ]
train
https://github.com/AguaClara/aguaclara/blob/8dd4e734768b166a7fc2b60388a24df2f93783fc/aguaclara/core/physchem.py#L681-L685
AguaClara/aguaclara
aguaclara/core/physchem.py
headloss_kozeny
def headloss_kozeny(Length, Diam, Vel, Porosity, Nu): """Return the Carmen Kozeny Sand Bed head loss.""" #Checking input validity ut.check_range([Length, ">0", "Length"], [Diam, ">0", "Diam"], [Vel, ">0", "Velocity"], [Nu, ">0", "Nu"], [Porosity, "0-1", "Porosity"]) ...
python
def headloss_kozeny(Length, Diam, Vel, Porosity, Nu): """Return the Carmen Kozeny Sand Bed head loss.""" #Checking input validity ut.check_range([Length, ">0", "Length"], [Diam, ">0", "Diam"], [Vel, ">0", "Velocity"], [Nu, ">0", "Nu"], [Porosity, "0-1", "Porosity"]) ...
[ "def", "headloss_kozeny", "(", "Length", ",", "Diam", ",", "Vel", ",", "Porosity", ",", "Nu", ")", ":", "#Checking input validity", "ut", ".", "check_range", "(", "[", "Length", ",", "\">0\"", ",", "\"Length\"", "]", ",", "[", "Diam", ",", "\">0\"", ",",...
Return the Carmen Kozeny Sand Bed head loss.
[ "Return", "the", "Carmen", "Kozeny", "Sand", "Bed", "head", "loss", "." ]
train
https://github.com/AguaClara/aguaclara/blob/8dd4e734768b166a7fc2b60388a24df2f93783fc/aguaclara/core/physchem.py#L689-L698
AguaClara/aguaclara
aguaclara/research/peristaltic_pump.py
vol_per_rev_3_stop
def vol_per_rev_3_stop(color="", inner_diameter=0): """Return the volume per revolution of an Ismatec 6 roller pump given the inner diameter (ID) of 3-stop tubing. The calculation is interpolated from the table found at http://www.ismatec.com/int_e/pumps/t_mini_s_ms_ca/tubing_msca2.htm. Note: 1...
python
def vol_per_rev_3_stop(color="", inner_diameter=0): """Return the volume per revolution of an Ismatec 6 roller pump given the inner diameter (ID) of 3-stop tubing. The calculation is interpolated from the table found at http://www.ismatec.com/int_e/pumps/t_mini_s_ms_ca/tubing_msca2.htm. Note: 1...
[ "def", "vol_per_rev_3_stop", "(", "color", "=", "\"\"", ",", "inner_diameter", "=", "0", ")", ":", "if", "color", "!=", "\"\"", ":", "inner_diameter", "=", "ID_colored_tube", "(", "color", ")", "term1", "=", "(", "R_pump", "*", "2", "*", "np", ".", "pi...
Return the volume per revolution of an Ismatec 6 roller pump given the inner diameter (ID) of 3-stop tubing. The calculation is interpolated from the table found at http://www.ismatec.com/int_e/pumps/t_mini_s_ms_ca/tubing_msca2.htm. Note: 1. Either input a string as the tubing color code or a numbe...
[ "Return", "the", "volume", "per", "revolution", "of", "an", "Ismatec", "6", "roller", "pump", "given", "the", "inner", "diameter", "(", "ID", ")", "of", "3", "-", "stop", "tubing", ".", "The", "calculation", "is", "interpolated", "from", "the", "table", ...
train
https://github.com/AguaClara/aguaclara/blob/8dd4e734768b166a7fc2b60388a24df2f93783fc/aguaclara/research/peristaltic_pump.py#L14-L48
AguaClara/aguaclara
aguaclara/research/peristaltic_pump.py
ID_colored_tube
def ID_colored_tube(color): """Look up the inner diameter of Ismatec 3-stop tubing given its color code. :param color: Color of the 3-stop tubing :type color: string :returns: Inner diameter of the 3-stop tubing (mm) :rtype: float :Examples: >>> from aguaclara.research.peristaltic_pump i...
python
def ID_colored_tube(color): """Look up the inner diameter of Ismatec 3-stop tubing given its color code. :param color: Color of the 3-stop tubing :type color: string :returns: Inner diameter of the 3-stop tubing (mm) :rtype: float :Examples: >>> from aguaclara.research.peristaltic_pump i...
[ "def", "ID_colored_tube", "(", "color", ")", ":", "tubing_data_path", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "__file__", ")", ",", "\"data\"", ",", "\"3_stop_tubing.txt\"", ")", "df", "=", "pd", ".", "read_csv",...
Look up the inner diameter of Ismatec 3-stop tubing given its color code. :param color: Color of the 3-stop tubing :type color: string :returns: Inner diameter of the 3-stop tubing (mm) :rtype: float :Examples: >>> from aguaclara.research.peristaltic_pump import ID_colored_tube >>> from ...
[ "Look", "up", "the", "inner", "diameter", "of", "Ismatec", "3", "-", "stop", "tubing", "given", "its", "color", "code", "." ]
train
https://github.com/AguaClara/aguaclara/blob/8dd4e734768b166a7fc2b60388a24df2f93783fc/aguaclara/research/peristaltic_pump.py#L51-L75
AguaClara/aguaclara
aguaclara/research/peristaltic_pump.py
vol_per_rev_LS
def vol_per_rev_LS(id_number): """Look up the volume per revolution output by a Masterflex L/S pump through L/S tubing of the given ID number. :param id_number: Identification number of the L/S tubing. Valid numbers are 13-18, 24, 35, and 36. :type id_number: int :return: Volume per revolution out...
python
def vol_per_rev_LS(id_number): """Look up the volume per revolution output by a Masterflex L/S pump through L/S tubing of the given ID number. :param id_number: Identification number of the L/S tubing. Valid numbers are 13-18, 24, 35, and 36. :type id_number: int :return: Volume per revolution out...
[ "def", "vol_per_rev_LS", "(", "id_number", ")", ":", "tubing_data_path", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "__file__", ")", ",", "\"data\"", ",", "\"LS_tubing.txt\"", ")", "df", "=", "pd", ".", "read_csv", ...
Look up the volume per revolution output by a Masterflex L/S pump through L/S tubing of the given ID number. :param id_number: Identification number of the L/S tubing. Valid numbers are 13-18, 24, 35, and 36. :type id_number: int :return: Volume per revolution output by a Masterflex L/S pump through t...
[ "Look", "up", "the", "volume", "per", "revolution", "output", "by", "a", "Masterflex", "L", "/", "S", "pump", "through", "L", "/", "S", "tubing", "of", "the", "given", "ID", "number", "." ]
train
https://github.com/AguaClara/aguaclara/blob/8dd4e734768b166a7fc2b60388a24df2f93783fc/aguaclara/research/peristaltic_pump.py#L78-L101
AguaClara/aguaclara
aguaclara/research/peristaltic_pump.py
flow_rate
def flow_rate(vol_per_rev, rpm): """Return the flow rate from a pump given the volume of fluid pumped per revolution and the desired pump speed. :param vol_per_rev: Volume of fluid output per revolution (dependent on pump and tubing) :type vol_per_rev: float :param rpm: Desired pump speed in revolu...
python
def flow_rate(vol_per_rev, rpm): """Return the flow rate from a pump given the volume of fluid pumped per revolution and the desired pump speed. :param vol_per_rev: Volume of fluid output per revolution (dependent on pump and tubing) :type vol_per_rev: float :param rpm: Desired pump speed in revolu...
[ "def", "flow_rate", "(", "vol_per_rev", ",", "rpm", ")", ":", "return", "(", "vol_per_rev", "*", "rpm", ")", ".", "to", "(", "u", ".", "mL", "/", "u", ".", "s", ")" ]
Return the flow rate from a pump given the volume of fluid pumped per revolution and the desired pump speed. :param vol_per_rev: Volume of fluid output per revolution (dependent on pump and tubing) :type vol_per_rev: float :param rpm: Desired pump speed in revolutions per minute :type rpm: float ...
[ "Return", "the", "flow", "rate", "from", "a", "pump", "given", "the", "volume", "of", "fluid", "pumped", "per", "revolution", "and", "the", "desired", "pump", "speed", "." ]
train
https://github.com/AguaClara/aguaclara/blob/8dd4e734768b166a7fc2b60388a24df2f93783fc/aguaclara/research/peristaltic_pump.py#L104-L123
AguaClara/aguaclara
aguaclara/core/head_loss.py
k_value_expansion
def k_value_expansion(ent_pipe_id, exit_pipe_id, q, fitting_angle=180, rounded=False, nu=con.WATER_NU, pipe_rough=mats.PVC_PIPE_ROUGH): """Calculates the minor loss coefficient (k-value) of a square, tapered, or rounded expansion in a pipe. Defaults to square. To...
python
def k_value_expansion(ent_pipe_id, exit_pipe_id, q, fitting_angle=180, rounded=False, nu=con.WATER_NU, pipe_rough=mats.PVC_PIPE_ROUGH): """Calculates the minor loss coefficient (k-value) of a square, tapered, or rounded expansion in a pipe. Defaults to square. To...
[ "def", "k_value_expansion", "(", "ent_pipe_id", ",", "exit_pipe_id", ",", "q", ",", "fitting_angle", "=", "180", ",", "rounded", "=", "False", ",", "nu", "=", "con", ".", "WATER_NU", ",", "pipe_rough", "=", "mats", ".", "PVC_PIPE_ROUGH", ")", ":", "if", ...
Calculates the minor loss coefficient (k-value) of a square, tapered, or rounded expansion in a pipe. Defaults to square. To use tapered, set angle to something that isn't 180. To use rounded, set rounded to True. Parameters: ent_pipe_id: Entrance pipe's inner diameter from which fluid flows....
[ "Calculates", "the", "minor", "loss", "coefficient", "(", "k", "-", "value", ")", "of", "a", "square", "tapered", "or", "rounded", "expansion", "in", "a", "pipe", ".", "Defaults", "to", "square", "." ]
train
https://github.com/AguaClara/aguaclara/blob/8dd4e734768b166a7fc2b60388a24df2f93783fc/aguaclara/core/head_loss.py#L21-L67
AguaClara/aguaclara
aguaclara/core/head_loss.py
k_value_reduction
def k_value_reduction(ent_pipe_id, exit_pipe_id, q, fitting_angle=180, rounded=False, nu=con.WATER_NU, pipe_rough=mats.PVC_PIPE_ROUGH): """Calculates the minor loss coefficient (k-value) of a square, tapered, or rounded reduction in a pipe. Defaults to square. To...
python
def k_value_reduction(ent_pipe_id, exit_pipe_id, q, fitting_angle=180, rounded=False, nu=con.WATER_NU, pipe_rough=mats.PVC_PIPE_ROUGH): """Calculates the minor loss coefficient (k-value) of a square, tapered, or rounded reduction in a pipe. Defaults to square. To...
[ "def", "k_value_reduction", "(", "ent_pipe_id", ",", "exit_pipe_id", ",", "q", ",", "fitting_angle", "=", "180", ",", "rounded", "=", "False", ",", "nu", "=", "con", ".", "WATER_NU", ",", "pipe_rough", "=", "mats", ".", "PVC_PIPE_ROUGH", ")", ":", "if", ...
Calculates the minor loss coefficient (k-value) of a square, tapered, or rounded reduction in a pipe. Defaults to square. To use tapered, set angle to something that isn't 180. To use rounded, set rounded to True. Parameters: ent_pipe_id: Entrance pipe's inner diameter from which fluid flows....
[ "Calculates", "the", "minor", "loss", "coefficient", "(", "k", "-", "value", ")", "of", "a", "square", "tapered", "or", "rounded", "reduction", "in", "a", "pipe", ".", "Defaults", "to", "square", "." ]
train
https://github.com/AguaClara/aguaclara/blob/8dd4e734768b166a7fc2b60388a24df2f93783fc/aguaclara/core/head_loss.py#L72-L118
AguaClara/aguaclara
aguaclara/core/head_loss.py
k_value_orifice
def k_value_orifice(pipe_id, orifice_id, orifice_l, q, nu=con.WATER_NU): """Calculates the minor loss coefficient of an orifice plate in a pipe. Parameters: pipe_id: Entrance pipe's inner diameter from which fluid flows. orifice_id: Orifice's inner diameter. orif...
python
def k_value_orifice(pipe_id, orifice_id, orifice_l, q, nu=con.WATER_NU): """Calculates the minor loss coefficient of an orifice plate in a pipe. Parameters: pipe_id: Entrance pipe's inner diameter from which fluid flows. orifice_id: Orifice's inner diameter. orif...
[ "def", "k_value_orifice", "(", "pipe_id", ",", "orifice_id", ",", "orifice_l", ",", "q", ",", "nu", "=", "con", ".", "WATER_NU", ")", ":", "if", "orifice_id", ">", "pipe_id", ":", "raise", "ValueError", "(", "'The orifice\\'s inner diameter cannot be larger than'"...
Calculates the minor loss coefficient of an orifice plate in a pipe. Parameters: pipe_id: Entrance pipe's inner diameter from which fluid flows. orifice_id: Orifice's inner diameter. orifice_l: Orifice's length from start to end. q: Fluid's q rate. nu: Fluid's dynamic v...
[ "Calculates", "the", "minor", "loss", "coefficient", "of", "an", "orifice", "plate", "in", "a", "pipe", "." ]
train
https://github.com/AguaClara/aguaclara/blob/8dd4e734768b166a7fc2b60388a24df2f93783fc/aguaclara/core/head_loss.py#L123-L155