Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
left=np.fmax(s, edges.left[keep_edges]),
right=np.fmin(e, edges.right[keep_edges]),
parent=edges.parent[keep_edges],
child=edges.child[keep_edges])
self.delete_sites(
np.where(np.logical_not(keep_sites))[0], record_provenance=False)
self.sort()
if simplify:
self.simplify()
if record_provenance:
parameters = {
"command": "keep_intervals",
"TODO": "add parameters"
}
self.provenances.add_row(record=json.dumps(
provenance.get_provenance_dict(parameters)))
self.mutations.set_columns(
site=site_map[self.mutations.site[keep_mutations]],
node=self.mutations.node[keep_mutations],
derived_state=new_ds,
derived_state_offset=new_ds_offset,
parent=mutation_map[self.mutations.parent[keep_mutations]],
metadata=new_md,
metadata_offset=new_md_offset)
if record_provenance:
# TODO replace with a version of https://github.com/tskit-dev/tskit/pull/243
parameters = {
"command": "delete_sites",
"TODO": "add parameters"
}
self.provenances.add_row(record=json.dumps(
provenance.get_provenance_dict(parameters)))
Returns the V2 tree provenance attributes reformatted as a provenance record.
"""
environment = {}
parameters = {}
# Try to get the provenance strings. Malformed JSON should not prevent us
# from finishing the conversion.
try:
environment = json.loads(str(attrs["environment"]))
except ValueError:
logging.warn("Failed to convert environment provenance")
try:
parameters = json.loads(str(attrs["parameters"]))
except ValueError:
logging.warn("Failed to convert parameters provenance")
parameters["command"] = command
provenance_dict = provenance.get_provenance_dict(parameters)
provenance_dict["version"] = environment.get("msprime_version", "Unknown_version")
provenance_dict["environment"] = environment
return json.dumps(provenance_dict).encode()
filter_zero_mutation_sites=filter_zero_mutation_sites,
reduce_to_site_topology=reduce_to_site_topology,
filter_populations=filter_populations,
filter_individuals=filter_individuals,
filter_sites=filter_sites,
keep_unary=keep_unary)
if record_provenance:
# TODO add simplify arguments here
# TODO also make sure we convert all the arguments so that they are
# definitely JSON encodable.
parameters = {
"command": "simplify",
"TODO": "add simplify parameters"
}
tables.provenances.add_row(record=json.dumps(
provenance.get_provenance_dict(parameters)))
new_ts = tables.tree_sequence()
assert new_ts.sequence_length == self.sequence_length
if map_nodes:
return new_ts, node_map
else:
return new_ts