Skip to content

Commit

Permalink
Removed som prints and corrected errors detected by docs workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
francescalb committed Feb 9, 2023
1 parent e2a7665 commit 5246dc0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
4 changes: 0 additions & 4 deletions dlite_cuds/utils/cuds2dlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,19 @@ def cuds2dlite(
if list_prop is None:
list_prop = list_prop_0
list_prop_uri = get_object_props_uri(graph, obj, cuds_relations)
print("list_prop_uri", list_prop_uri)
else:
# compare the two lists
if list_prop != list_prop_0:
raise DLiteCUDSError(
f"Error: the list of properties is not the same: {list_prop_0}"
)
print("list_prop_uri", list_prop_uri)
# Fetch the unit and values
# That the CUDS is consitent and that all similar properties have the
# same unit and type is assumed
list_prop_data = {}
for prop_uri in list_prop_uri:
prop = get_value_prop(graph, prop_uri)
dict_0 = {}
print("prop", prop)
for key in prop: # pylint: disable=consider-using-dict-items
if key != "concept":
dict_0[key] = prop[key]
Expand Down Expand Up @@ -85,7 +82,6 @@ def cuds2dlite(
datamodel = DataModel(uri=uri, description=description)
if list_prop:
for prop in set(list_prop):
print("prop", prop)
prop_name = prop.split("#")[1]
prop_type = list_prop_data[prop]["datatype"] # "float"
if prop_type == "integer":
Expand Down
21 changes: 13 additions & 8 deletions dlite_cuds/utils/dlite2cuds.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
""" Converting dlite collection to cuds."""
import uuid
from typing import Optional
from typing import Optional, Union

import dlite
from dlite import Collection
Expand Down Expand Up @@ -169,15 +169,21 @@ def get_triple_instance(graph, instance):
return triple


def get_triples_property(prop_name, namespace, value, etype, pred_v=None): # unit
def get_triples_property(
prop_name: str,
namespace: str,
value: Union[str, int, float],
etype: str,
pred_v: Optional[str] = None,
):
"""
Get the list of triples defining a property as a cuds (inverse_of is not included)
Arguments:
prop_name: property bane
namespace: namespace
value: value
etype: type of value
pred_v: predicate used for assigning DataProperty, defaults to owl:topDataProperty
prop_name: property bane
namespace: namespace
value: value
etype: type of value
pred_v: predicate used for assigning DataProperty, defaults to owl:topDataProperty
"""
triples_prop = []
cuds_prefix = "http://www.osp-core.com/cuds#"
Expand Down Expand Up @@ -215,5 +221,4 @@ def get_object_typed(value, etype):
if etype in ["float32", "float64"]:
return Literal(value, datatype=XSD.float)

print(etype, value)
raise ValueError("in get_object_typed, etype not recognized: ", etype)

0 comments on commit 5246dc0

Please sign in to comment.