Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert doubles and floats to decimals #311

Merged
merged 4 commits into from
Dec 23, 2020

Conversation

dr-shorthair
Copy link
Contributor

Fixes #307

Simon Cox added 4 commits December 9, 2020 17:51
# Conflicts:
#	vocab/unit/VOCAB_QUDT-UNITS-ALL-v2.1.ttl
# Conflicts:
#	vocab/unit/VOCAB_QUDT-UNITS-ALL-v2.1.ttl
INSERT { ?u qudt:conversionMultiplier ?md }
WHERE {
 ?u a qudt:Unit ;
  qudt:conversionMultiplier ?m .
 BIND( DATATYPE(?m) as ?mt )
 FILTER( ?mt != xsd:decimal )
 BIND( xsd:decimal(?m) as ?md )
}

DELETE { ?u qudt:conversionMultiplier ?m }
WHERE {
 ?u a qudt:Unit ;
  qudt:conversionMultiplier ?m .
 BIND( DATATYPE(?m) as ?mt )
 FILTER( ?mt != xsd:decimal )
}

INSERT { ?u qudt:conversionOffset ?od }
WHERE {
 ?u a qudt:Unit ;
  qudt:conversionOffset ?o .
 BIND( DATATYPE(?o) as ?ot )
 FILTER( ?ot != xsd:decimal )
 BIND( xsd:decimal(?o) as ?od )
}

DELETE { ?u qudt:conversionOffset ?o }
WHERE {
 ?u a qudt:Unit ;
  qudt:conversionOffset ?o .
 BIND( DATATYPE(?o) as ?ot )
 FILTER( ?ot != xsd:decimal )
}

DELETE { ?u qudt:conversionOffset ?o }
WHERE {
 ?u a qudt:Unit ;
  qudt:conversionOffset ?o .
 FILTER( ?o = 0.0 )
}
@dr-shorthair
Copy link
Contributor Author

dr-shorthair commented Dec 23, 2020

Used the following SPARQL

INSERT { ?u qudt:conversionMultiplier ?md }
WHERE {
	?u a qudt:Unit ;
		qudt:conversionMultiplier ?m .
	BIND( DATATYPE(?m) as ?mt )
	FILTER( ?mt != xsd:decimal )
	BIND( xsd:decimal(?m) as ?md )
}

DELETE { ?u qudt:conversionMultiplier ?m }
WHERE {
	?u a qudt:Unit ;
		qudt:conversionMultiplier ?m .
	BIND( DATATYPE(?m) as ?mt )
	FILTER( ?mt != xsd:decimal )
}

INSERT { ?u qudt:conversionOffset ?od }
WHERE {
	?u a qudt:Unit ;
		qudt:conversionOffset ?o .
	BIND( DATATYPE(?o) as ?ot )
	FILTER( ?ot != xsd:decimal )
	BIND( xsd:decimal(?o) as ?od )
}

DELETE { ?u qudt:conversionOffset ?o }
WHERE {
	?u a qudt:Unit ;
		qudt:conversionOffset ?o .
	BIND( DATATYPE(?o) as ?ot )
	FILTER( ?ot != xsd:decimal )
}

Also - remove all zero offets

DELETE { ?u qudt:conversionOffset ?o }
WHERE {
	?u a qudt:Unit ;
		qudt:conversionOffset ?o .
	FILTER( ?o = 0.0 )
}

@dr-shorthair dr-shorthair marked this pull request as ready for review December 23, 2020 00:34
@dr-shorthair dr-shorthair changed the title Converting doubles and floats to decimals (partial) Converting doubles and floats to decimals Dec 23, 2020
@dr-shorthair dr-shorthair changed the title Converting doubles and floats to decimals Convert doubles and floats to decimals Dec 23, 2020
@nicholascar
Copy link

remove all zero offets

Is this because it is inferred to be zero if not present by calculation queries?

@dr-shorthair
Copy link
Contributor Author

Offsets apply in very few cases - and only on interval scales (not ratio scales).
As they are the exceptional case, they need not be present in general.
(AFAICT there are only 3 valid offsets in the current catalogue.)

Copy link
Collaborator

@steveraysteveray steveraysteveray left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK.
I hope the multiplier for PlanckDensity doesn't break anything!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use of xsd:decimal instead of xsd:double for conversion factors
3 participants