cis_interface.metaschema.properties package¶
Subpackages¶
- cis_interface.metaschema.properties.tests package
- Submodules
- cis_interface.metaschema.properties.tests.test_ArrayMetaschemaProperties module
- cis_interface.metaschema.properties.tests.test_JSONArrayMetaschemaProperties module
- cis_interface.metaschema.properties.tests.test_JSONObjectMetaschemaProperties module
- cis_interface.metaschema.properties.tests.test_MetaschemaProperty module
- cis_interface.metaschema.properties.tests.test_ScalarMetaschemaProperties module
- cis_interface.metaschema.properties.tests.test_TypeMetaschemaProperty module
- Module contents
Submodules¶
cis_interface.metaschema.properties.ArrayMetaschemaProperties module¶
-
class
cis_interface.metaschema.properties.ArrayMetaschemaProperties.
LengthMetaschemaProperty
[source]¶ Bases:
cis_interface.metaschema.properties.MetaschemaProperty.MetaschemaProperty
Property class for ‘length’ property.
-
name
= 'length'¶
-
python_types
= (<class 'unyt.array.unyt_array'>, <class 'numpy.ndarray'>)¶
-
schema
= {'description': 'Number of elements in the 1D array.', 'minimum': 1, 'type': 'number'}¶
-
types
= ('1darray',)¶
-
-
class
cis_interface.metaschema.properties.ArrayMetaschemaProperties.
ShapeMetaschemaProperty
[source]¶ Bases:
cis_interface.metaschema.properties.MetaschemaProperty.MetaschemaProperty
Property class for ‘shape’ property.
-
classmethod
compare
(prop1, prop2, root1=None, root2=None)[source]¶ Comparison method for the ‘shape’ ndarray property.
-
name
= 'shape'¶
-
python_types
= (<class 'unyt.array.unyt_array'>, <class 'numpy.ndarray'>)¶
-
schema
= {'description': 'Shape of the ND array in each dimension.', 'items': {'minimum': 1, 'type': 'integer'}, 'type': 'array'}¶
-
types
= ('ndarray',)¶
-
classmethod
cis_interface.metaschema.properties.DefaultProperty module¶
-
class
cis_interface.metaschema.properties.DefaultProperty.
DefaultMetaschemaProperty
[source]¶ Bases:
cis_interface.metaschema.properties.MetaschemaProperty.MetaschemaProperty
Property class for ‘default’ property.
-
name
= 'default'¶
-
cis_interface.metaschema.properties.JSONArrayMetaschemaProperties module¶
-
class
cis_interface.metaschema.properties.JSONArrayMetaschemaProperties.
ItemsMetaschemaProperty
[source]¶ Bases:
cis_interface.metaschema.properties.MetaschemaProperty.MetaschemaProperty
Property class for ‘items’ property.
-
classmethod
compare
(prop1, prop2, root1=None, root2=None)[source]¶ Comparison method for ‘items’ container property.
-
name
= 'items'¶
-
python_types
= (<class 'pandas.core.frame.DataFrame'>, <class 'tuple'>, <class 'list'>, <class 'numpy.ndarray'>)¶
-
types
= ('array',)¶
-
classmethod
cis_interface.metaschema.properties.JSONObjectMetaschemaProperties module¶
-
class
cis_interface.metaschema.properties.JSONObjectMetaschemaProperties.
PropertiesMetaschemaProperty
[source]¶ Bases:
cis_interface.metaschema.properties.MetaschemaProperty.MetaschemaProperty
Property class for ‘properties’ property.
-
classmethod
compare
(prop1, prop2, root1=None, root2=None)[source]¶ Comparison method for ‘properties’ container property.
-
classmethod
encode
(instance, typedef=None)[source]¶ Encoder for the ‘properties’ container property.
-
name
= 'properties'¶
-
classmethod
normalize
(validator, value, instance, schema)[source]¶ Normalization method for ‘properties’ container property.
-
classmethod
post_validate
(validator, value, instance, schema)[source]¶ Actions performed after validation if normalizing.
-
python_types
= (<class 'dict'>,)¶
-
types
= ('object',)¶
-
classmethod
cis_interface.metaschema.properties.MetaschemaProperty module¶
-
class
cis_interface.metaschema.properties.MetaschemaProperty.
MetaschemaProperty
[source]¶ Bases:
object
Base class for adding properties to the metaschema.
-
classmethod
compare
(prop1, prop2, root1=None, root2=None)[source]¶ Method to determine compatiblity of one property value with another. This method is not necessarily symmetric in that the second value may not be compatible with the first even if the first is compatible with the second.
Parameters: Yields: str – Comparision failure messages.
-
classmethod
encode
(instance, typedef=None)[source]¶ Method to encode the property given the object.
Parameters: Returns: Encoded property for instance.
Return type:
-
name
= 'base'
-
classmethod
normalize
(validator, value, instance, schema)[source]¶ Method to normalize the instance based on the property value.
Parameters: Returns: Normalized object.
Return type:
-
classmethod
normalize_in_schema
(schema)[source]¶ Method to normalize the entry for this property in a schema.
Parameters: schema (dict) – Schema to normalize. Returns: Normalized schema. Return type: dict
-
classmethod
post_validate
(validator, value, instance, schema)[source]¶ Actions performed after validation if normalizing.
-
python_types
= ()
-
schema
= None
-
types
= ()
-
classmethod
validate
(validator, value, instance, schema)[source]¶ Validator for JSON schema validation of an instance by this property. If there is not a user provided validate function, the instance will be encoded and then the encoded value will be checked against the provided value using cls.compare.
Parameters: Yields: str – Error messages associated with failed validation.
-
classmethod
wrapped_validate
(validator, value, instance, schema)[source]¶ Wrapped validator that handles errors produced by the native validate method and ensures that the property is parsed by the base validator and raises the correct error if necessary.
Parameters: - *args – All arguments are passed to the validate class method.
- **kwargs – All keyword arguments are passed to the validate class method.
-
classmethod
-
cis_interface.metaschema.properties.MetaschemaProperty.
create_property
(name, schema, encode, validate=None, compare=None)[source]¶ Create a new property class.
Parameters: - name (str) – Name of the property.
- schema (dict) – JSON schema describing valid values for the property.
- encode (function) – Function to encode the property based on a provided instance. The function must take an instance as input and return the value of the property for that instance.
- validate (function, optional) – Function to determine if an instance is valid under the contraint of this property. The function must take as input a jsonschema validator, a property value, an instance to evaluate, and the schema. The function must return a boolean: True if the instance is valid, False otherwise. See cls.validate for additional information and default behavior.
- compare (function, optional) – Function to determine if two property values are compatible. The function must take as input two property values and return a boolean: True if the first property is compatible with the second, False otherwise. See cls.compare for additional information and default behavior.
cis_interface.metaschema.properties.ScalarMetaschemaProperties module¶
-
class
cis_interface.metaschema.properties.ScalarMetaschemaProperties.
PrecisionMetaschemaProperty
[source]¶ Bases:
cis_interface.metaschema.properties.MetaschemaProperty.MetaschemaProperty
Property class for ‘precision’ property.
-
classmethod
compare
(prop1, prop2, root1=None, root2=None)[source]¶ Comparison for the ‘precision’ scalar property.
-
name
= 'precision'¶
-
classmethod
normalize_in_schema
(schema)[source]¶ Normalization for the ‘precision’ scalar property in a schema.
-
python_types
= (<class 'numpy.complex128'>, <class 'numpy.float64'>, <class 'numpy.uint32'>, <class 'numpy.int32'>, <class 'numpy.bytes_'>, <class 'numpy.signedinteger'>, <class 'numpy.complex256'>, <class 'numpy.float128'>, <class 'numpy.uint64'>, <class 'unyt.array.unyt_array'>, <class 'numpy.int64'>, <class 'bytes'>, <class 'str'>, <class 'numpy.str_'>, <class 'float'>, <class 'numpy.unsignedinteger'>, <class 'int'>, <class 'numpy.float16'>, <class 'numpy.uint8'>, <class 'numpy.int8'>, <class 'unyt.array.unyt_quantity'>, <class 'numpy.ndarray'>, <class 'numpy.complex64'>, <class 'numpy.float32'>, <class 'complex'>, <class 'numpy.uint16'>, <class 'numpy.int16'>)¶
-
schema
= {'description': 'The size (in bits) of each item.', 'minimum': 1, 'type': 'number'}¶
-
types
= ('scalar', 'ndarray', 'unicode', 'float', 'bytes', '1darray', 'uint', 'int', 'complex')¶
-
classmethod
-
class
cis_interface.metaschema.properties.ScalarMetaschemaProperties.
SubtypeMetaschemaProperty
[source]¶ Bases:
cis_interface.metaschema.properties.MetaschemaProperty.MetaschemaProperty
Property class for ‘subtype’ property.
-
name
= 'subtype'¶
-
classmethod
normalize_in_schema
(schema)[source]¶ Normalization for the ‘subtype’ scalar property in a schema.
-
python_types
= (<class 'numpy.complex128'>, <class 'numpy.float64'>, <class 'numpy.uint32'>, <class 'numpy.int32'>, <class 'numpy.bytes_'>, <class 'numpy.signedinteger'>, <class 'numpy.complex256'>, <class 'numpy.float128'>, <class 'numpy.uint64'>, <class 'unyt.array.unyt_array'>, <class 'numpy.int64'>, <class 'bytes'>, <class 'str'>, <class 'numpy.str_'>, <class 'float'>, <class 'numpy.unsignedinteger'>, <class 'int'>, <class 'numpy.float16'>, <class 'numpy.uint8'>, <class 'numpy.int8'>, <class 'unyt.array.unyt_quantity'>, <class 'numpy.ndarray'>, <class 'numpy.complex64'>, <class 'numpy.float32'>, <class 'complex'>, <class 'numpy.uint16'>, <class 'numpy.int16'>)¶
-
schema
= {'description': 'The base type for each item.', 'enum': ['bytes', 'complex', 'float', 'int', 'uint', 'unicode'], 'type': 'string'}¶
-
types
= ('scalar', 'ndarray', '1darray')¶
-
-
class
cis_interface.metaschema.properties.ScalarMetaschemaProperties.
UnitsMetaschemaProperty
[source]¶ Bases:
cis_interface.metaschema.properties.MetaschemaProperty.MetaschemaProperty
Property class for ‘units’ property.
-
classmethod
compare
(prop1, prop2, root1=None, root2=None)[source]¶ Comparision for the ‘units’ scalar property.
-
name
= 'units'¶
-
python_types
= (<class 'numpy.complex128'>, <class 'numpy.float64'>, <class 'numpy.uint32'>, <class 'numpy.int32'>, <class 'numpy.bytes_'>, <class 'numpy.signedinteger'>, <class 'numpy.complex256'>, <class 'numpy.float128'>, <class 'numpy.uint64'>, <class 'unyt.array.unyt_array'>, <class 'numpy.int64'>, <class 'bytes'>, <class 'str'>, <class 'numpy.str_'>, <class 'float'>, <class 'numpy.unsignedinteger'>, <class 'int'>, <class 'numpy.float16'>, <class 'numpy.uint8'>, <class 'numpy.int8'>, <class 'unyt.array.unyt_quantity'>, <class 'numpy.ndarray'>, <class 'numpy.complex64'>, <class 'numpy.float32'>, <class 'complex'>, <class 'numpy.uint16'>, <class 'numpy.int16'>)¶
-
schema
= {'description': 'Physical units.', 'type': 'string'}¶
-
types
= ('scalar', 'ndarray', 'unicode', 'float', 'bytes', '1darray', 'uint', 'int', 'complex')¶
-
classmethod
cis_interface.metaschema.properties.TitleMetaschemaProperty module¶
-
class
cis_interface.metaschema.properties.TitleMetaschemaProperty.
TitleMetaschemaProperty
[source]¶ Bases:
cis_interface.metaschema.properties.MetaschemaProperty.MetaschemaProperty
Title property with validation of new properties.
-
name
= 'title'¶
-
python_types
= (<class 'pandas.core.frame.DataFrame'>, <class 'numpy.complex128'>, <class 'numpy.float64'>, <class 'numpy.uint32'>, <class 'numpy.int32'>, <class 'numpy.bytes_'>, <class 'numpy.signedinteger'>, <class 'numpy.complex256'>, <class 'numpy.float128'>, <class 'numpy.uint64'>, <class 'unyt.array.unyt_array'>, <class 'numpy.int64'>, <class 'bytes'>, <class 'str'>, <class 'numpy.str_'>, <class 'float'>, <class 'numpy.unsignedinteger'>, <class 'method'>, <class 'builtin_function_or_method'>, <class 'function'>, <class 'dict'>, <class 'int'>, <class 'numpy.float16'>, <class 'numpy.uint8'>, <class 'tuple'>, <class 'numpy.int8'>, <class 'numpy.ndarray'>, <class 'unyt.array.unyt_quantity'>, <class 'numbers.Number'>, <class 'numpy.complex64'>, <class 'numpy.float32'>, <class 'complex'>, <class 'numpy.uint16'>, <class 'numpy.int16'>, <class 'list'>, <class 'NoneType'>, <class 'bool'>)¶
-
types
= ('scalar', 'ndarray', 'unicode', 'boolean', 'float', 'bytes', 'null', 'number', '1darray', 'string', 'uint', 'int', 'function', 'object', 'complex', 'array', 'integer')¶
-
cis_interface.metaschema.properties.TypeMetaschemaProperty module¶
-
class
cis_interface.metaschema.properties.TypeMetaschemaProperty.
TypeMetaschemaProperty
[source]¶ Bases:
cis_interface.metaschema.properties.MetaschemaProperty.MetaschemaProperty
Type property with validation of new properties.
-
classmethod
compare
(prop1, prop2, root1=None, root2=None)[source]¶ Method to determine compatiblity of one property value with another. This method is not necessarily symmetric in that the second value may not be compatible with the first even if the first is compatible with the second.
Parameters: Yields: str – Comparision failure messages.
-
classmethod
encode
(instance, typedef=None)[source]¶ Method to encode the property given the object.
Parameters: Returns: Encoded property for instance.
Return type:
-
name
= 'type'¶
-
classmethod
normalize
(normalizer, value, instance, schema)[source]¶ Method to normalize the instance based on the property value.
Parameters: Returns: Normalized object.
Return type:
-
python_types
= (<class 'pandas.core.frame.DataFrame'>, <class 'numpy.complex128'>, <class 'numpy.float64'>, <class 'numpy.uint32'>, <class 'numpy.int32'>, <class 'numpy.bytes_'>, <class 'numpy.signedinteger'>, <class 'cis_interface.metaschema.datatypes.ObjMetaschemaType.ObjDict'>, <class 'numpy.complex256'>, <class 'numpy.float128'>, <class 'numpy.uint64'>, <class 'unyt.array.unyt_array'>, <class 'numpy.int64'>, <class 'bytes'>, <class 'str'>, <class 'numpy.str_'>, <class 'float'>, <class 'numpy.unsignedinteger'>, <class 'cis_interface.metaschema.datatypes.PlyMetaschemaType.PlyDict'>, <class 'method'>, <class 'builtin_function_or_method'>, <class 'function'>, <class 'dict'>, <class 'int'>, <class 'numpy.float16'>, <class 'numpy.uint8'>, <class 'tuple'>, <class 'numpy.int8'>, <class 'numpy.ndarray'>, <class 'unyt.array.unyt_quantity'>, <class 'numbers.Number'>, <class 'numpy.complex64'>, <class 'numpy.float32'>, <class 'complex'>, <class 'numpy.uint16'>, <class 'numpy.int16'>, <class 'list'>, <class 'NoneType'>, <class 'bool'>)¶
-
types
= ('scalar', 'ndarray', 'unicode', 'boolean', 'float', 'bytes', 'schema', 'number', '1darray', 'ply', 'string', 'obj', 'uint', 'int', 'array', 'function', 'object', 'complex', 'null', 'integer')¶
-
classmethod
Module contents¶
-
cis_interface.metaschema.properties.
get_metaschema_property
(property_name, skip_generic=False)[source]¶ Get the property class associated with a metaschema property.
Parameters: Returns: Associated property class.
Return type:
-
cis_interface.metaschema.properties.
get_registered_properties
()[source]¶ Return a dictionary of registered properties.
Returns: Registered property/class pairs. Return type: dict
-
cis_interface.metaschema.properties.
import_all_properties
()[source]¶ Import all types to ensure they are registered.
-
cis_interface.metaschema.properties.
register_metaschema_property
(prop_class)[source]¶ Register a schema property.
Parameters: prop_class (class) – Class to be registered.
Raises: ValueError
– If a property class has already been registered under the same name.ValueError
– If the base validator already has a validator function for the property and the new property class has a schema defined.ValueError
– If the base validator already has a validator function for the property and the validate method on the new property class is not disabled.ValueError
– If the property class does not have an entry in the existing metaschema.