Class: Chemicalml::Convention::Compchem::Constraints::MatrixRules
- Inherits:
-
Chemicalml::Convention::Constraint::NodeConstraint
- Object
- Constraint
- Chemicalml::Convention::Constraint::NodeConstraint
- Chemicalml::Convention::Compchem::Constraints::MatrixRules
- Includes:
- ModulePredicates
- Defined in:
- lib/chemicalml/convention/compchem/constraints/matrix_rules.rb
Overview
CompChem matrix value-container rules: MUST have rows
and columns attributes (each ≥ 1); dataType MUST be
integer or double; MUST have units.
Constant Summary collapse
- ALLOWED_TYPES =
%w[xsd:integer xsd:double].freeze
Instance Method Summary collapse
Methods included from ModulePredicates
#calculation_module?, #child_modules_with, #cml_module?, #compchem_root?, #environment_module?, #finalization_module?, #initialization_module?, #job_list_module?, #job_module?
Methods inherited from Chemicalml::Convention::Constraint::NodeConstraint
Instance Method Details
#check_node(node, path) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/chemicalml/convention/compchem/constraints/matrix_rules.rb', line 16 def check_node(node, path) violations = [] if node.rows.to_s.empty? || node.rows.to_i < 1 violations << violation(path: path.join('/'), message: 'matrix must have a rows attribute (minimum 1)') end if node.columns.to_s.empty? || node.columns.to_i < 1 violations << violation(path: path.join('/'), message: 'matrix must have a columns attribute (minimum 1)') end unless ALLOWED_TYPES.include?(node.data_type.to_s) violations << violation(path: path.join('/'), message: 'matrix dataType must be xsd:integer or xsd:double ' \ "(got #{node.data_type.inspect})") end if node.units.to_s.empty? violations << violation(path: path.join('/'), message: 'matrix must have units (even if dimensionless)') end violations end |