JUDI File¶
A JUDI File is associated with a parameter database and actually represents a collection of physical files, each corresponding to a row in the parameter database.
-
class
judi.
File
(name, param=None, mask=None, path=None, root='./judi_files')[source]¶ A file in JUDI is an object of class File and is instantiated by calling the following constructor
-
__init__
(name, param=None, mask=None, path=None, root='./judi_files')[source]¶ Create a JUDI file instance.
- Args:
- name (str): Name of the JUDI file to be created.
- Kwargs:
param (ParamDb): Parameter database associated with the JUDI file. If param is empty, the golbal parameter database is taken to be associated with the file.
mask (list of str): The list of parameters that are to be masked from the parameter database.
path: Specification of the physical path of the files associated with the JUDI file that is used to generate a column ‘path’ in the parameter database of the JUDI file. It can be of the following types: 1) callable: a user provider path generator that is passed to pandas apply function, 2) string or list of strings: actual path(s) to the physical files, and 3) None: JUDI automatically generates a path for each row.
root (str): Top level directory where the physical files associated with the JUDI file are created.
-
Some examples¶
The following code snippet creates a global parameter database with two parameters W and X and then creates a file with a parameter database that masks parameter W in the global parameter database.
>>> from judi import add_param, show_param_db, File
>>> add_param("1 2".split(), 'W')
0
>>> add_param("a b c".split(), 'X')
0
>>> show_param_db()
Global param db:
W X
0 1 a
1 1 b
2 1 c
3 2 a
4 2 b
5 2 c
>>> f = File('test', mask = ['W'])
Creating new directory ./judi_files/X~a
Creating new directory ./judi_files/X~b
Creating new directory ./judi_files/X~c
>>> show_param_db(f.param)
Param db:
X name path
0 a test ./judi_files/X~a/test
1 b test ./judi_files/X~b/test
2 c test ./judi_files/X~c/test